diff -Nru libquentier-0.5.0/debian/changelog libquentier-0.5.0/debian/changelog --- libquentier-0.5.0/debian/changelog 2019-06-19 09:02:59.000000000 +0000 +++ libquentier-0.5.0/debian/changelog 2019-07-11 10:47:02.000000000 +0000 @@ -1,8 +1,8 @@ -libquentier (0.5.0-1~ppa~quentier~201906190902~ubuntu18.10.1) cosmic; urgency=low +libquentier (0.5.0-1~ppa~quentier~201907111047~ubuntu18.10.1) cosmic; urgency=low * Auto build. - -- Dmitry Ivanov Wed, 19 Jun 2019 09:02:59 +0000 + -- Dmitry Ivanov Thu, 11 Jul 2019 10:47:02 +0000 libquentier (0.5.0-1) unstable; urgency=medium diff -Nru libquentier-0.5.0/debian/git-build-recipe.manifest libquentier-0.5.0/debian/git-build-recipe.manifest --- libquentier-0.5.0/debian/git-build-recipe.manifest 2019-06-19 09:02:59.000000000 +0000 +++ libquentier-0.5.0/debian/git-build-recipe.manifest 2019-07-11 10:47:02.000000000 +0000 @@ -1,3 +1,3 @@ -# git-build-recipe format 0.4 deb-version {debversion}~ppa~quentier~201906190902 -lp:libquentier-mirror git-commit:c83ce37ff2f34f124c94a9f60b02d085df19f72b +# git-build-recipe format 0.4 deb-version {debversion}~ppa~quentier~201907111047 +lp:libquentier-mirror git-commit:2d187f137a1ee80df813e39f57af01faa73b6c71 nest-part packaging lp:quentier-deb-packaging libquentier/debian debian git-commit:97087a8a8292854be014cb0d9e01423b9c933330 diff -Nru libquentier-0.5.0/headers/quentier/logging/QuentierLogger.h libquentier-0.5.0/headers/quentier/logging/QuentierLogger.h --- libquentier-0.5.0/headers/quentier/logging/QuentierLogger.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/headers/quentier/logging/QuentierLogger.h 2019-07-11 10:46:53.000000000 +0000 @@ -60,48 +60,60 @@ } // namespace quentier #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) -#define __QNLOG_QDEBUG_HELPER() \ - dbg.nospace(); \ - dbg.noquote() +#define __QNLOG_QDEBUG_HELPER() \ + dbg.nospace(); \ + dbg.noquote() \ +// __QNLOG_QDEBUG_HELPER #else -#define __QNLOG_QDEBUG_HELPER() \ - dbg.nospace() +#define __QNLOG_QDEBUG_HELPER() \ + dbg.nospace() \ +// __QNLOG_QDEBUG_HELPER #endif -#define __QNLOG_BASE(message, level) \ - if (quentier::QuentierIsLogLevelActive(quentier::LogLevel::level##Level)) { \ - QString msg; \ - QDebug dbg(&msg); \ - __QNLOG_QDEBUG_HELPER(); \ - dbg << message; \ - quentier::QuentierAddLogEntry(QStringLiteral(__FILE__), \ - __LINE__, msg, \ - quentier::LogLevel::level##Level); \ - } - -#define QNTRACE(message) \ - __QNLOG_BASE(message, Trace) - -#define QNDEBUG(message) \ - __QNLOG_BASE(message, Debug) - -#define QNINFO(message) \ - __QNLOG_BASE(message, Info) - -#define QNWARNING(message) \ - __QNLOG_BASE(message, Warn) - -#define QNERROR(message) \ - __QNLOG_BASE(message, Error) - -#define QUENTIER_SET_MIN_LOG_LEVEL(level) \ - quentier::QuentierSetMinLogLevel(quentier::LogLevel::level##Level) - -#define QUENTIER_INITIALIZE_LOGGING() \ - quentier::QuentierInitializeLogging() - -#define QUENTIER_ADD_STDOUT_LOG_DESTINATION() \ - quentier::QuentierAddStdOutLogDestination() +#define __QNLOG_BASE(message, level) \ + if (quentier::QuentierIsLogLevelActive(quentier::LogLevel::level##Level)) \ + { \ + QString msg; \ + QDebug dbg(&msg); \ + __QNLOG_QDEBUG_HELPER(); \ + dbg << message; \ + quentier::QuentierAddLogEntry(QStringLiteral(__FILE__), \ + __LINE__, msg, \ + quentier::LogLevel::level##Level); \ + } \ +// __QNLOG_BASE + +#define QNTRACE(message) \ + __QNLOG_BASE(message, Trace) \ +// QNTRACE + +#define QNDEBUG(message) \ + __QNLOG_BASE(message, Debug) \ +// QNDEBUG + +#define QNINFO(message) \ + __QNLOG_BASE(message, Info) \ +// QNINFO + +#define QNWARNING(message) \ + __QNLOG_BASE(message, Warn) \ +// QNWARNING + +#define QNERROR(message) \ + __QNLOG_BASE(message, Error) \ +// QNERROR + +#define QUENTIER_SET_MIN_LOG_LEVEL(level) \ + quentier::QuentierSetMinLogLevel(quentier::LogLevel::level##Level) \ +// QUENTIER_SET_MIN_LOG_LEVEL + +#define QUENTIER_INITIALIZE_LOGGING() \ + quentier::QuentierInitializeLogging() \ +// QUENTIER_INITIALIZE_LOGGING + +#define QUENTIER_ADD_STDOUT_LOG_DESTINATION() \ + quentier::QuentierAddStdOutLogDestination() \ +// QUENTIER_ADD_STDOUT_LOG_DESTINATION #define QNLOG_FILE_LINENUMBER_DELIMITER ":" diff -Nru libquentier-0.5.0/headers/quentier/types/IFavoritableDataElement.h libquentier-0.5.0/headers/quentier/types/IFavoritableDataElement.h --- libquentier-0.5.0/headers/quentier/types/IFavoritableDataElement.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/headers/quentier/types/IFavoritableDataElement.h 2019-07-11 10:46:53.000000000 +0000 @@ -37,29 +37,35 @@ virtual ~IFavoritableDataElement() {} }; -#define DECLARE_IS_FAVORITED \ - virtual bool isFavorited() const Q_DECL_OVERRIDE; - -#define DECLARE_SET_FAVORITED \ - virtual void setFavorited(const bool favorited) Q_DECL_OVERRIDE; - -#define QN_DECLARE_FAVORITED \ - DECLARE_IS_FAVORITED \ - DECLARE_SET_FAVORITED - -#define DEFINE_IS_FAVORITED(type) \ - bool type::isFavorited() const { \ - return d->m_isFavorited; \ - } - -#define DEFINE_SET_FAVORITED(type) \ - void type::setFavorited(const bool favorited) { \ - d->m_isFavorited = favorited; \ - } - -#define QN_DEFINE_FAVORITED(type) \ - DEFINE_IS_FAVORITED(type) \ - DEFINE_SET_FAVORITED(type) +#define DECLARE_IS_FAVORITED \ + virtual bool isFavorited() const Q_DECL_OVERRIDE; \ +// DECLARE_IS_FAVORITED + +#define DECLARE_SET_FAVORITED \ + virtual void setFavorited(const bool favorited) Q_DECL_OVERRIDE; \ +// DECLARE_SET_FAVORITED + +#define QN_DECLARE_FAVORITED \ + DECLARE_IS_FAVORITED \ + DECLARE_SET_FAVORITED \ +// QN_DECLARE_FAVORITED + +#define DEFINE_IS_FAVORITED(type) \ + bool type::isFavorited() const { \ + return d->m_isFavorited; \ + } \ +// DEFINE_IS_FAVORITED + +#define DEFINE_SET_FAVORITED(type) \ + void type::setFavorited(const bool favorited) { \ + d->m_isFavorited = favorited; \ + } \ +// DEFINE_SET_FAVORITED + +#define QN_DEFINE_FAVORITED(type) \ + DEFINE_IS_FAVORITED(type) \ + DEFINE_SET_FAVORITED(type) \ +// QN_DEFINE_FAVORITED } // namespace quentier diff -Nru libquentier-0.5.0/headers/quentier/types/ILocalStorageDataElement.h libquentier-0.5.0/headers/quentier/types/ILocalStorageDataElement.h --- libquentier-0.5.0/headers/quentier/types/ILocalStorageDataElement.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/headers/quentier/types/ILocalStorageDataElement.h 2019-07-11 10:46:53.000000000 +0000 @@ -37,30 +37,35 @@ virtual ~ILocalStorageDataElement() {} }; -#define DEFINE_LOCAL_UID_GETTER(type) \ - const QString type::localUid() const { \ - return UidGenerator::UidToString(d->m_localUid); \ - } - -#define DEFINE_LOCAL_UID_SETTER(type) \ - void type::setLocalUid(const QString & uid) { \ - d->m_localUid = uid; \ - } - -#define DEFINE_LOCAL_UID_UNSETTER(type) \ - void type::unsetLocalUid() { \ - d->m_localUid = QUuid(); \ - } - -#define QN_DECLARE_LOCAL_UID \ - virtual const QString localUid() const Q_DECL_OVERRIDE; \ - virtual void setLocalUid(const QString & guid) Q_DECL_OVERRIDE; \ - virtual void unsetLocalUid() Q_DECL_OVERRIDE; - -#define QN_DEFINE_LOCAL_UID(type) \ - DEFINE_LOCAL_UID_GETTER(type) \ - DEFINE_LOCAL_UID_SETTER(type) \ - DEFINE_LOCAL_UID_UNSETTER(type) +#define DEFINE_LOCAL_UID_GETTER(type) \ + const QString type::localUid() const { \ + return UidGenerator::UidToString(d->m_localUid); \ + } \ +// DEFINE_LOCAL_UID_GETTER + +#define DEFINE_LOCAL_UID_SETTER(type) \ + void type::setLocalUid(const QString & uid) { \ + d->m_localUid = uid; \ + } \ +// DEFINE_LOCAL_UID_SETTER + +#define DEFINE_LOCAL_UID_UNSETTER(type) \ + void type::unsetLocalUid() { \ + d->m_localUid = QUuid(); \ + } \ +// DEFINE_LOCAL_UID_UNSETTER + +#define QN_DECLARE_LOCAL_UID \ + virtual const QString localUid() const Q_DECL_OVERRIDE; \ + virtual void setLocalUid(const QString & guid) Q_DECL_OVERRIDE; \ + virtual void unsetLocalUid() Q_DECL_OVERRIDE; \ +// QN_DECLARE_LOCAL_UID + +#define QN_DEFINE_LOCAL_UID(type) \ + DEFINE_LOCAL_UID_GETTER(type) \ + DEFINE_LOCAL_UID_SETTER(type) \ + DEFINE_LOCAL_UID_UNSETTER(type) \ +// QN_DEFINE_LOCAL_UID } // namespace quentier diff -Nru libquentier-0.5.0/headers/quentier/types/INoteStoreDataElement.h libquentier-0.5.0/headers/quentier/types/INoteStoreDataElement.h --- libquentier-0.5.0/headers/quentier/types/INoteStoreDataElement.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/headers/quentier/types/INoteStoreDataElement.h 2019-07-11 10:46:53.000000000 +0000 @@ -52,53 +52,65 @@ virtual ~INoteStoreDataElement() {} }; -#define DECLARE_IS_DIRTY \ - virtual bool isDirty() const Q_DECL_OVERRIDE; - -#define DECLARE_SET_DIRTY \ - virtual void setDirty(const bool isDirty) Q_DECL_OVERRIDE; - -#define QN_DECLARE_DIRTY \ - DECLARE_IS_DIRTY \ - DECLARE_SET_DIRTY - -#define DEFINE_IS_DIRTY(type) \ - bool type::isDirty() const { \ - return d->m_isDirty; \ - } - -#define DEFINE_SET_DIRTY(type) \ - void type::setDirty(const bool dirty) { \ - d->m_isDirty = dirty; \ - } - -#define QN_DEFINE_DIRTY(type) \ - DEFINE_IS_DIRTY(type) \ - DEFINE_SET_DIRTY(type) - -#define DECLARE_IS_LOCAL \ - virtual bool isLocal() const Q_DECL_OVERRIDE; - -#define DECLARE_SET_LOCAL \ - virtual void setLocal(const bool isLocal) Q_DECL_OVERRIDE; - -#define QN_DECLARE_LOCAL \ - DECLARE_IS_LOCAL \ - DECLARE_SET_LOCAL - -#define DEFINE_IS_LOCAL(type) \ - bool type::isLocal() const { \ - return d->m_isLocal; \ - } - -#define DEFINE_SET_LOCAL(type) \ - void type::setLocal(const bool local) { \ - d->m_isLocal = local; \ - } - -#define QN_DEFINE_LOCAL(type) \ - DEFINE_IS_LOCAL(type) \ - DEFINE_SET_LOCAL(type) +#define DECLARE_IS_DIRTY \ + virtual bool isDirty() const Q_DECL_OVERRIDE; \ +// DECLARE_IS_DIRTY + +#define DECLARE_SET_DIRTY \ + virtual void setDirty(const bool isDirty) Q_DECL_OVERRIDE; \ +// DECLARE_SET_DIRTY + +#define QN_DECLARE_DIRTY \ + DECLARE_IS_DIRTY \ + DECLARE_SET_DIRTY \ +// QN_DECLARE_DIRTY + +#define DEFINE_IS_DIRTY(type) \ + bool type::isDirty() const { \ + return d->m_isDirty; \ + } \ +// DEFINE_IS_DIRTY + +#define DEFINE_SET_DIRTY(type) \ + void type::setDirty(const bool dirty) { \ + d->m_isDirty = dirty; \ + } \ +// DEFINE_SET_DIRTY + +#define QN_DEFINE_DIRTY(type) \ + DEFINE_IS_DIRTY(type) \ + DEFINE_SET_DIRTY(type) \ +// QN_DEFINE_DIRTY + +#define DECLARE_IS_LOCAL \ + virtual bool isLocal() const Q_DECL_OVERRIDE; \ +// DECLARE_IS_LOCAL + +#define DECLARE_SET_LOCAL \ + virtual void setLocal(const bool isLocal) Q_DECL_OVERRIDE; \ +// DECLARE_SET_LOCAL + +#define QN_DECLARE_LOCAL \ + DECLARE_IS_LOCAL \ + DECLARE_SET_LOCAL \ +// QN_DECLARE_LOCAL + +#define DEFINE_IS_LOCAL(type) \ + bool type::isLocal() const { \ + return d->m_isLocal; \ + } \ +// DEFINE_IS_LOCAL + +#define DEFINE_SET_LOCAL(type) \ + void type::setLocal(const bool local) { \ + d->m_isLocal = local; \ + } \ +// DEFINE_SET_LOCAL + +#define QN_DEFINE_LOCAL(type) \ + DEFINE_IS_LOCAL(type) \ + DEFINE_SET_LOCAL(type) \ +// QN_DEFINE_LOCAL } // namespace quentier diff -Nru libquentier-0.5.0/headers/quentier/utility/Printable.h libquentier-0.5.0/headers/quentier/utility/Printable.h --- libquentier-0.5.0/headers/quentier/utility/Printable.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/headers/quentier/utility/Printable.h 2019-07-11 10:46:53.000000000 +0000 @@ -113,13 +113,15 @@ return str; } -#define QUENTIER_DECLARE_PRINTABLE(type, ...) \ - QUENTIER_EXPORT QTextStream & operator << (QTextStream & strm, const type & obj); \ - inline QDebug & operator << (QDebug & debug, const type & obj) \ - { \ - debug << ToString(obj); \ - return debug; \ - } +#define QUENTIER_DECLARE_PRINTABLE(type, ...) \ + QUENTIER_EXPORT QTextStream & \ + operator << (QTextStream & strm, const type & obj); \ + inline QDebug & operator << (QDebug & debug, const type & obj) \ + { \ + debug << ToString(obj); \ + return debug; \ + } \ +// QUENTIER_DECLARE_PRINTABLE QUENTIER_DECLARE_PRINTABLE(qevercloud::Contact) QUENTIER_DECLARE_PRINTABLE(qevercloud::Identity) diff -Nru libquentier-0.5.0/headers/quentier/utility/QuentierCheckPtr.h libquentier-0.5.0/headers/quentier/utility/QuentierCheckPtr.h --- libquentier-0.5.0/headers/quentier/utility/QuentierCheckPtr.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/headers/quentier/utility/QuentierCheckPtr.h 2019-07-11 10:46:53.000000000 +0000 @@ -22,22 +22,23 @@ #include #ifndef QUENTIER_CHECK_PTR -#define QUENTIER_CHECK_PTR(pointer, ...) \ -{ \ - if (Q_UNLIKELY(!pointer)) \ - { \ - using quentier::NullPtrException; \ - ErrorString quentier_null_ptr_error(QT_TRANSLATE_NOOP("", \ - "Detected unintended "\ - "null pointer")); \ - quentier_null_ptr_error.details() = QStringLiteral(__FILE__); \ - quentier_null_ptr_error.details() += QStringLiteral(" ("); \ - quentier_null_ptr_error.details() += QString::number(__LINE__); \ - quentier_null_ptr_error.details() += QStringLiteral(") "); \ - quentier_null_ptr_error.details() += QStringLiteral("" #__VA_ARGS__ ""); \ - throw NullPtrException(quentier_null_ptr_error); \ - } \ -} +#define QUENTIER_CHECK_PTR(pointer, ...) \ +{ \ + if (Q_UNLIKELY(!pointer)) \ + { \ + using quentier::NullPtrException; \ + ErrorString quentier_null_ptr_error( \ + QT_TRANSLATE_NOOP("", "Detected unintended null pointer")); \ + quentier_null_ptr_error.details() = QStringLiteral(__FILE__); \ + quentier_null_ptr_error.details() += QStringLiteral(" ("); \ + quentier_null_ptr_error.details() += QString::number(__LINE__); \ + quentier_null_ptr_error.details() += QStringLiteral(") "); \ + quentier_null_ptr_error.details() += \ + QString::fromUtf8("" #__VA_ARGS__ ""); \ + throw NullPtrException(quentier_null_ptr_error); \ + } \ +} \ +// QUENTIER_CHECK_PTR #endif #endif // LIB_QUENTIER_UTILITY_QUENTIER_CHECK_PTR_H diff -Nru libquentier-0.5.0/src/enml/DecryptedTextManager_p.cpp libquentier-0.5.0/src/enml/DecryptedTextManager_p.cpp --- libquentier-0.5.0/src/enml/DecryptedTextManager_p.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/enml/DecryptedTextManager_p.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -34,15 +34,13 @@ const QString & cipher, const size_t keyLength) { - QNDEBUG(QStringLiteral("DecryptedTextManagerPrivate::addEntry: hash = ") - << hash << QStringLiteral(", rememberForSession = ") - << (rememberForSession - ? QStringLiteral("true") - : QStringLiteral("false"))); + QNDEBUG("DecryptedTextManagerPrivate::addEntry: hash = " + << hash << ", rememberForSession = " + << (rememberForSession ? "true" : "false")); if (passphrase.isEmpty()) { - QNWARNING(QStringLiteral("detected attempt to add decrypted text for " - "empty passphrase to decrypted text manager")); + QNWARNING("detected attempt to add decrypted text for " + "empty passphrase to decrypted text manager"); return; } @@ -56,8 +54,7 @@ void DecryptedTextManagerPrivate::removeEntry(const QString & hash) { - QNDEBUG(QStringLiteral("DecryptedTextManagerPrivate::removeEntry: hash = ") - << hash); + QNDEBUG("DecryptedTextManagerPrivate::removeEntry: hash = " << hash); auto it = m_dataHash.find(hash); if (it != m_dataHash.end()) { @@ -71,8 +68,7 @@ void DecryptedTextManagerPrivate::clearNonRememberedForSessionEntries() { - QNDEBUG(QStringLiteral("DecryptedTextManagerPrivate::" - "clearNonRememberedForSessionEntries")); + QNDEBUG("DecryptedTextManagerPrivate::clearNonRememberedForSessionEntries"); for(auto it = m_dataHash.begin(); it != m_dataHash.end();) { @@ -95,19 +91,18 @@ QString & decryptedText, bool & rememberForSession) const { - QNDEBUG(QStringLiteral("DecryptedTextManagerPrivate::" - "findDecryptedTextByEncryptedText: ") << encryptedText); + QNDEBUG("DecryptedTextManagerPrivate::findDecryptedTextByEncryptedText: " + << encryptedText); DataHash::const_iterator dataIt = m_dataHash.find(encryptedText); if (dataIt == m_dataHash.end()) { - QNTRACE(QStringLiteral("Can't find the entry in the up to date data hash, " - "trying the stale hash")); + QNTRACE("Can't find entry in the up to date data hash, trying the stale hash"); // Try the stale data hash dataIt = m_staleDataHash.find(encryptedText); if (dataIt == m_staleDataHash.end()) { - QNTRACE(QStringLiteral("Can't find the entry in the stale data hash as well")); + QNTRACE("Can't find entry in the stale data hash as well"); return false; } } @@ -115,7 +110,7 @@ const Data & data = dataIt.value(); decryptedText = data.m_decryptedText; rememberForSession = data.m_rememberForSession; - QNTRACE(QStringLiteral("Found decrypted text")); + QNTRACE("Found decrypted text"); return true; } @@ -124,19 +119,18 @@ const QString & newDecryptedText, QString & newEncryptedText) { - QNDEBUG(QStringLiteral("DecryptedTextManagerPrivate::modifyDecryptedText: ") - << QStringLiteral("original decrypted text = ") - << originalEncryptedText); + QNDEBUG("DecryptedTextManagerPrivate::modifyDecryptedText: " + << "original decrypted text = " << originalEncryptedText); bool foundInDataHash = true; - DataHash::iterator it = m_dataHash.find(originalEncryptedText); + auto it = m_dataHash.find(originalEncryptedText); if (it == m_dataHash.end()) { foundInDataHash = false; // Try the stale data hash instead it = m_staleDataHash.find(originalEncryptedText); if (it == m_staleDataHash.end()) { - QNDEBUG(QStringLiteral("Could not find original hash")); + QNDEBUG("Could not find original hash"); return false; } } @@ -148,8 +142,7 @@ entry.m_cipher, entry.m_keyLength, newEncryptedText, errorDescription); if (!res) { - QNWARNING(QStringLiteral("Could not re-encrypt the decrypted text: ") - << errorDescription); + QNWARNING("Could not re-encrypt the decrypted text: " << errorDescription); return false; } diff -Nru libquentier-0.5.0/src/enml/ENMLConverter.cpp libquentier-0.5.0/src/enml/ENMLConverter.cpp --- libquentier-0.5.0/src/enml/ENMLConverter.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/enml/ENMLConverter.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -19,7 +19,6 @@ #include #include "ENMLConverter_p.h" #include -#include namespace quentier { @@ -37,8 +36,6 @@ ErrorString & errorDescription, const QVector & skipRules) const { - QNDEBUG(QStringLiteral("ENMLConverter::htmlToNoteContent")); - Q_D(const ENMLConverter); return d->htmlToNoteContent(html, skipRules, noteContent, decryptedTextManager, errorDescription); @@ -48,8 +45,6 @@ QString & cleanedUpHtml, ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("ENMLConverter::cleanupExternalHtml")); - Q_D(const ENMLConverter); return d->cleanupExternalHtml(inputHtml, cleanedUpHtml, errorDescription); } @@ -58,8 +53,6 @@ ErrorString & errorDescription, const QVector & skipRules) const { - QNDEBUG(QStringLiteral("ENMLConverter::htmlToQTextDocument")); - Q_D(const ENMLConverter); return d->htmlToQTextDocument(html, doc, errorDescription, skipRules); } @@ -69,8 +62,6 @@ DecryptedTextManager & decryptedTextManager, NoteContentToHtmlExtraData & extraData) const { - QNDEBUG(QStringLiteral("ENMLConverter::noteContentToHtml")); - Q_D(const ENMLConverter); return d->noteContentToHtml(noteContent, html, errorDescription, decryptedTextManager, extraData); @@ -168,54 +159,54 @@ QTextStream & ENMLConverter::SkipHtmlElementRule::print(QTextStream & strm) const { -#define PRINT_COMPARISON_RULE(rule) \ - switch(rule) \ - { \ - case Equals: \ - strm << QStringLiteral("Equals"); \ - break; \ - case StartsWith: \ - strm << QStringLiteral("Starts with"); \ - break; \ - case EndsWith: \ - strm << QStringLiteral("Ends with"); \ - break; \ - case Contains: \ - strm << QStringLiteral("Contains"); \ - break; \ - default: \ - strm << QStringLiteral("unknown"); \ - break; \ - } - - strm << QStringLiteral("SkipHtmlElementRule: {\n"); - strm << QStringLiteral(" element name to skip = ") << m_elementNameToSkip - << QStringLiteral(", rule: "); +#define PRINT_COMPARISON_RULE(rule) \ + switch(rule) \ + { \ + case Equals: \ + strm << "Equals"; \ + break; \ + case StartsWith: \ + strm << "Starts with"; \ + break; \ + case EndsWith: \ + strm << "Ends with"; \ + break; \ + case Contains: \ + strm << "Contains"; \ + break; \ + default: \ + strm << "Unknown (" << static_cast(rule) << ")"; \ + break; \ + } \ +// PRINT_COMPARISON_RULE + + strm << "SkipHtmlElementRule: {\n"; + strm << " element name to skip = " << m_elementNameToSkip << ", rule: "; PRINT_COMPARISON_RULE(m_elementNameComparisonRule) - strm << QStringLiteral(", case ") + strm << ", case " << ((m_elementNameCaseSensitivity == Qt::CaseSensitive) - ? QStringLiteral("sensitive") - : QStringLiteral("insensitive")); - strm << QStringLiteral("\n"); + ? "sensitive" + : "insensitive"); + strm << "\n"; - strm << QStringLiteral(" attribute name to skip = ") + strm << " attribute name to skip = " << m_attributeNameToSkip - << QStringLiteral(", rule: "); + << ", rule: "; PRINT_COMPARISON_RULE(m_attributeNameComparisonRule) - strm << QStringLiteral(", case ") + strm << ", case " << ((m_attributeNameCaseSensitivity == Qt::CaseSensitive) - ? QStringLiteral("sensitive") - : QStringLiteral("insensitive")); - strm << QStringLiteral("\n"); + ? "sensitive" + : "insensitive"); + strm << "\n"; - strm << QStringLiteral(" attribute value to skip = ") + strm << " attribute value to skip = " << m_attributeValueToSkip - << QStringLiteral(", rule: "); + << ", rule: "; PRINT_COMPARISON_RULE(m_attributeValueComparisonRule) - strm << QStringLiteral(", case ") + strm << ", case " << ((m_attributeValueCaseSensitivity == Qt::CaseSensitive) - ? QStringLiteral("sensitive") - : QStringLiteral("insensitive")); + ? "sensitive" + : "insensitive"); strm << "\n}\n"; return strm; diff -Nru libquentier-0.5.0/src/enml/ENMLConverter_p.cpp libquentier-0.5.0/src/enml/ENMLConverter_p.cpp --- libquentier-0.5.0/src/enml/ENMLConverter_p.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/enml/ENMLConverter_p.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -46,13 +46,14 @@ // 25 Mb in bytes #define ENEX_MAX_RESOURCE_DATA_SIZE (26214400) -#define ENEX_DATE_TIME_FORMAT (QStringLiteral("yyyyMMdd'T'HHmmss'Z'")) +#define ENEX_DATE_TIME_FORMAT "yyyyMMdd'T'HHmmss'Z'" #define ENEX_DATE_TIME_FORMAT_STRFTIME "%Y%m%dT%H%M%SZ" namespace quentier { -#define WRAP(x) \ - << QStringLiteral(x) +#define WRAP(x) \ + << QStringLiteral(x) \ +// WRAP ENMLConverterPrivate::ENMLConverterPrivate(QObject * parent) : QObject(parent), @@ -79,14 +80,14 @@ void xmlValidationErrorFunc(void * ctx, const char * msg, va_list args) { - QNDEBUG(QStringLiteral("xmlValidationErrorFunc")); + QNDEBUG("xmlValidationErrorFunc"); QString currentError; currentError.sprintf(msg, args); QString * pErrorString = reinterpret_cast(ctx); *pErrorString += currentError; - QNDEBUG(QStringLiteral("Error string: ") << *pErrorString); + QNDEBUG("Error string: " << *pErrorString); } ENMLConverterPrivate::~ENMLConverterPrivate() @@ -100,8 +101,8 @@ DecryptedTextManager & decryptedTextManager, ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("ENMLConverterPrivate::htmlToNoteContent: ") << html - << QStringLiteral("\nskip element rules: ") << skipRules); + QNDEBUG("ENMLConverterPrivate::htmlToNoteContent: " << html + << "\nskip element rules: " << skipRules); if (!m_pHtmlCleaner) { m_pHtmlCleaner = new HTMLCleaner; @@ -116,7 +117,7 @@ return false; } - QNTRACE(QStringLiteral("HTML converted to XML by tidy: ") << m_cachedConvertedXml); + QNTRACE("HTML converted to XML by tidy: " << m_cachedConvertedXml); QXmlStreamReader reader(m_cachedConvertedXml); @@ -168,15 +169,15 @@ if (reader.isStartElement()) { if (skippedElementNestingCounter) { - QNTRACE(QStringLiteral("Skipping everything inside element skipped " - "together with its contents by the rules")); + QNTRACE("Skipping everything inside element skipped " + "together with its contents by the rules"); ++skippedElementNestingCounter; continue; } lastElementName = reader.name().toString(); if (lastElementName == QStringLiteral("form")) { - QNTRACE(QStringLiteral("Skipping
tag")); + QNTRACE("Skipping tag"); continue; } else if (lastElementName == QStringLiteral("html")) { @@ -184,13 +185,13 @@ continue; } else if (lastElementName == QStringLiteral("title")) { - QNTRACE(QStringLiteral("Skipping tag")); + QNTRACE("Skipping <title> tag"); continue; } else if (lastElementName == QStringLiteral("body")) { lastElementName = QStringLiteral("en-note"); - QNTRACE(QStringLiteral("Found \"body\" HTML tag, will replace it " - "with \"en-note\" tag for written ENML")); + QNTRACE("Found \"body\" HTML tag, will replace it " + "with \"en-note\" tag for written ENML"); } QSet<QString>::const_iterator tagIt = @@ -198,8 +199,7 @@ if ((tagIt != m_forbiddenXhtmlTags.constEnd()) && (lastElementName != QStringLiteral("object"))) { - QNTRACE(QStringLiteral("Skipping forbidden XHTML tag: ") - << lastElementName); + QNTRACE("Skipping forbidden XHTML tag: " << lastElementName); continue; } @@ -209,10 +209,10 @@ tagIt = m_evernoteSpecificXhtmlTags.find(lastElementName); if (tagIt == m_evernoteSpecificXhtmlTags.end()) { - QNTRACE(QStringLiteral("Haven't found tag ") << lastElementName - << QStringLiteral(" within the list of allowed XHTML " - "tags or within Evernote-specific tags, " - "skipping it")); + QNTRACE("Haven't found tag " << lastElementName + << " within the list of allowed XHTML " + "tags or within Evernote-specific tags, " + "skipping it"); continue; } } @@ -223,11 +223,11 @@ shouldSkipElement(lastElementName, lastElementAttributes, skipRules); if (shouldSkip != ShouldSkipElementResult::ShouldNotSkip) { - QNTRACE(QStringLiteral("Skipping element ") << lastElementName - << QStringLiteral(" per skip rules; the contents would be ") + QNTRACE("Skipping element " << lastElementName + << " per skip rules; the contents would be " << (shouldSkip == ShouldSkipElementResult::SkipWithContents - ? QStringLiteral("skipped") - : QStringLiteral("preserved"))); + ? "skipped" + : "preserved")); if (shouldSkip == ShouldSkipElementResult::SkipWithContents) { ++skippedElementNestingCounter; @@ -248,8 +248,8 @@ lastElementAttributes.value(QStringLiteral("en-tag")).toString(); if (enTag == QStringLiteral("en-decrypted")) { - QNTRACE(QStringLiteral("Found decrypted text area, need to " - "convert it back to en-crypt form")); + QNTRACE("Found decrypted text area, need to " + "convert it back to en-crypt form"); bool res = decryptedTextToEnml(reader, decryptedTextManager, writer, errorDescription); if (!res) { @@ -261,7 +261,7 @@ else if (enTag == QStringLiteral("en-todo")) { if (!lastElementAttributes.hasAttribute(QStringLiteral("src"))) { - QNWARNING(QStringLiteral("Found en-todo tag without src attribute")); + QNWARNING("Found en-todo tag without src attribute"); continue; } @@ -311,7 +311,7 @@ writer.writeAttributes(enCryptAttributes); writer.writeCharacters(attributes.value(QStringLiteral("encrypted_text")).toString()); ++writeElementCounter; - QNTRACE(QStringLiteral("Started writing en-crypt tag")); + QNTRACE("Started writing en-crypt tag"); insideEnCryptElement = true; continue; } @@ -350,7 +350,7 @@ writer.writeAttributes(enMediaAttributes); enMediaAttributes.clear(); - QNTRACE(QStringLiteral("Wrote en-media element from img element in HTML")); + QNTRACE("Wrote en-media element from img element in HTML"); continue; } @@ -362,8 +362,7 @@ { QStringRef attributeName = it->name(); if (isForbiddenXhtmlAttribute(attributeName.toString())) { - QNTRACE(QStringLiteral("Erasing the forbidden attribute ") - << attributeName); + QNTRACE("Erasing the forbidden attribute " << attributeName); it = lastElementAttributes.erase(it); continue; } @@ -371,7 +370,7 @@ if ((lastElementName == QStringLiteral("a")) && (attributeName == QStringLiteral("en-hyperlink-id"))) { - QNTRACE(QStringLiteral("Erasing custom attribute en-hyperlink-id")); + QNTRACE("Erasing custom attribute en-hyperlink-id"); it = lastElementAttributes.erase(it); continue; } @@ -382,8 +381,8 @@ writer.writeStartElement(lastElementName); writer.writeAttributes(lastElementAttributes); ++writeElementCounter; - QNTRACE(QStringLiteral("Wrote element: name = ") << lastElementName - << QStringLiteral(" and its attributes")); + QNTRACE("Wrote element: name = " << lastElementName + << " and its attributes"); } if ((writeElementCounter > 0) && reader.isCharacters()) @@ -404,11 +403,11 @@ if (reader.isCDATA()) { writer.writeCDATA(text); - QNTRACE(QStringLiteral("Wrote CDATA: ") << text); + QNTRACE("Wrote CDATA: " << text); } else { writer.writeCharacters(text); - QNTRACE(QStringLiteral("Wrote characters: ") << text); + QNTRACE("Wrote characters: " << text); } } @@ -444,21 +443,21 @@ if (reader.hasError()) { errorDescription.setBase(QT_TR_NOOP("Can't convert the note's html to ENML")); errorDescription.details() = reader.errorString(); - QNWARNING(QStringLiteral("Error reading html: ") << errorDescription - << QStringLiteral(", HTML: ") << html << QStringLiteral("\nXML: ") + QNWARNING("Error reading html: " << errorDescription + << ", HTML: " << html << "\nXML: " << m_cachedConvertedXml); return false; } noteContent = QString::fromUtf8(noteContentBuffer.buffer()); - QNTRACE(QStringLiteral("Converted ENML: ") << noteContent); + QNTRACE("Converted ENML: " << noteContent); ErrorString validationError; res = validateAndFixupEnml(noteContent, validationError); if (!res) { errorDescription = validationError; - QNWARNING(errorDescription << QStringLiteral(", ENML: ") << noteContent - << QStringLiteral("\nHTML: ") << html); + QNWARNING(errorDescription << ", ENML: " << noteContent + << "\nHTML: " << html); return false; } @@ -469,7 +468,7 @@ ErrorString & errorDescription, const QVector<SkipHtmlElementRule> & skipRules) const { - QNDEBUG(QStringLiteral("ENMLConverterPrivate::htmlToQTextDocument: ") << html); + QNDEBUG("ENMLConverterPrivate::htmlToQTextDocument: " << html); if (!m_pHtmlCleaner) { m_pHtmlCleaner = new HTMLCleaner; @@ -484,7 +483,7 @@ return false; } - QNTRACE(QStringLiteral("HTML converted to XML by tidy: ") << m_cachedConvertedXml); + QNTRACE("HTML converted to XML by tidy: " << m_cachedConvertedXml); QXmlStreamReader reader(m_cachedConvertedXml); @@ -530,8 +529,8 @@ if (reader.isStartElement()) { if (skippedElementNestingCounter) { - QNTRACE(QStringLiteral("Skipping everything inside element " - "skipped together with its contents")); + QNTRACE("Skipping everything inside element " + "skipped together with its contents"); ++skippedElementNestingCounter; continue; } @@ -543,11 +542,11 @@ shouldSkipElement(lastElementName, lastElementAttributes, skipRules); if (shouldSkip != ShouldSkipElementResult::ShouldNotSkip) { - QNTRACE(QStringLiteral("Skipping element ") << lastElementName - << QStringLiteral(" per skip rules; the contents would be ") + QNTRACE("Skipping element " << lastElementName + << " per skip rules; the contents would be " << (shouldSkip == ShouldSkipElementResult::SkipWithContents - ? QStringLiteral("skipped") - : QStringLiteral("preserved"))); + ? "skipped" + : "preserved")); if (shouldSkip == ShouldSkipElementResult::SkipWithContents) { ++skippedElementNestingCounter; @@ -566,7 +565,7 @@ (lastElementName == QStringLiteral("col")) || (lastElementName == QStringLiteral("colgroup")) ) { - QNTRACE(QStringLiteral("Skipping element ") << lastElementName); + QNTRACE("Skipping element " << lastElementName); ++skippedElementNestingCounter; continue; } @@ -577,8 +576,7 @@ QStringRef relAttrRef = lastElementAttributes.value(QStringLiteral("rel")); if (!relAttrRef.isEmpty()) { - QNTRACE(QStringLiteral("Skipping CSS style element ") - << lastElementName); + QNTRACE("Skipping CSS style element " << lastElementName); ++skippedElementNestingCounter; continue; } @@ -586,31 +584,31 @@ if (lastElementName == QStringLiteral("abbr")) { lastElementName = QStringLiteral("div"); - QNTRACE(QStringLiteral("Replaced abbr with div")); + QNTRACE("Replaced abbr with div"); } else if (lastElementName == QStringLiteral("acronym")) { lastElementName = QStringLiteral("u"); - QNTRACE(QStringLiteral("Replaced acronym with u")); + QNTRACE("Replaced acronym with u"); } else if (lastElementName == QStringLiteral("del")) { lastElementName = QStringLiteral("s"); - QNTRACE(QStringLiteral("Replaced del with s")); + QNTRACE("Replaced del with s"); } else if (lastElementName == QStringLiteral("ins")) { lastElementName = QStringLiteral("u"); - QNTRACE(QStringLiteral("Replaced ins with u")); + QNTRACE("Replaced ins with u"); } else if (lastElementName == QStringLiteral("q")) { lastElementName = QStringLiteral("blockquote"); - QNTRACE(QStringLiteral("Replaced q with blockquote")); + QNTRACE("Replaced q with blockquote"); } else if (lastElementName == QStringLiteral("strike")) { lastElementName = QStringLiteral("s"); - QNTRACE(QStringLiteral("Replaced strike with s")); + QNTRACE("Replaced strike with s"); } else if (lastElementName == QStringLiteral("xmp")) { lastElementName = QStringLiteral("tt"); - QNTRACE(QStringLiteral("Replaced xmp with tt")); + QNTRACE("Replaced xmp with tt"); } writer.writeStartElement(lastElementName); @@ -810,9 +808,8 @@ } else { - QNDEBUG(QStringLiteral("img tag with src = ") << srcAttr - << QStringLiteral(" already has some data associated " - "with the document")); + QNDEBUG("img tag with src = " << srcAttr + << " already has some data associated with the document"); img = existingDocImgData.value<QImage>(); } @@ -844,17 +841,15 @@ } else { - QNTRACE(QStringLiteral("Won't add the outline to " - "the generic resource image: " - "the method is not run inside " - "the main thread")); + QNTRACE("Won't add the outline to the generic " + "resource image: the method is not run " + "inside the main thread"); } } else { - QNTRACE(QStringLiteral("Won't add the outline to the generic " - "resource image: not running " - "a QApplication")); + QNTRACE("Won't add the outline to the generic " + "resource image: not running a QApplication"); } } @@ -869,7 +864,7 @@ ++writeElementCounter; - QNTRACE(QStringLiteral("Wrote element: name = ") << lastElementName); + QNTRACE("Wrote element: name = " << lastElementName); } if ((writeElementCounter > 0) && reader.isCharacters()) @@ -882,11 +877,11 @@ if (reader.isCDATA()) { writer.writeCDATA(text); - QNTRACE(QStringLiteral("Wrote CDATA: ") << text); + QNTRACE("Wrote CDATA: " << text); } else { writer.writeCharacters(text); - QNTRACE(QStringLiteral("Wrote characters: ") << text); + QNTRACE("Wrote characters: " << text); } } @@ -915,9 +910,8 @@ errorDescription.setBase(QT_TR_NOOP("Can't convert the note's html " "to QTextDocument")); errorDescription.details() = reader.errorString(); - QNWARNING(QStringLiteral("Error reading html: ") << errorDescription - << QStringLiteral(", HTML: ") << html - << QStringLiteral("\nXML: ") << m_cachedConvertedXml); + QNWARNING("Error reading html: " << errorDescription << ", HTML: " + << html << "\nXML: " << m_cachedConvertedXml); return false; } @@ -929,8 +923,7 @@ "to QTextDocument: the document " "is empty after setting the simplified " "HTML")); - QNWARNING(errorDescription << QStringLiteral(", simplified HTML: ") - << simplifiedHtml); + QNWARNING(errorDescription << ", simplified HTML: " << simplifiedHtml); return false; } @@ -941,8 +934,7 @@ QString & cleanedUpHtml, ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("ENMLConverterPrivate::cleanupExternalHtml: input HTML = ") - << inputHtml); + QNDEBUG("ENMLConverterPrivate::cleanupExternalHtml: input HTML = " << inputHtml); if (!m_pHtmlCleaner) { m_pHtmlCleaner = new HTMLCleaner; @@ -961,7 +953,7 @@ return false; } - QNTRACE(QStringLiteral("HTML converted to XML: ") << m_cachedConvertedXml); + QNTRACE("HTML converted to XML: " << m_cachedConvertedXml); QXmlStreamReader reader(m_cachedConvertedXml); @@ -1005,16 +997,15 @@ QSet<QString>::const_iterator tagIt = m_forbiddenXhtmlTags.find(lastElementName); if (tagIt != m_forbiddenXhtmlTags.constEnd()) { - QNTRACE(QStringLiteral("Skipping forbidden tag: ") << lastElementName); + QNTRACE("Skipping forbidden tag: " << lastElementName); continue; } tagIt = m_allowedXhtmlTags.find(lastElementName); if (tagIt == m_allowedXhtmlTags.end()) { - QNTRACE(QStringLiteral("Haven't found tag ") << lastElementName - << QStringLiteral(" within the list of allowed XHTML tags, " - "skipping it")); + QNTRACE("Haven't found tag " << lastElementName + << " within the list of allowed XHTML tags, skipping it"); continue; } @@ -1026,8 +1017,7 @@ { QStringRef attributeName = it->name(); if (isForbiddenXhtmlAttribute(attributeName.toString())) { - QNTRACE(QStringLiteral("Erasing the forbidden attribute ") - << attributeName); + QNTRACE("Erasing the forbidden attribute " << attributeName); it = lastElementAttributes.erase(it); continue; } @@ -1038,8 +1028,8 @@ writer.writeStartElement(lastElementName); writer.writeAttributes(lastElementAttributes); ++writeElementCounter; - QNTRACE(QStringLiteral("Wrote element: name = ") << lastElementName - << QStringLiteral(" and its attributes")); + QNTRACE("Wrote element: name = " << lastElementName + << " and its attributes"); } if ((writeElementCounter > 0) && reader.isCharacters()) @@ -1048,11 +1038,11 @@ if (reader.isCDATA()) { writer.writeCDATA(text); - QNTRACE(QStringLiteral("Wrote CDATA: ") << text); + QNTRACE("Wrote CDATA: " << text); } else { writer.writeCharacters(text); - QNTRACE(QStringLiteral("Wrote characters: ") << text); + QNTRACE("Wrote characters: " << text); } } @@ -1070,15 +1060,15 @@ if (reader.hasError()) { errorDescription.setBase(QT_TR_NOOP("Failed to clean up the input HTML")); errorDescription.details() = reader.errorString(); - QNWARNING(QStringLiteral("Error reading the input HTML: ") << errorDescription - << QStringLiteral(", input HTML: ") << inputHtml - << QStringLiteral("\n\nSupplemented input HTML: ") << supplementedHtml - << QStringLiteral("\n\nHTML converted to XML: ") << m_cachedConvertedXml); + QNWARNING("Error reading the input HTML: " << errorDescription + << ", input HTML: " << inputHtml + << "\n\nSupplemented input HTML: " << supplementedHtml + << "\n\nHTML converted to XML: " << m_cachedConvertedXml); return false; } cleanedUpHtml = QString::fromUtf8(outputSupplementedHtmlBuffer.buffer()); - QNDEBUG(QStringLiteral("Cleaned up HTML: ") << cleanedUpHtml); + QNDEBUG("Cleaned up HTML: " << cleanedUpHtml); return true; } @@ -1088,7 +1078,7 @@ DecryptedTextManager & decryptedTextManager, NoteContentToHtmlExtraData & extraData) const { - QNDEBUG(QStringLiteral("ENMLConverterPrivate::noteContentToHtml: ") << noteContent); + QNDEBUG("ENMLConverterPrivate::noteContentToHtml: " << noteContent); extraData.m_numEnToDoNodes = 0; extraData.m_numHyperlinkNodes = 0; @@ -1142,7 +1132,7 @@ if (lastElementName == QStringLiteral("en-note")) { - QNTRACE(QStringLiteral("Replacing en-note with \"body\" tag")); + QNTRACE("Replacing en-note with \"body\" tag"); lastElementName = QStringLiteral("body"); } else if (lastElementName == QStringLiteral("en-media")) @@ -1180,8 +1170,8 @@ writer.writeStartElement(lastElementName); writer.writeAttributes(lastElementAttributes); - QNTRACE(QStringLiteral("Wrote start element: ") << lastElementName - << QStringLiteral(" and its attributes")); + QNTRACE("Wrote start element: " << lastElementName + << " and its attributes"); } if ((writeElementCounter > 0) && reader.isCharacters()) @@ -1211,11 +1201,11 @@ if (reader.isCDATA()) { writer.writeCDATA(data); - QNTRACE(QStringLiteral("Wrote CDATA: ") << data); + QNTRACE("Wrote CDATA: " << data); } else { writer.writeCharacters(data); - QNTRACE(QStringLiteral("Wrote characters: ") << data); + QNTRACE("Wrote characters: " << data); } } @@ -1225,7 +1215,7 @@ // NOTE: the following trick seems to prevent the occurrence of // self-closing empty XML tags which are sometimes misinterpreted // by web engines as unclosed tags - writer.writeCharacters(QStringLiteral("")); + writer.writeCharacters(QLatin1String("")); } writer.writeEndElement(); @@ -1234,7 +1224,7 @@ } if (reader.hasError()) { - QNWARNING(QStringLiteral("Error reading ENML: ") << reader.errorString()); + QNWARNING("Error reading ENML: " << reader.errorString()); return false; } @@ -1245,14 +1235,14 @@ bool ENMLConverterPrivate::validateEnml(const QString & enml, ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("ENMLConverterPrivate::validateEnml")); + QNDEBUG("ENMLConverterPrivate::validateEnml"); return validateAgainstDtd(enml, QStringLiteral(":/enml2.dtd"), errorDescription); } bool ENMLConverterPrivate::validateAndFixupEnml(QString & enml, ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("ENMLConverterPrivate::validateAndFixupEnml: ") << enml); + QNDEBUG("ENMLConverterPrivate::validateAndFixupEnml: " << enml); bool res = validateEnml(enml, errorDescription); if (res) { @@ -1327,12 +1317,11 @@ if (QuentierIsLogLevelActive(LogLevel::TraceLevel)) { - QNTRACE(QStringLiteral("Parsed forbidden attributes per element: ")); + QNTRACE("Parsed forbidden attributes per element: "); for(auto it = elementToForbiddenAttributes.constBegin(), end = elementToForbiddenAttributes.constEnd(); it != end; ++it) { - QNTRACE(QStringLiteral("[") << it.key() - << QStringLiteral("]: ") << it.value()); + QNTRACE("[" << it.key() << "]: " << it.value()); } } @@ -1379,8 +1368,7 @@ auto it = elementToForbiddenAttributes.find(lastElementName); if (it == elementToForbiddenAttributes.end()) { - QNTRACE(QStringLiteral("No forbidden attributes for element ") - << lastElementName); + QNTRACE("No forbidden attributes for element " << lastElementName); writer.writeStartElement(lastElementName); writer.writeAttributes(lastElementAttributes); continue; @@ -1394,8 +1382,7 @@ { QString attributeName = ait->name().toString(); if (forbiddenAttributes.contains(attributeName)) { - QNTRACE(QStringLiteral("Erasing the forbidden attribute ") - << attributeName); + QNTRACE("Erasing the forbidden attribute " << attributeName); ait = lastElementAttributes.erase(ait); continue; } @@ -1405,8 +1392,8 @@ writer.writeStartElement(lastElementName); writer.writeAttributes(lastElementAttributes); - QNTRACE(QStringLiteral("Wrote element: name = ") << lastElementName - << QStringLiteral(" and its attributes")); + QNTRACE("Wrote element: name = " << lastElementName + << " and its attributes"); } if (reader.isCharacters()) @@ -1415,11 +1402,11 @@ if (reader.isCDATA()) { writer.writeCDATA(text); - QNTRACE(QStringLiteral("Wrote CDATA: ") << text); + QNTRACE("Wrote CDATA: " << text); } else { writer.writeCharacters(text); - QNTRACE(QStringLiteral("Wrote characters: ") << text); + QNTRACE("Wrote characters: " << text); } } @@ -1429,13 +1416,13 @@ } if (Q_UNLIKELY(reader.hasError())) { - QNWARNING(QStringLiteral("Wasn't able to fixup the ENML as it is a malformed XML: ") + QNWARNING("Wasn't able to fixup the ENML as it is a malformed XML: " << reader.errorString()); return false; } enml = QString::fromUtf8(fixedUpEnmlBuffer.buffer()); - QNTRACE(QStringLiteral("ENML after fixing up: ") << enml); + QNTRACE("ENML after fixing up: " << enml); return validateEnml(enml, errorDescription); } @@ -1444,8 +1431,7 @@ QString & plainText, ErrorString & errorMessage) { - QNTRACE(QStringLiteral("ENMLConverterPrivate::noteContentToPlainText: ") - << noteContent); + QNTRACE("ENMLConverterPrivate::noteContentToPlainText: " << noteContent); plainText.resize(0); @@ -1617,19 +1603,19 @@ QString ENMLConverterPrivate::resourceHtml(const Resource & resource, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("ENMLConverterPrivate::resourceHtml")); + QNDEBUG("ENMLConverterPrivate::resourceHtml"); if (Q_UNLIKELY(!resource.hasDataHash())) { errorDescription.setBase(QT_TR_NOOP("Can't compose the resource's html " "representation: no data hash is set")); - QNWARNING(errorDescription << QStringLiteral(", resource: ") << resource); + QNWARNING(errorDescription << ", resource: " << resource); return QString(); } if (Q_UNLIKELY(!resource.hasMime())) { errorDescription.setBase(QT_TR_NOOP("Can't compose the resource's html " "representation: no mime type is set")); - QNWARNING(errorDescription << QStringLiteral(", resource: ") << resource); + QNWARNING(errorDescription << ", resource: " << resource); return QString(); } @@ -1652,7 +1638,7 @@ res = resourceInfoToHtml(attributes, writer, errorDescription); if (Q_UNLIKELY(!res)) { - QNWARNING(errorDescription << QStringLiteral(", resource: ") << resource); + QNWARNING(errorDescription << ", resource: " << resource); return QString(); } @@ -1662,13 +1648,13 @@ void ENMLConverterPrivate::escapeString(QString & string, const bool simplify) { - QNTRACE(QStringLiteral("String before escaping: ") << string); + QNTRACE("String before escaping: " << string); string.replace(QStringLiteral("\'"), QStringLiteral("\\x27"), Qt::CaseInsensitive); string.replace(QStringLiteral("\""), QStringLiteral("\\x22"), Qt::CaseInsensitive); if (simplify) { string = string.simplified(); } - QNTRACE(QStringLiteral("String after escaping: ") << string); + QNTRACE("String after escaping: " << string); } bool ENMLConverterPrivate::exportNotesToEnex( @@ -1677,13 +1663,13 @@ const ENMLConverter::EnexExportTags::type exportTagsOption, QString & enex, ErrorString & errorDescription, const QString & version) const { - QNDEBUG(QStringLiteral("ENMLConverterPrivate::exportNotesToEnex: num notes = ") - << notes.size() << QStringLiteral(", num tag names by tag local uids = ") - << tagNamesByTagLocalUids.size() << QStringLiteral(", export tags option = ") + QNDEBUG("ENMLConverterPrivate::exportNotesToEnex: num notes = " + << notes.size() << ", num tag names by tag local uids = " + << tagNamesByTagLocalUids.size() << ", export tags option = " << ((exportTagsOption == ENMLConverter::EnexExportTags::Yes) - ? QStringLiteral("Yes") - : QStringLiteral("No")) - << QStringLiteral(", version = ") << version); + ? "Yes" + : "No") + << ", version = " << version); enex.resize(0); @@ -1758,8 +1744,8 @@ ((exportTagsOption != ENMLConverter::EnexExportTags::Yes) || !note.hasTagLocalUids())) { - QNINFO(QStringLiteral("Skipping note without title, content, " - "resources or tags in export to ENML")); + QNINFO("Skipping note without title, content, " + "resources or tags in export to ENML"); continue; } @@ -1814,9 +1800,9 @@ const QString & tagName = tagNameIt.value(); if (Q_UNLIKELY(tagName.isEmpty())) { - QNWARNING(QStringLiteral("Skipping tag with empty name, ") - << QStringLiteral(" tag local uid = ") << *tagIt - << QStringLiteral(", note: ") << note); + QNWARNING("Skipping tag with empty name, " + << " tag local uid = " << *tagIt + << ", note: " << note); continue; } @@ -1969,14 +1955,14 @@ { const Resource & resource = *resIt; if (!resource.hasDataBody()) { - QNINFO(QStringLiteral("Skipping ENEX export of a resource " - "without data body: ") << resource); + QNINFO("Skipping ENEX export of a resource " + "without data body: " << resource); continue; } if (!resource.hasMime()) { - QNINFO(QStringLiteral("Skipping ENEX export of a resource " - "without mime type: ") << resource); + QNINFO("Skipping ENEX export of a resource " + "without mime type: " << resource); continue; } @@ -1988,8 +1974,7 @@ errorDescription.setBase( QT_TR_NOOP("Can't export note(s) to ENEX: found resource " "larger than 25 Mb")); - QNINFO(errorDescription << QStringLiteral(", resource: ") - << resource); + QNINFO(errorDescription << ", resource: " << resource); return false; } @@ -2172,7 +2157,7 @@ error.appendBase(errorDescription.additionalBases()); error.details() = errorDescription.details(); errorDescription = error; - QNWARNING(errorDescription << QStringLiteral(", enex: ") << enex); + QNWARNING(errorDescription << ", enex: " << enex); return false; } @@ -2183,18 +2168,18 @@ QHash<QString, QStringList> & tagNamesByNoteLocalUid, ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("ENMLConverterPrivate::importEnex")); + QNDEBUG("ENMLConverterPrivate::importEnex"); if (Q_UNLIKELY(enex.isEmpty())) { errorDescription.setBase(QT_TR_NOOP("Can't import ENEX: the input is empty")); - QNWARNING(errorDescription << QStringLiteral(", enex: ") << enex); + QNWARNING(errorDescription << ", enex: " << enex); return false; } notes.resize(0); tagNamesByNoteLocalUid.clear(); - const QString dateTimeFormat = ENEX_DATE_TIME_FORMAT; + const QString dateTimeFormat = QStringLiteral(ENEX_DATE_TIME_FORMAT); bool insideNote = false; bool insideNoteContent = false; @@ -2227,25 +2212,25 @@ } if (elementName == QStringLiteral("export-date")) { - QNTRACE(QStringLiteral("export date: ") + QNTRACE("export date: " << reader.readElementText(QXmlStreamReader::SkipChildElements)); continue; } if (elementName == QStringLiteral("application")) { - QNTRACE(QStringLiteral("application: ") + QNTRACE("application: " << reader.readElementText(QXmlStreamReader::SkipChildElements)); continue; } if (elementName == QStringLiteral("version")) { - QNTRACE(QStringLiteral("version") + QNTRACE("version" << reader.readElementText(QXmlStreamReader::SkipChildElements)); continue; } if (elementName == QStringLiteral("note")) { - QNTRACE(QStringLiteral("Starting a new note")); + QNTRACE("Starting a new note"); currentNote.clear(); currentNote.setLocalUid(UidGenerator::Generate()); insideNote = true; @@ -2258,7 +2243,7 @@ { QString title = reader.readElementText(QXmlStreamReader::SkipChildElements); - QNTRACE(QStringLiteral("Note title: ") << title); + QNTRACE("Note title: " << title); currentNote.setTitle(title); continue; } @@ -2272,7 +2257,7 @@ if (elementName == QStringLiteral("content")) { if (insideNote) { - QNTRACE(QStringLiteral("Start of note content")); + QNTRACE("Start of note content"); insideNoteContent = true; currentNoteContent.resize(0); continue; @@ -2290,7 +2275,7 @@ { QString creationDateTimeString = reader.readElementText(QXmlStreamReader::SkipChildElements); - QNTRACE(QStringLiteral("Creation datetime: ") << creationDateTimeString); + QNTRACE("Creation datetime: " << creationDateTimeString); QDateTime creationDateTime = QDateTime::fromString(creationDateTimeString, dateTimeFormat); if (Q_UNLIKELY(!creationDateTime.isValid())) @@ -2304,7 +2289,7 @@ qint64 timestamp = timestampFromDateTime(creationDateTime); currentNote.setCreationTimestamp(timestamp); - QNTRACE(QStringLiteral("Set creation timestamp to ") << timestamp); + QNTRACE("Set creation timestamp to " << timestamp); continue; } @@ -2320,8 +2305,7 @@ { QString modificationDateTimeString = reader.readElementText(QXmlStreamReader::SkipChildElements); - QNTRACE(QStringLiteral("Modification datetime: ") - << modificationDateTimeString); + QNTRACE("Modification datetime: " << modificationDateTimeString); QDateTime modificationDateTime = QDateTime::fromString(modificationDateTimeString, dateTimeFormat); if (Q_UNLIKELY(!modificationDateTime.isValid())) @@ -2335,7 +2319,7 @@ qint64 timestamp = timestampFromDateTime(modificationDateTime); currentNote.setModificationTimestamp(timestamp); - QNTRACE(QStringLiteral("Set modification timestamp to ") << timestamp); + QNTRACE("Set modification timestamp to " << timestamp); continue; } @@ -2358,9 +2342,8 @@ if (!tagNames.contains(tagName)) { tagNames << tagName; - QNTRACE(QStringLiteral("Added tag name ") << tagName - << QStringLiteral(" for note local uid ") - << noteLocalUid); + QNTRACE("Added tag name " << tagName + << " for note local uid " << noteLocalUid); } continue; @@ -2374,7 +2357,7 @@ if (elementName == QStringLiteral("note-attributes")) { if (insideNote) { - QNTRACE(QStringLiteral("Start of note attributes")); + QNTRACE("Start of note attributes"); insideNoteAttributes = true; continue; } @@ -2405,7 +2388,7 @@ qevercloud::NoteAttributes & noteAttributes = currentNote.noteAttributes(); noteAttributes.latitude = latitudeNum; - QNTRACE(QStringLiteral("Set note latitude to ") << latitudeNum); + QNTRACE("Set note latitude to " << latitudeNum); continue; } else if (insideResourceAttributes) @@ -2413,7 +2396,7 @@ qevercloud::ResourceAttributes & resourceAttributes = currentResource.resourceAttributes(); resourceAttributes.latitude = latitudeNum; - QNTRACE(QStringLiteral("Set resource latitude to ") << latitudeNum); + QNTRACE("Set resource latitude to " << latitudeNum); continue; } @@ -2449,8 +2432,7 @@ qevercloud::NoteAttributes & noteAttributes = currentNote.noteAttributes(); noteAttributes.longitude = longitudeNum; - QNTRACE(QStringLiteral("Set note longitude to ") - << longitudeNum); + QNTRACE("Set note longitude to " << longitudeNum); continue; } else if (insideResourceAttributes) @@ -2458,8 +2440,7 @@ qevercloud::ResourceAttributes & resourceAttributes = currentResource.resourceAttributes(); resourceAttributes.longitude = longitudeNum; - QNTRACE(QStringLiteral("Set resource longitude to ") - << longitudeNum); + QNTRACE("Set resource longitude to " << longitudeNum); continue; } @@ -2495,8 +2476,7 @@ qevercloud::NoteAttributes & noteAttributes = currentNote.noteAttributes(); noteAttributes.altitude = altitudeNum; - QNTRACE(QStringLiteral("Set note altitude to ") - << altitudeNum); + QNTRACE("Set note altitude to " << altitudeNum); continue; } else if (insideResourceAttributes) @@ -2504,8 +2484,7 @@ qevercloud::ResourceAttributes & resourceAttributes = currentResource.resourceAttributes(); resourceAttributes.altitude = altitudeNum; - QNTRACE(QStringLiteral("Set resource altitude to ") - << altitudeNum); + QNTRACE("Set resource altitude to " << altitudeNum); continue; } @@ -2529,7 +2508,7 @@ qevercloud::NoteAttributes & noteAttributes = currentNote.noteAttributes(); noteAttributes.author = author; - QNTRACE(QStringLiteral("Set author to ") << author); + QNTRACE("Set author to " << author); continue; } @@ -2548,7 +2527,7 @@ qevercloud::NoteAttributes & noteAttributes = currentNote.noteAttributes(); noteAttributes.source = source; - QNTRACE(QStringLiteral("Set source to ") << source); + QNTRACE("Set source to " << source); continue; } @@ -2570,8 +2549,7 @@ qevercloud::NoteAttributes & noteAttributes = currentNote.noteAttributes(); noteAttributes.sourceURL = sourceUrl; - QNTRACE(QStringLiteral("Set note source url to ") - << sourceUrl); + QNTRACE("Set note source url to " << sourceUrl); continue; } else if (insideResource && insideResourceAttributes) @@ -2579,8 +2557,7 @@ qevercloud::ResourceAttributes & resourceAttributes = currentResource.resourceAttributes(); resourceAttributes.sourceURL = sourceUrl; - QNTRACE(QStringLiteral("Set resource source url to ") - << sourceUrl); + QNTRACE("Set resource source url to " << sourceUrl); continue; } @@ -2604,8 +2581,7 @@ qevercloud::NoteAttributes & noteAttributes = currentNote.noteAttributes(); noteAttributes.sourceApplication = sourceApplication; - QNTRACE(QStringLiteral("Set source application to ") - << sourceApplication); + QNTRACE("Set source application to " << sourceApplication); continue; } @@ -2633,8 +2609,7 @@ qevercloud::NoteAttributes & noteAttributes = currentNote.noteAttributes(); noteAttributes.reminderOrder = reminderOrderNum; - QNTRACE(QStringLiteral("Set the reminder order to ") - << reminderOrderNum); + QNTRACE("Set the reminder order to " << reminderOrderNum); continue; } @@ -2666,7 +2641,7 @@ qevercloud::NoteAttributes & noteAttributes = currentNote.noteAttributes(); noteAttributes.reminderTime = timestamp; - QNTRACE(QStringLiteral("Set reminder time to ") << timestamp); + QNTRACE("Set reminder time to " << timestamp); continue; } @@ -2698,7 +2673,7 @@ qevercloud::NoteAttributes & noteAttributes = currentNote.noteAttributes(); noteAttributes.subjectDate = timestamp; - QNTRACE(QStringLiteral("Set subject date to ") << timestamp); + QNTRACE("Set subject date to " << timestamp); continue; } @@ -2731,7 +2706,7 @@ qevercloud::NoteAttributes & noteAttributes = currentNote.noteAttributes(); noteAttributes.reminderDoneTime = timestamp; - QNTRACE(QStringLiteral("Set reminder done time to ") << timestamp); + QNTRACE("Set reminder done time to " << timestamp); continue; } @@ -2752,7 +2727,7 @@ qevercloud::NoteAttributes & noteAttributes = currentNote.noteAttributes(); noteAttributes.placeName = placeName; - QNTRACE(QStringLiteral("Set place name to ") << placeName); + QNTRACE("Set place name to " << placeName); continue; } @@ -2771,7 +2746,7 @@ qevercloud::NoteAttributes & noteAttributes = currentNote.noteAttributes(); noteAttributes.contentClass = contentClass; - QNTRACE(QStringLiteral("Set content class to ") << contentClass); + QNTRACE("Set content class to " << contentClass); continue; } @@ -2815,9 +2790,8 @@ Q_UNUSED(noteAttributes.applicationData->keysOnly.ref().insert(key)); noteAttributes.applicationData->fullMap.ref()[key] = value; - QNTRACE(QStringLiteral("Inserted note application ") - << QStringLiteral("data entry: key = ") << key - << QStringLiteral(", value = ") << value); + QNTRACE("Inserted note application data entry: key = " + << key << ", value = " << value); continue; } else @@ -2856,9 +2830,8 @@ Q_UNUSED(resourceAttributes.applicationData->keysOnly.ref().insert(key)); resourceAttributes.applicationData->fullMap.ref()[key] = value; - QNTRACE(QStringLiteral("Inserted resource application ") - << QStringLiteral("data entry: key = ") << key - << QStringLiteral(", value = ") << value); + QNTRACE("Inserted resource application data entry: key = " + << key << ", value = " << value); continue; } else @@ -2886,7 +2859,7 @@ if (elementName == QStringLiteral("resource")) { - QNTRACE(QStringLiteral("Start of resource tag")); + QNTRACE("Start of resource tag"); insideResource = true; currentResource.clear(); @@ -2902,7 +2875,7 @@ if (elementName == QStringLiteral("data")) { if (insideResource) { - QNTRACE(QStringLiteral("Start of resource data")); + QNTRACE("Start of resource data"); insideResourceData = true; continue; } @@ -2920,7 +2893,7 @@ QString mime = reader.readElementText(QXmlStreamReader::SkipChildElements); currentResource.setMime(mime); - QNTRACE(QStringLiteral("Set resource mime to ") << mime); + QNTRACE("Set resource mime to " << mime); continue; } @@ -2949,7 +2922,7 @@ } currentResource.setWidth(widthNum); - QNTRACE(QStringLiteral("Set resource width to ") << widthNum); + QNTRACE("Set resource width to " << widthNum); continue; } @@ -2977,7 +2950,7 @@ } currentResource.setHeight(heightNum); - QNTRACE(QStringLiteral("Set resource height to ") << heightNum); + QNTRACE("Set resource height to " << heightNum); continue; } @@ -2990,7 +2963,7 @@ if (elementName == QStringLiteral("recognition")) { if (insideResource) { - QNTRACE(QStringLiteral("Start of resource recognition data")); + QNTRACE("Start of resource recognition data"); insideResourceRecognitionData = true; continue; } @@ -3004,7 +2977,7 @@ if (elementName == QStringLiteral("resource-attributes")) { if (insideResource) { - QNTRACE(QStringLiteral("Start of resource attributes")); + QNTRACE("Start of resource attributes"); insideResourceAttributes = true; continue; } @@ -3036,7 +3009,7 @@ qevercloud::ResourceAttributes & resourceAttributes = currentResource.resourceAttributes(); resourceAttributes.timestamp = timestamp; - QNTRACE(QStringLiteral("Set resource timestamp to ") << timestamp); + QNTRACE("Set resource timestamp to " << timestamp); continue; } @@ -3056,7 +3029,7 @@ qevercloud::ResourceAttributes & resourceAttributes = currentResource.resourceAttributes(); resourceAttributes.cameraMake = cameraMake; - QNTRACE(QStringLiteral("Set camera make to ") << cameraMake); + QNTRACE("Set camera make to " << cameraMake); continue; } @@ -3075,7 +3048,7 @@ qevercloud::ResourceAttributes & resourceAttributes = currentResource.resourceAttributes(); resourceAttributes.recoType = recoType; - QNTRACE(QStringLiteral("Set reco type to ") << recoType); + QNTRACE("Set reco type to " << recoType); continue; } @@ -3094,7 +3067,7 @@ qevercloud::ResourceAttributes & resourceAttributes = currentResource.resourceAttributes(); resourceAttributes.fileName = fileName; - QNTRACE(QStringLiteral("Set file name to ") << fileName); + QNTRACE("Set file name to " << fileName); continue; } @@ -3114,11 +3087,11 @@ currentResource.resourceAttributes(); if (attachment == QStringLiteral("true")) { resourceAttributes.attachment = true; - QNTRACE(QStringLiteral("Set attachment to true")); + QNTRACE("Set attachment to true"); } else if (attachment == QStringLiteral("false")) { resourceAttributes.attachment = false; - QNTRACE(QStringLiteral("Set attachment to false")); + QNTRACE("Set attachment to false"); } else { errorDescription.setBase( @@ -3140,7 +3113,7 @@ if (elementName == QStringLiteral("alternate-data")) { if (insideResource) { - QNTRACE(QStringLiteral("Start of resource alternate data")); + QNTRACE("Start of resource alternate data"); insideResourceAlternateData = true; continue; } @@ -3158,8 +3131,7 @@ { if (insideNoteContent && reader.isCDATA()) { currentNoteContent = reader.text().toString(); - QNTRACE(QStringLiteral("Current note content: ") - << currentNoteContent); + QNTRACE("Current note content: " << currentNoteContent); continue; } @@ -3169,14 +3141,14 @@ { currentResourceData = QByteArray::fromBase64(reader.text().toString().toLocal8Bit()); - QNTRACE(QStringLiteral("Read resource data")); + QNTRACE("Read resource data"); continue; } if (insideResourceRecognitionData) { currentResourceRecognitionData = reader.text().toString().toUtf8(); - QNTRACE(QStringLiteral("Read resource recognition data")); + QNTRACE("Read resource recognition data"); ErrorString error; bool res = validateRecoIndex( @@ -3200,7 +3172,7 @@ { currentResourceAlternateData = QByteArray::fromBase64(reader.text().toString().toLocal8Bit()); - QNTRACE(QStringLiteral("Read resource alternate data")); + QNTRACE("Read resource alternate data"); continue; } } @@ -3213,28 +3185,27 @@ if (elementName == QStringLiteral("content")) { - QNTRACE(QStringLiteral("End of note content: ") - << currentNoteContent); + QNTRACE("End of note content: " << currentNoteContent); currentNote.setContent(currentNoteContent); insideNoteContent = false; continue; } if (elementName == QStringLiteral("note-attributes")) { - QNTRACE(QStringLiteral("End of note attributes")); + QNTRACE("End of note attributes"); insideNoteAttributes = false; continue; } if (elementName == QStringLiteral("resource-attributes")) { - QNTRACE(QStringLiteral("End of resource attributes")); + QNTRACE("End of resource attributes"); insideResourceAttributes = false; continue; } if (elementName == QStringLiteral("data")) { - QNTRACE(QStringLiteral("End of resource data")); + QNTRACE("End of resource data"); currentResource.setDataBody(currentResourceData); currentResource.setDataHash( QCryptographicHash::hash(currentResourceData, @@ -3246,7 +3217,7 @@ if (elementName == QStringLiteral("recognition")) { - QNTRACE(QStringLiteral("End of resource recognition data")); + QNTRACE("End of resource recognition data"); currentResource.setRecognitionDataBody( currentResourceRecognitionData); currentResource.setRecognitionDataHash( @@ -3259,7 +3230,7 @@ } if (elementName == QStringLiteral("alternate-data")) { - QNTRACE(QStringLiteral("End of resource alternate data")); + QNTRACE("End of resource alternate data"); currentResource.setAlternateDataBody(currentResourceAlternateData); currentResource.setAlternateDataHash( QCryptographicHash::hash(currentResourceAlternateData, @@ -3272,13 +3243,13 @@ if (elementName == QStringLiteral("resource")) { - QNTRACE(QStringLiteral("End of resource")); + QNTRACE("End of resource"); if (Q_UNLIKELY(!currentResource.hasDataBody())) { errorDescription.setBase( QT_TR_NOOP("Parsed resource without a data body")); - QNWARNING(errorDescription << QStringLiteral(", resource: ") + QNWARNING(errorDescription << ", resource: " << currentResource); return false; } @@ -3288,7 +3259,7 @@ errorDescription.setBase( QT_TR_NOOP("Internal error: data hash is not computed " "for the resource")); - QNWARNING(errorDescription << QStringLiteral(", resource: ") + QNWARNING(errorDescription << ", resource: " << currentResource); return false; } @@ -3298,7 +3269,7 @@ errorDescription.setBase( QT_TR_NOOP("Internal error: data size is not computed " "for the resource")); - QNWARNING(errorDescription << QStringLiteral(", resource: ") + QNWARNING(errorDescription << ", resource: " << currentResource); return false; } @@ -3307,21 +3278,21 @@ { errorDescription.setBase( QT_TR_NOOP("Parsed resource without a mime type")); - QNWARNING(errorDescription << QStringLiteral(", resource: ") + QNWARNING(errorDescription << ", resource: " << currentResource); return false; } insideResource = false; currentNote.addResource(currentResource); - QNTRACE(QStringLiteral("Added resource to note: ") << currentResource); + QNTRACE("Added resource to note: " << currentResource); currentResource.clear(); continue; } if (elementName == QStringLiteral("note")) { - QNTRACE(QStringLiteral("End of note: ") << currentNote); + QNTRACE("End of note: " << currentNote); notes << currentNote; currentNote.clear(); insideNote = false; @@ -3330,7 +3301,7 @@ } } - QNDEBUG(QStringLiteral("ENEX import end: num notes = ") << notes.size()); + QNDEBUG("ENEX import end: num notes = " << notes.size()); return true; } @@ -3381,7 +3352,7 @@ const quint64 enToDoIndex, QXmlStreamWriter & writer) const { - QNDEBUG(QStringLiteral("ENMLConverterPrivate::toDoTagsToHtml")); + QNDEBUG("ENMLConverterPrivate::toDoTagsToHtml"); QXmlStreamAttributes originalAttributes = reader.attributes(); bool checked = false; @@ -3392,11 +3363,11 @@ } } - QNTRACE(QStringLiteral("Converting ") + QNTRACE("Converting " << (checked - ? QStringLiteral("completed") - : QStringLiteral("not yet completed")) - << QStringLiteral(" ToDo item")); + ? "completed" + : "not yet completed") + << " ToDo item"); writer.writeStartElement(QStringLiteral("img")); @@ -3426,10 +3397,10 @@ QXmlStreamWriter & writer, DecryptedTextManager & decryptedTextManager, bool & convertedToEnCryptNode) const { - QNDEBUG(QStringLiteral("ENMLConverterPrivate::encryptedTextToHtml: ") - << QStringLiteral("encrypted text = ") << encryptedTextCharacters - << QStringLiteral(", en-crypt index = ") << enCryptIndex - << QStringLiteral(", en-decrypted index = ") << enDecryptedIndex); + QNDEBUG("ENMLConverterPrivate::encryptedTextToHtml: " + << "encrypted text = " << encryptedTextCharacters + << ", en-crypt index = " << enCryptIndex + << ", en-decrypted index = " << enDecryptedIndex); QString cipher; if (enCryptAttributes.hasAttribute(QStringLiteral("cipher"))) { @@ -3454,8 +3425,8 @@ if (foundDecryptedText) { - QNTRACE(QStringLiteral("Found encrypted text which has already been ") - << QStringLiteral("decrypted and cached; encrypted text = ") + QNTRACE("Found encrypted text which has already been " + << "decrypted and cached; encrypted text = " << encryptedTextCharacters); size_t keyLength = 0; @@ -3464,8 +3435,8 @@ bool conversionResult = false; keyLength = static_cast<size_t>(length.toUInt(&conversionResult)); if (!conversionResult) { - QNWARNING(QStringLiteral("Can't convert encryption key length ") - << QStringLiteral("from string to unsigned integer: ") + QNWARNING("Can't convert encryption key length " + << "from string to unsigned integer: " << length); keyLength = 0; } @@ -3506,7 +3477,7 @@ writer.writeAttribute(QStringLiteral("encrypted_text"), encryptedTextCharacters.toString()); - QNTRACE(QStringLiteral("Wrote element corresponding to en-crypt ENML tag")); + QNTRACE("Wrote element corresponding to en-crypt ENML tag"); writer.writeAttribute(QStringLiteral("en-crypt-id"), QString::number(enCryptIndex)); @@ -3525,7 +3496,7 @@ const QXmlStreamAttributes & attributes, QXmlStreamWriter & writer, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("ENMLConverterPrivate::resourceInfoToHtml")); + QNDEBUG("ENMLConverterPrivate::resourceInfoToHtml"); if (!attributes.hasAttribute(QStringLiteral("hash"))) { errorDescription.setBase(QT_TR_NOOP("Detected incorrect en-media tag " @@ -3630,7 +3601,7 @@ QXmlStreamWriter & writer, ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("ENMLConverterPrivate::decryptedTextToEnml")); + QNDEBUG("ENMLConverterPrivate::decryptedTextToEnml"); const QXmlStreamAttributes attributes = reader.attributes(); if (!attributes.hasAttribute(QStringLiteral("encrypted_text"))) { @@ -3687,23 +3658,23 @@ if (reader.hasError()) { errorDescription.setBase(QT_TR_NOOP("Text decryption failed")); errorDescription.details() = reader.errorString(); - QNWARNING(QStringLiteral("Couldn't read the nested contents of en-decrypted ") - << QStringLiteral("div, reader has error: ") << errorDescription); + QNWARNING("Couldn't read the nested contents of en-decrypted " + << "div, reader has error: " << errorDescription); return false; } if (storedDecryptedText != actualDecryptedText) { - QNTRACE(QStringLiteral("Found modified decrypted text, need to re-encrypt")); + QNTRACE("Found modified decrypted text, need to re-encrypt"); QString actualEncryptedText; res = decryptedTextManager.modifyDecryptedText(encryptedText, actualDecryptedText, actualEncryptedText); if (res) { - QNTRACE(QStringLiteral("Re-evaluated the modified decrypted text's ") - << QStringLiteral("encrypted text; was: ") << encryptedText - << QStringLiteral("; new: ") << actualEncryptedText); + QNTRACE("Re-evaluated the modified decrypted text's " + << "encrypted text; was: " << encryptedText + << "; new: " << actualEncryptedText); encryptedText = actualEncryptedText; } } @@ -3732,7 +3703,7 @@ writer.writeCharacters(encryptedText); writer.writeEndElement(); - QNTRACE(QStringLiteral("Wrote en-crypt ENML tag from en-decrypted p tag")); + QNTRACE("Wrote en-crypt ENML tag from en-decrypted p tag"); return true; } @@ -3786,21 +3757,21 @@ (attributes.value(QStringLiteral("id")) == QStringLiteral("decrypted_text_html_to_enml_temporary"))) { - QNTRACE(QStringLiteral("Skipping the start of temporarily added div")); + QNTRACE("Skipping the start of temporarily added div"); continue; } writer.writeStartElement(decryptedTextReader.name().toString()); writer.writeAttributes(attributes); foundFormattedText = true; - QNTRACE(QStringLiteral("Wrote start element from decrypted text: ") + QNTRACE("Wrote start element from decrypted text: " << decryptedTextReader.name()); } if (decryptedTextReader.isCharacters()) { writer.writeCharacters(decryptedTextReader.text().toString()); foundFormattedText = true; - QNTRACE(QStringLiteral("Wrote characters from decrypted text: ") + QNTRACE("Wrote characters from decrypted text: " << decryptedTextReader.text()); } @@ -3811,32 +3782,31 @@ (attributes.value(QStringLiteral("id")) == QStringLiteral("decrypted_text_html_to_enml_temporary"))) { - QNTRACE(QStringLiteral("Skipping the end of temporarily added div")); + QNTRACE("Skipping the end of temporarily added div"); continue; } writer.writeEndElement(); - QNTRACE(QStringLiteral("Wrote end element from decrypted text: ") + QNTRACE("Wrote end element from decrypted text: " << decryptedTextReader.name()); } } if (decryptedTextReader.hasError()) { - QNWARNING(QStringLiteral("Decrypted text reader has error: ") + QNWARNING("Decrypted text reader has error: " << decryptedTextReader.errorString()); } if (!foundFormattedText) { writer.writeCharacters(decryptedText); - QNTRACE(QStringLiteral("Wrote unformatted decrypted text: ") - << decryptedText); + QNTRACE("Wrote unformatted decrypted text: " << decryptedText); } } bool ENMLConverterPrivate::validateEnex(const QString & enex, ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("ENMLConverterPrivate::validateEnex")); + QNDEBUG("ENMLConverterPrivate::validateEnex"); return validateAgainstDtd(enex, QStringLiteral(":/evernote-export3.dtd"), errorDescription); } @@ -3844,8 +3814,7 @@ bool ENMLConverterPrivate::validateRecoIndex(const QString & recoIndex, ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("ENMLConverterPrivate::validateRecoIndex: reco index = ") - << recoIndex); + QNDEBUG("ENMLConverterPrivate::validateRecoIndex: reco index = " << recoIndex); return validateAgainstDtd(recoIndex, QStringLiteral(":/recoIndex.dtd"), errorDescription); } @@ -3854,8 +3823,7 @@ const QString & dtdFilePath, ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("ENMLConverterPrivate::validateAgainstDtd: dtd file ") - << dtdFilePath); + QNDEBUG("ENMLConverterPrivate::validateAgainstDtd: dtd file " << dtdFilePath); errorDescription.clear(); @@ -3864,7 +3832,7 @@ if (!pDoc) { errorDescription.setBase(QT_TR_NOOP("Could not validate document, can't " "parse the input into xml doc")); - QNWARNING(errorDescription << QStringLiteral(": input = ") << input); + QNWARNING(errorDescription << ": input = " << input); return false; } @@ -3872,8 +3840,8 @@ if (!dtdFile.open(QIODevice::ReadOnly)) { errorDescription.setBase(QT_TR_NOOP("Could not validate document, can't " "open the resource file with DTD")); - QNWARNING(errorDescription << QStringLiteral(": input = ") << input - << QStringLiteral(", DTD file path = ") << dtdFilePath); + QNWARNING(errorDescription << ": input = " << input + << ", DTD file path = " << dtdFilePath); xmlFreeDoc(pDoc); return false; } @@ -3951,13 +3919,13 @@ return timestamp; } -ShouldSkipElementResult::type -ENMLConverterPrivate::shouldSkipElement(const QString & elementName, - const QXmlStreamAttributes & attributes, - const QVector<SkipHtmlElementRule> & skipRules) const +ShouldSkipElementResult::type ENMLConverterPrivate::shouldSkipElement( + const QString & elementName, + const QXmlStreamAttributes & attributes, + const QVector<SkipHtmlElementRule> & skipRules) const { - QNDEBUG(QStringLiteral("ENMLConverterPrivate::shouldSkipElement: element name = ") - << elementName << QStringLiteral(", attributes = ") << attributes); + QNDEBUG("ENMLConverterPrivate::shouldSkipElement: element name = " + << elementName << ", attributes = " << attributes); if (skipRules.isEmpty()) { return ShouldSkipElementResult::ShouldNotSkip; @@ -3966,16 +3934,17 @@ ShouldSkipElementResult::Types flags; flags |= ShouldSkipElementResult::ShouldNotSkip; -#define CHECK_IF_SHOULD_SKIP() \ - if (shouldSkip) \ - { \ - if (rule.m_includeElementContents) { \ - flags |= ShouldSkipElementResult::SkipButPreserveContents; \ - } \ - else { \ - return ShouldSkipElementResult::SkipWithContents; \ - } \ - } +#define CHECK_IF_SHOULD_SKIP() \ + if (shouldSkip) \ + { \ + if (rule.m_includeElementContents) { \ + flags |= ShouldSkipElementResult::SkipButPreserveContents; \ + } \ + else { \ + return ShouldSkipElementResult::SkipWithContents; \ + } \ + } \ +// CHECK_IF_SHOULD_SKIP const int numAttributes = attributes.size(); @@ -4013,8 +3982,7 @@ rule.m_elementNameCaseSensitivity); break; default: - QNWARNING(QStringLiteral("Detected unhandled " - "SkipHtmlElementRule::ComparisonRule")); + QNWARNING("Detected unhandled SkipHtmlElementRule::ComparisonRule"); break; } @@ -4055,8 +4023,7 @@ rule.m_attributeNameCaseSensitivity); break; default: - QNWARNING(QStringLiteral("Detected unhandled " - "SkipHtmlElementRule::ComparisonRule")); + QNWARNING("Detected unhandled SkipHtmlElementRule::ComparisonRule"); break; } @@ -4098,8 +4065,7 @@ rule.m_attributeValueCaseSensitivity); break; default: - QNWARNING(QStringLiteral("Detected unhandled " - "SkipHtmlElementRule::ComparisonRule")); + QNWARNING("Detected unhandled SkipHtmlElementRule::ComparisonRule"); break; } @@ -4121,17 +4087,17 @@ { const int numAttributes = attributes.size(); - strm << QStringLiteral("QXmlStreamAttributes(") << numAttributes - << QStringLiteral("): {\n"); + strm << "QXmlStreamAttributes(" << numAttributes + << "): {\n"; for(int i = 0; i < numAttributes; ++i) { const QXmlStreamAttribute & attribute = attributes[i]; - strm << QStringLiteral(" [") << i << QStringLiteral("]: name = ") - << attribute.name().toString() << QStringLiteral(", value = ") - << attribute.value().toString() << QStringLiteral("\n"); + strm << " [" << i << "]: name = " + << attribute.name().toString() << ", value = " + << attribute.value().toString() << "\n"; } - strm << QStringLiteral("}\n"); + strm << "}\n"; return strm; } @@ -4140,26 +4106,25 @@ QTextStream & strm, const QVector<quentier::ENMLConverter::SkipHtmlElementRule> & rules) { - strm << QStringLiteral("SkipHtmlElementRules"); + strm << "SkipHtmlElementRules"; if (rules.isEmpty()) { - strm << QStringLiteral(": <empty>"); + strm << ": <empty>"; return strm; } const int numRules = rules.size(); - strm << QStringLiteral("(") << numRules << QStringLiteral("): {\n"); + strm << "(" << numRules << "): {\n"; typedef quentier::ENMLConverter::SkipHtmlElementRule SkipHtmlElementRule; for(int i = 0; i < numRules; ++i) { const SkipHtmlElementRule & rule = rules[i]; - strm << QStringLiteral(" [") << i << QStringLiteral("]: ") - << rule << QStringLiteral("\n"); + strm << " [" << i << "]: " + << rule << "\n"; } - strm << QStringLiteral("}\n"); - + strm << "}\n"; return strm; } diff -Nru libquentier-0.5.0/src/enml/HTMLCleaner.cpp libquentier-0.5.0/src/enml/HTMLCleaner.cpp --- libquentier-0.5.0/src/enml/HTMLCleaner.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/enml/HTMLCleaner.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -66,8 +66,8 @@ bool HTMLCleaner::htmlToXml(const QString & html, QString & output, QString & errorDescription) { - QNDEBUG(QStringLiteral("HTMLCleaner::htmlToXml")); - QNTRACE(QStringLiteral("html = ") << html); + QNDEBUG("HTMLCleaner::htmlToXml"); + QNTRACE("html = " << html); return m_impl->convertHtml(html, TidyXmlOut, output, errorDescription); } @@ -75,16 +75,16 @@ bool HTMLCleaner::htmlToXhtml(const QString & html, QString & output, QString & errorDescription) { - QNDEBUG(QStringLiteral("HTMLCleaner::htmlToXhtml")); - QNTRACE(QStringLiteral("html = ") << html); + QNDEBUG("HTMLCleaner::htmlToXhtml"); + QNTRACE("html = " << html); return m_impl->convertHtml(html, TidyXhtmlOut, output, errorDescription); } bool HTMLCleaner::cleanupHtml(QString & html, QString & errorDescription) { - QNDEBUG(QStringLiteral("HTMLCleaner::cleanupHtml")); - QNTRACE(QStringLiteral("html = ") << html); + QNDEBUG("HTMLCleaner::cleanupHtml"); + QNTRACE("html = " << html); return m_impl->convertHtml(html, TidyHtmlOut, html, errorDescription); } @@ -101,110 +101,108 @@ int rc = -1; Bool ok = tidyOptSetBool(m_tidyDoc, outputFormat, yes); - QNTRACE(QStringLiteral("tidyOptSetBool: output format: ok = ") - << (ok ? QStringLiteral("true") : QStringLiteral("false"))); + QNTRACE("tidyOptSetBool: output format: ok = " << (ok ? "true" : "false")); if (ok) { ok = tidyOptSetBool(m_tidyDoc, TidyPreserveEntities, yes); - QNTRACE(QStringLiteral("tidyOptSetBool: preserve entities = yes: ok = ") - << (ok ? QStringLiteral("true") : QStringLiteral("false"))); + QNTRACE("tidyOptSetBool: preserve entities = yes: ok = " + << (ok ? "true" : "false")); } if (ok) { ok = tidyOptSetInt(m_tidyDoc, TidyMergeDivs, no); - QNTRACE(QStringLiteral("tidyOptSetInt: merge divs = no: ok = ") - << (ok ? QStringLiteral("true") : QStringLiteral("false"))); + QNTRACE("tidyOptSetInt: merge divs = no: ok = " + << (ok ? "true" : "false")); } if (ok) { ok = tidyOptSetInt(m_tidyDoc, TidyMergeSpans, no); - QNTRACE(QStringLiteral("tidyOptSetInt: merge spans = no: ok = ") - << (ok ? QStringLiteral("true") : QStringLiteral("false"))); + QNTRACE("tidyOptSetInt: merge spans = no: ok = " + << (ok ? "true" : "false")); } if (ok) { ok = tidyOptSetBool(m_tidyDoc, TidyMergeEmphasis, no); - QNTRACE(QStringLiteral("tidyOptSetBool: merge emphasis = no: ok = ") - << (ok ? QStringLiteral("true") : QStringLiteral("false"))); + QNTRACE("tidyOptSetBool: merge emphasis = no: ok = " + << (ok ? "true" : "false")); } if (ok) { ok = tidyOptSetBool(m_tidyDoc, TidyDropEmptyElems, no); - QNTRACE(QStringLiteral("tidyOptSetBool: drop empty elemens = no: ok = ") - << (ok ? QStringLiteral("true") : QStringLiteral("false"))); + QNTRACE("tidyOptSetBool: drop empty elemens = no: ok = " + << (ok ? "true" : "false")); } if (ok) { ok = tidyOptSetInt(m_tidyDoc, TidyIndentContent, TidyNoState); - QNTRACE(QStringLiteral("tidyOptSetInt: indent content = no: ok = ") - << (ok ? QStringLiteral("true") : QStringLiteral("false"))); + QNTRACE("tidyOptSetInt: indent content = no: ok = " + << (ok ? "true" : "false")); } if (ok) { ok = tidyOptSetBool(m_tidyDoc, TidyIndentAttributes, no); - QNTRACE(QStringLiteral("tidyOptSetBool: indent attributes = no: ok = ") - << (ok ? QStringLiteral("true") : QStringLiteral("false"))); + QNTRACE("tidyOptSetBool: indent attributes = no: ok = " + << (ok ? "true" : "false")); } if (ok) { ok = tidyOptSetBool(m_tidyDoc, TidyIndentCdata, no); - QNTRACE(QStringLiteral("tidyOptSetBool: indent CDATA = no: ok = ") - << (ok ? QStringLiteral("true") : QStringLiteral("false"))); + QNTRACE("tidyOptSetBool: indent CDATA = no: ok = " + << (ok ? "true" : "false")); } if (ok) { ok = tidyOptSetInt(m_tidyDoc, TidyVertSpace, TidyNoState); - QNTRACE(QStringLiteral("tidyOptSetBool: vert space = no: ok = ") - << (ok ? QStringLiteral("true") : QStringLiteral("false"))); + QNTRACE("tidyOptSetBool: vert space = no: ok = " + << (ok ? "true" : "false")); } if (ok) { ok = tidyOptSetBool(m_tidyDoc, TidyMark, no); - QNTRACE(QStringLiteral("tidyOptSetBool: tidy mark = no: ok = ") - << (ok ? QStringLiteral("true") : QStringLiteral("false"))); + QNTRACE("tidyOptSetBool: tidy mark = no: ok = " + << (ok ? "true" : "false")); } if (ok) { ok = tidyOptSetInt(m_tidyDoc, TidyBodyOnly, TidyYesState); - QNTRACE(QStringLiteral("tidyOptSetBool: tidy body only = yes: ok = ") - << (ok ? QStringLiteral("true") : QStringLiteral("false"))); + QNTRACE("tidyOptSetBool: tidy body only = yes: ok = " + << (ok ? "true" : "false")); } if (ok) { ok = tidyOptSetInt(m_tidyDoc, TidyWrapLen, 0); - QNTRACE(QStringLiteral("tidyOptSetInt: wrap len = 0: ok = ") - << (ok ? QStringLiteral("true") : QStringLiteral("false"))); + QNTRACE("tidyOptSetInt: wrap len = 0: ok = " + << (ok ? "true" : "false")); } if (ok) { ok = tidyOptSetValue(m_tidyDoc, TidyDoctype, "omit"); - QNTRACE(QStringLiteral("tidyOptSetBool: doctype = omit: ok = ") - << (ok ? QStringLiteral("true") : QStringLiteral("false"))); + QNTRACE("tidyOptSetBool: doctype = omit: ok = " + << (ok ? "true" : "false")); } if (ok) { rc = tidySetErrorBuffer(m_tidyDoc, &m_tidyErrorBuffer); - QNTRACE(QStringLiteral("tidySetErrorBuffer: rc = ") << rc); + QNTRACE("tidySetErrorBuffer: rc = " << rc); } if (rc >= 0) { rc = tidyParseString(m_tidyDoc, html.toUtf8().constData()); - QNTRACE(QStringLiteral("tidyParseString: rc = ") << rc); + QNTRACE("tidyParseString: rc = " << rc); } if (rc >= 0) { rc = tidyCleanAndRepair(m_tidyDoc); - QNTRACE(QStringLiteral("tidyCleanAndRepair: rc = ") << rc); + QNTRACE("tidyCleanAndRepair: rc = " << rc); } if (rc >= 0) { rc = tidyRunDiagnostics(m_tidyDoc); - QNTRACE(QStringLiteral("tidyRunDiagnostics: rc = ") << rc); + QNTRACE("tidyRunDiagnostics: rc = " << rc); } if (rc > 1) { int forceOutputRc = tidyOptSetBool(m_tidyDoc, TidyForceOutput, yes); - QNTRACE(QStringLiteral("tidyOptSetBool (force output): rc = ") - << forceOutputRc); + QNTRACE("tidyOptSetBool (force output): rc = " << forceOutputRc); if (!forceOutputRc) { rc = -1; } @@ -212,7 +210,7 @@ if (rc >= 0) { rc = tidySaveBuffer(m_tidyDoc, &m_tidyOutput); - QNTRACE(QStringLiteral("tidySaveBuffer: rc = ") << rc); + QNTRACE("tidySaveBuffer: rc = " << rc); } if (rc < 0) @@ -221,7 +219,7 @@ QByteArray errorBody = QByteArray(reinterpret_cast<const char*>(m_tidyErrorBuffer.bp), static_cast<int>(m_tidyErrorBuffer.size)); - QNINFO(errorPrefix << QStringLiteral(": ") << errorBody); + QNINFO(errorPrefix << ": " << errorBody); errorDescription = errorPrefix; errorDescription += QStringLiteral(": "); errorDescription += QString::fromUtf8(errorBody.constData(), @@ -230,7 +228,7 @@ } if (rc > 0) { - QNTRACE(QStringLiteral("Tidy diagnostics: ") + QNTRACE("Tidy diagnostics: " << QByteArray(reinterpret_cast<const char*>(m_tidyErrorBuffer.bp), static_cast<int>(m_tidyErrorBuffer.size))); } @@ -335,9 +333,8 @@ errorDescription = QStringLiteral("Error while trying to clean up " "the html after tidy-html5: "); errorDescription += reader.errorString(); - QNWARNING(errorDescription << QStringLiteral("; original HTML: ") - << html << QStringLiteral("\nHtml converted to XML by tidy: ") - << output); + QNWARNING(errorDescription << "; original HTML: " << html + << "\nHtml converted to XML by tidy: " << output); return false; } diff -Nru libquentier-0.5.0/src/exception/IQuentierException.cpp libquentier-0.5.0/src/exception/IQuentierException.cpp --- libquentier-0.5.0/src/exception/IQuentierException.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/exception/IQuentierException.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -22,15 +22,16 @@ namespace quentier { -#define INIT_WHAT_MESSAGE() \ - QByteArray bytes = m_message.nonLocalizedString().toLocal8Bit(); \ - int size = bytes.size(); \ - if (size >= 0) { \ - size_t usize = static_cast<size_t>(size); \ - m_whatMessage = new char[usize + 1]; \ - Q_UNUSED(strncpy(m_whatMessage, bytes.constData(), usize)) \ - m_whatMessage[usize] = '\0'; \ - } +#define INIT_WHAT_MESSAGE() \ + QByteArray bytes = m_message.nonLocalizedString().toLocal8Bit(); \ + int size = bytes.size(); \ + if (size >= 0) { \ + size_t usize = static_cast<size_t>(size); \ + m_whatMessage = new char[usize + 1]; \ + Q_UNUSED(strncpy(m_whatMessage, bytes.constData(), usize)) \ + m_whatMessage[usize] = '\0'; \ + } \ +// INIT_WHAT_MESSAGE IQuentierException::IQuentierException(const ErrorString & message) : Printable(), @@ -74,8 +75,8 @@ QTextStream & IQuentierException::print(QTextStream & strm) const { - strm << QStringLiteral("\n <") << exceptionDisplayName() << QStringLiteral(">"); - strm << QStringLiteral("\n message: ") << m_message.nonLocalizedString(); + strm << "\n <" << exceptionDisplayName() << ">"; + strm << "\n message: " << m_message.nonLocalizedString(); return strm; } diff -Nru libquentier-0.5.0/src/local_storage/DefaultLocalStorageCacheExpiryChecker.cpp libquentier-0.5.0/src/local_storage/DefaultLocalStorageCacheExpiryChecker.cpp --- libquentier-0.5.0/src/local_storage/DefaultLocalStorageCacheExpiryChecker.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/local_storage/DefaultLocalStorageCacheExpiryChecker.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -75,18 +75,18 @@ { const char * indent = " "; - strm << QStringLiteral("DefaultLocalStorageCacheExpiryChecker: {\n") ; - strm << indent << QStringLiteral("max notes to store: ") - << MAX_NOTES_TO_STORE << QStringLiteral(";\n"); - strm << indent << QStringLiteral("max notebooks to store: ") - << MAX_NOTEBOOKS_TO_STORE << QStringLiteral(";\n"); - strm << indent << QStringLiteral("max tags to store: ") - << MAX_TAGS_TO_STORE << QStringLiteral(";\n"); - strm << indent << QStringLiteral("max linked notebooks to store: ") - << MAX_LINKED_NOTEBOOKS_TO_STORE << QStringLiteral(";\n"); - strm << indent << QStringLiteral("max saved searches to store: ") - << MAX_SAVED_SEARCHES_TO_STORE << QStringLiteral("\n"); - strm << QStringLiteral("};\n"); + strm << "DefaultLocalStorageCacheExpiryChecker: {\n"; + strm << indent << "max notes to store: " + << MAX_NOTES_TO_STORE << ";\n"; + strm << indent << "max notebooks to store: " + << MAX_NOTEBOOKS_TO_STORE << ";\n"; + strm << indent << "max tags to store: " + << MAX_TAGS_TO_STORE << ";\n"; + strm << indent << "max linked notebooks to store: " + << MAX_LINKED_NOTEBOOKS_TO_STORE << ";\n"; + strm << indent << "max saved searches to store: " + << MAX_SAVED_SEARCHES_TO_STORE << "\n"; + strm << "};\n"; return strm; } diff -Nru libquentier-0.5.0/src/local_storage/LocalStorageCacheManager.cpp libquentier-0.5.0/src/local_storage/LocalStorageCacheManager.cpp --- libquentier-0.5.0/src/local_storage/LocalStorageCacheManager.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/local_storage/LocalStorageCacheManager.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -68,25 +68,24 @@ d->clearAllNotes(); } -#define FIND_OBJECT(Type) \ -const Type * LocalStorageCacheManager::find##Type(\ - const QString & uid, const LocalStorageCacheManager::WhichUid whichUid) const \ -{ \ - Q_D(const LocalStorageCacheManager); \ - \ - switch(whichUid) { \ - case LocalUid: \ - return d->find##Type##ByLocalUid(uid); \ - case Guid: \ - return d->find##Type##ByGuid(uid); \ - default: \ - { \ - QNERROR(QStringLiteral("Detected incorrect local uid/remote guid qualifier "\ - "in local storage cache manager")); \ - return Q_NULLPTR; \ - } \ - } \ -} +#define FIND_OBJECT(Type) \ +const Type * LocalStorageCacheManager::find##Type( \ + const QString & uid, \ + const LocalStorageCacheManager::WhichUid whichUid) const \ +{ \ + Q_D(const LocalStorageCacheManager); \ + switch(whichUid) { \ + case LocalUid: \ + return d->find##Type##ByLocalUid(uid); \ + case Guid: \ + return d->find##Type##ByGuid(uid); \ + default: \ + QNERROR("Detected incorrect local uid/remote guid " \ + "qualifier in local storage cache manager"); \ + return Q_NULLPTR; \ + } \ +} \ +// FIND_OBJECT FIND_OBJECT(Note) FIND_OBJECT(Resource) @@ -208,7 +207,8 @@ d->expungeLinkedNotebook(linkedNotebook); } -const LinkedNotebook * LocalStorageCacheManager::findLinkedNotebook(const QString & guid) const +const LinkedNotebook * LocalStorageCacheManager::findLinkedNotebook( + const QString & guid) const { Q_D(const LocalStorageCacheManager); return d->findLinkedNotebookByGuid(guid); diff -Nru libquentier-0.5.0/src/local_storage/LocalStorageCacheManager_p.cpp libquentier-0.5.0/src/local_storage/LocalStorageCacheManager_p.cpp --- libquentier-0.5.0/src/local_storage/LocalStorageCacheManager_p.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/local_storage/LocalStorageCacheManager_p.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -26,7 +26,8 @@ namespace quentier { -LocalStorageCacheManagerPrivate::LocalStorageCacheManagerPrivate(LocalStorageCacheManager & q) : +LocalStorageCacheManagerPrivate::LocalStorageCacheManagerPrivate( + LocalStorageCacheManager & q) : q_ptr(&q), m_cacheExpiryChecker(new DefaultLocalStorageCacheExpiryChecker(q)), m_notesCache(), @@ -60,12 +61,13 @@ m_savedSearchesCache.empty()); } -#define NUM_CACHED_OBJECTS(type, method_name, cache_name, IndexType) \ -size_t LocalStorageCacheManagerPrivate::method_name() const \ -{ \ - const auto & index = cache_name.get<type##Holder::IndexType>(); \ - return index.size(); \ -} +#define NUM_CACHED_OBJECTS(type, method_name, cache_name, IndexType) \ +size_t LocalStorageCacheManagerPrivate::method_name() const \ +{ \ + const auto & index = cache_name.get<type##Holder::IndexType>(); \ + return index.size(); \ +} \ +// NUM_CACHED_OBJECTS NUM_CACHED_OBJECTS(Note, numCachedNotes, m_notesCache, ByLocalUid) NUM_CACHED_OBJECTS(Resource, numCachesResources, m_resourcesCache, ByLocalUid) @@ -78,65 +80,54 @@ #undef NUM_CACHED_OBJECTS -#define CACHE_OBJECT(Type, name, cache_type, cache_name, expiry_checker, \ - IndexType, IndexAccessor) \ -void LocalStorageCacheManagerPrivate::cache##Type(const Type & name) \ -{ \ - QUENTIER_CHECK_PTR(m_cacheExpiryChecker.data()); \ - \ - typedef \ - boost::multi_index::index<cache_type,Type##Holder::ByLastAccessTimestamp>::type \ - LastAccessTimestampIndex; \ - LastAccessTimestampIndex & latIndex = \ - cache_name.get<Type##Holder::ByLastAccessTimestamp>(); \ - \ - if (Q_LIKELY(!m_cacheExpiryChecker.isNull())) \ - { \ - bool res = false; \ - while(!res && !latIndex.empty()) \ - { \ - res = m_cacheExpiryChecker->expiry_checker(); \ - if (Q_UNLIKELY(!res)) { \ - auto latIndexBegin = latIndex.begin(); \ - QNTRACE(QStringLiteral("Going to remove the object from the local "\ - "storage cache: ") << *latIndexBegin); \ - Q_UNUSED(latIndex.erase(latIndexBegin)); \ - continue; \ - } \ - } \ - } \ - \ - Type##Holder name##Holder; \ - name##Holder.m_##name = name; \ - name##Holder.m_lastAccessTimestamp = QDateTime::currentMSecsSinceEpoch(); \ - \ - /* See whether the item is already in the cache */ \ - typedef \ - boost::multi_index::index<cache_type,Type##Holder::IndexType>::type \ - Index; \ - Index & uniqueIndex = cache_name.get<Type##Holder::IndexType>(); \ - Index::iterator it = uniqueIndex.find(name.IndexAccessor()); \ - if (it != uniqueIndex.end()) { \ - uniqueIndex.replace(it, name##Holder); \ - QNTRACE(QStringLiteral("Updated " #name " in the local storage cache: ") \ - << name); \ - return; \ - } \ - \ - /* If got here, no existing item was found in the cache */ \ - auto insertionResult = cache_name.insert(name##Holder); \ - if (Q_UNLIKELY(!insertionResult.second)) { \ - QNWARNING(QStringLiteral("Failed to insert " #name " into the cache of "\ - "local storage manager: ") << name); \ - ErrorString error(QT_TRANSLATE_NOOP("LocalStorageCacheManagerPrivate", \ - "Unable to insert the data item into "\ - "the local storage cache")); \ - error.details() = QStringLiteral( #name ); \ - throw LocalStorageCacheManagerException(error); \ - } \ - \ - QNTRACE(QStringLiteral("Added " #name " to the local storage cache: ") << name); \ -} +#define CACHE_OBJECT(Type, name, cache_type, cache_name, expiry_checker, \ + IndexType, IndexAccessor) \ +void LocalStorageCacheManagerPrivate::cache##Type(const Type & name) \ +{ \ + QUENTIER_CHECK_PTR(m_cacheExpiryChecker.data()); \ + auto & latIndex = \ + cache_name.get<Type##Holder::ByLastAccessTimestamp>(); \ + if (Q_LIKELY(!m_cacheExpiryChecker.isNull())) \ + { \ + bool res = false; \ + while(!res && !latIndex.empty()) \ + { \ + res = m_cacheExpiryChecker->expiry_checker(); \ + if (Q_UNLIKELY(!res)) { \ + auto latIndexBegin = latIndex.begin(); \ + QNTRACE("Going to remove the object from the local " \ + << "storage cache: " << *latIndexBegin); \ + Q_UNUSED(latIndex.erase(latIndexBegin)); \ + continue; \ + } \ + } \ + } \ + Type##Holder name##Holder; \ + name##Holder.m_##name = name; \ + name##Holder.m_lastAccessTimestamp = QDateTime::currentMSecsSinceEpoch(); \ + /* See whether the item is already in the cache */ \ + auto & uniqueIndex = cache_name.get<Type##Holder::IndexType>(); \ + auto it = uniqueIndex.find(name.IndexAccessor()); \ + if (it != uniqueIndex.end()) { \ + uniqueIndex.replace(it, name##Holder); \ + QNTRACE("Updated " #name " in the local storage cache: " << name); \ + return; \ + } \ + /* If got here, no existing item was found in the cache */ \ + auto insertionResult = cache_name.insert(name##Holder); \ + if (Q_UNLIKELY(!insertionResult.second)) \ + { \ + QNWARNING("Failed to insert " #name " into the cache of " \ + << "local storage manager: " << name); \ + ErrorString error(QT_TRANSLATE_NOOP("LocalStorageCacheManagerPrivate", \ + "Unable to insert the data item into " \ + "the local storage cache")); \ + error.details() = QStringLiteral( #name ); \ + throw LocalStorageCacheManagerException(error); \ + } \ + QNTRACE("Added " #name " to the local storage cache: " << name); \ +} \ +// CACHE_OBJECT CACHE_OBJECT(Note, note, NotesCache, m_notesCache, checkNotes, ByLocalUid, localUid) CACHE_OBJECT(Resource, resource, ResourcesCache, m_resourcesCache, @@ -151,39 +142,33 @@ #undef CACHE_OBJECT -#define EXPUNGE_OBJECT(Type, name, cache_type, cache_name) \ -void LocalStorageCacheManagerPrivate::expunge##Type(const Type & name) \ -{ \ - bool name##HasGuid = name.hasGuid(); \ - const QString uid = (name##HasGuid ? name.guid() : name.localUid()); \ - \ - if (name##HasGuid) \ - { \ - typedef \ - boost::multi_index::index<cache_type,Type##Holder::ByGuid>::type \ - UidIndex; \ - UidIndex & index = cache_name.get<Type##Holder::ByGuid>(); \ - UidIndex::iterator it = index.find(uid); \ - if (it != index.end()) { \ - index.erase(it); \ - QNDEBUG(QStringLiteral("Expunged " #name " from the local storage "\ - "cache: ") << name); \ - } \ - } \ - else \ - { \ - typedef \ - boost::multi_index::index<cache_type,Type##Holder::ByLocalUid>::type \ - UidIndex; \ - UidIndex & index = cache_name.get<Type##Holder::ByLocalUid>(); \ - UidIndex::iterator it = index.find(uid); \ - if (it != index.end()) { \ - index.erase(it); \ - QNDEBUG(QStringLiteral("Expunged " #name " from the local storage "\ - "cache: ") << name); \ - } \ - } \ -} +#define EXPUNGE_OBJECT(Type, name, cache_type, cache_name) \ +void LocalStorageCacheManagerPrivate::expunge##Type(const Type & name) \ +{ \ + bool name##HasGuid = name.hasGuid(); \ + const QString uid = (name##HasGuid ? name.guid() : name.localUid()); \ + if (name##HasGuid) \ + { \ + auto & index = cache_name.get<Type##Holder::ByGuid>(); \ + auto it = index.find(uid); \ + if (it != index.end()) { \ + index.erase(it); \ + QNDEBUG("Expunged " #name " from the local storage cache: " \ + << name); \ + } \ + } \ + else \ + { \ + auto & index = cache_name.get<Type##Holder::ByLocalUid>(); \ + auto it = index.find(uid); \ + if (it != index.end()) { \ + index.erase(it); \ + QNDEBUG("Expunged " #name " from the local storage cache: " \ + << name); \ + } \ + } \ +} \ +// EXPUNGE_OBJECT EXPUNGE_OBJECT(Note, note, NotesCache, m_notesCache) EXPUNGE_OBJECT(Resource, resource, ResourcesCache, m_resourcesCache) @@ -197,29 +182,27 @@ const LinkedNotebook & linkedNotebook) { const QString guid = linkedNotebook.guid(); - - typedef boost::multi_index::index<LinkedNotebooksCache, - LinkedNotebookHolder::ByGuid>::type GuidIndex; - GuidIndex & index = m_linkedNotebooksCache.get<LinkedNotebookHolder::ByGuid>(); - GuidIndex::iterator it = index.find(guid); + auto & index = m_linkedNotebooksCache.get<LinkedNotebookHolder::ByGuid>(); + auto it = index.find(guid); if (it != index.end()) { index.erase(it); - QNDEBUG(QStringLiteral("Expunged linked notebook from the local storage cache: ") + QNDEBUG("Expunged linked notebook from the local storage cache: " << linkedNotebook); } } -#define FIND_OBJECT(Type, name, tag, cache_name) \ -const Type * LocalStorageCacheManagerPrivate::find##Type##tag(const QString & guid) const \ -{ \ - const auto & index = cache_name.get<Type##Holder::tag>(); \ - auto it = index.find(guid); \ - if (it == index.end()) { \ - return Q_NULLPTR; \ - } \ - \ - return &(it->m_##name); \ -} +#define FIND_OBJECT(Type, name, tag, cache_name) \ +const Type * LocalStorageCacheManagerPrivate::find##Type##tag( \ + const QString & guid) const \ +{ \ + const auto & index = cache_name.get<Type##Holder::tag>(); \ + auto it = index.find(guid); \ + if (it == index.end()) { \ + return Q_NULLPTR; \ + } \ + return &(it->m_##name); \ +} \ +// FIND_OBJECT FIND_OBJECT(Note, note, ByLocalUid, m_notesCache) FIND_OBJECT(Note, note, ByGuid, m_notesCache) @@ -276,112 +259,97 @@ QTextStream & LocalStorageCacheManagerPrivate::print(QTextStream & strm) const { - strm << QStringLiteral("LocalStorageCacheManager: {\n"); - strm << QStringLiteral("Notes cache: {\n"); + strm << "LocalStorageCacheManager: {\n"; + strm << "Notes cache: {\n"; - const NotesCache::index<NoteHolder::ByLocalUid>::type & notesCacheIndex = - m_notesCache.get<NoteHolder::ByLocalUid>(); - typedef NotesCache::index<NoteHolder::ByLocalUid>::type::const_iterator NotesConstIter; - NotesConstIter notesCacheEnd = notesCacheIndex.end(); - for(NotesConstIter it = notesCacheIndex.begin(); it != notesCacheEnd; ++it) { + const auto & notesCacheIndex = m_notesCache.get<NoteHolder::ByLocalUid>(); + auto notesCacheEnd = notesCacheIndex.end(); + for(auto it = notesCacheIndex.begin(); it != notesCacheEnd; ++it) { strm << *it; } - strm << QStringLiteral("}; \n"); - strm << QStringLiteral("Resources cache: {\n"); + strm << "}; \n"; + strm << "Resources cache: {\n"; - const ResourcesCache::index<ResourceHolder::ByLocalUid>::type & resourcesCacheIndex = + const auto & resourcesCacheIndex = m_resourcesCache.get<ResourceHolder::ByLocalUid>(); - - typedef ResourcesCache::index<ResourceHolder::ByLocalUid>::type::const_iterator - ResourcesConstIter; - - ResourcesConstIter resourcesCacheEnd = resourcesCacheIndex.end(); - for(ResourcesConstIter it = resourcesCacheIndex.begin(); - it != resourcesCacheEnd; ++it) + auto resourcesCacheEnd = resourcesCacheIndex.end(); + for(auto it = resourcesCacheIndex.begin(); it != resourcesCacheEnd; ++it) { strm << *it; } - strm << QStringLiteral("}; \n"); - strm << QStringLiteral("Notebooks cache: {\n"); + strm << "}; \n"; + strm << "Notebooks cache: {\n"; - const NotebooksCache::index<NotebookHolder::ByLocalUid>::type & notebooksCacheIndex = + const auto & notebooksCacheIndex = m_notebooksCache.get<NotebookHolder::ByLocalUid>(); - - typedef NotebooksCache::index<NotebookHolder::ByLocalUid>::type::const_iterator - NotebooksConstIter; - - NotebooksConstIter notebooksCacheEnd = notebooksCacheIndex.end(); - for(NotebooksConstIter it = notebooksCacheIndex.begin(); + auto notebooksCacheEnd = notebooksCacheIndex.end(); + for(auto it = notebooksCacheIndex.begin(); it != notebooksCacheEnd; ++it) { strm << *it; } - strm << QStringLiteral("}; \n"); - strm << QStringLiteral("Tags cache: {\n"); + strm << "}; \n"; + strm << "Tags cache: {\n"; - const TagsCache::index<TagHolder::ByLocalUid>::type & tagsCacheIndex = - m_tagsCache.get<TagHolder::ByLocalUid>(); - typedef TagsCache::index<TagHolder::ByLocalUid>::type::const_iterator TagsConstIter; - TagsConstIter tagsCacheEnd = tagsCacheIndex.end(); - for(TagsConstIter it = tagsCacheIndex.begin(); it != tagsCacheEnd; ++it) { + const auto & tagsCacheIndex = m_tagsCache.get<TagHolder::ByLocalUid>(); + auto tagsCacheEnd = tagsCacheIndex.end(); + for(auto it = tagsCacheIndex.begin(); it != tagsCacheEnd; ++it) { strm << *it; } - strm << QStringLiteral("}; \n"); - strm << QStringLiteral("Linked notebooks cache: {\n"); + strm << "}; \n"; + strm << "Linked notebooks cache: {\n"; - const LinkedNotebooksCache::index<LinkedNotebookHolder::ByGuid>::type & linkedNotebooksCacheIndex = + const auto & linkedNotebooksCacheIndex = m_linkedNotebooksCache.get<LinkedNotebookHolder::ByGuid>(); - typedef LinkedNotebooksCache::index<LinkedNotebookHolder::ByGuid>::type::const_iterator - LinkedNotebooksConstIter; - LinkedNotebooksConstIter linkedNotebooksCacheEnd = linkedNotebooksCacheIndex.end(); - for(LinkedNotebooksConstIter it = linkedNotebooksCacheIndex.begin(); + auto linkedNotebooksCacheEnd = linkedNotebooksCacheIndex.end(); + for(auto it = linkedNotebooksCacheIndex.begin(); it != linkedNotebooksCacheEnd; ++it) { strm << *it; } - strm << QStringLiteral("}; \n"); - strm << QStringLiteral("Saved searches cache: {\n"); + strm << "}; \n"; + strm << "Saved searches cache: {\n"; - const SavedSearchesCache::index<SavedSearchHolder::ByLocalUid>::type & savedSearchesCacheIndex = + const auto & savedSearchesCacheIndex = m_savedSearchesCache.get<SavedSearchHolder::ByLocalUid>(); - typedef SavedSearchesCache::index<SavedSearchHolder::ByLocalUid>::type::const_iterator - SavedSearchesConstIter; - SavedSearchesConstIter savedSearchesCacheEnd = savedSearchesCacheIndex.end(); - for(SavedSearchesConstIter it = savedSearchesCacheIndex.begin(); + auto savedSearchesCacheEnd = savedSearchesCacheIndex.end(); + for(auto it = savedSearchesCacheIndex.begin(); it != savedSearchesCacheEnd; ++it) { strm << *it; } - strm << QStringLiteral("}; \n"); + strm << "}; \n"; if (m_cacheExpiryChecker.isNull()) { - strm << QStringLiteral("Cache expiry checker is null! \n"); + strm << "Cache expiry checker is null! \n"; } else { strm << *m_cacheExpiryChecker; } - strm << QStringLiteral("}; \n"); + strm << "}; \n"; return strm; } -#define GET_GUID(Type, name) \ -const QString LocalStorageCacheManagerPrivate::Type##Holder::guid() const \ -{ \ - /* NOTE: This precaution is required for storage of local notes in the cache */ \ - if (m_##name.hasGuid()) { \ - return m_##name.guid(); \ - } \ - else { \ - return QString(); \ - } \ -} +#define GET_GUID(Type, name) \ +const QString LocalStorageCacheManagerPrivate::Type##Holder::guid() const \ +{ \ + /* NOTE: This precaution is required for storage of local notes in the */ \ + /* cache */ \ + if (m_##name.hasGuid()) { \ + return m_##name.guid(); \ + } \ + else { \ + return QString(); \ + } \ +} \ +// GET_GUID GET_GUID(Note, note) GET_GUID(Resource, resource) @@ -392,57 +360,55 @@ #undef GET_GUID -QTextStream & LocalStorageCacheManagerPrivate::NoteHolder::print(QTextStream & strm) const +QTextStream & LocalStorageCacheManagerPrivate::NoteHolder::print( + QTextStream & strm) const { - strm << QStringLiteral("NoteHolder: note = ") << m_note - << QStringLiteral("last access timestamp = ") - << printableDateTimeFromTimestamp(m_lastAccessTimestamp) - << QStringLiteral("\n"); + strm << "NoteHolder: note = " << m_note << "last access timestamp = " + << printableDateTimeFromTimestamp(m_lastAccessTimestamp) << "\n"; return strm; } -QTextStream & LocalStorageCacheManagerPrivate::ResourceHolder::print(QTextStream & strm) const +QTextStream & LocalStorageCacheManagerPrivate::ResourceHolder::print( + QTextStream & strm) const { - strm << QStringLiteral("ResourceHolder: resource = ") << m_resource - << QStringLiteral(", last access timestamp = ") - << printableDateTimeFromTimestamp(m_lastAccessTimestamp) - << QStringLiteral("\n"); + strm << "ResourceHolder: resource = " << m_resource + << ", last access timestamp = " + << printableDateTimeFromTimestamp(m_lastAccessTimestamp) << "\n"; return strm; } -QTextStream & LocalStorageCacheManagerPrivate::NotebookHolder::print(QTextStream & strm) const +QTextStream & LocalStorageCacheManagerPrivate::NotebookHolder::print( + QTextStream & strm) const { - strm << QStringLiteral("NotebookHolder: notebook = ") << m_notebook - << QStringLiteral("last access timestamp = ") - << printableDateTimeFromTimestamp(m_lastAccessTimestamp) - << QStringLiteral("\n"); + strm << "NotebookHolder: notebook = " << m_notebook + << "last access timestamp = " + << printableDateTimeFromTimestamp(m_lastAccessTimestamp) << "\n"; return strm; } -QTextStream & LocalStorageCacheManagerPrivate::TagHolder::print(QTextStream & strm) const +QTextStream & LocalStorageCacheManagerPrivate::TagHolder::print( + QTextStream & strm) const { - strm << QStringLiteral("TagHolder: tag = ") << m_tag - << QStringLiteral("last access timestamp = ") - << printableDateTimeFromTimestamp(m_lastAccessTimestamp) - << QStringLiteral("\n"); + strm << "TagHolder: tag = " << m_tag << "last access timestamp = " + << printableDateTimeFromTimestamp(m_lastAccessTimestamp) << "\n"; return strm; } -QTextStream & LocalStorageCacheManagerPrivate::LinkedNotebookHolder::print(QTextStream & strm) const +QTextStream & LocalStorageCacheManagerPrivate::LinkedNotebookHolder::print( + QTextStream & strm) const { - strm << QStringLiteral("LinkedNotebookHolder: linked notebook = ") - << m_linkedNotebook << QStringLiteral("last access timestamp = ") - << printableDateTimeFromTimestamp(m_lastAccessTimestamp) - << QStringLiteral("\n"); + strm << "LinkedNotebookHolder: linked notebook = " + << m_linkedNotebook << "last access timestamp = " + << printableDateTimeFromTimestamp(m_lastAccessTimestamp) << "\n"; return strm; } -QTextStream & LocalStorageCacheManagerPrivate::SavedSearchHolder::print(QTextStream & strm) const +QTextStream & LocalStorageCacheManagerPrivate::SavedSearchHolder::print( + QTextStream & strm) const { - strm << QStringLiteral("SavedSearchHolder: saved search = ") << m_savedSearch - << QStringLiteral("last access timestamp = ") - << printableDateTimeFromTimestamp(m_lastAccessTimestamp) - << QStringLiteral("\n"); + strm << "SavedSearchHolder: saved search = " << m_savedSearch + << "last access timestamp = " + << printableDateTimeFromTimestamp(m_lastAccessTimestamp) << "\n"; return strm; } diff -Nru libquentier-0.5.0/src/local_storage/LocalStorageManagerAsync.cpp libquentier-0.5.0/src/local_storage/LocalStorageManagerAsync.cpp --- libquentier-0.5.0/src/local_storage/LocalStorageManagerAsync.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/local_storage/LocalStorageManagerAsync.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -102,7 +102,9 @@ { resources = note.resources(); QList<Resource> noteResources = resources; - for(auto it = noteResources.begin(), end = noteResources.end(); it != end; ++it) { + for(auto it = noteResources.begin(), end = noteResources.end(); + it != end; ++it) + { Resource & resource = *it; resource.setDataBody(QByteArray()); resource.setAlternateDataBody(QByteArray()); @@ -112,9 +114,10 @@ } -LocalStorageManagerAsync::LocalStorageManagerAsync(const Account & account, - const LocalStorageManager::StartupOptions options, - QObject * parent) : +LocalStorageManagerAsync::LocalStorageManagerAsync( + const Account & account, + const LocalStorageManager::StartupOptions options, + QObject * parent) : QObject(parent), d_ptr(new LocalStorageManagerAsyncPrivate) { @@ -132,7 +135,8 @@ d->setUseCache(useCache); } -const LocalStorageCacheManager * LocalStorageManagerAsync::localStorageCacheManager() const +const LocalStorageCacheManager * +LocalStorageManagerAsync::localStorageCacheManager() const { Q_D(const LocalStorageManagerAsync); @@ -205,17 +209,17 @@ } catch(const std::exception & e) { - ErrorString error(QT_TR_NOOP("Can't get user count from the local storage: " - "caught exception")); + ErrorString error(QT_TR_NOOP("Can't get user count from the local " + "storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT getUserCountFailed(error, requestId); } } -void LocalStorageManagerAsync::onSwitchUserRequest(Account account, - LocalStorageManager::StartupOptions startupOptions, +void LocalStorageManagerAsync::onSwitchUserRequest( + Account account, LocalStorageManager::StartupOptions startupOptions, QUuid requestId) { Q_D(LocalStorageManagerAsync); @@ -267,7 +271,7 @@ "caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT addUserFailed(user, error, requestId); } } @@ -290,11 +294,11 @@ } catch(const std::exception & e) { - ErrorString error(QT_TR_NOOP("Can't update user within the local storage: " - "caught exception")); + ErrorString error(QT_TR_NOOP("Can't update user within the local " + "storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT updateUserFailed(user, error, requestId); } } @@ -317,10 +321,11 @@ } catch(const std::exception & e) { - ErrorString error(QT_TR_NOOP("Can't find user in the local storage: caught exception")); + ErrorString error(QT_TR_NOOP("Can't find user in the local storage: " + "caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT findUserFailed(user, error, requestId); } } @@ -347,7 +352,7 @@ "storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT deleteUserFailed(user, error, requestId); } } @@ -374,7 +379,7 @@ "caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT expungeUserFailed(user, error, requestId); } } @@ -400,13 +405,13 @@ "storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT getNotebookCountFailed(error, requestId); } } -void LocalStorageManagerAsync::onAddNotebookRequest(Notebook notebook, - QUuid requestId) +void LocalStorageManagerAsync::onAddNotebookRequest( + Notebook notebook, QUuid requestId) { Q_D(LocalStorageManagerAsync); @@ -414,7 +419,8 @@ { ErrorString errorDescription; - bool res = d->m_pLocalStorageManager->addNotebook(notebook, errorDescription); + bool res = d->m_pLocalStorageManager->addNotebook(notebook, + errorDescription); if (!res) { Q_EMIT addNotebookFailed(notebook, errorDescription, requestId); return; @@ -432,13 +438,13 @@ "caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT addNotebookFailed(notebook, error, requestId); } } -void LocalStorageManagerAsync::onUpdateNotebookRequest(Notebook notebook, - QUuid requestId) +void LocalStorageManagerAsync::onUpdateNotebookRequest( + Notebook notebook, QUuid requestId) { Q_D(LocalStorageManagerAsync); @@ -446,7 +452,8 @@ { ErrorString errorDescription; - bool res = d->m_pLocalStorageManager->updateNotebook(notebook, errorDescription); + bool res = d->m_pLocalStorageManager->updateNotebook(notebook, + errorDescription); if (!res) { Q_EMIT updateNotebookFailed(notebook, errorDescription, requestId); return; @@ -460,17 +467,17 @@ } catch(const std::exception & e) { - ErrorString error(QT_TR_NOOP("Can't update notebook in the local storage: " - "caught exception")); + ErrorString error(QT_TR_NOOP("Can't update notebook in the local " + "storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT updateNotebookFailed(notebook, error, requestId); } } -void LocalStorageManagerAsync::onFindNotebookRequest(Notebook notebook, - QUuid requestId) +void LocalStorageManagerAsync::onFindNotebookRequest( + Notebook notebook, QUuid requestId) { Q_D(LocalStorageManagerAsync); @@ -503,7 +510,7 @@ { const QString notebookName = notebook.name(); const Notebook * pNotebook = - d->m_pLocalStorageCacheManager->findNotebookByName(notebookName); + d->m_pLocalStorageCacheManager->findNotebookByName(notebookName); if (pNotebook) { notebook = *pNotebook; foundNotebookInCache = true; @@ -529,13 +536,13 @@ "caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT findNotebookFailed(notebook, error, requestId); } } -void LocalStorageManagerAsync::onFindDefaultNotebookRequest(Notebook notebook, - QUuid requestId) +void LocalStorageManagerAsync::onFindDefaultNotebookRequest( + Notebook notebook, QUuid requestId) { Q_D(LocalStorageManagerAsync); @@ -543,10 +550,12 @@ { ErrorString errorDescription; - bool res = d->m_pLocalStorageManager->findDefaultNotebook(notebook, - errorDescription); + bool res = + d->m_pLocalStorageManager->findDefaultNotebook(notebook, + errorDescription); if (!res) { - Q_EMIT findDefaultNotebookFailed(notebook, errorDescription, requestId); + Q_EMIT findDefaultNotebookFailed(notebook, errorDescription, + requestId); return; } @@ -558,13 +567,13 @@ "the local storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT findDefaultNotebookFailed(notebook, error, requestId); } } -void LocalStorageManagerAsync::onFindLastUsedNotebookRequest(Notebook notebook, - QUuid requestId) +void LocalStorageManagerAsync::onFindLastUsedNotebookRequest( + Notebook notebook, QUuid requestId) { Q_D(LocalStorageManagerAsync); @@ -572,10 +581,12 @@ { ErrorString errorDescription; - bool res = d->m_pLocalStorageManager->findLastUsedNotebook(notebook, - errorDescription); + bool res = + d->m_pLocalStorageManager->findLastUsedNotebook(notebook, + errorDescription); if (!res) { - Q_EMIT findLastUsedNotebookFailed(notebook, errorDescription, requestId); + Q_EMIT findLastUsedNotebookFailed(notebook, errorDescription, + requestId); return; } @@ -587,13 +598,13 @@ "the local storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT findLastUsedNotebookFailed(notebook, error, requestId); } } -void LocalStorageManagerAsync::onFindDefaultOrLastUsedNotebookRequest(Notebook notebook, - QUuid requestId) +void LocalStorageManagerAsync::onFindDefaultOrLastUsedNotebookRequest( + Notebook notebook, QUuid requestId) { Q_D(LocalStorageManagerAsync); @@ -601,10 +612,13 @@ { ErrorString errorDescription; - bool res = d->m_pLocalStorageManager->findDefaultOrLastUsedNotebook(notebook, - errorDescription); + bool res = d->m_pLocalStorageManager->findDefaultOrLastUsedNotebook( + notebook, + errorDescription); + if (!res) { - Q_EMIT findDefaultOrLastUsedNotebookFailed(notebook, errorDescription, + Q_EMIT findDefaultOrLastUsedNotebookFailed(notebook, + errorDescription, requestId); return; } @@ -617,7 +631,7 @@ "within the local storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT findDefaultOrLastUsedNotebookFailed(notebook, error, requestId); } } @@ -634,10 +648,11 @@ try { ErrorString errorDescription; - QList<Notebook> notebooks = - d->m_pLocalStorageManager->listAllNotebooks(errorDescription, limit, - offset, order, orderDirection, - linkedNotebookGuid); + QList<Notebook> notebooks = d->m_pLocalStorageManager->listAllNotebooks( + errorDescription, limit, + offset, order, orderDirection, + linkedNotebookGuid); + if (notebooks.isEmpty() && !errorDescription.isEmpty()) { Q_EMIT listAllNotebooksFailed(limit, offset, order, orderDirection, linkedNotebookGuid, errorDescription, @@ -663,7 +678,7 @@ "storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT listAllNotebooksFailed(limit, offset, order, orderDirection, linkedNotebookGuid, error, requestId); } @@ -691,7 +706,7 @@ "the local storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT listAllSharedNotebooksFailed(error, requestId); } } @@ -708,10 +723,11 @@ try { ErrorString errorDescription; - QList<Notebook> notebooks = - d->m_pLocalStorageManager->listNotebooks(flag, errorDescription, limit, - offset, order, orderDirection, - linkedNotebookGuid); + QList<Notebook> notebooks = d->m_pLocalStorageManager->listNotebooks( + flag, errorDescription, limit, + offset, order, orderDirection, + linkedNotebookGuid); + if (notebooks.isEmpty() && !errorDescription.isEmpty()) { Q_EMIT listNotebooksFailed(flag, limit, offset, order, orderDirection, linkedNotebookGuid, errorDescription, @@ -737,7 +753,7 @@ "caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT listNotebooksFailed(flag, limit, offset, order, orderDirection, linkedNotebookGuid, error, requestId); } @@ -752,8 +768,10 @@ { ErrorString errorDescription; QList<SharedNotebook> sharedNotebooks = - d->m_pLocalStorageManager->listSharedNotebooksPerNotebookGuid(notebookGuid, - errorDescription); + d->m_pLocalStorageManager->listSharedNotebooksPerNotebookGuid( + notebookGuid, + errorDescription); + if (sharedNotebooks.isEmpty() && !errorDescription.isEmpty()) { Q_EMIT listSharedNotebooksPerNotebookGuidFailed(notebookGuid, errorDescription, @@ -771,14 +789,14 @@ "from the local storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT listSharedNotebooksPerNotebookGuidFailed(notebookGuid, error, requestId); } } -void LocalStorageManagerAsync::onExpungeNotebookRequest(Notebook notebook, - QUuid requestId) +void LocalStorageManagerAsync::onExpungeNotebookRequest( + Notebook notebook, QUuid requestId) { Q_D(LocalStorageManagerAsync); @@ -801,11 +819,11 @@ } catch(const std::exception & e) { - ErrorString error(QT_TR_NOOP("Can't expunge notebook from the local storage: " - "caught exception")); + ErrorString error(QT_TR_NOOP("Can't expunge notebook from the local " + "storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT expungeNotebookFailed(notebook, error, requestId); } } @@ -817,7 +835,8 @@ try { ErrorString errorDescription; - int count = d->m_pLocalStorageManager->linkedNotebookCount(errorDescription); + int count = d->m_pLocalStorageManager->linkedNotebookCount( + errorDescription); if (count < 0) { Q_EMIT getLinkedNotebookCountFailed(errorDescription, requestId); } @@ -831,13 +850,13 @@ "the local storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT getLinkedNotebookCountFailed(error, requestId); } } -void LocalStorageManagerAsync::onAddLinkedNotebookRequest(LinkedNotebook linkedNotebook, - QUuid requestId) +void LocalStorageManagerAsync::onAddLinkedNotebookRequest( + LinkedNotebook linkedNotebook, QUuid requestId) { Q_D(LocalStorageManagerAsync); @@ -848,7 +867,8 @@ bool res = d->m_pLocalStorageManager->addLinkedNotebook(linkedNotebook, errorDescription); if (!res) { - Q_EMIT addLinkedNotebookFailed(linkedNotebook, errorDescription, requestId); + Q_EMIT addLinkedNotebookFailed(linkedNotebook, errorDescription, + requestId); return; } @@ -860,17 +880,17 @@ } catch(const std::exception & e) { - ErrorString error(QT_TR_NOOP("Can't add linked notebook to the local storage: " - "caught exception")); + ErrorString error(QT_TR_NOOP("Can't add linked notebook to the local " + "storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT addLinkedNotebookFailed(linkedNotebook, error, requestId); } } -void LocalStorageManagerAsync::onUpdateLinkedNotebookRequest(LinkedNotebook linkedNotebook, - QUuid requestId) +void LocalStorageManagerAsync::onUpdateLinkedNotebookRequest( + LinkedNotebook linkedNotebook, QUuid requestId) { Q_D(LocalStorageManagerAsync); @@ -878,8 +898,10 @@ { ErrorString errorDescription; - bool res = d->m_pLocalStorageManager->updateLinkedNotebook(linkedNotebook, - errorDescription); + bool res = d->m_pLocalStorageManager->updateLinkedNotebook( + linkedNotebook, + errorDescription); + if (!res) { Q_EMIT updateLinkedNotebookFailed(linkedNotebook, errorDescription, requestId); @@ -898,13 +920,13 @@ "storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT updateLinkedNotebookFailed(linkedNotebook, error, requestId); } } -void LocalStorageManagerAsync::onFindLinkedNotebookRequest(LinkedNotebook linkedNotebook, - QUuid requestId) +void LocalStorageManagerAsync::onFindLinkedNotebookRequest( + LinkedNotebook linkedNotebook, QUuid requestId) { Q_D(LocalStorageManagerAsync); @@ -926,8 +948,10 @@ if (!foundLinkedNotebookInCache) { - bool res = d->m_pLocalStorageManager->findLinkedNotebook(linkedNotebook, - errorDescription); + bool res = d->m_pLocalStorageManager->findLinkedNotebook( + linkedNotebook, + errorDescription); + if (!res) { Q_EMIT findLinkedNotebookFailed(linkedNotebook, errorDescription, requestId); @@ -939,11 +963,11 @@ } catch(const std::exception & e) { - ErrorString error(QT_TR_NOOP("Can't find linked notebook within the local " - "storage: caught exception")); + ErrorString error(QT_TR_NOOP("Can't find linked notebook within " + "the local storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT findLinkedNotebookFailed(linkedNotebook, error, requestId); } } @@ -960,12 +984,15 @@ { ErrorString errorDescription; QList<LinkedNotebook> linkedNotebooks = - d->m_pLocalStorageManager->listAllLinkedNotebooks(errorDescription, - limit, offset, order, - orderDirection); + d->m_pLocalStorageManager->listAllLinkedNotebooks( + errorDescription, + limit, offset, order, + orderDirection); + if (linkedNotebooks.isEmpty() && !errorDescription.isEmpty()) { - Q_EMIT listAllLinkedNotebooksFailed(limit, offset, order, orderDirection, - errorDescription, requestId); + Q_EMIT listAllLinkedNotebooksFailed(limit, offset, order, + orderDirection, errorDescription, + requestId); return; } @@ -978,8 +1005,9 @@ } } - Q_EMIT listAllLinkedNotebooksComplete(limit, offset, order, orderDirection, - linkedNotebooks, requestId); + Q_EMIT listAllLinkedNotebooksComplete(limit, offset, order, + orderDirection, linkedNotebooks, + requestId); } catch(const std::exception & e) { @@ -987,9 +1015,9 @@ "the local storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); - Q_EMIT listAllLinkedNotebooksFailed(limit, offset, order, orderDirection, - error, requestId); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); + Q_EMIT listAllLinkedNotebooksFailed(limit, offset, order, + orderDirection, error, requestId); } } @@ -1006,9 +1034,11 @@ { ErrorString errorDescription; QList<LinkedNotebook> linkedNotebooks = - d->m_pLocalStorageManager->listLinkedNotebooks(flag, errorDescription, - limit, offset, order, - orderDirection); + d->m_pLocalStorageManager->listLinkedNotebooks( + flag, errorDescription, + limit, offset, order, + orderDirection); + if (linkedNotebooks.isEmpty() && !errorDescription.isEmpty()) { Q_EMIT listLinkedNotebooksFailed(flag, limit, offset, order, orderDirection, errorDescription, @@ -1030,18 +1060,18 @@ } catch(const std::exception & e) { - ErrorString error(QT_TR_NOOP("Can't list linked notebooks from the local " - "storage: caught exception")); + ErrorString error(QT_TR_NOOP("Can't list linked notebooks from " + "the local storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT listLinkedNotebooksFailed(flag, limit, offset, order, orderDirection, error, requestId); } } -void LocalStorageManagerAsync::onExpungeLinkedNotebookRequest(LinkedNotebook linkedNotebook, - QUuid requestId) +void LocalStorageManagerAsync::onExpungeLinkedNotebookRequest( + LinkedNotebook linkedNotebook, QUuid requestId) { Q_D(LocalStorageManagerAsync); @@ -1049,8 +1079,10 @@ { ErrorString errorDescription; - bool res = d->m_pLocalStorageManager->expungeLinkedNotebook(linkedNotebook, - errorDescription); + bool res = d->m_pLocalStorageManager->expungeLinkedNotebook( + linkedNotebook, + errorDescription); + if (!res) { Q_EMIT expungeLinkedNotebookFailed(linkedNotebook, errorDescription, requestId); @@ -1065,18 +1097,17 @@ } catch(const std::exception & e) { - ErrorString error(QT_TR_NOOP("Can't expunge linked notebook from the local " - "storage: caught exception")); + ErrorString error(QT_TR_NOOP("Can't expunge linked notebook from " + "the local storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT expungeLinkedNotebookFailed(linkedNotebook, error, requestId); } } void LocalStorageManagerAsync::onGetNoteCountRequest( - LocalStorageManager::NoteCountOptions options, - QUuid requestId) + LocalStorageManager::NoteCountOptions options, QUuid requestId) { Q_D(LocalStorageManagerAsync); @@ -1094,11 +1125,11 @@ } catch(const std::exception & e) { - ErrorString error(QT_TR_NOOP("Can't get note count from the local storage: " - "caught exception")); + ErrorString error(QT_TR_NOOP("Can't get note count from the local " + "storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT getNoteCountFailed(error, options, requestId); } } @@ -1130,15 +1161,14 @@ "the local storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); - Q_EMIT getNoteCountPerNotebookFailed(error, notebook, options, requestId); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); + Q_EMIT getNoteCountPerNotebookFailed(error, notebook, options, + requestId); } } void LocalStorageManagerAsync::onGetNoteCountPerTagRequest( - Tag tag, - LocalStorageManager::NoteCountOptions options, - QUuid requestId) + Tag tag, LocalStorageManager::NoteCountOptions options, QUuid requestId) { Q_D(LocalStorageManagerAsync); @@ -1148,7 +1178,8 @@ int count = d->m_pLocalStorageManager->noteCountPerTag( tag, errorDescription, options); if (count < 0) { - Q_EMIT getNoteCountPerTagFailed(errorDescription, tag, options, requestId); + Q_EMIT getNoteCountPerTagFailed(errorDescription, tag, options, + requestId); } else { Q_EMIT getNoteCountPerTagComplete(count, tag, options, requestId); @@ -1160,7 +1191,7 @@ "the local storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT getNoteCountPerTagFailed(error, tag, options, requestId); } } @@ -1192,7 +1223,7 @@ "the local storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT getNoteCountsPerAllTagsFailed(error, options, requestId); } } @@ -1215,7 +1246,8 @@ requestId); } else { - Q_EMIT getNoteCountPerNotebooksAndTagsComplete(count, notebookLocalUids, + Q_EMIT getNoteCountPerNotebooksAndTagsComplete(count, + notebookLocalUids, tagLocalUids, options, requestId); } @@ -1227,7 +1259,7 @@ "exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT getNoteCountPerNotebooksAndTagsFailed(error, notebookLocalUids, tagLocalUids, options, requestId); @@ -1271,7 +1303,7 @@ "caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT addNoteFailed(note, error, requestId); } } @@ -1289,7 +1321,8 @@ #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) static const QMetaMethod noteMovedToAnotherNotebookSignal = - QMetaMethod::fromSignal(&LocalStorageManagerAsync::noteMovedToAnotherNotebook); + QMetaMethod::fromSignal( + &LocalStorageManagerAsync::noteMovedToAnotherNotebook); if (isSignalConnected(noteMovedToAnotherNotebookSignal)) { shouldCheckForNotebookChange = true; } @@ -1297,7 +1330,8 @@ if (options & LocalStorageManager::UpdateNoteOption::UpdateTags) { static const QMetaMethod noteTagListChangedSignal = - QMetaMethod::fromSignal(&LocalStorageManagerAsync::noteTagListChanged); + QMetaMethod::fromSignal( + &LocalStorageManagerAsync::noteTagListChanged); if (isSignalConnected(noteTagListChangedSignal)) { shouldCheckForTagListUpdate = true; } @@ -1364,7 +1398,8 @@ } if (!res) { - Q_EMIT updateNoteFailed(note, options, errorDescription, requestId); + Q_EMIT updateNoteFailed(note, options, errorDescription, + requestId); return; } } @@ -1385,7 +1420,8 @@ { Note noteForCaching = note; QList<Resource> resourcesForCaching; - splitNoteAndResourcesForCaching(noteForCaching, resourcesForCaching); + splitNoteAndResourcesForCaching(noteForCaching, + resourcesForCaching); d->m_pLocalStorageCacheManager->cacheNote(noteForCaching); if (options & LocalStorageManager::UpdateNoteOption::UpdateResourceBinaryData) @@ -1399,7 +1435,8 @@ else { // Since resources metadata might have changed, it would - // become stale within the cache so need to remove it from there + // become stale within the cache so need to remove it from + // there for(auto it = resourcesForCaching.constBegin(), end = resourcesForCaching.constEnd(); it != end; ++it) { @@ -1430,29 +1467,35 @@ { bool notebookChanged = false; if (note.hasNotebookGuid() && previousNoteVersion.hasNotebookGuid()) { - notebookChanged = (note.notebookGuid() != previousNoteVersion.notebookGuid()); + notebookChanged = + (note.notebookGuid() != previousNoteVersion.notebookGuid()); } else { - notebookChanged = (note.notebookLocalUid() != previousNoteVersion.notebookLocalUid()); + notebookChanged = + (note.notebookLocalUid() != previousNoteVersion.notebookLocalUid()); } - if (notebookChanged) { - QNDEBUG(QStringLiteral("Notebook change detected for note ") - << note.localUid() << QStringLiteral(": moved from notebook ") + if (notebookChanged) + { + QNDEBUG("Notebook change detected for note " + << note.localUid() << ": moved from notebook " << previousNoteVersion.notebookLocalUid() - << QStringLiteral(" to notebook ") << note.notebookLocalUid()); - Q_EMIT noteMovedToAnotherNotebook(note.localUid(), - previousNoteVersion.notebookLocalUid(), - note.notebookLocalUid()); + << " to notebook " << note.notebookLocalUid()); + Q_EMIT noteMovedToAnotherNotebook( + note.localUid(), + previousNoteVersion.notebookLocalUid(), + note.notebookLocalUid()); } } if (shouldCheckForTagListUpdate) { - const QStringList & previousTagLocalUids = previousNoteVersion.tagLocalUids(); + const QStringList & previousTagLocalUids = + previousNoteVersion.tagLocalUids(); const QStringList & updatedTagLocalUids = note.tagLocalUids(); - bool tagListUpdated = (previousTagLocalUids.size() != updatedTagLocalUids.size()); + bool tagListUpdated = + (previousTagLocalUids.size() != updatedTagLocalUids.size()); if (!tagListUpdated) { for(auto it = previousTagLocalUids.constBegin(), @@ -1467,11 +1510,12 @@ } } - if (tagListUpdated) { - QNDEBUG(QStringLiteral("Tags list update detected for note ") - << note.localUid() << QStringLiteral(": previous tag local uids: ") + if (tagListUpdated) + { + QNDEBUG("Tags list update detected for note " + << note.localUid() << ": previous tag local uids: " << previousTagLocalUids.join(QStringLiteral(", ")) - << QStringLiteral("; updated tag local uids: ") + << "; updated tag local uids: " << updatedTagLocalUids.join(QStringLiteral(","))); Q_EMIT noteTagListChanged(note.localUid(), previousTagLocalUids, updatedTagLocalUids); @@ -1484,7 +1528,7 @@ "caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT updateNoteFailed(note, options, error, requestId); } } @@ -1508,7 +1552,8 @@ ? LocalStorageCacheManager::Guid : LocalStorageCacheManager::LocalUid); - const Note * pNote = d->m_pLocalStorageCacheManager->findNote(uid, wu); + const Note * pNote = + d->m_pLocalStorageCacheManager->findNote(uid, wu); if (pNote) { note = *pNote; @@ -1532,7 +1577,10 @@ : LocalStorageCacheManager::LocalUid); const Resource * pResource = - d->m_pLocalStorageCacheManager->findResource(resourceUid, rwu); + d->m_pLocalStorageCacheManager->findResource( + resourceUid, + rwu); + if (pResource) { resource = *pResource; @@ -1541,11 +1589,14 @@ { LocalStorageManager::GetResourceOptions resourceOptions = LocalStorageManager::GetResourceOption::WithBinaryData; - bool res = d->m_pLocalStorageManager->findEnResource(resource, - resourceOptions, - errorDescription); + bool res = d->m_pLocalStorageManager->findEnResource( + resource, + resourceOptions, + errorDescription); + if (!res) { - Q_EMIT findNoteFailed(note, options, errorDescription, + Q_EMIT findNoteFailed(note, options, + errorDescription, requestId); return; } @@ -1570,7 +1621,9 @@ if (!foundNoteInCache && d->m_useCache) { QList<Resource> resources = note.resources(); - for(auto it = resources.begin(), end = resources.end(); it != end; ++it) { + for(auto it = resources.begin(), + end = resources.end(); it != end; ++it) + { Resource & resource = *it; resource.setDataBody(QByteArray()); resource.setAlternateDataBody(QByteArray()); @@ -1578,7 +1631,8 @@ Note noteWithoutResourceBinaryData = note; noteWithoutResourceBinaryData.setResources(resources); - d->m_pLocalStorageCacheManager->cacheNote(noteWithoutResourceBinaryData); + d->m_pLocalStorageCacheManager->cacheNote( + noteWithoutResourceBinaryData); } if (foundNoteInCache && @@ -1591,11 +1645,11 @@ } catch(const std::exception & e) { - ErrorString error(QT_TR_NOOP("Can't find note within the local storage: " - "caught exception")); + ErrorString error(QT_TR_NOOP("Can't find note within the local " + "storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT findNoteFailed(note, options, error, requestId); } } @@ -1613,11 +1667,11 @@ { ErrorString errorDescription; - QList<Note> notes = - d->m_pLocalStorageManager->listNotesPerNotebook(notebook, options, - errorDescription, - flag, limit, offset, - order, orderDirection); + QList<Note> notes = d->m_pLocalStorageManager->listNotesPerNotebook( + notebook, options, errorDescription, + flag, limit, offset, order, + orderDirection); + if (notes.isEmpty() && !errorDescription.isEmpty()) { Q_EMIT listNotesPerNotebookFailed(notebook, options, flag, limit, offset, order, orderDirection, @@ -1636,9 +1690,10 @@ "the local storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); - Q_EMIT listNotesPerNotebookFailed(notebook, options, flag, limit, offset, - order, orderDirection, error, requestId); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); + Q_EMIT listNotesPerNotebookFailed(notebook, options, flag, limit, + offset, order, orderDirection, + error, requestId); } } @@ -1655,14 +1710,15 @@ { ErrorString errorDescription; - QList<Note> notes = - d->m_pLocalStorageManager->listNotesPerTag(tag, options, - errorDescription, - flag, limit, offset, - order, orderDirection); + QList<Note> notes = d->m_pLocalStorageManager->listNotesPerTag( + tag, options, errorDescription, + flag, limit, offset, order, + orderDirection); + if (notes.isEmpty() && !errorDescription.isEmpty()) { - Q_EMIT listNotesPerTagFailed(tag, options, flag, limit, offset, order, - orderDirection, errorDescription, requestId); + Q_EMIT listNotesPerTagFailed(tag, options, flag, limit, offset, + order, orderDirection, + errorDescription, requestId); return; } @@ -1676,7 +1732,7 @@ "storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT listNotesPerTagFailed(tag, options, flag, limit, offset, order, orderDirection, error, requestId); } @@ -1698,6 +1754,7 @@ QList<Note> notes = d->m_pLocalStorageManager->listNotesPerNotebooksAndTags( notebookLocalUids, tagLocalUids, options, errorDescription, flag, limit, offset, order, orderDirection); + if (notes.isEmpty() && !errorDescription.isEmpty()) { Q_EMIT listNotesPerNotebooksAndTagsFailed( notebookLocalUids, tagLocalUids, options, flag, limit, offset, @@ -1716,7 +1773,7 @@ "from the local storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT listNotesPerNotebooksAndTagsFailed( notebookLocalUids, tagLocalUids, options, flag, limit, offset, order, orderDirection, error, requestId); @@ -1757,7 +1814,7 @@ "the local storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT listNotesByLocalUidsFailed( noteLocalUids, options, flag, limit, offset, order, orderDirection, error, requestId); @@ -1799,7 +1856,7 @@ "caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT listNotesFailed(flag, options, limit, offset, order, orderDirection, linkedNotebookGuid, error, requestId); } @@ -1814,8 +1871,10 @@ { ErrorString errorDescription; QStringList noteLocalUids = - d->m_pLocalStorageManager->findNoteLocalUidsWithSearchQuery(noteSearchQuery, - errorDescription); + d->m_pLocalStorageManager->findNoteLocalUidsWithSearchQuery( + noteSearchQuery, + errorDescription); + if (noteLocalUids.isEmpty() && !errorDescription.isEmpty()) { Q_EMIT findNoteLocalUidsWithSearchQueryFailed(noteSearchQuery, errorDescription, @@ -1833,7 +1892,7 @@ "within the local storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT findNoteLocalUidsWithSearchQueryFailed(noteSearchQuery, error, requestId); } @@ -1870,11 +1929,11 @@ } catch(const std::exception & e) { - ErrorString error(QT_TR_NOOP("Can't expunge note from the local storage: " - "caught exception")); + ErrorString error(QT_TR_NOOP("Can't expunge note from the local " + "storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT expungeNoteFailed(note, error, requestId); } } @@ -1896,11 +1955,11 @@ } catch(const std::exception & e) { - ErrorString error(QT_TR_NOOP("Can't get tag count from the local storage: " - "caught exception")); + ErrorString error(QT_TR_NOOP("Can't get tag count from the local " + "storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT getTagCountFailed(error, requestId); } } @@ -1931,7 +1990,7 @@ "caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT addTagFailed(tag, error, requestId); } } @@ -1962,7 +2021,7 @@ "caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT updateTagFailed(tag, error, requestId); } } @@ -1987,7 +2046,8 @@ ? LocalStorageCacheManager::Guid : LocalStorageCacheManager::LocalUid); - const Tag * pTag = d->m_pLocalStorageCacheManager->findTag(uid, wg); + const Tag * pTag = + d->m_pLocalStorageCacheManager->findTag(uid, wg); if (pTag) { tag = *pTag; foundTagInCache = true; @@ -1996,7 +2056,8 @@ else if (tag.hasName() && !tag.name().isEmpty()) { const QString tagName = tag.name(); - const Tag * pTag = d->m_pLocalStorageCacheManager->findTagByName(tagName); + const Tag * pTag = + d->m_pLocalStorageCacheManager->findTagByName(tagName); if (pTag) { tag = *pTag; foundTagInCache = true; @@ -2021,7 +2082,7 @@ "caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT findTagFailed(tag, error, requestId); } } @@ -2068,7 +2129,7 @@ "the local storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT listAllTagsPerNoteFailed(note, flag, limit, offset, order, orderDirection, error, requestId); } @@ -2110,11 +2171,11 @@ } catch(const std::exception & e) { - ErrorString error(QT_TR_NOOP("Can't list all tags from the local storage: " - "caught exception")); + ErrorString error(QT_TR_NOOP("Can't list all tags from the local " + "storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT listAllTagsFailed(limit, offset, order, orderDirection, linkedNotebookGuid, error, requestId); } @@ -2158,7 +2219,7 @@ "caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT listTagsFailed(flag, limit, offset, order, orderDirection, linkedNotebookGuid, error, requestId); } @@ -2176,13 +2237,15 @@ { ErrorString errorDescription; QList<std::pair<Tag, QStringList> > tagsWithNoteLocalUids = - d->m_pLocalStorageManager->listTagsWithNoteLocalUids(flag, errorDescription, - limit, offset, order, - orderDirection, - linkedNotebookGuid); + d->m_pLocalStorageManager->listTagsWithNoteLocalUids( + flag, errorDescription, limit, + offset, order, orderDirection, + linkedNotebookGuid); + if (tagsWithNoteLocalUids.isEmpty() && !errorDescription.isEmpty()) { Q_EMIT listTagsWithNoteLocalUidsFailed(flag, limit, offset, order, - orderDirection, linkedNotebookGuid, + orderDirection, + linkedNotebookGuid, errorDescription, requestId); } @@ -2196,8 +2259,10 @@ } Q_EMIT listTagsWithNoteLocalUidsComplete(flag, limit, offset, order, - orderDirection, linkedNotebookGuid, - tagsWithNoteLocalUids, requestId); + orderDirection, + linkedNotebookGuid, + tagsWithNoteLocalUids, + requestId); } catch(const std::exception & e) { @@ -2205,9 +2270,10 @@ "the local storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT listTagsWithNoteLocalUidsFailed(flag, limit, offset, order, - orderDirection, linkedNotebookGuid, + orderDirection, + linkedNotebookGuid, error, requestId); } } @@ -2221,9 +2287,10 @@ ErrorString errorDescription; QStringList expungedChildTagLocalUids; - bool res = d->m_pLocalStorageManager->expungeTag(tag, - expungedChildTagLocalUids, - errorDescription); + bool res = d->m_pLocalStorageManager->expungeTag( + tag, expungedChildTagLocalUids, + errorDescription); + if (!res) { Q_EMIT expungeTagFailed(tag, errorDescription, requestId); return; @@ -2250,19 +2317,23 @@ "caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT expungeTagFailed(tag, error, requestId); } } -void LocalStorageManagerAsync::onExpungeNotelessTagsFromLinkedNotebooksRequest(QUuid requestId) +void LocalStorageManagerAsync::onExpungeNotelessTagsFromLinkedNotebooksRequest( + QUuid requestId) { Q_D(LocalStorageManagerAsync); try { ErrorString errorDescription; - bool res = d->m_pLocalStorageManager->expungeNotelessTagsFromLinkedNotebooks(errorDescription); + bool res = + d->m_pLocalStorageManager->expungeNotelessTagsFromLinkedNotebooks( + errorDescription); + if (!res) { Q_EMIT expungeNotelessTagsFromLinkedNotebooksFailed(errorDescription, requestId); @@ -2282,7 +2353,7 @@ "the local storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT expungeNotelessTagsFromLinkedNotebooksFailed(error, requestId); } } @@ -2308,7 +2379,7 @@ "the local storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT getResourceCountFailed(error, requestId); } } @@ -2341,7 +2412,7 @@ "caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT addResourceFailed(resource, error, requestId); } } @@ -2370,11 +2441,11 @@ } catch(const std::exception & e) { - ErrorString error(QT_TR_NOOP("Can't update resource in the local storage: " - "caught exception")); + ErrorString error(QT_TR_NOOP("Can't update resource in the local " + "storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT updateResourceFailed(resource, error, requestId); } } @@ -2436,11 +2507,11 @@ } catch(const std::exception & e) { - ErrorString error(QT_TR_NOOP("Can't find resource within the local storage: " - "caught exception")); + ErrorString error(QT_TR_NOOP("Can't find resource within the local " + "storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT findResourceFailed(resource, options, error, requestId); } } @@ -2469,11 +2540,11 @@ } catch(const std::exception & e) { - ErrorString error(QT_TR_NOOP("Can't expunge resource from the local storage: " - "caught exception")); + ErrorString error(QT_TR_NOOP("Can't expunge resource from the local " + "storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT expungeResourceFailed(resource, error, requestId); } } @@ -2499,7 +2570,7 @@ "the local storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT getSavedSearchCountFailed(error, requestId); } } @@ -2528,11 +2599,11 @@ } catch(const std::exception & e) { - ErrorString error(QT_TR_NOOP("Can't add saved search to the local storage: " - "caught exception")); + ErrorString error(QT_TR_NOOP("Can't add saved search to the local " + "storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT addSavedSearchFailed(search, error, requestId); } } @@ -2565,7 +2636,7 @@ "storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT updateSavedSearchFailed(search, error, requestId); } } @@ -2604,7 +2675,8 @@ { const QString searchName = search.name(); const SavedSearch * pSearch = - d->m_pLocalStorageCacheManager->findSavedSearchByName(searchName); + d->m_pLocalStorageCacheManager->findSavedSearchByName( + searchName); if (pSearch) { search = *pSearch; foundCachedSavedSearch = true; @@ -2615,7 +2687,8 @@ if (!foundCachedSavedSearch) { bool res = - d->m_pLocalStorageManager->findSavedSearch(search, errorDescription); + d->m_pLocalStorageManager->findSavedSearch(search, + errorDescription); if (!res) { Q_EMIT findSavedSearchFailed(search, errorDescription, requestId); return; @@ -2630,7 +2703,7 @@ "storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT findSavedSearchFailed(search, error, requestId); } } @@ -2674,7 +2747,7 @@ "the local storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT listAllSavedSearchesFailed(limit, offset, order, orderDirection, error, requestId); } @@ -2697,7 +2770,6 @@ limit, offset, order, orderDirection); if (savedSearches.isEmpty() && !errorDescription.isEmpty()) { - QNTRACE(QStringLiteral("Failed: ") << errorDescription); Q_EMIT listSavedSearchesFailed(flag, limit, offset, order, orderDirection, errorDescription, requestId); @@ -2723,7 +2795,7 @@ "the local storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT listSavedSearchesFailed(flag, limit, offset, order, orderDirection, error, requestId); } @@ -2757,7 +2829,7 @@ "the local storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT expungeSavedSearchFailed(search, error, requestId); } } @@ -2789,7 +2861,7 @@ "the local storage: caught exception")); error.details() = QString::fromUtf8(e.what()); SysInfo sysInfo; - QNERROR(error << QStringLiteral("; backtrace: ") << sysInfo.stackTrace()); + QNERROR(error << "; backtrace: " << sysInfo.stackTrace()); Q_EMIT accountHighUsnFailed(linkedNotebookGuid, error, requestId); } } diff -Nru libquentier-0.5.0/src/local_storage/LocalStorageManager.cpp libquentier-0.5.0/src/local_storage/LocalStorageManager.cpp --- libquentier-0.5.0/src/local_storage/LocalStorageManager.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/local_storage/LocalStorageManager.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -85,13 +85,15 @@ d->switchUser(account, options); } -bool LocalStorageManager::isLocalStorageVersionTooHigh(ErrorString & errorDescription) +bool LocalStorageManager::isLocalStorageVersionTooHigh( + ErrorString & errorDescription) { Q_D(LocalStorageManager); return d->isLocalStorageVersionTooHigh(errorDescription); } -bool LocalStorageManager::localStorageRequiresUpgrade(ErrorString & errorDescription) +bool LocalStorageManager::localStorageRequiresUpgrade( + ErrorString & errorDescription) { Q_D(LocalStorageManager); return d->localStorageRequiresUpgrade(errorDescription); @@ -122,54 +124,54 @@ return d->userCount(errorDescription); } -bool LocalStorageManager::addNotebook(Notebook & notebook, - ErrorString & errorDescription) +bool LocalStorageManager::addNotebook( + Notebook & notebook, ErrorString & errorDescription) { Q_D(LocalStorageManager); return d->addNotebook(notebook, errorDescription); } -bool LocalStorageManager::updateNotebook(Notebook & notebook, - ErrorString & errorDescription) +bool LocalStorageManager::updateNotebook( + Notebook & notebook, ErrorString & errorDescription) { Q_D(LocalStorageManager); return d->updateNotebook(notebook, errorDescription); } -bool LocalStorageManager::findNotebook(Notebook & notebook, - ErrorString & errorDescription) const +bool LocalStorageManager::findNotebook( + Notebook & notebook, ErrorString & errorDescription) const { Q_D(const LocalStorageManager); return d->findNotebook(notebook, errorDescription); } -bool LocalStorageManager::findDefaultNotebook(Notebook & notebook, - ErrorString & errorDescription) const +bool LocalStorageManager::findDefaultNotebook( + Notebook & notebook, ErrorString & errorDescription) const { Q_D(const LocalStorageManager); return d->findDefaultNotebook(notebook, errorDescription); } -bool LocalStorageManager::findLastUsedNotebook(Notebook & notebook, - ErrorString & errorDescription) const +bool LocalStorageManager::findLastUsedNotebook( + Notebook & notebook, ErrorString & errorDescription) const { Q_D(const LocalStorageManager); return d->findLastUsedNotebook(notebook, errorDescription); } -bool LocalStorageManager::findDefaultOrLastUsedNotebook(Notebook & notebook, - ErrorString & errorDescription) const +bool LocalStorageManager::findDefaultOrLastUsedNotebook( + Notebook & notebook, ErrorString & errorDescription) const { Q_D(const LocalStorageManager); return d->findDefaultOrLastUsedNotebook(notebook, errorDescription); } QList<Notebook> -LocalStorageManager::listAllNotebooks(ErrorString & errorDescription, - const size_t limit, const size_t offset, - const ListNotebooksOrder::type order, - const OrderDirection::type orderDirection, - const QString & linkedNotebookGuid) const +LocalStorageManager::listAllNotebooks( + ErrorString & errorDescription, const size_t limit, const size_t offset, + const ListNotebooksOrder::type order, + const OrderDirection::type orderDirection, + const QString & linkedNotebookGuid) const { Q_D(const LocalStorageManager); return d->listAllNotebooks(errorDescription, limit, offset, order, @@ -177,12 +179,12 @@ } QList<Notebook> -LocalStorageManager::listNotebooks(const ListObjectsOptions flag, - ErrorString & errorDescription, - const size_t limit, const size_t offset, - const ListNotebooksOrder::type order, - const OrderDirection::type orderDirection, - const QString & linkedNotebookGuid) const +LocalStorageManager::listNotebooks( + const ListObjectsOptions flag, ErrorString & errorDescription, + const size_t limit, const size_t offset, + const ListNotebooksOrder::type order, + const OrderDirection::type orderDirection, + const QString & linkedNotebookGuid) const { Q_D(const LocalStorageManager); return d->listNotebooks(flag, errorDescription, limit, offset, order, @@ -190,59 +192,61 @@ } QList<SharedNotebook> -LocalStorageManager::listAllSharedNotebooks(ErrorString & errorDescription) const +LocalStorageManager::listAllSharedNotebooks( + ErrorString & errorDescription) const { Q_D(const LocalStorageManager); return d->listAllSharedNotebooks(errorDescription); } QList<SharedNotebook> -LocalStorageManager::listSharedNotebooksPerNotebookGuid(const QString & notebookGuid, - ErrorString & errorDescription) const +LocalStorageManager::listSharedNotebooksPerNotebookGuid( + const QString & notebookGuid, ErrorString & errorDescription) const { Q_D(const LocalStorageManager); return d->listSharedNotebooksPerNotebookGuid(notebookGuid, errorDescription); } -bool LocalStorageManager::expungeNotebook(Notebook & notebook, - ErrorString & errorDescription) +bool LocalStorageManager::expungeNotebook( + Notebook & notebook, ErrorString & errorDescription) { Q_D(LocalStorageManager); return d->expungeNotebook(notebook, errorDescription); } -int LocalStorageManager::linkedNotebookCount(ErrorString & errorDescription) const +int LocalStorageManager::linkedNotebookCount( + ErrorString & errorDescription) const { Q_D(const LocalStorageManager); return d->linkedNotebookCount(errorDescription); } -bool LocalStorageManager::addLinkedNotebook(const LinkedNotebook & linkedNotebook, - ErrorString & errorDescription) +bool LocalStorageManager::addLinkedNotebook( + const LinkedNotebook & linkedNotebook, ErrorString & errorDescription) { Q_D(LocalStorageManager); return d->addLinkedNotebook(linkedNotebook, errorDescription); } -bool LocalStorageManager::updateLinkedNotebook(const LinkedNotebook & linkedNotebook, - ErrorString & errorDescription) +bool LocalStorageManager::updateLinkedNotebook( + const LinkedNotebook & linkedNotebook, ErrorString & errorDescription) { Q_D(LocalStorageManager); return d->updateLinkedNotebook(linkedNotebook, errorDescription); } -bool LocalStorageManager::findLinkedNotebook(LinkedNotebook & linkedNotebook, - ErrorString & errorDescription) const +bool LocalStorageManager::findLinkedNotebook( + LinkedNotebook & linkedNotebook, ErrorString & errorDescription) const { Q_D(const LocalStorageManager); return d->findLinkedNotebook(linkedNotebook, errorDescription); } QList<LinkedNotebook> -LocalStorageManager::listAllLinkedNotebooks(ErrorString & errorDescription, - const size_t limit, const size_t offset, - const ListLinkedNotebooksOrder::type order, - const OrderDirection::type orderDirection) const +LocalStorageManager::listAllLinkedNotebooks( + ErrorString & errorDescription, const size_t limit, const size_t offset, + const ListLinkedNotebooksOrder::type order, + const OrderDirection::type orderDirection) const { Q_D(const LocalStorageManager); return d->listAllLinkedNotebooks(errorDescription, limit, offset, @@ -250,26 +254,26 @@ } QList<LinkedNotebook> -LocalStorageManager::listLinkedNotebooks(const ListObjectsOptions flag, - ErrorString & errorDescription, - const size_t limit, const size_t offset, - const ListLinkedNotebooksOrder::type order, - const OrderDirection::type orderDirection) const +LocalStorageManager::listLinkedNotebooks( + const ListObjectsOptions flag, ErrorString & errorDescription, + const size_t limit, const size_t offset, + const ListLinkedNotebooksOrder::type order, + const OrderDirection::type orderDirection) const { Q_D(const LocalStorageManager); return d->listLinkedNotebooks(flag, errorDescription, limit, offset, order, orderDirection); } -bool LocalStorageManager::expungeLinkedNotebook(const LinkedNotebook & linkedNotebook, - ErrorString & errorDescription) +bool LocalStorageManager::expungeLinkedNotebook( + const LinkedNotebook & linkedNotebook, ErrorString & errorDescription) { Q_D(LocalStorageManager); return d->expungeLinkedNotebook(linkedNotebook, errorDescription); } -int LocalStorageManager::noteCount(ErrorString & errorDescription, - const NoteCountOptions options) const +int LocalStorageManager::noteCount( + ErrorString & errorDescription, const NoteCountOptions options) const { Q_D(const LocalStorageManager); return d->noteCount(errorDescription, options); @@ -303,8 +307,7 @@ int LocalStorageManager::noteCountPerNotebooksAndTags( const QStringList & notebookLocalUids, - const QStringList & tagLocalUids, - ErrorString & errorDescription, + const QStringList & tagLocalUids, ErrorString & errorDescription, const LocalStorageManager::NoteCountOptions options) const { Q_D(const LocalStorageManager); @@ -318,27 +321,26 @@ return d->addNote(note, errorDescription); } -bool LocalStorageManager::updateNote(Note & note, const UpdateNoteOptions options, - ErrorString & errorDescription) +bool LocalStorageManager::updateNote( + Note & note, const UpdateNoteOptions options, + ErrorString & errorDescription) { Q_D(LocalStorageManager); return d->updateNote(note, options, errorDescription); } -bool LocalStorageManager::findNote(Note & note, const GetNoteOptions options, - ErrorString & errorDescription) const +bool LocalStorageManager::findNote( + Note & note, const GetNoteOptions options, + ErrorString & errorDescription) const { Q_D(const LocalStorageManager); return d->findNote(note, options, errorDescription); } QList<Note> LocalStorageManager::listNotesPerNotebook( - const Notebook & notebook, - const GetNoteOptions options, - ErrorString & errorDescription, - const ListObjectsOptions & flag, - const size_t limit, const size_t offset, - const ListNotesOrder::type & order, + const Notebook & notebook, const GetNoteOptions options, + ErrorString & errorDescription, const ListObjectsOptions & flag, + const size_t limit, const size_t offset, const ListNotesOrder::type & order, const OrderDirection::type & orderDirection) const { Q_D(const LocalStorageManager); @@ -347,12 +349,9 @@ } QList<Note> LocalStorageManager::listNotesPerTag( - const Tag & tag, - const GetNoteOptions options, - ErrorString & errorDescription, - const ListObjectsOptions & flag, - const size_t limit, const size_t offset, - const ListNotesOrder::type & order, + const Tag & tag, const GetNoteOptions options, + ErrorString & errorDescription, const ListObjectsOptions & flag, + const size_t limit, const size_t offset, const ListNotesOrder::type & order, const OrderDirection::type & orderDirection) const { Q_D(const LocalStorageManager); @@ -404,24 +403,24 @@ order, orderDirection, linkedNotebookGuid); } -QStringList -LocalStorageManager::findNoteLocalUidsWithSearchQuery(const NoteSearchQuery & noteSearchQuery, - ErrorString & errorDescription) const +QStringList LocalStorageManager::findNoteLocalUidsWithSearchQuery( + const NoteSearchQuery & noteSearchQuery, + ErrorString & errorDescription) const { Q_D(const LocalStorageManager); return d->findNoteLocalUidsWithSearchQuery(noteSearchQuery, errorDescription); } -NoteList -LocalStorageManager::findNotesWithSearchQuery(const NoteSearchQuery & noteSearchQuery, - const GetNoteOptions options, - ErrorString & errorDescription) const +NoteList LocalStorageManager::findNotesWithSearchQuery( + const NoteSearchQuery & noteSearchQuery, + const GetNoteOptions options, ErrorString & errorDescription) const { Q_D(const LocalStorageManager); return d->findNotesWithSearchQuery(noteSearchQuery, options, errorDescription); } -bool LocalStorageManager::expungeNote(Note & note, ErrorString & errorDescription) +bool LocalStorageManager::expungeNote( + Note & note, ErrorString & errorDescription) { Q_D(LocalStorageManager); return d->expungeNote(note, errorDescription); @@ -445,44 +444,40 @@ return d->updateTag(tag, errorDescription); } -bool LocalStorageManager::findTag(Tag & tag, ErrorString & errorDescription) const +bool LocalStorageManager::findTag( + Tag & tag, ErrorString & errorDescription) const { Q_D(const LocalStorageManager); return d->findTag(tag, errorDescription); } -QList<Tag> -LocalStorageManager::listAllTagsPerNote(const Note & note, - ErrorString & errorDescription, - const ListObjectsOptions & flag, - const size_t limit, const size_t offset, - const ListTagsOrder::type & order, - const OrderDirection::type & orderDirection) const +QList<Tag> LocalStorageManager::listAllTagsPerNote( + const Note & note, ErrorString & errorDescription, + const ListObjectsOptions & flag, const size_t limit, + const size_t offset, const ListTagsOrder::type & order, + const OrderDirection::type & orderDirection) const { Q_D(const LocalStorageManager); return d->listAllTagsPerNote(note, errorDescription, flag, limit, offset, order, orderDirection); } -QList<Tag> -LocalStorageManager::listAllTags(ErrorString & errorDescription, - const size_t limit, const size_t offset, - const ListTagsOrder::type order, - const OrderDirection::type orderDirection, - const QString & linkedNotebookGuid) const +QList<Tag> LocalStorageManager::listAllTags( + ErrorString & errorDescription, const size_t limit, const size_t offset, + const ListTagsOrder::type order, const OrderDirection::type orderDirection, + const QString & linkedNotebookGuid) const { Q_D(const LocalStorageManager); return d->listAllTags(errorDescription, limit, offset, order, orderDirection, linkedNotebookGuid); } -QList<Tag> -LocalStorageManager::listTags(const ListObjectsOptions flag, - ErrorString & errorDescription, - const size_t limit, const size_t offset, - const ListTagsOrder::type & order, - const OrderDirection::type orderDirection, - const QString & linkedNotebookGuid) const +QList<Tag> LocalStorageManager::listTags( + const ListObjectsOptions flag, ErrorString & errorDescription, + const size_t limit, const size_t offset, + const ListTagsOrder::type & order, + const OrderDirection::type orderDirection, + const QString & linkedNotebookGuid) const { Q_D(const LocalStorageManager); return d->listTags(flag, errorDescription, limit, offset, @@ -490,27 +485,27 @@ } QList<std::pair<Tag, QStringList> > -LocalStorageManager::listTagsWithNoteLocalUids(const ListObjectsOptions flag, - ErrorString & errorDescription, - const size_t limit, - const size_t offset, - const ListTagsOrder::type & order, - const OrderDirection::type orderDirection, - const QString & linkedNotebookGuid) const +LocalStorageManager::listTagsWithNoteLocalUids( + const ListObjectsOptions flag, + ErrorString & errorDescription, const size_t limit, const size_t offset, + const ListTagsOrder::type & order, const OrderDirection::type orderDirection, + const QString & linkedNotebookGuid) const { Q_D(const LocalStorageManager); return d->listTagsWithNoteLocalUids(flag, errorDescription, limit, offset, order, orderDirection, linkedNotebookGuid); } -bool LocalStorageManager::expungeTag(Tag & tag, QStringList & expungedChildTagLocalUids, - ErrorString & errorDescription) +bool LocalStorageManager::expungeTag( + Tag & tag, QStringList & expungedChildTagLocalUids, + ErrorString & errorDescription) { Q_D(LocalStorageManager); return d->expungeTag(tag, expungedChildTagLocalUids, errorDescription); } -bool LocalStorageManager::expungeNotelessTagsFromLinkedNotebooks(ErrorString & errorDescription) +bool LocalStorageManager::expungeNotelessTagsFromLinkedNotebooks( + ErrorString & errorDescription) { Q_D(LocalStorageManager); return d->expungeNotelessTagsFromLinkedNotebooks(errorDescription); @@ -522,30 +517,30 @@ return d->enResourceCount(errorDescription); } -bool LocalStorageManager::addEnResource(Resource & resource, - ErrorString & errorDescription) +bool LocalStorageManager::addEnResource( + Resource & resource, ErrorString & errorDescription) { Q_D(LocalStorageManager); return d->addEnResource(resource, errorDescription); } -bool LocalStorageManager::updateEnResource(Resource & resource, - ErrorString & errorDescription) +bool LocalStorageManager::updateEnResource( + Resource & resource, ErrorString & errorDescription) { Q_D(LocalStorageManager); return d->updateEnResource(resource, errorDescription); } -bool LocalStorageManager::findEnResource(Resource & resource, - const GetResourceOptions options, - ErrorString & errorDescription) const +bool LocalStorageManager::findEnResource( + Resource & resource, const GetResourceOptions options, + ErrorString & errorDescription) const { Q_D(const LocalStorageManager); return d->findEnResource(resource, options, errorDescription); } -bool LocalStorageManager::expungeEnResource(Resource & resource, - ErrorString & errorDescription) +bool LocalStorageManager::expungeEnResource( + Resource & resource, ErrorString & errorDescription) { Q_D(LocalStorageManager); return d->expungeEnResource(resource, errorDescription); @@ -557,59 +552,58 @@ return d->savedSearchCount(errorDescription); } -bool LocalStorageManager::addSavedSearch(SavedSearch & search, - ErrorString & errorDescription) +bool LocalStorageManager::addSavedSearch( + SavedSearch & search, ErrorString & errorDescription) { Q_D(LocalStorageManager); return d->addSavedSearch(search, errorDescription); } -bool LocalStorageManager::updateSavedSearch(SavedSearch & search, - ErrorString & errorDescription) +bool LocalStorageManager::updateSavedSearch( + SavedSearch & search, ErrorString & errorDescription) { Q_D(LocalStorageManager); return d->updateSavedSearch(search, errorDescription); } -bool LocalStorageManager::findSavedSearch(SavedSearch & search, - ErrorString & errorDescription) const +bool LocalStorageManager::findSavedSearch( + SavedSearch & search, ErrorString & errorDescription) const { Q_D(const LocalStorageManager); return d->findSavedSearch(search, errorDescription); } -QList<SavedSearch> -LocalStorageManager::listAllSavedSearches(ErrorString & errorDescription, - const size_t limit, const size_t offset, - const ListSavedSearchesOrder::type order, - const OrderDirection::type orderDirection) const +QList<SavedSearch> LocalStorageManager::listAllSavedSearches( + ErrorString & errorDescription, + const size_t limit, const size_t offset, + const ListSavedSearchesOrder::type order, + const OrderDirection::type orderDirection) const { Q_D(const LocalStorageManager); return d->listAllSavedSearches(errorDescription, limit, offset, order, orderDirection); } -QList<SavedSearch> -LocalStorageManager::listSavedSearches(const ListObjectsOptions flag, - ErrorString & errorDescription, - const size_t limit, const size_t offset, - const ListSavedSearchesOrder::type order, - const OrderDirection::type orderDirection) const +QList<SavedSearch> LocalStorageManager::listSavedSearches( + const ListObjectsOptions flag, ErrorString & errorDescription, + const size_t limit, const size_t offset, + const ListSavedSearchesOrder::type order, + const OrderDirection::type orderDirection) const { Q_D(const LocalStorageManager); return d->listSavedSearches(flag, errorDescription, limit, offset, order, orderDirection); } -bool LocalStorageManager::expungeSavedSearch(SavedSearch & search, - ErrorString & errorDescription) +bool LocalStorageManager::expungeSavedSearch( + SavedSearch & search, ErrorString & errorDescription) { Q_D(LocalStorageManager); return d->expungeSavedSearch(search, errorDescription); } -qint32 LocalStorageManager::accountHighUsn(const QString & linkedNotebookGuid, - ErrorString & errorDescription) +qint32 LocalStorageManager::accountHighUsn( + const QString & linkedNotebookGuid, ErrorString & errorDescription) { Q_D(LocalStorageManager); return d->accountHighUsn(linkedNotebookGuid, errorDescription); diff -Nru libquentier-0.5.0/src/local_storage/LocalStorageManager_p.cpp libquentier-0.5.0/src/local_storage/LocalStorageManager_p.cpp --- libquentier-0.5.0/src/local_storage/LocalStorageManager_p.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/local_storage/LocalStorageManager_p.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -164,8 +164,7 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(QStringLiteral("Found invalid user: ") << user - << QStringLiteral("\nError: ") << error); + QNWARNING("Found invalid user: " << user << "\nError: " << error); return false; } @@ -175,7 +174,7 @@ errorDescription.base() = errorPrefix.base(); errorDescription.appendBase(QT_TR_NOOP("user with the same id already exists")); errorDescription.details() = userId; - QNWARNING(errorDescription << QStringLiteral(", id: ") << userId); + QNWARNING(errorDescription << ", id: " << userId); return false; } @@ -206,8 +205,8 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(QStringLiteral("Found invalid user: ") << user - << QStringLiteral("\nError: ") << error); + QNWARNING("Found invalid user: " << user + << "\nError: " << error); return false; } @@ -217,7 +216,7 @@ errorDescription.base() = errorPrefix.base(); errorDescription.appendBase(QT_TR_NOOP("user with the specified id was not found")); errorDescription.details() = userId; - QNWARNING(errorDescription << QStringLiteral(", id: ") << userId); + QNWARNING(errorDescription << ", id: " << userId); return false; } @@ -238,7 +237,7 @@ bool LocalStorageManagerPrivate::findUser(User & user, ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::findUser")); + QNDEBUG("LocalStorageManagerPrivate::findUser"); ErrorString errorPrefix(QT_TR_NOOP("Can't find user data in the local storage database")); @@ -251,7 +250,7 @@ qint32 id = user.id(); QString userId = QString::number(id); - QNDEBUG(QStringLiteral("Looking for user with id = ") << userId); + QNDEBUG("Looking for user with id = " << userId); QString queryString = QStringLiteral("SELECT * FROM Users LEFT OUTER JOIN UserAttributes " @@ -354,25 +353,29 @@ return true; } -#define SET_ERROR() \ - errorDescription.base() = errorPrefix.base(); \ - errorDescription.details() = query.lastError().text(); \ - QNERROR(errorDescription << QStringLiteral(", last query: ") \ - << lastExecutedQuery(query)) - -#define SET_INT_CONVERSION_ERROR() \ - errorDescription.base() = errorPrefix.base(); \ - errorDescription.appendBase(QT_TRANSLATE_NOOP("LocalStorageManagerPrivate", \ - "can't convert the fetched data to int")); \ - QNERROR(errorDescription << QStringLiteral(": ") << query.value(0)) - -#define SET_NO_DATA_FOUND() \ - errorDescription.base() = errorPrefix.base(); \ - errorDescription.appendBase(QT_TRANSLATE_NOOP("LocalStorageManagerPrivate", \ - "no data found")); \ - QNDEBUG(errorDescription) +#define SET_ERROR() \ + errorDescription.base() = errorPrefix.base(); \ + errorDescription.details() = query.lastError().text(); \ + QNERROR(errorDescription << ", last query: " << lastExecutedQuery(query)) \ +// SET_ERROR + +#define SET_INT_CONVERSION_ERROR() \ + errorDescription.base() = errorPrefix.base(); \ + errorDescription.appendBase( \ + QT_TRANSLATE_NOOP("LocalStorageManagerPrivate", \ + "can't convert the fetched data to int")); \ + QNERROR(errorDescription << ": " << query.value(0)) \ +// SET_INT_CONVERSION_ERROR + +#define SET_NO_DATA_FOUND() \ + errorDescription.base() = errorPrefix.base(); \ + errorDescription.appendBase(QT_TRANSLATE_NOOP("LocalStorageManagerPrivate",\ + "no data found")); \ + QNDEBUG(errorDescription) \ +// SET_NO_DATA_FOUND -int LocalStorageManagerPrivate::notebookCount(ErrorString & errorDescription) const +int LocalStorageManagerPrivate::notebookCount( + ErrorString & errorDescription) const { ErrorString errorPrefix(QT_TR_NOOP("Can't get the number of notebooks from " "the local storage database")); @@ -391,7 +394,7 @@ } if (!query.next()) { - QNDEBUG(QStringLiteral("Found no notebooks in local storage database")); + QNDEBUG("Found no notebooks in local storage database"); return 0; } @@ -406,27 +409,26 @@ return count; } -void LocalStorageManagerPrivate::switchUser(const Account & account, - const LocalStorageManager::StartupOptions options) +void LocalStorageManagerPrivate::switchUser( + const Account & account, const LocalStorageManager::StartupOptions options) { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::switchUser: ") << account.name() - << QStringLiteral(", clear database = ") + QNDEBUG("LocalStorageManagerPrivate::switchUser: " << account.name() + << ", clear database = " << ((options & LocalStorageManager::StartupOption::ClearDatabase) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", override lock = ") + ? "true" + : "false") + << ", override lock = " << ((options & LocalStorageManager::StartupOption::OverrideLock) - ? QStringLiteral("true") - : QStringLiteral("false"))); - QNTRACE(QStringLiteral("Account: ") << account); + ? "true" + : "false")); + QNTRACE("Account: " << account); if (!m_databaseFilePath.isEmpty() && (m_currentAccount.type() == account.type()) && (m_currentAccount.name() == account.name()) && (m_currentAccount.id() == account.id())) { - QNDEBUG(QStringLiteral("The same account and it has already been " - "initialized once, skipping")); + QNDEBUG("The same account and it has already been initialized once"); return; } @@ -461,7 +463,8 @@ m_sqlDatabase.close(); - QString sqlDatabaseConnectionName = QStringLiteral("quentier_sqlite_connection"); + QString sqlDatabaseConnectionName = + QStringLiteral("quentier_sqlite_connection"); if (!QSqlDatabase::contains(sqlDatabaseConnectionName)) { m_sqlDatabase = QSqlDatabase::addDatabase(sqlDriverName, sqlDatabaseConnectionName); @@ -484,9 +487,9 @@ throw DatabaseOpeningException(error); } - m_databaseFilePath += QStringLiteral("/") + QStringLiteral(QUENTIER_DATABASE_NAME); - QNDEBUG(QStringLiteral("Attempting to open or create database file: ") - << m_databaseFilePath); + m_databaseFilePath += + QStringLiteral("/") + QStringLiteral(QUENTIER_DATABASE_NAME); + QNDEBUG("Attempting to open or create database file: " << m_databaseFilePath); QFileInfo databaseFileInfo(m_databaseFilePath); @@ -495,8 +498,8 @@ { bool res = databaseFileDir.mkpath(databaseFileDir.absolutePath()); if (!res) { - ErrorString error(QT_TR_NOOP("Can't create the folder for local storage " - "database file")); + ErrorString error(QT_TR_NOOP("Can't create folder for the local " + "storage database file")); throw DatabaseOpeningException(error); } } @@ -504,13 +507,15 @@ if (databaseFileInfo.exists()) { if (Q_UNLIKELY(!databaseFileInfo.isReadable())) { - ErrorString error(QT_TR_NOOP("Local storage database file is not readable")); + ErrorString error(QT_TR_NOOP("Local storage database file is not " + "readable")); error.details() = m_databaseFilePath; throw DatabaseOpeningException(error); } if (Q_UNLIKELY(!databaseFileInfo.isWritable())) { - ErrorString error(QT_TR_NOOP("Local storage database file is not writable")); + ErrorString error(QT_TR_NOOP("Local storage database file is not " + "writable")); error.details() = m_databaseFilePath; throw DatabaseOpeningException(error); } @@ -537,10 +542,8 @@ * message says */ bool databaseFileExists = databaseFileInfo.exists(); - QNDEBUG(QStringLiteral("Database file exists before locking: ") - << (databaseFileExists - ? QStringLiteral("true") - : QStringLiteral("false"))); + QNDEBUG("Database file exists before locking: " + << (databaseFileExists ? "true" : "false")); bool lockResult = false; @@ -567,15 +570,14 @@ throw DatabaseLockedException(error); } else { - QNINFO(QStringLiteral("Local storage database file ") - << m_databaseFilePath - << QStringLiteral(" is locked but nobody cares")); + QNINFO("Local storage database file " << m_databaseFilePath + << " is locked but nobody cares"); } } #endif // Q_OS_WIN if (options & LocalStorageManager::StartupOption::ClearDatabase) { - QNDEBUG(QStringLiteral("Cleaning up the whole database for account: ") + QNDEBUG("Cleaning up the whole database for account: " << m_currentAccount); clearDatabaseFile(); } @@ -635,7 +637,8 @@ clearCachedQueries(); } -bool LocalStorageManagerPrivate::isLocalStorageVersionTooHigh(ErrorString & errorDescription) +bool LocalStorageManagerPrivate::isLocalStorageVersionTooHigh( + ErrorString & errorDescription) { qint32 currentVersion = localStorageVersion(errorDescription); if (currentVersion < 0) { @@ -646,7 +649,8 @@ return currentVersion > highestSupportedVersion; } -bool LocalStorageManagerPrivate::localStorageRequiresUpgrade(ErrorString & errorDescription) +bool LocalStorageManagerPrivate::localStorageRequiresUpgrade( + ErrorString & errorDescription) { qint32 currentVersion = localStorageVersion(errorDescription); if (currentVersion < 0) { @@ -669,24 +673,26 @@ return m_pLocalStoragePatchManager->patchesForCurrentVersion(); } -qint32 LocalStorageManagerPrivate::localStorageVersion(ErrorString & errorDescription) +qint32 LocalStorageManagerPrivate::localStorageVersion( + ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::localStorageVersion")); + QNDEBUG("LocalStorageManagerPrivate::localStorageVersion"); QString queryString = QStringLiteral("SELECT version FROM Auxiliary LIMIT 1"); QSqlQuery query(m_sqlDatabase); bool res = query.exec(queryString); if (Q_UNLIKELY(!res)) { - errorDescription.setBase(QT_TR_NOOP("failed to execute SQL query checking " - "whether the database requires an upgrade")); + errorDescription.setBase(QT_TR_NOOP("failed to execute SQL query " + "checking whether the database " + "requires an upgrade")); errorDescription.details() = query.lastError().text(); QNWARNING(errorDescription); return -1; } if (!query.next()) { - QNDEBUG(QStringLiteral("No version was found within the local storage " - "database, assuming version 1")); + QNDEBUG("No version was found within the local storage database, " + "assuming version 1"); return 1; } @@ -695,13 +701,13 @@ bool conversionResult = false; int version = value.toInt(&conversionResult); if (Q_UNLIKELY(!conversionResult)) { - errorDescription.setBase(QT_TR_NOOP("failed to decode the current database " - "version")); - QNWARNING(errorDescription << QStringLiteral(", value = ") << value); + errorDescription.setBase(QT_TR_NOOP("failed to decode the current " + "database version")); + QNWARNING(errorDescription << ", value = " << value); return -1; } - QNDEBUG(QStringLiteral("Version = ") << version); + QNDEBUG("Version = " << version); return version; } @@ -729,7 +735,7 @@ } if (!query.next()) { - QNDEBUG(QStringLiteral("Found no users in local storage database")); + QNDEBUG("Found no users in local storage database"); return 0; } @@ -757,8 +763,7 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(QStringLiteral("Found invalid notebook: ") << notebook - << QStringLiteral("\nError: ") << error); + QNWARNING("Found invalid notebook: " << notebook << "\nError: " << error); return false; } @@ -788,8 +793,8 @@ if (res || !localUid.isEmpty()) { errorDescription.base() = errorPrefix.base(); errorDescription.appendBase(QT_TR_NOOP("found existing notebook " - "corresponding to the added " - "notebook by guid")); + "corresponding to the " + "added notebook by guid")); errorDescription.details() = uid; QNWARNING(errorDescription); return false; @@ -845,8 +850,7 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(QStringLiteral("Found invalid notebook: ") << notebook - << QStringLiteral("\nError: ") << error); + QNWARNING("Found invalid notebook: " << notebook << "\nError: " << error); return false; } @@ -898,11 +902,12 @@ bool foundByOtherColumn = false; if (notebookHasGuid) { - QNDEBUG(QStringLiteral("Failed to find the notebook by guid within " - "the local storage, trying to find it by local uid")); + QNDEBUG("Failed to find the notebook by guid within " + "the local storage, trying to find it by local uid"); column = QStringLiteral("localUid"); uid = localUid; - foundByOtherColumn = rowExists(QStringLiteral("Notebooks"), column, uid); + foundByOtherColumn = + rowExists(QStringLiteral("Notebooks"), column, uid); } if (!foundByOtherColumn) { @@ -931,14 +936,14 @@ return true; } -bool LocalStorageManagerPrivate::findNotebook(Notebook & notebook, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::findNotebook( + Notebook & notebook, ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::findNotebook: notebook = ") + QNDEBUG("LocalStorageManagerPrivate::findNotebook: notebook = " << notebook); - ErrorString errorPrefix(QT_TR_NOOP("Can't find notebook in the local storage " - "database")); + ErrorString errorPrefix(QT_TR_NOOP("Can't find notebook in the local " + "storage database")); bool searchingByName = false; @@ -1058,8 +1063,8 @@ return true; } -bool LocalStorageManagerPrivate::findDefaultNotebook(Notebook & notebook, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::findDefaultNotebook( + Notebook & notebook, ErrorString & errorDescription) const { ErrorString errorPrefix(QT_TR_NOOP("Can't find the default notebook in " "the local storage database")); @@ -1113,8 +1118,8 @@ return true; } -bool LocalStorageManagerPrivate::findLastUsedNotebook(Notebook & notebook, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::findLastUsedNotebook( + Notebook & notebook, ErrorString & errorDescription) const { ErrorString errorPrefix(QT_TR_NOOP("Can't find the last used notebook in " "the local storage database")); @@ -1169,8 +1174,8 @@ return true; } -bool LocalStorageManagerPrivate::findDefaultOrLastUsedNotebook(Notebook & notebook, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::findDefaultOrLastUsedNotebook( + Notebook & notebook, ErrorString & errorDescription) const { bool res = findDefaultNotebook(notebook, errorDescription); if (res) { @@ -1180,27 +1185,27 @@ return findLastUsedNotebook(notebook, errorDescription); } -QList<Notebook> -LocalStorageManagerPrivate::listAllNotebooks(ErrorString & errorDescription, - const size_t limit, const size_t offset, - const LocalStorageManager::ListNotebooksOrder::type & order, - const LocalStorageManager::OrderDirection::type & orderDirection, - const QString & linkedNotebookGuid) const +QList<Notebook> LocalStorageManagerPrivate::listAllNotebooks( + ErrorString & errorDescription, + const size_t limit, const size_t offset, + const LocalStorageManager::ListNotebooksOrder::type & order, + const LocalStorageManager::OrderDirection::type & orderDirection, + const QString & linkedNotebookGuid) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::listAllNotebooks")); + QNDEBUG("LocalStorageManagerPrivate::listAllNotebooks"); return listNotebooks(LocalStorageManager::ListAll, errorDescription, limit, offset, order, orderDirection, linkedNotebookGuid); } -QList<Notebook> -LocalStorageManagerPrivate::listNotebooks(const LocalStorageManager::ListObjectsOptions flag, - ErrorString & errorDescription, - const size_t limit, const size_t offset, - const LocalStorageManager::ListNotebooksOrder::type & order, - const LocalStorageManager::OrderDirection::type & orderDirection, - const QString & linkedNotebookGuid) const +QList<Notebook> LocalStorageManagerPrivate::listNotebooks( + const LocalStorageManager::ListObjectsOptions flag, + ErrorString & errorDescription, + const size_t limit, const size_t offset, + const LocalStorageManager::ListNotebooksOrder::type & order, + const LocalStorageManager::OrderDirection::type & orderDirection, + const QString & linkedNotebookGuid) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::listNotebooks: flag = ") << flag); + QNDEBUG("LocalStorageManagerPrivate::listNotebooks: flag = " << flag); QString linkedNotebookGuidSqlQueryCondition; if (!linkedNotebookGuid.isNull()) @@ -1222,10 +1227,10 @@ linkedNotebookGuidSqlQueryCondition); } -QList<SharedNotebook> -LocalStorageManagerPrivate::listAllSharedNotebooks(ErrorString & errorDescription) const +QList<SharedNotebook> LocalStorageManagerPrivate::listAllSharedNotebooks( + ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::listAllSharedNotebooks")); + QNDEBUG("LocalStorageManagerPrivate::listAllSharedNotebooks"); QList<SharedNotebook> sharedNotebooks; ErrorString errorPrefix(QT_TR_NOOP("Can't list all shared notebooks")); @@ -1234,8 +1239,8 @@ bool res = query.exec(QStringLiteral("SELECT * FROM SharedNotebooks")); if (!res) { errorDescription.base() = errorPrefix.base(); - QNERROR(errorDescription << QStringLiteral("last error = ") - << query.lastError() << QStringLiteral(", last query = ") + QNERROR(errorDescription << "last error = " + << query.lastError() << ", last query = " << query.lastQuery()); errorDescription.details() += query.lastError().text(); return sharedNotebooks; @@ -1264,8 +1269,7 @@ } int numSharedNotebooks = sharedNotebooks.size(); - QNDEBUG(QStringLiteral("found ") << numSharedNotebooks - << QStringLiteral(" shared notebooks")); + QNDEBUG("found " << numSharedNotebooks << " shared notebooks"); if (numSharedNotebooks <= 0) { errorDescription.base() = errorPrefix.base(); @@ -1278,8 +1282,8 @@ } QList<SharedNotebook> -LocalStorageManagerPrivate::listSharedNotebooksPerNotebookGuid(const QString & notebookGuid, - ErrorString & errorDescription) const +LocalStorageManagerPrivate::listSharedNotebooksPerNotebookGuid( + const QString & notebookGuid, ErrorString & errorDescription) const { QList<SharedNotebook> sharedNotebooks; @@ -1301,15 +1305,16 @@ } QList<qevercloud::SharedNotebook> -LocalStorageManagerPrivate::listEnSharedNotebooksPerNotebookGuid(const QString & notebookGuid, - ErrorString & errorDescription) const +LocalStorageManagerPrivate::listEnSharedNotebooksPerNotebookGuid( + const QString & notebookGuid, ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::listSharedNotebooksPerNotebookGuid: guid = ") - << notebookGuid); + QNDEBUG("LocalStorageManagerPrivate::listSharedNotebooksPerNotebookGuid: " + << "guid = " << notebookGuid); QList<qevercloud::SharedNotebook> qecSharedNotebooks; - ErrorString errorPrefix(QT_TR_NOOP("Can't list shared notebooks per notebook guid")); + ErrorString errorPrefix( + QT_TR_NOOP("Can't list shared notebooks per notebook guid")); if (!checkGuid(notebookGuid)) { errorDescription.base() = errorPrefix.base(); @@ -1358,7 +1363,8 @@ } } - qSort(sharedNotebooks.begin(), sharedNotebooks.end(), SharedNotebookCompareByIndex()); + qSort(sharedNotebooks.begin(), sharedNotebooks.end(), + SharedNotebookCompareByIndex()); for(auto it = sharedNotebooks.constBegin(), end = sharedNotebooks.constEnd(); it != end; ++it) @@ -1367,16 +1373,15 @@ } numSharedNotebooks = qecSharedNotebooks.size(); - QNDEBUG(QStringLiteral("found ") << numSharedNotebooks - << QStringLiteral(" shared notebooks")); + QNDEBUG("found " << numSharedNotebooks << " shared notebooks"); return qecSharedNotebooks; } -bool LocalStorageManagerPrivate::expungeNotebook(Notebook & notebook, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::expungeNotebook( + Notebook & notebook, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::expungeNotebook: notebook = ") + QNDEBUG("LocalStorageManagerPrivate::expungeNotebook: notebook = " << notebook); ErrorString errorPrefix(QT_TR_NOOP("Can't expunge notebook from " @@ -1428,7 +1433,8 @@ !rowExists(QStringLiteral("Notebooks"), column, uid)) { errorDescription.base() = errorPrefix.base(); - errorDescription.appendBase(QT_TR_NOOP("notebook to be expunged was not found")); + errorDescription.appendBase( + QT_TR_NOOP("notebook to be expunged was not found")); errorDescription.details() = column; errorDescription.details() = QStringLiteral(" = "); errorDescription.details() = uid; @@ -1458,7 +1464,8 @@ return true; } -int LocalStorageManagerPrivate::linkedNotebookCount(ErrorString & errorDescription) const +int LocalStorageManagerPrivate::linkedNotebookCount( + ErrorString & errorDescription) const { ErrorString errorPrefix(QT_TR_NOOP("Can't get the number of linked notebooks " "in the local storage database")); @@ -1477,7 +1484,7 @@ } if (!query.next()) { - QNDEBUG(QStringLiteral("Found no linked notebooks in local storage database")); + QNDEBUG("Found no linked notebooks in local storage database"); return 0; } @@ -1492,8 +1499,8 @@ return count; } -bool LocalStorageManagerPrivate::addLinkedNotebook(const LinkedNotebook & linkedNotebook, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::addLinkedNotebook( + const LinkedNotebook & linkedNotebook, ErrorString & errorDescription) { ErrorString errorPrefix(QT_TR_NOOP("Can't add linked notebook to " "the local storage database")); @@ -1505,8 +1512,8 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(QStringLiteral("Found invalid LinkedNotebook: ") - << linkedNotebook << QStringLiteral("\nError: ") << error); + QNWARNING("Found invalid LinkedNotebook: " << linkedNotebook + << "\nError: " << error); return false; } @@ -1536,8 +1543,8 @@ return true; } -bool LocalStorageManagerPrivate::updateLinkedNotebook(const LinkedNotebook & linkedNotebook, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::updateLinkedNotebook( + const LinkedNotebook & linkedNotebook, ErrorString & errorDescription) { ErrorString errorPrefix(QT_TR_NOOP("Can't update linked notebook in " "the local storage database")); @@ -1549,8 +1556,8 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(QStringLiteral("Found invalid LinkedNotebook: ") - << linkedNotebook << QStringLiteral("\nError: ") << error); + QNWARNING("Found invalid LinkedNotebook: " << linkedNotebook + << "\nError: " << error); return false; } @@ -1581,26 +1588,28 @@ return true; } -bool LocalStorageManagerPrivate::findLinkedNotebook(LinkedNotebook & linkedNotebook, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::findLinkedNotebook( + LinkedNotebook & linkedNotebook, ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::findLinkedNotebook")); + QNDEBUG("LocalStorageManagerPrivate::findLinkedNotebook"); ErrorString errorPrefix(QT_TR_NOOP("Can't find linked notebook in " "the local storage database")); if (!linkedNotebook.hasGuid()) { errorDescription.base() = errorPrefix.base(); - errorDescription.appendBase(QT_TR_NOOP("linked notebook's guid is not set")); + errorDescription.appendBase( + QT_TR_NOOP("linked notebook's guid is not set")); QNWARNING(errorDescription); return false; } QString notebookGuid = linkedNotebook.guid(); - QNDEBUG(QStringLiteral("guid = ") << notebookGuid); + QNDEBUG("guid = " << notebookGuid); if (!checkGuid(notebookGuid)) { errorDescription.base() = errorPrefix.base(); - errorDescription.appendBase(QT_TR_NOOP("linked notebook's guid is invalid")); + errorDescription.appendBase( + QT_TR_NOOP("linked notebook's guid is invalid")); errorDescription.details() = notebookGuid; QNWARNING(errorDescription); return false; @@ -1641,43 +1650,40 @@ return true; } -QList<LinkedNotebook> -LocalStorageManagerPrivate::listAllLinkedNotebooks(ErrorString & errorDescription, - const size_t limit, - const size_t offset, - const LocalStorageManager::ListLinkedNotebooksOrder::type order, - const LocalStorageManager::OrderDirection::type & orderDirection) const +QList<LinkedNotebook> LocalStorageManagerPrivate::listAllLinkedNotebooks( + ErrorString & errorDescription, const size_t limit, const size_t offset, + const LocalStorageManager::ListLinkedNotebooksOrder::type order, + const LocalStorageManager::OrderDirection::type & orderDirection) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::listAllLinkedNotebooks")); + QNDEBUG("LocalStorageManagerPrivate::listAllLinkedNotebooks"); return listLinkedNotebooks(LocalStorageManager::ListAll, errorDescription, limit, offset, order, orderDirection); } -QList<LinkedNotebook> -LocalStorageManagerPrivate::listLinkedNotebooks(const LocalStorageManager::ListObjectsOptions flag, - ErrorString & errorDescription, - const size_t limit, - const size_t offset, - const LocalStorageManager::ListLinkedNotebooksOrder::type & order, - const LocalStorageManager::OrderDirection::type & orderDirection) const +QList<LinkedNotebook> LocalStorageManagerPrivate::listLinkedNotebooks( + const LocalStorageManager::ListObjectsOptions flag, + ErrorString & errorDescription, const size_t limit, const size_t offset, + const LocalStorageManager::ListLinkedNotebooksOrder::type & order, + const LocalStorageManager::OrderDirection::type & orderDirection) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::listLinkedNotebooks: flag = ") << flag); + QNDEBUG("LocalStorageManagerPrivate::listLinkedNotebooks: flag = " << flag); return listObjects<LinkedNotebook, LocalStorageManager::ListLinkedNotebooksOrder::type>( flag, errorDescription, limit, offset, order, orderDirection); } -bool LocalStorageManagerPrivate::expungeLinkedNotebook(const LinkedNotebook & linkedNotebook, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::expungeLinkedNotebook( + const LinkedNotebook & linkedNotebook, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::expungeLinkedNotebook: linked notebook = ") - << linkedNotebook); + QNDEBUG("LocalStorageManagerPrivate::expungeLinkedNotebook: " + << "linked notebook = " << linkedNotebook); ErrorString errorPrefix(QT_TR_NOOP("Can't expunge linked notebook from " "the local storage database")); if (!linkedNotebook.hasGuid()) { errorDescription.base() = errorPrefix.base(); - errorDescription.appendBase(QT_TR_NOOP("linked notebook's guid is not set")); + errorDescription.appendBase( + QT_TR_NOOP("linked notebook's guid is not set")); QNWARNING(errorDescription); return false; } @@ -1686,7 +1692,8 @@ if (!checkGuid(linkedNotebookGuid)) { errorDescription.base() = errorPrefix.base(); - errorDescription.appendBase(QT_TR_NOOP("linked notebook's guid is invalid")); + errorDescription.appendBase( + QT_TR_NOOP("linked notebook's guid is invalid")); errorDescription.details() = linkedNotebookGuid; QNWARNING(errorDescription); return false; @@ -1744,7 +1751,7 @@ } if (!query.next()) { - QNDEBUG(QStringLiteral("Found no notes in local storage database")); + QNDEBUG("Found no notes in local storage database"); return 0; } @@ -1763,8 +1770,8 @@ const Notebook & notebook, ErrorString & errorDescription, const LocalStorageManager::NoteCountOptions options) const { - ErrorString errorPrefix(QT_TR_NOOP("Can't get the number of notes per notebook " - "in the local storage database")); + ErrorString errorPrefix(QT_TR_NOOP("Can't get the number of notes per " + "notebook in the local storage database")); ErrorString error; bool res = notebook.checkParameters(error); @@ -1773,8 +1780,8 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(QStringLiteral("Found invalid notebook: ") << notebook - << QStringLiteral("\nError: ") << error); + QNWARNING("Found invalid notebook: " << notebook + << "\nError: " << error); return -1; } @@ -1808,8 +1815,8 @@ } if (!query.next()) { - QNDEBUG(QStringLiteral("Found no notes per given notebook in the local " - "storage database")); + QNDEBUG("Found no notes per given notebook in the local " + "storage database"); return 0; } @@ -1837,8 +1844,7 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(QStringLiteral("Found invalid tag: ") << tag - << QStringLiteral("\nError: ") << error); + QNWARNING("Found invalid tag: " << tag << "\nError: " << error); return -1; } @@ -1872,8 +1878,8 @@ } if (!query.next()) { - QNDEBUG(QStringLiteral("Found no notes per given tag " - "in the local storage database")); + QNDEBUG("Found no notes per given tag " + "in the local storage database"); return 0; } @@ -1996,7 +2002,8 @@ end = notebookLocalUids.constEnd(); it != end; ++it) { queryString += - QStringLiteral("'") + sqlEscapeString(*it) + QStringLiteral("', "); + QStringLiteral("'") + sqlEscapeString(*it) + + QStringLiteral("', "); } queryString.chop(2); queryString += QStringLiteral(")) "); @@ -2015,7 +2022,8 @@ end = tagLocalUids.constEnd(); it != end; ++it) { queryString += - QStringLiteral("'") + sqlEscapeString(*it) + QStringLiteral("', "); + QStringLiteral("'") + sqlEscapeString(*it) + + QStringLiteral("', "); } queryString.chop(2); queryString += QStringLiteral(")))"); @@ -2042,8 +2050,8 @@ } if (!query.next()) { - QNDEBUG(QStringLiteral("Found no notes per given notebooks and tags " - "in the local storage database")); + QNDEBUG("Found no notes per given notebooks and tags " + "in the local storage database"); return 0; } @@ -2075,9 +2083,11 @@ return queryPart; } -bool LocalStorageManagerPrivate::addNote(Note & note, ErrorString & errorDescription) +bool LocalStorageManagerPrivate::addNote( + Note & note, ErrorString & errorDescription) { - ErrorString errorPrefix(QT_TR_NOOP("Can't add note to the local storage database")); + ErrorString errorPrefix( + QT_TR_NOOP("Can't add note to the local storage database")); ErrorString error; QString notebookLocalUid; @@ -2087,7 +2097,7 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(errorDescription << QStringLiteral(", note: ") << note); + QNWARNING(errorDescription << ", note: " << note); return false; } @@ -2110,7 +2120,7 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(errorDescription << QStringLiteral(", note: ") << note); + QNWARNING(errorDescription << ", note: " << note); return false; } @@ -2123,8 +2133,8 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(QStringLiteral("Found invalid note: ") << errorDescription - << QStringLiteral("; note: ") << note); + QNWARNING("Found invalid note: " << errorDescription << "; note: " + << note); return false; } @@ -2142,7 +2152,7 @@ if (!checkGuid(uid)) { errorDescription.base() = errorPrefix.base(); errorDescription.appendBase(QT_TR_NOOP("note's guid is invalid")); - QNWARNING(errorDescription << QStringLiteral(", note: ") << note); + QNWARNING(errorDescription << ", note: " << note); return false; } @@ -2154,7 +2164,7 @@ errorDescription.base() = errorPrefix.base(); errorDescription.appendBase(QT_TR_NOOP("found already existing " "note with the same guid")); - QNWARNING(errorDescription << QStringLiteral(", guid: ") << uid); + QNWARNING(errorDescription << ", guid: " << uid); return false; } @@ -2179,7 +2189,7 @@ errorDescription.details() = column; errorDescription.details() += QStringLiteral(" = "); errorDescription.details() += uid; - QNWARNING(errorDescription << QStringLiteral(", note: ") << note); + QNWARNING(errorDescription << ", note: " << note); return false; } @@ -2189,15 +2199,15 @@ LocalStorageManager::UpdateNoteOption::UpdateTags); res = insertOrReplaceNote(note, options, errorDescription); if (!res) { - QNWARNING(QStringLiteral("Note which produced the error: ") << note); + QNWARNING("Note which produced the error: " << note); } return res; } -bool LocalStorageManagerPrivate::updateNote(Note & note, - const LocalStorageManager::UpdateNoteOptions options, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::updateNote( + Note & note, const LocalStorageManager::UpdateNoteOptions options, + ErrorString & errorDescription) { ErrorString errorPrefix(QT_TR_NOOP("Can't update note in the local " "storage database")); @@ -2246,7 +2256,7 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(QStringLiteral("Found invalid note: ") << note); + QNWARNING("Found invalid note: " << note); return false; } @@ -2299,9 +2309,8 @@ bool foundByOtherColumn = false; if (noteHasGuid) { - QNDEBUG(QStringLiteral("Failed to find the note by guid within " - "the local storage, trying to find it " - "by local uid")); + QNDEBUG("Failed to find the note by guid within " + "the local storage, trying to find it by local uid"); column = QStringLiteral("localUid"); uid = localUid; foundByOtherColumn = rowExists(QStringLiteral("Notes"), column, uid); @@ -2321,17 +2330,17 @@ res = insertOrReplaceNote(note, options, errorDescription); if (!res) { - QNWARNING(QStringLiteral("Note which produced the error: ") << note); + QNWARNING("Note which produced the error: " << note); } return res; } -bool LocalStorageManagerPrivate::findNote(Note & note, - const LocalStorageManager::GetNoteOptions options, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::findNote( + Note & note, const LocalStorageManager::GetNoteOptions options, + ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::findNote")); + QNDEBUG("LocalStorageManagerPrivate::findNote"); ErrorString errorPrefix(QT_TR_NOOP("Can't find note in the local " "storage database")); @@ -2490,7 +2499,8 @@ if (withResourceMetadata) { - int resourceLocalUidIndex = rec.indexOf(QStringLiteral("resourceLocalUid")); + int resourceLocalUidIndex = + rec.indexOf(QStringLiteral("resourceLocalUid")); if (resourceLocalUidIndex >= 0) { QVariant value = rec.value(resourceLocalUidIndex); @@ -2498,10 +2508,12 @@ { QString resourceLocalUid = value.toString(); auto it = resourceIndexPerLocalUid.find(resourceLocalUid); - bool resourceIndexNotFound = (it == resourceIndexPerLocalUid.end()); + bool resourceIndexNotFound = + (it == resourceIndexPerLocalUid.end()); if (resourceIndexNotFound) { int resourceIndexInList = resources.size(); - resourceIndexPerLocalUid[resourceLocalUid] = resourceIndexInList; + resourceIndexPerLocalUid[resourceLocalUid] = + resourceIndexInList; resources << Resource(); } @@ -2624,19 +2636,18 @@ const LocalStorageManager::ListNotesOrder::type & order, const LocalStorageManager::OrderDirection::type & orderDirection) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::listNotesPerNotebook: notebook = ") - << notebook << QStringLiteral("\nWith resource metadata = ") + QNDEBUG("LocalStorageManagerPrivate::listNotesPerNotebook: notebook = " + << notebook << "\nWith resource metadata = " << ((options & LocalStorageManager::GetNoteOption::WithResourceMetadata) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with resource binary data = ") + ? "true" + : "false") + << ", with resource binary data = " << ((options & LocalStorageManager::GetNoteOption::WithResourceBinaryData) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", flag = ") << flag << QStringLiteral(", limit = ") - << limit << QStringLiteral(", offset = ") << offset - << QStringLiteral(", order = ") << order - << QStringLiteral(", order direction = ") << orderDirection); + ? "true" + : "false") + << ", flag = " << flag << ", limit = " << limit << ", offset = " + << offset << ", order = " << order << ", order direction = " + << orderDirection); ErrorString errorPrefix(QT_TR_NOOP("Can't list notes per notebook")); @@ -2680,19 +2691,18 @@ const LocalStorageManager::ListNotesOrder::type & order, const LocalStorageManager::OrderDirection::type & orderDirection) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::listNotesPerTag: tag = ") - << tag << QStringLiteral("\nWith resource metadata = ") + QNDEBUG("LocalStorageManagerPrivate::listNotesPerTag: tag = " + << tag << "\nWith resource metadata = " << ((options & LocalStorageManager::GetNoteOption::WithResourceMetadata) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with resource binary data = ") + ? "true" + : "false") + << ", with resource binary data = " << ((options & LocalStorageManager::GetNoteOption::WithResourceBinaryData) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", flag = ") << flag << QStringLiteral(", limit = ") - << limit << QStringLiteral(", offset = ") << offset - << QStringLiteral(", order = ") << order - << QStringLiteral(", order direction = ") << orderDirection); + ? "true" + : "false") + << ", flag = " << flag << ", limit = " << limit << ", offset = " + << offset << ", order = " << order << ", order direction = " + << orderDirection); ErrorString errorPrefix(QT_TR_NOOP("Can't list all notes with tag")); @@ -2739,19 +2749,18 @@ const LocalStorageManager::ListNotesOrder::type & order, const LocalStorageManager::OrderDirection::type & orderDirection) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::listNotesPerNotebooksAndTags: ") - << QStringLiteral("flag = ") << flag + QNDEBUG("LocalStorageManagerPrivate::listNotesPerNotebooksAndTags: " + << "flag = " << flag << ((options & LocalStorageManager::GetNoteOption::WithResourceMetadata) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with resource binary data = ") + ? "true" + : "false") + << ", with resource binary data = " << ((options & LocalStorageManager::GetNoteOption::WithResourceBinaryData) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", notebook local uids: ") + ? "true" + : "false") + << ", notebook local uids: " << notebookLocalUids.join(QStringLiteral(", ")) - << QStringLiteral(", tag local uids: ") - << tagLocalUids.join(QStringLiteral(", "))); + << ", tag local uids: " << tagLocalUids.join(QStringLiteral(", "))); ErrorString errorPrefix(QT_TR_NOOP("Can't list notes per notebooks and tags " "from the local storage database")); @@ -2826,18 +2835,16 @@ const LocalStorageManager::ListNotesOrder::type order, const LocalStorageManager::OrderDirection::type & orderDirection) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::listNotesByLocalUids: ") - << QStringLiteral("flag = ") << flag - << QStringLiteral(", with resource metadata = ") + QNDEBUG("LocalStorageManagerPrivate::listNotesByLocalUids: " + << "flag = " << flag << ", with resource metadata = " << ((options & LocalStorageManager::GetNoteOption::WithResourceMetadata) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with resource binary data = ") + ? "true" + : "false") + << ", with resource binary data = " << ((options & LocalStorageManager::GetNoteOption::WithResourceBinaryData) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", note local uids: ") - << noteLocalUids.join(QStringLiteral(","))); + ? "true" + : "false") + << ", note local uids: " << noteLocalUids.join(QStringLiteral(","))); if (noteLocalUids.isEmpty()) { return QList<Note>(); @@ -2870,16 +2877,16 @@ const LocalStorageManager::OrderDirection::type & orderDirection, const QString & linkedNotebookGuid) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::listNotes: flag = ") << flag - << QStringLiteral(", with resource metadata = ") + QNDEBUG("LocalStorageManagerPrivate::listNotes: flag = " << flag + << ", with resource metadata = " << ((options & LocalStorageManager::GetNoteOption::WithResourceMetadata) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with resource binary data = ") + ? "true" + : "false") + << ", with resource binary data = " << ((options & LocalStorageManager::GetNoteOption::WithResourceBinaryData) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", linked notebook guid = ") << linkedNotebookGuid); + ? "true" + : "false") + << ", linked notebook guid = " << linkedNotebookGuid); ErrorString errorPrefix(QT_TR_NOOP("Can't list notes from the local storage database")); @@ -2990,10 +2997,10 @@ return notes; } -bool LocalStorageManagerPrivate::expungeNote(Note & note, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::expungeNote( + Note & note, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::expungeNote: note = ") << note); + QNDEBUG("LocalStorageManagerPrivate::expungeNote: note = " << note); ErrorString errorPrefix(QT_TR_NOOP("Can't expunge note from the local " "storage database")); @@ -3083,7 +3090,8 @@ !rowExists(QStringLiteral("Notes"), column, uid)) { errorDescription.base() = errorPrefix.base(); - errorDescription.appendBase(QT_TR_NOOP("note to be expunged was not found")); + errorDescription.appendBase( + QT_TR_NOOP("note to be expunged was not found")); errorDescription.details() = column; errorDescription.details() += QStringLiteral(" = "); errorDescription.details() += uid; @@ -3109,11 +3117,11 @@ return true; } -QStringList -LocalStorageManagerPrivate::findNoteLocalUidsWithSearchQuery(const NoteSearchQuery & noteSearchQuery, - ErrorString & errorDescription) const +QStringList LocalStorageManagerPrivate::findNoteLocalUidsWithSearchQuery( + const NoteSearchQuery & noteSearchQuery, + ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::findNoteLocalUidsWithSearchQuery: ") + QNDEBUG("LocalStorageManagerPrivate::findNoteLocalUidsWithSearchQuery: " << noteSearchQuery); if (!noteSearchQuery.isMatcheable()) { @@ -3130,7 +3138,8 @@ Transaction transaction(m_sqlDatabase, *this, Transaction::Selection); Q_UNUSED(transaction) - ErrorString errorPrefix(QT_TR_NOOP("Can't find notes with the note search query")); + ErrorString errorPrefix( + QT_TR_NOOP("Can't find notes with the note search query")); ErrorString error; bool res = noteSearchQueryToSQL(noteSearchQuery, queryString, error); @@ -3147,7 +3156,7 @@ res = query.exec(queryString); if (!res) { SET_ERROR(); - QNWARNING(QStringLiteral("Full executed SQL query: ") << queryString); + QNWARNING("Full executed SQL query: " << queryString); return QStringList(); } @@ -3179,28 +3188,30 @@ return result; } -NoteList LocalStorageManagerPrivate::findNotesWithSearchQuery(const NoteSearchQuery & noteSearchQuery, - const LocalStorageManager::GetNoteOptions options, - ErrorString & errorDescription) const +NoteList LocalStorageManagerPrivate::findNotesWithSearchQuery( + const NoteSearchQuery & noteSearchQuery, + const LocalStorageManager::GetNoteOptions options, + ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::findNotesWithSearchQuery: ") - << noteSearchQuery << QStringLiteral("\nWith resource metadata = ") + QNDEBUG("LocalStorageManagerPrivate::findNotesWithSearchQuery: " + << noteSearchQuery << "\nWith resource metadata = " << ((options & LocalStorageManager::GetNoteOption::WithResourceMetadata) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with resource binary data = ") + ? "true" + : "false") + << ", with resource binary data = " << ((options & LocalStorageManager::GetNoteOption::WithResourceBinaryData) - ? QStringLiteral("true") - : QStringLiteral("false"))); + ? "true" + : "false")); - QStringList foundLocalUids = findNoteLocalUidsWithSearchQuery(noteSearchQuery, - errorDescription); + QStringList foundLocalUids = + findNoteLocalUidsWithSearchQuery(noteSearchQuery, errorDescription); if (foundLocalUids.isEmpty()) { return NoteList(); } QString joinedLocalUids; - for(auto it = foundLocalUids.begin(), end = foundLocalUids.end(); it != end; ++it) + for(auto it = foundLocalUids.begin(), + end = foundLocalUids.end(); it != end; ++it) { const QString & item = *it; @@ -3213,7 +3224,8 @@ joinedLocalUids += QStringLiteral("'"); } - ErrorString errorPrefix(QT_TR_NOOP("Can't find notes with the note search query")); + ErrorString errorPrefix( + QT_TR_NOOP("Can't find notes with the note search query")); QString queryString = QString::fromUtf8("SELECT * FROM Notes WHERE localUid IN (%1)") @@ -3321,7 +3333,7 @@ } if (!query.next()) { - QNDEBUG(QStringLiteral("Found no tags in local storage database")); + QNDEBUG("Found no tags in local storage database"); return 0; } @@ -3336,9 +3348,11 @@ return count; } -bool LocalStorageManagerPrivate::addTag(Tag & tag, ErrorString & errorDescription) +bool LocalStorageManagerPrivate::addTag( + Tag & tag, ErrorString & errorDescription) { - ErrorString errorPrefix(QT_TR_NOOP("Can't add tag to the local storage database")); + ErrorString errorPrefix( + QT_TR_NOOP("Can't add tag to the local storage database")); ErrorString error; bool res = tag.checkParameters(error); @@ -3347,8 +3361,7 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(QStringLiteral("Found invalid tag: ") << errorDescription - << QStringLiteral(", tag: ") << tag); + QNWARNING("Found invalid tag: " << errorDescription << ", tag: " << tag); return false; } @@ -3369,10 +3382,11 @@ res = getTagLocalUidForGuid(uid, localUid, error); if (res || !localUid.isEmpty()) { errorDescription.base() = errorPrefix.base(); - errorDescription.appendBase(QT_TR_NOOP("found already existing tag")); + errorDescription.appendBase( + QT_TR_NOOP("found already existing tag")); errorDescription.details() = QStringLiteral("guid = "); errorDescription.details() += uid; - QNWARNING(errorDescription << QStringLiteral(", tag: ") << tag); + QNWARNING(errorDescription << ", tag: " << tag); return false; } @@ -3395,7 +3409,7 @@ errorDescription.details() = column; errorDescription.details() += QStringLiteral(" = "); errorDescription.details() += uid; - QNWARNING(errorDescription << QStringLiteral(", tag: ") << tag); + QNWARNING(errorDescription << ", tag: " << tag); return false; } @@ -3406,7 +3420,7 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(errorDescription << QStringLiteral(", tag: ") << tag); + QNWARNING(errorDescription << ", tag: " << tag); return false; } @@ -3417,15 +3431,15 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(errorDescription << QStringLiteral(", tag: ") << tag); + QNWARNING(errorDescription << ", tag: " << tag); return false; } return true; } -bool LocalStorageManagerPrivate::updateTag(Tag & tag, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::updateTag( + Tag & tag, ErrorString & errorDescription) { ErrorString errorPrefix(QT_TR_NOOP("Can't update tag in the local " "storage database")); @@ -3437,8 +3451,7 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(QStringLiteral("Found invalid tag: ") << errorDescription - << QStringLiteral(", tag: ") << tag); + QNWARNING("Found invalid tag: " << errorDescription << ", tag: " << tag); return false; } @@ -3462,7 +3475,7 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(errorDescription << QStringLiteral(", tag: ") << tag); + QNWARNING(errorDescription << ", tag: " << tag); return false; } @@ -3481,9 +3494,8 @@ bool foundByOtherColumn = false; if (tagHasGuid) { - QNDEBUG(QStringLiteral("Failed to find the tag by guid within " - "the local storage, trying to find it " - "by local uid")); + QNDEBUG("Failed to find the tag by guid within " + "the local storage, trying to find it by local uid"); column = QStringLiteral("localUid"); uid = tag.localUid(); foundByOtherColumn = rowExists(QStringLiteral("Tags"), column, uid); @@ -3491,12 +3503,12 @@ if (!foundByOtherColumn) { errorDescription.base() = errorPrefix.base(); - errorDescription.appendBase(QT_TR_NOOP("tag was not found in the local " - "storage database")); + errorDescription.appendBase(QT_TR_NOOP("tag was not found in the " + "local storage database")); errorDescription.details() = column; errorDescription.details() += QStringLiteral(" = "); errorDescription.details() += uid; - QNWARNING(errorDescription << QStringLiteral(", tag: ") << tag); + QNWARNING(errorDescription << ", tag: " << tag); return false; } } @@ -3508,7 +3520,7 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(errorDescription << QStringLiteral(", tag: ") << tag); + QNWARNING(errorDescription << ", tag: " << tag); return false; } @@ -3519,17 +3531,17 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(errorDescription << QStringLiteral(", tag: ") << tag); + QNWARNING(errorDescription << ", tag: " << tag); return false; } return true; } -bool LocalStorageManagerPrivate::findTag(Tag & tag, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::findTag( + Tag & tag, ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::findTag")); + QNDEBUG("LocalStorageManagerPrivate::findTag"); ErrorString errorPrefix(QT_TR_NOOP("Can't find tag in the local " "storage database")); @@ -3547,7 +3559,7 @@ errorDescription.base() = errorPrefix.base(); errorDescription.appendBase(QT_TR_NOOP("tag's guid is invalid")); errorDescription.details() = value; - QNWARNING(errorDescription << QStringLiteral(", tag: ") << tag); + QNWARNING(errorDescription << ", tag: " << tag); return false; } } @@ -3615,7 +3627,7 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(errorDescription << QStringLiteral(", tag: ") << tag); + QNWARNING(errorDescription << ", tag: " << tag); return false; } @@ -3623,13 +3635,14 @@ return true; } -QList<Tag> LocalStorageManagerPrivate::listAllTagsPerNote(const Note & note, ErrorString & errorDescription, - const LocalStorageManager::ListObjectsOptions & flag, - const size_t limit, const size_t offset, - const LocalStorageManager::ListTagsOrder::type & order, - const LocalStorageManager::OrderDirection::type & orderDirection) const +QList<Tag> LocalStorageManagerPrivate::listAllTagsPerNote( + const Note & note, ErrorString & errorDescription, + const LocalStorageManager::ListObjectsOptions & flag, + const size_t limit, const size_t offset, + const LocalStorageManager::ListTagsOrder::type & order, + const LocalStorageManager::OrderDirection::type & orderDirection) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::listAllTagsPerNote")); + QNDEBUG("LocalStorageManagerPrivate::listAllTagsPerNote"); QList<Tag> tags; ErrorString errorPrefix(QT_TR_NOOP("Can't list all tags per note from " @@ -3678,7 +3691,7 @@ } if (query.size() == 0) { - QNDEBUG(QStringLiteral("No tags for this note were found")); + QNDEBUG("No tags for this note were found"); return tags; } @@ -3693,8 +3706,9 @@ if (tagLocalUid.isEmpty()) { errorDescription.base() = errorPrefix.base(); - errorDescription.appendBase(QT_TR_NOOP("internal error: no tag's local " - "uid in the result of SQL query")); + errorDescription.appendBase( + QT_TR_NOOP("internal error: no tag's local " + "uid in the result of SQL query")); tags.clear(); return tags; } @@ -3714,12 +3728,10 @@ noteGuidSqlQueryCondition += QStringLiteral(")"); ErrorString error; - tags = - listObjects<Tag, LocalStorageManager::ListTagsOrder::type>(flag, error, - limit, offset, - order, - orderDirection, - noteGuidSqlQueryCondition); + tags = listObjects<Tag, LocalStorageManager::ListTagsOrder::type>( + flag, error, limit, offset, order, orderDirection, + noteGuidSqlQueryCondition); + if (tags.isEmpty() && !error.isEmpty()) { errorDescription.base() = errorPrefix.base(); errorDescription.appendBase(error.base()); @@ -3731,27 +3743,25 @@ return tags; } -QList<Tag> -LocalStorageManagerPrivate::listAllTags(ErrorString & errorDescription, - const size_t limit, const size_t offset, - const LocalStorageManager::ListTagsOrder::type & order, - const LocalStorageManager::OrderDirection::type & orderDirection, - const QString & linkedNotebookGuid) const +QList<Tag> LocalStorageManagerPrivate::listAllTags( + ErrorString & errorDescription, const size_t limit, const size_t offset, + const LocalStorageManager::ListTagsOrder::type & order, + const LocalStorageManager::OrderDirection::type & orderDirection, + const QString & linkedNotebookGuid) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::listAllTags")); + QNDEBUG("LocalStorageManagerPrivate::listAllTags"); return listTags(LocalStorageManager::ListAll, errorDescription, limit, offset, order, orderDirection, linkedNotebookGuid); } -QList<Tag> -LocalStorageManagerPrivate::listTags(const LocalStorageManager::ListObjectsOptions flag, - ErrorString & errorDescription, - const size_t limit, const size_t offset, - const LocalStorageManager::ListTagsOrder::type & order, - const LocalStorageManager::OrderDirection::type & orderDirection, - const QString & linkedNotebookGuid) const +QList<Tag> LocalStorageManagerPrivate::listTags( + const LocalStorageManager::ListObjectsOptions flag, + ErrorString & errorDescription, const size_t limit, const size_t offset, + const LocalStorageManager::ListTagsOrder::type & order, + const LocalStorageManager::OrderDirection::type & orderDirection, + const QString & linkedNotebookGuid) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::listTags: flag = ") << flag); + QNDEBUG("LocalStorageManagerPrivate::listTags: flag = " << flag); QString linkedNotebookGuidSqlQueryCondition; if (!linkedNotebookGuid.isNull()) { @@ -3768,14 +3778,14 @@ } QList<std::pair<Tag, QStringList> > -LocalStorageManagerPrivate::listTagsWithNoteLocalUids(const LocalStorageManager::ListObjectsOptions flag, - ErrorString & errorDescription, - const size_t limit, const size_t offset, - const LocalStorageManager::ListTagsOrder::type & order, - const LocalStorageManager::OrderDirection::type & orderDirection, - const QString & linkedNotebookGuid) const +LocalStorageManagerPrivate::listTagsWithNoteLocalUids( + const LocalStorageManager::ListObjectsOptions flag, + ErrorString & errorDescription, const size_t limit, const size_t offset, + const LocalStorageManager::ListTagsOrder::type & order, + const LocalStorageManager::OrderDirection::type & orderDirection, + const QString & linkedNotebookGuid) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::listTagsWithNoteLocalUids: flag = ") + QNDEBUG("LocalStorageManagerPrivate::listTagsWithNoteLocalUids: flag = " << flag); QString linkedNotebookGuidSqlQueryCondition; @@ -3792,11 +3802,11 @@ orderDirection, linkedNotebookGuidSqlQueryCondition); } -bool LocalStorageManagerPrivate::expungeTag(Tag & tag, - QStringList & expungedChildTagLocalUids, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::expungeTag( + Tag & tag, QStringList & expungedChildTagLocalUids, + ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::expungeTag: ") << tag); + QNDEBUG("LocalStorageManagerPrivate::expungeTag: " << tag); ErrorString errorPrefix(QT_TR_NOOP("Can't expunge tag from " "the local storage database")); @@ -3829,9 +3839,9 @@ bool res = getTagLocalUidForGuid(uid, localUid, error); if (!res || localUid.isEmpty()) { errorDescription.base() = errorPrefix.base(); - errorDescription.appendBase(QT_TR_NOOP("tag to be expunged was not " - "found in the local storage " - "database")); + errorDescription.appendBase( + QT_TR_NOOP("tag to be expunged was not found in the local " + "storage database")); errorDescription.details() = QStringLiteral("local uid = "); errorDescription.details() += localUid; QNWARNING(errorDescription); @@ -3879,21 +3889,19 @@ int index = record.indexOf(QStringLiteral("localUid")); if (Q_UNLIKELY(index < 0)) { - QNDEBUG(QStringLiteral("Index of localUid within the SQL " - "record is negative")); + QNDEBUG("Index of localUid within the SQL record is negative"); continue; } QVariant value = record.value(index); if (Q_UNLIKELY(value.isNull())) { - QNDEBUG(QStringLiteral("The value from the SQL record is null")); + QNDEBUG("The value from the SQL record is null"); continue; } QString childTagLocalUid = value.toString(); if (Q_UNLIKELY(childTagLocalUid.isEmpty())) { - QNDEBUG(QStringLiteral("The string from the value from " - "the SQL record is empty")); + QNDEBUG("The string from the value from the SQL record is empty"); continue; } @@ -3917,7 +3925,8 @@ return true; } -bool LocalStorageManagerPrivate::expungeNotelessTagsFromLinkedNotebooks(ErrorString & errorDescription) +bool LocalStorageManagerPrivate::expungeNotelessTagsFromLinkedNotebooks( + ErrorString & errorDescription) { ErrorString errorPrefix(QT_TR_NOOP("Can't expunge tags from linked notebooks " "not connected to any notes")); @@ -3932,7 +3941,8 @@ return true; } -int LocalStorageManagerPrivate::enResourceCount(ErrorString & errorDescription) const +int LocalStorageManagerPrivate::enResourceCount( + ErrorString & errorDescription) const { ErrorString errorPrefix(QT_TR_NOOP("Can't get the number of resources " "in the local storage database")); @@ -3951,7 +3961,7 @@ } if (!query.next()) { - QNDEBUG(QStringLiteral("Found no resources in local storage database")); + QNDEBUG("Found no resources in local storage database"); return 0; } @@ -3966,12 +3976,11 @@ return count; } -bool LocalStorageManagerPrivate::findEnResource(Resource & resource, - const LocalStorageManager::GetResourceOptions options, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::findEnResource( + Resource & resource, const LocalStorageManager::GetResourceOptions options, + ErrorString & errorDescription) const { - QNTRACE(QStringLiteral("LocalStorageManagerPrivate::findEnResource: ") - << resource); + QNTRACE("LocalStorageManagerPrivate::findEnResource: " << resource); ErrorString errorPrefix(QT_TR_NOOP("Can't find resource in the local " "storage database")); @@ -4054,8 +4063,8 @@ return true; } -bool LocalStorageManagerPrivate::expungeEnResource(Resource & resource, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::expungeEnResource( + Resource & resource, ErrorString & errorDescription) { ErrorString errorPrefix(QT_TR_NOOP("Can't expunge resource from " "the local storage database")); @@ -4144,8 +4153,9 @@ !rowExists(QStringLiteral("Resources"), column, uid)) { errorDescription.base() = errorPrefix.base(); - errorDescription.appendBase(QT_TR_NOOP("resource to be expunged was not " - "found in the local storage database")); + errorDescription.appendBase( + QT_TR_NOOP("resource to be expunged was not found in the local " + "storage database")); errorDescription.details() = column; errorDescription.details() += QStringLiteral(" = "); errorDescription.details() += uid; @@ -4172,7 +4182,8 @@ return true; } -int LocalStorageManagerPrivate::savedSearchCount(ErrorString & errorDescription) const +int LocalStorageManagerPrivate::savedSearchCount( + ErrorString & errorDescription) const { ErrorString errorPrefix(QT_TR_NOOP("Can't get the number of saved searches " "in the local storage database")); @@ -4191,7 +4202,7 @@ } if (!query.next()) { - QNDEBUG(QStringLiteral("Found no saved searches in local storage database")); + QNDEBUG("Found no saved searches in local storage database"); return 0; } @@ -4206,8 +4217,8 @@ return count; } -bool LocalStorageManagerPrivate::addSavedSearch(SavedSearch & search, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::addSavedSearch( + SavedSearch & search, ErrorString & errorDescription) { ErrorString errorPrefix(QT_TR_NOOP("Can't add saved search to " "the local storage database")); @@ -4219,8 +4230,8 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(QStringLiteral("Found invalid SavedSearch: ") << search - << QStringLiteral("\nError: ") << error); + QNWARNING("Found invalid SavedSearch: " << search + << "\nError: " << error); return false; } @@ -4239,9 +4250,11 @@ { error.clear(); res = getSavedSearchLocalUidForGuid(uid, localUid, error); - if (res || !localUid.isEmpty()) { + if (res || !localUid.isEmpty()) + { errorDescription.base() = errorPrefix.base(); - errorDescription.appendBase(QT_TR_NOOP("saved search already exists")); + errorDescription.appendBase( + QT_TR_NOOP("saved search already exists")); errorDescription.details() = column; errorDescription.details() += QStringLiteral(" = "); errorDescription.details() += uid; @@ -4286,8 +4299,8 @@ return true; } -bool LocalStorageManagerPrivate::updateSavedSearch(SavedSearch & search, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::updateSavedSearch( + SavedSearch & search, ErrorString & errorDescription) { ErrorString errorPrefix(QT_TR_NOOP("Can't update saved search in " "the local storage database")); @@ -4299,8 +4312,8 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(QStringLiteral("Found invalid SavedSearch: ") << search - << QStringLiteral("\nError: ") << error); + QNWARNING("Found invalid SavedSearch: " << search << "\nError: " + << error); return false; } @@ -4347,8 +4360,8 @@ bool foundByOtherColumn = false; if (searchHasGuid) { - QNDEBUG(QStringLiteral("Failed to find the saved search by guid within " - "the local storage, trying to find it by local uid")); + QNDEBUG("Failed to find the saved search by guid within " + "the local storage, trying to find it by local uid"); column = QStringLiteral("localUid"); uid = search.localUid(); foundByOtherColumn = rowExists(QStringLiteral("SavedSearches"), @@ -4382,10 +4395,10 @@ return true; } -bool LocalStorageManagerPrivate::findSavedSearch(SavedSearch & search, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::findSavedSearch( + SavedSearch & search, ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::findSavedSearch")); + QNDEBUG("LocalStorageManagerPrivate::findSavedSearch"); ErrorString errorPrefix(QT_TR_NOOP("Can't find saved search " "in the local storage database")); @@ -4399,7 +4412,8 @@ if (!checkGuid(value)) { errorDescription.base() = errorPrefix.base(); - errorDescription.appendBase(QT_TR_NOOP("saved search's guid is invalid")); + errorDescription.appendBase( + QT_TR_NOOP("saved search's guid is invalid")); errorDescription.details() = value; return false; } @@ -4457,35 +4471,32 @@ return true; } -QList<SavedSearch> -LocalStorageManagerPrivate::listAllSavedSearches(ErrorString & errorDescription, - const size_t limit, const size_t offset, - const LocalStorageManager::ListSavedSearchesOrder::type & order, - const LocalStorageManager::OrderDirection::type & orderDirection) const +QList<SavedSearch> LocalStorageManagerPrivate::listAllSavedSearches( + ErrorString & errorDescription, const size_t limit, const size_t offset, + const LocalStorageManager::ListSavedSearchesOrder::type & order, + const LocalStorageManager::OrderDirection::type & orderDirection) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::listAllSavedSearches")); + QNDEBUG("LocalStorageManagerPrivate::listAllSavedSearches"); return listSavedSearches(LocalStorageManager::ListAll, errorDescription, limit, offset, order, orderDirection); } -QList<SavedSearch> -LocalStorageManagerPrivate::listSavedSearches(const LocalStorageManager::ListObjectsOptions flag, - ErrorString & errorDescription, - const size_t limit, const size_t offset, - const LocalStorageManager::ListSavedSearchesOrder::type & order, - const LocalStorageManager::OrderDirection::type & orderDirection) const +QList<SavedSearch> LocalStorageManagerPrivate::listSavedSearches( + const LocalStorageManager::ListObjectsOptions flag, + ErrorString & errorDescription, const size_t limit, const size_t offset, + const LocalStorageManager::ListSavedSearchesOrder::type & order, + const LocalStorageManager::OrderDirection::type & orderDirection) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::listSavedSearches: flag = ") - << flag); + QNDEBUG("LocalStorageManagerPrivate::listSavedSearches: flag = " << flag); return listObjects<SavedSearch, LocalStorageManager::ListSavedSearchesOrder::type>( flag, errorDescription, limit, offset, order, orderDirection); } -bool LocalStorageManagerPrivate::expungeSavedSearch(SavedSearch & search, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::expungeSavedSearch( + SavedSearch & search, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::expungeSavedSearch: " - "saved search = ") << search); + QNDEBUG("LocalStorageManagerPrivate::expungeSavedSearch: saved search = " + << search); ErrorString errorPrefix(QT_TR_NOOP("Can't expunge saved search from " "the local storage database")); @@ -4497,8 +4508,8 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(QStringLiteral("Found invalid SavedSearch: ") << search - << QStringLiteral("\nError: ") << error); + QNWARNING("Found invalid SavedSearch: " << search << "\nError: " + << error); return false; } @@ -4517,11 +4528,12 @@ { error.clear(); res = getSavedSearchLocalUidForGuid(uid, localUid, error); - if (!res || localUid.isEmpty()) { + if (!res || localUid.isEmpty()) + { errorDescription.base() = errorPrefix.base(); - errorDescription.appendBase(QT_TR_NOOP("saved search to be expunged " - "was not found in the local " - "storage database")); + errorDescription.appendBase( + QT_TR_NOOP("saved search to be expunged was not found in " + "the local storage database")); errorDescription.details() = column; errorDescription.details() += QStringLiteral(" = "); errorDescription.details() += uid; @@ -4564,11 +4576,11 @@ return true; } -qint32 LocalStorageManagerPrivate::accountHighUsn(const QString & linkedNotebookGuid, - ErrorString & errorDescription) +qint32 LocalStorageManagerPrivate::accountHighUsn( + const QString & linkedNotebookGuid, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::accountHighUsn: " - "linked notebook guid = ") << linkedNotebookGuid); + QNDEBUG("LocalStorageManagerPrivate::accountHighUsn: linked notebook guid = " + << linkedNotebookGuid); qint32 updateSequenceNumber = 0; @@ -4589,9 +4601,10 @@ QString::fromUtf8("='%1'").arg(sqlEscapeString(linkedNotebookGuid)); } -#define ADD_TABLE_AND_USN_COLUMN(tableName, usnColumnName) \ - tablesAndUsnColumns \ - << HighUsnRequestData(tableName, usnColumnName, queryCondition) +#define ADD_TABLE_AND_USN_COLUMN(tableName, usnColumnName) \ + tablesAndUsnColumns \ + << HighUsnRequestData(tableName, usnColumnName, queryCondition) \ +// ADD_TABLE_AND_USN_COLUMN ADD_TABLE_AND_USN_COLUMN(QStringLiteral("Notebooks"), QStringLiteral("updateSequenceNumber")); @@ -4661,24 +4674,22 @@ updateSequenceNumber = std::max(updateSequenceNumber, usn); - QNTRACE(QStringLiteral("Max update sequence number from table ") - << it->m_tableName << QStringLiteral(": ") << usn << - QStringLiteral(", overall max USN so far: ") << updateSequenceNumber); + QNTRACE("Max update sequence number from table " << it->m_tableName + << ": " << usn << ", overall max USN so far: " + << updateSequenceNumber); } - QNDEBUG(QStringLiteral("Max USN = ") << updateSequenceNumber); + QNDEBUG("Max USN = " << updateSequenceNumber); return updateSequenceNumber; } -bool LocalStorageManagerPrivate::updateSequenceNumberFromTable(const QString & tableName, - const QString & usnColumnName, - const QString & queryCondition, - qint32 & usn, - ErrorString & errorDescription) -{ - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::updateSequenceNumberFromTable: ") - << tableName << QStringLiteral(", usn column name = ") << usnColumnName - << QStringLiteral(", query condition = ") << queryCondition); +bool LocalStorageManagerPrivate::updateSequenceNumberFromTable( + const QString & tableName, const QString & usnColumnName, + const QString & queryCondition, qint32 & usn, ErrorString & errorDescription) +{ + QNDEBUG("LocalStorageManagerPrivate::updateSequenceNumberFromTable: " + << tableName << ", usn column name = " << usnColumnName + << ", query condition = " << queryCondition); ErrorString errorPrefix(QT_TR_NOOP("failed to get the update sequence number " "from one of local storage database tables")); @@ -4694,7 +4705,7 @@ DATABASE_CHECK_AND_SET_ERROR() if (!query.next()) { - QNDEBUG(QStringLiteral("No query result for table ") << tableName); + QNDEBUG("No query result for table " << tableName); // NOTE: consider this the acceptable result, the table might be empty usn = 0; return true; @@ -4704,7 +4715,7 @@ QVariant value = query.value(0); usn = value.toInt(&conversionResult); if (Q_UNLIKELY(!conversionResult)) { - QNDEBUG(QStringLiteral("Failed to convert the query result to int")); + QNDEBUG("Failed to convert the query result to int"); /** * NOTE: surprising but this seems to happen when the table on which * the query runs is empty, so need to handle it gently: don't return @@ -4716,9 +4727,10 @@ return true; } -bool LocalStorageManagerPrivate::compactLocalStorage(ErrorString & errorDescription) +bool LocalStorageManagerPrivate::compactLocalStorage( + ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::compactLocalStorage")); + QNDEBUG("LocalStorageManagerPrivate::compactLocalStorage"); clearCachedQueries(); @@ -4731,16 +4743,16 @@ return true; } -void LocalStorageManagerPrivate::processPostTransactionException(ErrorString message, - QSqlError error) +void LocalStorageManagerPrivate::processPostTransactionException( + ErrorString message, QSqlError error) { - QNERROR(message << QStringLiteral(": ") << error); + QNERROR(message << ": " << error); message.details() += error.text(); throw DatabaseSqlErrorException(message); } -bool LocalStorageManagerPrivate::addEnResource(Resource & resource, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::addEnResource( + Resource & resource, ErrorString & errorDescription) { ErrorString errorPrefix(QT_TR_NOOP("Can't add resource to " "the local storage database")); @@ -4751,7 +4763,7 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(QStringLiteral("Found invalid resource: ") << resource); + QNWARNING("Found invalid resource: " << resource); return false; } @@ -4759,7 +4771,7 @@ errorDescription.base() = errorPrefix.base(); errorDescription.appendBase(QT_TR_NOOP("both resource's note local uid " "and note guid are empty")); - QNWARNING(errorDescription << QStringLiteral(", resource: ") << resource); + QNWARNING(errorDescription << ", resource: " << resource); return false; } @@ -4871,8 +4883,8 @@ return true; } -bool LocalStorageManagerPrivate::updateEnResource(Resource & resource, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::updateEnResource( + Resource & resource, ErrorString & errorDescription) { ErrorString errorPrefix(QT_TR_NOOP("Can't update resource " "in the local storage database")); @@ -4883,7 +4895,7 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(QStringLiteral("Found invalid resource: ") << resource); + QNWARNING("Found invalid resource: " << resource); return false; } @@ -4891,7 +4903,7 @@ errorDescription.base() = errorPrefix.base(); errorDescription.appendBase(QT_TR_NOOP("both resource's note local uid " "and note guid are empty")); - QNWARNING(errorDescription << QStringLiteral(", resource: ") << resource); + QNWARNING(errorDescription << ", resource: " << resource); return false; } @@ -4960,19 +4972,20 @@ bool foundByOtherColumn = false; if (resourceHasGuid) { - QNDEBUG(QStringLiteral("Failed to find the resource by guid within " - "the local storage, trying to find it " - "by local uid")); + QNDEBUG("Failed to find the resource by guid within " + "the local storage, trying to find it by local uid"); column = QStringLiteral("resourceLocalUid"); uid = resource.localUid(); - foundByOtherColumn = rowExists(QStringLiteral("Resources"), column, uid); + foundByOtherColumn = + rowExists(QStringLiteral("Resources"), column, uid); } - if (!foundByOtherColumn) { + if (!foundByOtherColumn) + { errorDescription.base() = errorPrefix.base(); - errorDescription.appendBase(QT_TR_NOOP("resource to be updated was " - "not found in the local storage " - "database")); + errorDescription.appendBase( + QT_TR_NOOP("resource to be updated was not found in the local " + "storage database")); errorDescription.details() = column; errorDescription.details() += QStringLiteral(" = "); errorDescription.details() += uid; @@ -4997,12 +5010,12 @@ void LocalStorageManagerPrivate::unlockDatabaseFile() { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::unlockDatabaseFile: ") + QNDEBUG("LocalStorageManagerPrivate::unlockDatabaseFile: " << m_databaseFilePath); #ifndef Q_OS_WIN if (m_databaseFilePath.isEmpty()) { - QNDEBUG(QStringLiteral("No database file, nothing to do")); + QNDEBUG("No database file, nothing to do"); return; } @@ -5010,10 +5023,9 @@ m_databaseFileLock.unlock(); } catch(boost::interprocess::interprocess_exception & exc) { - QNWARNING(QStringLiteral("Caught exception trying to unlock the database " - "file: error code = ") - << exc.get_error_code() << QStringLiteral(", error message = ") - << exc.what() << QStringLiteral("; native error = ") + QNWARNING("Caught exception trying to unlock the database file: error = " + << exc.get_error_code() << ", error message = " + << exc.what() << "; native error = " << exc.get_native_error()); } #endif @@ -5025,14 +5037,15 @@ bool res; // Checking whether auxiliary table exists - res = query.exec(QStringLiteral("SELECT name FROM sqlite_master WHERE name='Auxiliary'")); + res = query.exec( + QStringLiteral("SELECT name FROM sqlite_master WHERE name='Auxiliary'")); ErrorString errorPrefix(QT_TR_NOOP("Can't check whether Auxiliary table exists")); DATABASE_CHECK_AND_SET_ERROR() bool auxiliaryTableExists = query.next(); - QNDEBUG(QStringLiteral("Auxiliary table ") << + QNDEBUG("Auxiliary table " << (auxiliaryTableExists - ? QStringLiteral("already exists") - : QStringLiteral("doesn't exist yet"))); + ? "already exists" + : "doesn't exist yet")); if (!auxiliaryTableExists) { @@ -5772,11 +5785,13 @@ return true; } -bool LocalStorageManagerPrivate::insertOrReplaceNotebookRestrictions(const QString & localUid, - const qevercloud::NotebookRestrictions & notebookRestrictions, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::insertOrReplaceNotebookRestrictions( + const QString & localUid, + const qevercloud::NotebookRestrictions & notebookRestrictions, + ErrorString & errorDescription) { - ErrorString errorPrefix(QT_TR_NOOP("can't insert or replace notebook restrictions")); + ErrorString errorPrefix( + QT_TR_NOOP("can't insert or replace notebook restrictions")); bool res = checkAndPrepareInsertOrReplaceNotebookRestrictionsQuery(); QSqlQuery & query = m_insertOrReplaceNotebookRestrictionsQuery; @@ -5786,13 +5801,14 @@ query.bindValue(QStringLiteral(":localUid"), localUid); -#define BIND_RESTRICTION(name) \ - query.bindValue(QStringLiteral(":" #name), \ - (notebookRestrictions.name.isSet() \ - ? (notebookRestrictions.name.ref() \ - ? 1 \ - : 0) \ - : nullValue)) +#define BIND_RESTRICTION(name) \ + query.bindValue(QStringLiteral(":" #name), \ + (notebookRestrictions.name.isSet() \ + ? (notebookRestrictions.name.ref() \ + ? 1 \ + : 0) \ + : nullValue)) \ +// BIND_RESTRICTION BIND_RESTRICTION(noReadNotes); BIND_RESTRICTION(noCreateNotes); @@ -5832,10 +5848,11 @@ return true; } -bool LocalStorageManagerPrivate::insertOrReplaceSharedNotebook(const SharedNotebook & sharedNotebook, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::insertOrReplaceSharedNotebook( + const SharedNotebook & sharedNotebook, ErrorString & errorDescription) { - // NOTE: this method is expected to be called after the sanity check of sharedNotebook object! + // NOTE: this method is expected to be called after the sanity check of + // sharedNotebook object! ErrorString errorPrefix(QT_TR_NOOP("can't insert or replace shared notebook")); @@ -5922,9 +5939,9 @@ return true; } -bool LocalStorageManagerPrivate::rowExists(const QString & tableName, - const QString & uniqueKeyName, - const QVariant & uniqueKeyValue) const +bool LocalStorageManagerPrivate::rowExists( + const QString & tableName, const QString & uniqueKeyName, + const QVariant & uniqueKeyValue) const { QString key = uniqueKeyValue.toString(); key = sqlEscapeString(key); @@ -5934,17 +5951,19 @@ QSqlQuery query(m_sqlDatabase); bool res = query.exec(queryString); - if (!res) { - QNWARNING(QStringLiteral("Unable to check the existence of row with key name ") - << uniqueKeyName << QStringLiteral(", value = ") << key - << QStringLiteral(" in table ") << tableName - << QStringLiteral(": unable to execute SQL statement: ") + if (!res) + { + QNWARNING("Unable to check the existence of row with key name " + << uniqueKeyName << ", value = " << key + << " in table " << tableName + << ": unable to execute SQL statement: " << query.lastError().text() - << QStringLiteral("; assuming no such row exists")); + << "; assuming no such row exists"); return false; } - if (query.next() && query.isValid()) { + if (query.next() && query.isValid()) + { bool conversionResult = false; int count = query.value(0).toInt(&conversionResult); if (!conversionResult) { @@ -5956,8 +5975,8 @@ return false; } -bool LocalStorageManagerPrivate::insertOrReplaceUser(const User & user, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::insertOrReplaceUser( + const User & user, ErrorString & errorDescription) { // NOTE: this method is expected to be called after the check of user object // for sanity of its parameters! @@ -6063,8 +6082,8 @@ // Clean entries from UserAttributesViewedPromotions table { QString queryString = - QString::fromUtf8("DELETE FROM UserAttributesViewedPromotions WHERE id=%1") - .arg(userId); + QString::fromUtf8("DELETE FROM UserAttributesViewedPromotions " + "WHERE id=%1").arg(userId); QSqlQuery query(m_sqlDatabase); bool res = query.exec(queryString); @@ -6074,8 +6093,9 @@ // Clean entries from UserAttributesRecentMailedAddresses table { QString queryString = - QString::fromUtf8("DELETE FROM UserAttributesRecentMailedAddresses WHERE id=%1") - .arg(userId); + QString::fromUtf8("DELETE FROM " + "UserAttributesRecentMailedAddresses " + "WHERE id=%1").arg(userId); QSqlQuery query(m_sqlDatabase); bool res = query.exec(queryString); @@ -6168,11 +6188,12 @@ return transaction.commit(errorDescription); } -bool LocalStorageManagerPrivate::insertOrReplaceBusinessUserInfo(const qevercloud::UserID id, - const qevercloud::BusinessUserInfo & info, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::insertOrReplaceBusinessUserInfo( + const qevercloud::UserID id, const qevercloud::BusinessUserInfo & info, + ErrorString & errorDescription) { - ErrorString errorPrefix(QT_TR_NOOP("can't insert or replace business user info")); + ErrorString errorPrefix( + QT_TR_NOOP("can't insert or replace business user info")); bool res = checkAndPrepareInsertOrReplaceBusinessUserInfoQuery(); QSqlQuery & query = m_insertOrReplaceBusinessUserInfoQuery; @@ -6204,9 +6225,9 @@ return true; } -bool LocalStorageManagerPrivate::insertOrReplaceAccounting(const qevercloud::UserID id, - const qevercloud::Accounting & accounting, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::insertOrReplaceAccounting( + const qevercloud::UserID id, const qevercloud::Accounting & accounting, + ErrorString & errorDescription) { ErrorString errorPrefix(QT_TR_NOOP("can't insert or replace accounting")); @@ -6218,11 +6239,12 @@ QVariant nullValue; -#define CHECK_AND_BIND_VALUE(name) \ - query.bindValue(QStringLiteral(":" #name), \ - accounting.name.isSet() \ - ? accounting.name.ref() \ - : nullValue) +#define CHECK_AND_BIND_VALUE(name) \ + query.bindValue(QStringLiteral(":" #name), \ + accounting.name.isSet() \ + ? accounting.name.ref() \ + : nullValue) \ +// CHECK_AND_BIND_VALUE CHECK_AND_BIND_VALUE(uploadLimitEnd); CHECK_AND_BIND_VALUE(uploadLimitNextMonth); @@ -6253,9 +6275,10 @@ return true; } -bool LocalStorageManagerPrivate::insertOrReplaceAccountLimits(const qevercloud::UserID id, - const qevercloud::AccountLimits & accountLimits, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::insertOrReplaceAccountLimits( + const qevercloud::UserID id, + const qevercloud::AccountLimits & accountLimits, + ErrorString & errorDescription) { ErrorString errorPrefix(QT_TR_NOOP("can't insert or replace account limits")); @@ -6267,11 +6290,12 @@ QVariant nullValue; -#define CHECK_AND_BIND_VALUE(name) \ - query.bindValue(QStringLiteral(":" #name), \ - accountLimits.name.isSet() \ - ? accountLimits.name.ref() \ - : nullValue) +#define CHECK_AND_BIND_VALUE(name) \ + query.bindValue(QStringLiteral(":" #name), \ + accountLimits.name.isSet() \ + ? accountLimits.name.ref() \ + : nullValue) \ +// CHECK_AND_BIND_VALUE CHECK_AND_BIND_VALUE(userMailLimitDaily); CHECK_AND_BIND_VALUE(noteSizeMax); @@ -6293,9 +6317,9 @@ return true; } -bool LocalStorageManagerPrivate::insertOrReplaceUserAttributes(const qevercloud::UserID id, - const qevercloud::UserAttributes & attributes, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::insertOrReplaceUserAttributes( + const qevercloud::UserID id, const qevercloud::UserAttributes & attributes, + ErrorString & errorDescription) { ErrorString errorPrefix(QT_TR_NOOP("can't insert or replace user attributes")); @@ -6309,11 +6333,12 @@ query.bindValue(QStringLiteral(":id"), id); -#define CHECK_AND_BIND_VALUE(name) \ - query.bindValue(QStringLiteral(":" #name), \ - (attributes.name.isSet() \ - ? attributes.name.ref() \ - : nullValue)) +#define CHECK_AND_BIND_VALUE(name) \ + query.bindValue(QStringLiteral(":" #name), \ + (attributes.name.isSet() \ + ? attributes.name.ref() \ + : nullValue)) \ +// CHECK_AND_BIND_VALUE CHECK_AND_BIND_VALUE(defaultLocationName); CHECK_AND_BIND_VALUE(defaultLatitude); @@ -6343,13 +6368,12 @@ #undef CHECK_AND_BIND_VALUE -#define CHECK_AND_BIND_BOOLEAN_VALUE(name) \ - query.bindValue(QStringLiteral(":" #name), \ - (attributes.name.isSet() \ - ? (attributes.name.ref() \ - ? 1 \ - : 0) \ - : nullValue)) +#define CHECK_AND_BIND_BOOLEAN_VALUE(name) \ + query.bindValue(QStringLiteral(":" #name), \ + (attributes.name.isSet() \ + ? (attributes.name.ref() ? 1 : 0) \ + : nullValue)) \ +// CHECK_AND_BIND_BOOLEAN_VALUE CHECK_AND_BIND_BOOLEAN_VALUE(preactivation); CHECK_AND_BIND_BOOLEAN_VALUE(clipFullPage); @@ -6368,8 +6392,8 @@ // Clean viewed promotions first, then re-insert { QString queryString = - QString::fromUtf8("DELETE FROM UserAttributesViewedPromotions WHERE id=%1") - .arg(id); + QString::fromUtf8("DELETE FROM UserAttributesViewedPromotions " + "WHERE id=%1").arg(id); QSqlQuery query(m_sqlDatabase); bool res = query.exec(queryString); @@ -6378,7 +6402,8 @@ if (attributes.viewedPromotions.isSet()) { - bool res = checkAndPrepareInsertOrReplaceUserAttributesViewedPromotionsQuery(); + bool res = + checkAndPrepareInsertOrReplaceUserAttributesViewedPromotionsQuery(); QSqlQuery & query = m_insertOrReplaceUserAttributesViewedPromotionsQuery; DATABASE_CHECK_AND_SET_ERROR() @@ -6397,8 +6422,8 @@ // Clean recent mailed addresses first, then re-insert { QString queryString = - QString::fromUtf8("DELETE FROM UserAttributesRecentMailedAddresses WHERE id=%1") - .arg(id); + QString::fromUtf8("DELETE FROM UserAttributesRecentMailedAddresses " + "WHERE id=%1").arg(id); QSqlQuery query(m_sqlDatabase); bool res = query.exec(queryString); @@ -6407,7 +6432,8 @@ if (attributes.recentMailedAddresses.isSet()) { - bool res = checkAndPrepareInsertOrReplaceUserAttributesRecentMailedAddressesQuery(); + bool res = + checkAndPrepareInsertOrReplaceUserAttributesRecentMailedAddressesQuery(); QSqlQuery & query = m_insertOrReplaceUserAttributesRecentMailedAddressesQuery; DATABASE_CHECK_AND_SET_ERROR() @@ -6432,7 +6458,7 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to get the count of users")); + QNDEBUG("Preparing SQL query to get the count of users"); m_getUserCountQuery = QSqlQuery(m_sqlDatabase); QString queryString = QStringLiteral("SELECT COUNT(*) FROM Users " @@ -6452,19 +6478,21 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to insert or replace user")); + QNDEBUG("Preparing SQL query to insert or replace user"); m_insertOrReplaceUserQuery = QSqlQuery(m_sqlDatabase); QString queryString = QStringLiteral("INSERT OR REPLACE INTO Users" - "(id, username, email, name, timezone, privilege, serviceLevel, " - "userCreationTimestamp, userModificationTimestamp, userIsDirty, " - "userIsLocal, userDeletionTimestamp, userIsActive, userShardId, " - "userPhotoUrl, userPhotoLastUpdateTimestamp) " - "VALUES(:id, :username, :email, :name, :timezone, :privilege, " - ":serviceLevel, :userCreationTimestamp, :userModificationTimestamp, " - ":userIsDirty, :userIsLocal, :userDeletionTimestamp, :userIsActive, " - ":userShardId, :userPhotoUrl, :userPhotoLastUpdateTimestamp)"); + "(id, username, email, name, timezone, privilege, " + "serviceLevel, userCreationTimestamp, " + "userModificationTimestamp, userIsDirty, " + "userIsLocal, userDeletionTimestamp, userIsActive, " + "userShardId, userPhotoUrl, userPhotoLastUpdateTimestamp) " + "VALUES(:id, :username, :email, :name, :timezone, " + ":privilege, :serviceLevel, :userCreationTimestamp, " + ":userModificationTimestamp, :userIsDirty, :userIsLocal, " + ":userDeletionTimestamp, :userIsActive, :userShardId, " + ":userPhotoUrl, :userPhotoLastUpdateTimestamp)"); bool res = m_insertOrReplaceUserQuery.prepare(queryString); if (res) { m_insertOrReplaceUserQueryPrepared = true; @@ -6479,7 +6507,7 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to insert or replace accounting")); + QNDEBUG("Preparing SQL query to insert or replace accounting"); m_insertOrReplaceAccountingQuery = QSqlQuery(m_sqlDatabase); QString queryString = @@ -6498,8 +6526,9 @@ ":premiumServiceSKU, :lastSuccessfulCharge, " ":lastFailedCharge, :lastFailedChargeReason, " ":nextPaymentDue, :premiumLockUntil, :updated, " - ":premiumSubscriptionNumber, :lastRequestedCharge, :currency, " - ":unitPrice, :unitDiscount, :nextChargeDate, :availablePoints)"); + ":premiumSubscriptionNumber, :lastRequestedCharge, " + ":currency, :unitPrice, :unitDiscount, :nextChargeDate, " + ":availablePoints)"); bool res = m_insertOrReplaceAccountingQuery.prepare(queryString); if (res) { m_insertOrReplaceAccountingQueryPrepared = true; @@ -6514,7 +6543,7 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to insert or replace account limits")); + QNDEBUG("Preparing SQL query to insert or replace account limits"); m_insertOrReplaceAccountLimitsQuery = QSqlQuery(m_sqlDatabase); QString queryString = @@ -6523,9 +6552,10 @@ "userLinkedNotebookMax, uploadLimit, userNoteCountMax, " "userNotebookCountMax, userTagCountMax, noteTagCountMax, " "userSavedSearchesMax, noteResourceCountMax) " - "VALUES(:id, :userMailLimitDaily, :noteSizeMax, :resourceSizeMax, " - ":userLinkedNotebookMax, :uploadLimit, :userNoteCountMax, " - ":userNotebookCountMax, :userTagCountMax, :noteTagCountMax, " + "VALUES(:id, :userMailLimitDaily, :noteSizeMax, " + ":resourceSizeMax, :userLinkedNotebookMax, :uploadLimit, " + ":userNoteCountMax, :userNotebookCountMax, " + ":userTagCountMax, :noteTagCountMax, " ":userSavedSearchesMax, :noteResourceCountMax)"); bool res = m_insertOrReplaceAccountLimitsQuery.prepare(queryString); if (res) { @@ -6541,7 +6571,7 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQl query to insert or replace business user info")); + QNDEBUG("Preparing SQl query to insert or replace business user info"); m_insertOrReplaceBusinessUserInfoQuery = QSqlQuery(m_sqlDatabase); QString queryString = @@ -6563,7 +6593,7 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to insert or replace user attributes")); + QNDEBUG("Preparing SQL query to insert or replace user attributes"); m_insertOrReplaceUserAttributesQuery = QSqlQuery(m_sqlDatabase); QString queryString = @@ -6612,8 +6642,8 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to insert or replace user " - "attributes viewed promotions")); + QNDEBUG("Preparing SQL query to insert or replace user " + "attributes viewed promotions"); m_insertOrReplaceUserAttributesViewedPromotionsQuery = QSqlQuery(m_sqlDatabase); QString queryString = @@ -6633,10 +6663,11 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to insert or replace user " - "attributes recent mailed addresses")); + QNDEBUG("Preparing SQL query to insert or replace user " + "attributes recent mailed addresses"); - m_insertOrReplaceUserAttributesRecentMailedAddressesQuery = QSqlQuery(m_sqlDatabase); + m_insertOrReplaceUserAttributesRecentMailedAddressesQuery = + QSqlQuery(m_sqlDatabase); QString queryString = QStringLiteral("INSERT OR REPLACE INTO UserAttributesRecentMailedAddresses" "(id, address) VALUES(:id, :address)"); @@ -6654,7 +6685,7 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to mark user deleted")); + QNDEBUG("Preparing SQL query to mark user deleted"); m_deleteUserQuery = QSqlQuery(m_sqlDatabase); QString queryString = @@ -6669,8 +6700,8 @@ return res; } -bool LocalStorageManagerPrivate::insertOrReplaceNotebook(const Notebook & notebook, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::insertOrReplaceNotebook( + const Notebook & notebook, ErrorString & errorDescription) { // NOTE: this method expects to be called after notebook is already checked // for sanity of its parameters! @@ -6830,8 +6861,8 @@ else { QString queryString = - QString::fromUtf8("DELETE FROM NotebookRestrictions WHERE localUid='%1'") - .arg(localUid); + QString::fromUtf8("DELETE FROM NotebookRestrictions " + "WHERE localUid='%1'").arg(localUid); QSqlQuery query(m_sqlDatabase); bool res = query.exec(queryString); @@ -6854,8 +6885,8 @@ { const SharedNotebook & sharedNotebook = sharedNotebooks[i]; if (!sharedNotebook.hasId()) { - QNWARNING(QStringLiteral("Found shared notebook without primary " - "identifier of the share set, skipping it: ") + QNWARNING("Found shared notebook without primary " + << "identifier of the share set, skipping it: " << sharedNotebook); continue; } @@ -6881,7 +6912,7 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to get the count of notebooks")); + QNDEBUG("Preparing SQL query to get the count of notebooks"); m_getNotebookCountQuery = QSqlQuery(m_sqlDatabase); QString queryString = QStringLiteral("SELECT COUNT(*) FROM Notebooks"); @@ -6899,18 +6930,19 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to insert or replace notebook")); + QNDEBUG("Preparing SQL query to insert or replace notebook"); m_insertOrReplaceNotebookQuery = QSqlQuery(m_sqlDatabase); QString queryString = QStringLiteral("INSERT OR REPLACE INTO Notebooks" - "(localUid, guid, linkedNotebookGuid, updateSequenceNumber, " - "notebookName, notebookNameUpper, creationTimestamp, " - "modificationTimestamp, isDirty, isLocal, " - "isDefault, isLastUsed, isFavorited, publishingUri, " - "publishingNoteSortOrder, publishingAscendingSort, " - "publicDescription, isPublished, stack, " - "businessNotebookDescription, businessNotebookPrivilegeLevel, " + "(localUid, guid, linkedNotebookGuid, " + "updateSequenceNumber, notebookName, notebookNameUpper, " + "creationTimestamp, modificationTimestamp, isDirty, " + "isLocal, isDefault, isLastUsed, isFavorited, " + "publishingUri, publishingNoteSortOrder, " + "publishingAscendingSort, publicDescription, isPublished, " + "stack, businessNotebookDescription, " + "businessNotebookPrivilegeLevel, " "businessNotebookIsRecommended, contactId, " "recipientReminderNotifyEmail, recipientReminderNotifyInApp, " "recipientInMyList, recipientStack) " @@ -6919,10 +6951,11 @@ ":creationTimestamp, :modificationTimestamp, :isDirty, " ":isLocal, :isDefault, :isLastUsed, :isFavorited, " ":publishingUri, :publishingNoteSortOrder, " - ":publishingAscendingSort, :publicDescription, :isPublished, " - ":stack, :businessNotebookDescription, " - ":businessNotebookPrivilegeLevel, :businessNotebookIsRecommended, " - ":contactId, :recipientReminderNotifyEmail, " + ":publishingAscendingSort, :publicDescription, " + ":isPublished, :stack, :businessNotebookDescription, " + ":businessNotebookPrivilegeLevel, " + ":businessNotebookIsRecommended, :contactId, " + ":recipientReminderNotifyEmail, " ":recipientReminderNotifyInApp, :recipientInMyList, " ":recipientStack)"); bool res = m_insertOrReplaceNotebookQuery.prepare(queryString); @@ -6939,26 +6972,29 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to insert or replace notebook restrictions")); + QNDEBUG("Preparing SQL query to insert or replace notebook restrictions"); m_insertOrReplaceNotebookRestrictionsQuery = QSqlQuery(m_sqlDatabase); QString queryString = QStringLiteral("INSERT OR REPLACE INTO NotebookRestrictions" "(localUid, noReadNotes, noCreateNotes, noUpdateNotes, " "noExpungeNotes, noShareNotes, noEmailNotes, " - "noSendMessageToRecipients, " - "noUpdateNotebook, noExpungeNotebook, noSetDefaultNotebook, " - "noSetNotebookStack, noPublishToPublic, noPublishToBusinessLibrary, " - "noCreateTags, noUpdateTags, noExpungeTags, noSetParentTag, " - "noCreateSharedNotebooks, updateWhichSharedNotebookRestrictions, " + "noSendMessageToRecipients, noUpdateNotebook, " + "noExpungeNotebook, noSetDefaultNotebook, " + "noSetNotebookStack, noPublishToPublic, " + "noPublishToBusinessLibrary, noCreateTags, noUpdateTags, " + "noExpungeTags, noSetParentTag, noCreateSharedNotebooks, " + "updateWhichSharedNotebookRestrictions, " "expungeWhichSharedNotebookRestrictions) " "VALUES(:localUid, :noReadNotes, :noCreateNotes, " ":noUpdateNotes, :noExpungeNotes, :noShareNotes, " ":noEmailNotes, :noSendMessageToRecipients, " - ":noUpdateNotebook, :noExpungeNotebook, :noSetDefaultNotebook, " - ":noSetNotebookStack, :noPublishToPublic, :noPublishToBusinessLibrary, " - ":noCreateTags, :noUpdateTags, :noExpungeTags, :noSetParentTag, " - ":noCreateSharedNotebooks, :updateWhichSharedNotebookRestrictions, " + ":noUpdateNotebook, :noExpungeNotebook, " + ":noSetDefaultNotebook, :noSetNotebookStack, " + ":noPublishToPublic, :noPublishToBusinessLibrary, " + ":noCreateTags, :noUpdateTags, :noExpungeTags, " + ":noSetParentTag, :noCreateSharedNotebooks, " + ":updateWhichSharedNotebookRestrictions, " ":expungeWhichSharedNotebookRestrictions)"); bool res = m_insertOrReplaceNotebookRestrictionsQuery.prepare(queryString); if (res) { @@ -6974,7 +7010,7 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to insert or replace shared notebook")); + QNDEBUG("Preparing SQL query to insert or replace shared notebook"); m_insertOrReplaceSharedNotebookQuery = QSqlQuery(m_sqlDatabase); QString queryString = @@ -6987,18 +7023,23 @@ "sharedNotebookPrivilegeLevel, " "sharedNotebookRecipientReminderNotifyEmail, " "sharedNotebookRecipientReminderNotifyInApp, " - "sharedNotebookSharerUserId, sharedNotebookRecipientUsername, " - "sharedNotebookRecipientUserId, sharedNotebookRecipientIdentityId, " + "sharedNotebookSharerUserId, " + "sharedNotebookRecipientUsername, " + "sharedNotebookRecipientUserId, " + "sharedNotebookRecipientIdentityId, " "sharedNotebookAssignmentTimestamp, indexInNotebook) " "VALUES(:sharedNotebookShareId, :sharedNotebookUserId, " ":sharedNotebookNotebookGuid, :sharedNotebookEmail, " ":sharedNotebookCreationTimestamp, " - ":sharedNotebookModificationTimestamp, :sharedNotebookGlobalId, " - ":sharedNotebookUsername, :sharedNotebookPrivilegeLevel, " + ":sharedNotebookModificationTimestamp, " + ":sharedNotebookGlobalId, :sharedNotebookUsername, " + ":sharedNotebookPrivilegeLevel, " ":sharedNotebookRecipientReminderNotifyEmail, " ":sharedNotebookRecipientReminderNotifyInApp, " - ":sharedNotebookSharerUserId, :sharedNotebookRecipientUsername, " - ":sharedNotebookRecipientUserId, :sharedNotebookRecipientIdentityId, " + ":sharedNotebookSharerUserId, " + ":sharedNotebookRecipientUsername, " + ":sharedNotebookRecipientUserId, " + ":sharedNotebookRecipientIdentityId, " ":sharedNotebookAssignmentTimestamp, :indexInNotebook) "); bool res = m_insertOrReplaceSharedNotebookQuery.prepare(queryString); if (res) { @@ -7008,8 +7049,8 @@ return res; } -bool LocalStorageManagerPrivate::insertOrReplaceLinkedNotebook(const LinkedNotebook & linkedNotebook, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::insertOrReplaceLinkedNotebook( + const LinkedNotebook & linkedNotebook, ErrorString & errorDescription) { // NOTE: this method expects to be called after the linked notebook // is already checked for sanity ot its parameters @@ -7083,7 +7124,7 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to get the count of linked notebooks")); + QNDEBUG("Preparing SQL query to get the count of linked notebooks"); m_getLinkedNotebookCountQuery = QSqlQuery(m_sqlDatabase); QString queryString = QStringLiteral("SELECT COUNT(*) FROM LinkedNotebooks"); @@ -7101,7 +7142,7 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to insert or replace linked notebook")); + QNDEBUG("Preparing SQL query to insert or replace linked notebook"); m_insertOrReplaceLinkedNotebookQuery = QSqlQuery(m_sqlDatabase); QString queryString = @@ -7122,9 +7163,9 @@ return res; } -bool LocalStorageManagerPrivate::getNoteLocalUidFromResource(const Resource & resource, - QString & noteLocalUid, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::getNoteLocalUidFromResource( + const Resource & resource, QString & noteLocalUid, + ErrorString & errorDescription) const { QNDEBUG("LocalStorageManagerPrivate::getNoteLocalUidFromResource: resource = " << resource); @@ -7138,8 +7179,8 @@ return true; } - QNTRACE(QStringLiteral("Resource doesn't have the note local uid, trying " - "to deduce it from note-resource linkage")); + QNTRACE("Resource doesn't have the note local uid, trying " + "to deduce it from note-resource linkage"); QString column, uid; bool resourceHasGuid = resource.hasGuid(); @@ -7190,13 +7231,12 @@ return true; } -bool LocalStorageManagerPrivate::getNotebookLocalUidFromNote(const Note & note, - QString & notebookLocalUid, - ErrorString & errorDescription) const -{ - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::getNotebookLocalUidFromNote: " - "note local uid = ") << note.localUid() - << QStringLiteral(", note guid = ") +bool LocalStorageManagerPrivate::getNotebookLocalUidFromNote( + const Note & note, QString & notebookLocalUid, + ErrorString & errorDescription) const +{ + QNDEBUG("LocalStorageManagerPrivate::getNotebookLocalUidFromNote: " + << "note local uid = " << note.localUid() << ", note guid = " << (note.hasGuid() ? note.guid() : QStringLiteral("<null>"))); ErrorString errorPrefix(QT_TR_NOOP("can't get notebook local uid for note")); @@ -7205,13 +7245,12 @@ if (note.hasNotebookLocalUid()) { notebookLocalUid = note.notebookLocalUid(); - QNTRACE(QStringLiteral("Notebook local uid taken from note: ") - << notebookLocalUid); + QNTRACE("Notebook local uid taken from note: " << notebookLocalUid); return true; } - QNTRACE(QStringLiteral("Note doesn't have the notebook local uid, " - "trying to deduce it from guid")); + QNTRACE("Note doesn't have the notebook local uid, trying to deduce it " + "from guid"); if (note.hasNotebookGuid()) { @@ -7230,9 +7269,10 @@ return false; } - notebookLocalUid = query.record().value(QStringLiteral("localUid")).toString(); - QNTRACE(QStringLiteral("Notebook local uid deduced from notebook's guid ") - << notebookGuid << QStringLiteral(": ") << notebookLocalUid); + notebookLocalUid = + query.record().value(QStringLiteral("localUid")).toString(); + QNTRACE("Notebook local uid deduced from notebook's guid " + << notebookGuid << ": " << notebookLocalUid); } else { @@ -7264,27 +7304,27 @@ notebookLocalUid = query.record().value(QStringLiteral("notebookLocalUid")).toString(); - QNTRACE(QStringLiteral("Notebook local uid deduced from note's ") << column - << QStringLiteral(" ") << uid << QStringLiteral(": ") << notebookLocalUid); + QNTRACE("Notebook local uid deduced from note's " << column << " " + << uid << ": " << notebookLocalUid); } if (notebookLocalUid.isEmpty()) { errorDescription.base() = errorPrefix.base(); - errorDescription.appendBase(QT_TR_NOOP("found notebook local uid is empty")); - QNDEBUG(errorDescription << QStringLiteral(", note: ") << note); + errorDescription.appendBase( + QT_TR_NOOP("found notebook local uid is empty")); + QNDEBUG(errorDescription << ", note: " << note); return false; } return true; } -bool LocalStorageManagerPrivate::getNotebookGuidForNote(const Note & note, - QString & notebookGuid, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::getNotebookGuidForNote( + const Note & note, QString & notebookGuid, + ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::getNotebookGuidForNote: " - "note local uid = ") << note.localUid() - << QStringLiteral(", note guid = ") + QNDEBUG("LocalStorageManagerPrivate::getNotebookGuidForNote: " + "note local uid = " << note.localUid() << ", note guid = " << (note.hasGuid() ? note.guid() : QStringLiteral("<null>"))); ErrorString errorPrefix(QT_TR_NOOP("can't get notebook guid for note")); @@ -7296,14 +7336,14 @@ return true; } - QNTRACE(QStringLiteral("Note doesn't have the notebook guid, " - "trying to deduce it from notebook local uid")); + QNTRACE("Note doesn't have the notebook guid, trying to deduce it from " + "notebook local uid"); if (!note.hasNotebookLocalUid()) { errorDescription.base() = errorPrefix.base(); errorDescription.appendBase(QT_TR_NOOP("note has neither notebook local " "uid nor notebook guid")); - QNDEBUG(errorDescription << QStringLiteral(", note: ") << note); + QNDEBUG(errorDescription << ", note: " << note); return false; } @@ -7325,17 +7365,17 @@ } notebookGuid = query.record().value(QStringLiteral("guid")).toString(); - QNTRACE(QStringLiteral("Found notebook guid corresponding to local uid ") - << notebookLocalUid << QStringLiteral(": ") << notebookGuid); + QNTRACE("Found notebook guid corresponding to local uid " + << notebookLocalUid << ": " << notebookGuid); return true; } -bool LocalStorageManagerPrivate::getNotebookLocalUidForGuid(const QString & notebookGuid, - QString & notebookLocalUid, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::getNotebookLocalUidForGuid( + const QString & notebookGuid, QString & notebookLocalUid, + ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::getNotebookLocalUidForGuid: " - "notebook guid = ") << notebookGuid); + QNDEBUG("LocalStorageManagerPrivate::getNotebookLocalUidForGuid: " + << "notebook guid = " << notebookGuid); ErrorString errorPrefix(QT_TR_NOOP("can't get notebook local uid for guid")); @@ -7348,13 +7388,16 @@ DATABASE_CHECK_AND_SET_ERROR() if (query.next()) { - notebookLocalUid = query.record().value(QStringLiteral("localUid")).toString(); + notebookLocalUid = + query.record().value(QStringLiteral("localUid")).toString(); } - if (notebookLocalUid.isEmpty()) { + if (notebookLocalUid.isEmpty()) + { errorDescription.base() = errorPrefix.base(); - errorDescription.appendBase(QT_TR_NOOP("no existing local uid corresponding " - "to notebook's guid was found")); + errorDescription.appendBase( + QT_TR_NOOP("no existing local uid corresponding to notebook's guid " + "was found")); errorDescription.details() = notebookGuid; QNDEBUG(errorDescription); return false; @@ -7363,12 +7406,12 @@ return true; } -bool LocalStorageManagerPrivate::getNoteLocalUidForGuid(const QString & noteGuid, - QString & noteLocalUid, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::getNoteLocalUidForGuid( + const QString & noteGuid, QString & noteLocalUid, + ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::getNoteLocalUidForGuid: " - "note guid = ") << noteGuid); + QNDEBUG("LocalStorageManagerPrivate::getNoteLocalUidForGuid: note guid = " + << noteGuid); ErrorString errorPrefix(QT_TR_NOOP("can't get note local uid for guid")); @@ -7381,13 +7424,16 @@ DATABASE_CHECK_AND_SET_ERROR() if (query.next()) { - noteLocalUid = query.record().value(QStringLiteral("localUid")).toString(); + noteLocalUid = + query.record().value(QStringLiteral("localUid")).toString(); } - if (noteLocalUid.isEmpty()) { + if (noteLocalUid.isEmpty()) + { errorDescription.base() = errorPrefix.base(); - errorDescription.appendBase(QT_TR_NOOP("no existing local uid corresponding " - "to note's guid was found")); + errorDescription.appendBase( + QT_TR_NOOP("no existing local uid corresponding to note's guid was " + "found")); errorDescription.details() = noteGuid; QNDEBUG(errorDescription); return false; @@ -7396,12 +7442,12 @@ return true; } -bool LocalStorageManagerPrivate::getNoteGuidForLocalUid(const QString & noteLocalUid, - QString & noteGuid, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::getNoteGuidForLocalUid( + const QString & noteLocalUid, QString & noteGuid, + ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::getNoteGuidForLocalUid: " - "note local uid = ") << noteLocalUid); + QNDEBUG("LocalStorageManagerPrivate::getNoteGuidForLocalUid: note local " + << "uid = " << noteLocalUid); ErrorString errorPrefix(QT_TR_NOOP("can't get note guid for local uid")); @@ -7420,12 +7466,12 @@ return true; } -bool LocalStorageManagerPrivate::getTagLocalUidForGuid(const QString & tagGuid, - QString & tagLocalUid, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::getTagLocalUidForGuid( + const QString & tagGuid, QString & tagLocalUid, + ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::getTagLocalUidForGuid: " - "tag guid = ") << tagGuid); + QNDEBUG("LocalStorageManagerPrivate::getTagLocalUidForGuid: tag guid = " + << tagGuid); ErrorString errorPrefix(QT_TR_NOOP("can't get tag local uid for guid")); @@ -7441,10 +7487,12 @@ tagLocalUid = query.record().value(QStringLiteral("localUid")).toString(); } - if (tagLocalUid.isEmpty()) { + if (tagLocalUid.isEmpty()) + { errorDescription.base() = errorPrefix.base(); - errorDescription.appendBase(QT_TR_NOOP("no existing local uid corresponding " - "to tag's guid was found")); + errorDescription.appendBase( + QT_TR_NOOP("no existing local uid corresponding to tag's guid was " + "found")); errorDescription.details() = tagGuid; QNDEBUG(errorDescription); return false; @@ -7453,31 +7501,34 @@ return true; } -bool LocalStorageManagerPrivate::getResourceLocalUidForGuid(const QString & resourceGuid, - QString & resourceLocalUid, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::getResourceLocalUidForGuid( + const QString & resourceGuid, QString & resourceLocalUid, + ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::getResourceLocalUidForGuid: " - "resource guid = ") << resourceGuid); + QNDEBUG("LocalStorageManagerPrivate::getResourceLocalUidForGuid: " + << "resource guid = " << resourceGuid); ErrorString errorPrefix(QT_TR_NOOP("can't get resource local uid for guid")); QString queryString = - QString::fromUtf8("SELECT resourceLocalUid FROM Resources WHERE resourceGuid = '%1'") - .arg(sqlEscapeString(resourceGuid)); + QString::fromUtf8("SELECT resourceLocalUid FROM Resources WHERE " + "resourceGuid = '%1'").arg(sqlEscapeString(resourceGuid)); QSqlQuery query(m_sqlDatabase); bool res = query.exec(queryString); DATABASE_CHECK_AND_SET_ERROR() if (query.next()) { - resourceLocalUid = query.record().value(QStringLiteral("resourceLocalUid")).toString(); + resourceLocalUid = + query.record().value(QStringLiteral("resourceLocalUid")).toString(); } - if (resourceLocalUid.isEmpty()) { + if (resourceLocalUid.isEmpty()) + { errorDescription.base() = errorPrefix.base(); - errorDescription.appendBase(QT_TR_NOOP("no existing local uid corresponding " - "to resource's guid was found")); + errorDescription.appendBase( + QT_TR_NOOP("no existing local uid corresponding " + "to resource's guid was found")); errorDescription.details() = resourceGuid; QNDEBUG(errorDescription); return false; @@ -7486,12 +7537,12 @@ return true; } -bool LocalStorageManagerPrivate::getSavedSearchLocalUidForGuid(const QString & savedSearchGuid, - QString & savedSearchLocalUid, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::getSavedSearchLocalUidForGuid( + const QString & savedSearchGuid, QString & savedSearchLocalUid, + ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::getSavedSearchLocalUidForGuid: " - "saved search guid = ") << savedSearchGuid); + QNDEBUG("LocalStorageManagerPrivate::getSavedSearchLocalUidForGuid: " + << "saved search guid = " << savedSearchGuid); ErrorString errorPrefix(QT_TR_NOOP("can't get saved search local uid for guid")); @@ -7504,13 +7555,16 @@ DATABASE_CHECK_AND_SET_ERROR() if (query.next()) { - savedSearchLocalUid = query.record().value(QStringLiteral("localUid")).toString(); + savedSearchLocalUid = + query.record().value(QStringLiteral("localUid")).toString(); } - if (savedSearchLocalUid.isEmpty()) { + if (savedSearchLocalUid.isEmpty()) + { errorDescription.base() = errorPrefix.base(); - errorDescription.appendBase(QT_TR_NOOP("no existing local uid corresponding " - "to saved search's guid was found")); + errorDescription.appendBase( + QT_TR_NOOP("no existing local uid corresponding " + "to saved search's guid was found")); errorDescription.details() = savedSearchGuid; QNDEBUG(errorDescription); return false; @@ -7519,20 +7573,20 @@ return true; } -bool LocalStorageManagerPrivate::insertOrReplaceNote(Note & note, - const LocalStorageManager::UpdateNoteOptions options, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::insertOrReplaceNote( + Note & note, const LocalStorageManager::UpdateNoteOptions options, + ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::insertOrReplaceNote: update tags = ") + QNDEBUG("LocalStorageManagerPrivate::insertOrReplaceNote: update tags = " << ((options & LocalStorageManager::UpdateNoteOption::UpdateTags) - ? QStringLiteral("true") : QStringLiteral("false")) - << QStringLiteral(", update resource metadata = ") + ? "true" : "false") + << ", update resource metadata = " << ((options & LocalStorageManager::UpdateNoteOption::UpdateResourceMetadata) - ? QStringLiteral("true") : QStringLiteral("false")) - << QStringLiteral(", update resource binary data = ") + ? "true" : "false") + << ", update resource binary data = " << ((options & LocalStorageManager::UpdateNoteOption::UpdateResourceBinaryData) - ? QStringLiteral("true") : QStringLiteral("false")) - << QStringLiteral(", note local uid = ") << note.localUid()); + ? "true" : "false") + << ", note local uid = " << note.localUid()); QNTRACE(note); // NOTE: this method expects to be called after the note is already checked @@ -7554,7 +7608,8 @@ if (!note.hasGuid()) { QString noteGuid; - bool res = getNoteGuidForLocalUid(note.localUid(), noteGuid, errorDescription); + bool res = getNoteGuidForLocalUid(note.localUid(), noteGuid, + errorDescription); if (!res) { return false; } @@ -7562,8 +7617,8 @@ noteGuidIsBeingCleared = !noteGuid.isEmpty(); } - QNDEBUG(QStringLiteral("Note guid is being cleared = ") << - (noteGuidIsBeingCleared ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("Note guid is being cleared = " << + (noteGuidIsBeingCleared ? "true" : "false")); if (noteGuidIsBeingCleared) { @@ -7579,14 +7634,14 @@ if (Q_UNLIKELY(resource.hasNoteGuid())) { errorDescription = errorPrefix; - errorDescription.appendBase(QT_TR_NOOP("note's guid is being " - "cleared but one of " - "note's resources has " - "non-empty note guid")); + errorDescription.appendBase( + QT_TR_NOOP("note's guid is being cleared but one of " + "note's resources has non-empty note guid")); if (resource.hasResourceAttributes() && resource.resourceAttributes().fileName.isSet()) { - errorDescription.details() = resource.resourceAttributes().fileName.ref(); + errorDescription.details() = + resource.resourceAttributes().fileName.ref(); } QNWARNING(errorDescription); @@ -7596,14 +7651,14 @@ if (Q_UNLIKELY(resource.hasGuid())) { errorDescription = errorPrefix; - errorDescription.appendBase(QT_TR_NOOP("note's guid is being " - "cleared but one of " - "note's resources has " - "non-empty guid")); + errorDescription.appendBase( + QT_TR_NOOP("note's guid is being cleared but one of " + "note's resources has non-empty guid")); if (resource.hasResourceAttributes() && resource.resourceAttributes().fileName.isSet()) { - errorDescription.details() = resource.resourceAttributes().fileName.ref(); + errorDescription.details() = + resource.resourceAttributes().fileName.ref(); } QNWARNING(errorDescription); @@ -7693,14 +7748,15 @@ std::pair<QString, QStringList> plainTextAndListOfWords = note.plainTextAndListOfWords(&error); - if (!error.isEmpty()) { + if (!error.isEmpty()) + { errorDescription.base() = errorPrefix.base(); errorDescription.appendBase(QT_TR_NOOP("can't get note's plain " "text and list of words")); errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(errorDescription << QStringLiteral(", note: ") << note); + QNWARNING(errorDescription << ", note: " << note); return false; } @@ -7739,14 +7795,10 @@ : nullValue)); query.bindValue(QStringLiteral(":isActive"), (note.hasActive() - ? (note.active() - ? 1 - : 0) + ? (note.active() ? 1 : 0) : nullValue)); query.bindValue(QStringLiteral(":hasAttributes"), - (note.hasNoteAttributes() - ? 1 - : 0)); + (note.hasNoteAttributes() ? 1 : 0)); QByteArray thumbnailData = note.thumbnailData(); query.bindValue(QStringLiteral(":thumbnail"), @@ -7767,11 +7819,12 @@ { const qevercloud::NoteAttributes & attributes = note.noteAttributes(); -#define BIND_ATTRIBUTE(name) \ - query.bindValue(QStringLiteral(":" #name), \ - (attributes.name.isSet() \ - ? attributes.name.ref() \ - : nullValue)) +#define BIND_ATTRIBUTE(name) \ + query.bindValue(QStringLiteral(":" #name), \ + (attributes.name.isSet() \ + ? attributes.name.ref() \ + : nullValue)) \ +// BIND_ATTRIBUTE BIND_ATTRIBUTE(subjectDate); BIND_ATTRIBUTE(latitude); @@ -7813,7 +7866,7 @@ keysOnlyString += QStringLiteral("'"); } - QNDEBUG(QStringLiteral("Application data keys only string: ") + QNDEBUG("Application data keys only string: " << keysOnlyString); query.bindValue(QStringLiteral(":applicationDataKeysOnly"), @@ -7843,9 +7896,9 @@ fullMapValuesString += QStringLiteral("'"); } - QNDEBUG(QStringLiteral("Application data map keys: ") + QNDEBUG("Application data map keys: " << fullMapKeysString - << QStringLiteral(", application data map values: ") + << ", application data map values: " << fullMapValuesString); query.bindValue(QStringLiteral(":applicationDataKeysMap"), @@ -7888,10 +7941,8 @@ classificationValues += QStringLiteral("'"); } - QNDEBUG(QStringLiteral("Classification keys: ") - << classificationKeys - << QStringLiteral(", classification values") - << classificationValues); + QNDEBUG("Classification keys: " << classificationKeys + << ", classification values" << classificationValues); query.bindValue(QStringLiteral(":classificationKeys"), classificationKeys); @@ -7908,8 +7959,9 @@ } else { -#define BIND_NULL_ATTRIBUTE(name) \ - query.bindValue(QStringLiteral(":" #name), nullValue) +#define BIND_NULL_ATTRIBUTE(name) \ + query.bindValue(QStringLiteral(":" #name), nullValue) \ +// BIND_NULL_ATTRIBUTE BIND_NULL_ATTRIBUTE(subjectDate); BIND_NULL_ATTRIBUTE(latitude); @@ -7950,15 +8002,15 @@ bool res = insertOrReplaceNoteRestrictions(localUid, restrictions, errorDescription); if (!res) { - QNWARNING(QStringLiteral("Note: ") << note); + QNWARNING("Note: " << note); return false; } } else { QString queryString = - QString::fromUtf8("DELETE FROM NoteRestrictions WHERE noteLocalUid='%1'") - .arg(localUid); + QString::fromUtf8("DELETE FROM NoteRestrictions WHERE " + "noteLocalUid='%1'").arg(localUid); QSqlQuery query(m_sqlDatabase); bool res = query.exec(queryString); @@ -7970,7 +8022,7 @@ const qevercloud::NoteLimits & limits = note.noteLimits(); bool res = insertOrReplaceNoteLimits(localUid, limits, errorDescription); if (!res) { - QNWARNING(QStringLiteral("Note: ") << note); + QNWARNING("Note: " << note); return false; } } @@ -7991,8 +8043,8 @@ { QString noteGuid = sqlEscapeString(note.guid()); QString queryString = - QString::fromUtf8("DELETE FROM SharedNotes WHERE sharedNoteNoteGuid='%1'") - .arg(noteGuid); + QString::fromUtf8("DELETE FROM SharedNotes WHERE " + "sharedNoteNoteGuid='%1'").arg(noteGuid); QSqlQuery query(m_sqlDatabase); bool res = query.exec(queryString); @@ -8007,7 +8059,7 @@ { bool res = insertOrReplaceSharedNote(*it, errorDescription); if (!res) { - QNWARNING(QStringLiteral("Note: ") << note); + QNWARNING("Note: " << note); return false; } } @@ -8057,7 +8109,8 @@ { // NOTE: the behavior expressed here is valid since tags are // synchronized before notes so they must exist within local - // storage database; if they don't then something went really wrong + // storage database; if they don't then something went really + // wrong const QString & tagId = *it; @@ -8078,8 +8131,7 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(errorDescription << QStringLiteral(", note: ") - << note); + QNWARNING(errorDescription << ", note: " << note); return false; } @@ -8127,7 +8179,7 @@ { if (!note.hasResources()) { - QNDEBUG(QStringLiteral("Deleting all resources the note might have had")); + QNDEBUG("Deleting all resources the note might have had"); QString queryString = QString::fromUtf8("DELETE FROM Resources WHERE noteLocalUid='%1'") .arg(localUid); @@ -8163,14 +8215,14 @@ return transaction.commit(errorDescription); } -bool LocalStorageManagerPrivate::insertOrReplaceSharedNote(const SharedNote & sharedNote, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::insertOrReplaceSharedNote( + const SharedNote & sharedNote, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::insertOrReplaceSharedNote: ") + QNDEBUG("LocalStorageManagerPrivate::insertOrReplaceSharedNote: " << sharedNote); - // NOTE: this method expects to be called after the shared note is already checked - // for sanity of its parameters! + // NOTE: this method expects to be called after the shared note is already + // checked for sanity of its parameters! ErrorString errorPrefix(QT_TR_NOOP("can't insert or replace shared note")); @@ -8268,9 +8320,10 @@ return true; } -bool LocalStorageManagerPrivate::insertOrReplaceNoteRestrictions(const QString & noteLocalUid, - const qevercloud::NoteRestrictions & noteRestrictions, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::insertOrReplaceNoteRestrictions( + const QString & noteLocalUid, + const qevercloud::NoteRestrictions & noteRestrictions, + ErrorString & errorDescription) { ErrorString errorPrefix(QT_TR_NOOP("can't insert or replace note restrictions")); @@ -8282,13 +8335,12 @@ query.bindValue(QStringLiteral(":noteLocalUid"), noteLocalUid); -#define BIND_RESTRICTION(column, name) \ - query.bindValue(QStringLiteral(":" #column), \ - (noteRestrictions.name.isSet() \ - ? (noteRestrictions.name.ref() \ - ? 1 \ - : 0) \ - : nullValue)) +#define BIND_RESTRICTION(column, name) \ + query.bindValue(QStringLiteral(":" #column), \ + (noteRestrictions.name.isSet() \ + ? (noteRestrictions.name.ref() ? 1 : 0) \ + : nullValue)) \ +// BIND_RESTRICTION BIND_RESTRICTION(noUpdateNoteTitle, noUpdateTitle); BIND_RESTRICTION(noUpdateNoteContent, noUpdateContent); @@ -8304,9 +8356,10 @@ return true; } -bool LocalStorageManagerPrivate::insertOrReplaceNoteLimits(const QString & noteLocalUid, - const qevercloud::NoteLimits & noteLimits, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::insertOrReplaceNoteLimits( + const QString & noteLocalUid, + const qevercloud::NoteLimits & noteLimits, + ErrorString & errorDescription) { ErrorString errorPrefix(QT_TR_NOOP("can't insert or replace note limits")); @@ -8318,11 +8371,12 @@ query.bindValue(QStringLiteral(":noteLocalUid"), noteLocalUid); -#define BIND_LIMIT(limit) \ - query.bindValue(QStringLiteral(":" #limit), \ - (noteLimits.limit.isSet() \ - ? noteLimits.limit.ref() \ - : nullValue)) +#define BIND_LIMIT(limit) \ + query.bindValue(QStringLiteral(":" #limit), \ + (noteLimits.limit.isSet() \ + ? noteLimits.limit.ref() \ + : nullValue)) \ +// BIND_LIMIT BIND_LIMIT(noteResourceCountMax); BIND_LIMIT(uploadLimit); @@ -8344,41 +8398,47 @@ return true; } - QNTRACE(QStringLiteral("Preparing SQL query to insert or replace note")); + QNTRACE("Preparing SQL query to insert or replace note"); m_insertOrReplaceNoteQuery = QSqlQuery(m_sqlDatabase); QString columns = - QStringLiteral("localUid, guid, updateSequenceNumber, isDirty, isLocal, " - "isFavorited, title, titleNormalized, content, contentLength, " - "contentHash, contentPlainText, contentListOfWords, " - "contentContainsFinishedToDo, contentContainsUnfinishedToDo, " + QStringLiteral("localUid, guid, updateSequenceNumber, isDirty, " + "isLocal, isFavorited, title, titleNormalized, content, " + "contentLength, contentHash, contentPlainText, " + "contentListOfWords, contentContainsFinishedToDo, " + "contentContainsUnfinishedToDo, " "contentContainsEncryption, creationTimestamp, " "modificationTimestamp, deletionTimestamp, isActive, " "hasAttributes, thumbnail, notebookLocalUid, notebookGuid, " - "subjectDate, latitude, longitude, altitude, author, source, " - "sourceURL, sourceApplication, shareDate, reminderOrder, " - "reminderDoneTime, reminderTime, placeName, contentClass, " - "lastEditedBy, creatorId, lastEditorId, sharedWithBusiness, " - "conflictSourceNoteGuid, noteTitleQuality, " - "applicationDataKeysOnly, applicationDataKeysMap, " - "applicationDataValues, classificationKeys, classificationValues"); + "subjectDate, latitude, longitude, altitude, author, " + "source, sourceURL, sourceApplication, shareDate, " + "reminderOrder, reminderDoneTime, reminderTime, placeName, " + "contentClass, lastEditedBy, creatorId, lastEditorId, " + "sharedWithBusiness, conflictSourceNoteGuid, " + "noteTitleQuality, applicationDataKeysOnly, " + "applicationDataKeysMap, applicationDataValues, " + "classificationKeys, classificationValues"); QString values = - QStringLiteral(":localUid, :guid, :updateSequenceNumber, :isDirty, :isLocal, " - ":isFavorited, :title, :titleNormalized, :content, :contentLength, " - ":contentHash, :contentPlainText, :contentListOfWords, " - ":contentContainsFinishedToDo, :contentContainsUnfinishedToDo, " + QStringLiteral(":localUid, :guid, :updateSequenceNumber, :isDirty, " + ":isLocal, :isFavorited, :title, :titleNormalized, " + ":content, :contentLength, :contentHash, " + ":contentPlainText, :contentListOfWords, " + ":contentContainsFinishedToDo, " + ":contentContainsUnfinishedToDo, " ":contentContainsEncryption, :creationTimestamp, " ":modificationTimestamp, :deletionTimestamp, :isActive, " - ":hasAttributes, :thumbnail, :notebookLocalUid, :notebookGuid, " - ":subjectDate, :latitude, :longitude, :altitude, :author, " - ":source, :sourceURL, :sourceApplication, :shareDate, " - ":reminderOrder, :reminderDoneTime, :reminderTime, :placeName, " + ":hasAttributes, :thumbnail, :notebookLocalUid, " + ":notebookGuid, :subjectDate, :latitude, :longitude, " + ":altitude, :author, :source, :sourceURL, " + ":sourceApplication, :shareDate, :reminderOrder, " + ":reminderDoneTime, :reminderTime, :placeName, " ":contentClass, :lastEditedBy, :creatorId, :lastEditorId, " - ":sharedWithBusiness, :conflictSourceNoteGuid, :noteTitleQuality, " - ":applicationDataKeysOnly, :applicationDataKeysMap, " - ":applicationDataValues, :classificationKeys, :classificationValues"); + ":sharedWithBusiness, :conflictSourceNoteGuid, " + ":noteTitleQuality, :applicationDataKeysOnly, " + ":applicationDataKeysMap, :applicationDataValues, " + ":classificationKeys, :classificationValues"); QString queryString = QString::fromUtf8("INSERT OR REPLACE INTO Notes(%1) VALUES(%2)") @@ -8398,7 +8458,7 @@ return true; } - QNTRACE(QStringLiteral("Preparing SQL query to insert or replace the shared note")); + QNTRACE("Preparing SQL query to insert or replace the shared note"); m_insertOrReplaceSharedNoteQuery = QSqlQuery(m_sqlDatabase); QString queryString = @@ -8460,7 +8520,7 @@ return true; } - QNTRACE(QStringLiteral("Preparing SQL query to insert or replace note restrictions")); + QNTRACE("Preparing SQL query to insert or replace note restrictions"); m_insertOrReplaceNoteRestrictionsQuery = QSqlQuery(m_sqlDatabase); QString queryString = @@ -8484,15 +8544,16 @@ return true; } - QNTRACE(QStringLiteral("Preparing SQL query to insert or replace note limits")); + QNTRACE("Preparing SQL query to insert or replace note limits"); m_insertOrReplaceNoteLimitsQuery = QSqlQuery(m_sqlDatabase); QString queryString = QStringLiteral("INSERT OR REPLACE INTO NoteLimits " "(noteLocalUid, noteResourceCountMax, uploadLimit, " "resourceSizeMax, noteSizeMax, uploaded) " - "VALUES(:noteLocalUid, :noteResourceCountMax, :uploadLimit, " - ":resourceSizeMax, :noteSizeMax, :uploaded)"); + "VALUES(:noteLocalUid, :noteResourceCountMax, " + ":uploadLimit, :resourceSizeMax, :noteSizeMax, " + ":uploaded)"); bool res = m_insertOrReplaceNoteLimitsQuery.prepare(queryString); if (res) { m_insertOrReplaceNoteLimitsQueryPrepared = true; @@ -8507,7 +8568,7 @@ return true; } - QNTRACE(QStringLiteral("Preparing SQL query to get the noCreateNotes notebook restriction")); + QNTRACE("Preparing SQL query to get the noCreateNotes notebook restriction"); m_canAddNoteToNotebookQuery = QSqlQuery(m_sqlDatabase); QString queryString = @@ -8527,7 +8588,7 @@ return true; } - QNTRACE(QStringLiteral("Preparing SQL query to get the noUpdateNotes notebook restriction")); + QNTRACE("Preparing SQL query to get the noUpdateNotes notebook restriction"); m_canUpdateNoteInNotebookQuery = QSqlQuery(m_sqlDatabase); QString queryString = @@ -8547,7 +8608,7 @@ return true; } - QNTRACE(QStringLiteral("Preparing SQL query to get the noExpungeNotes notebook restriction")); + QNTRACE("Preparing SQL query to get the noExpungeNotes notebook restriction"); m_canExpungeNoteInNotebookQuery = QSqlQuery(m_sqlDatabase); QString queryString = @@ -8567,7 +8628,7 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to insert or replace note into NoteTags table")); + QNDEBUG("Preparing SQL query to insert or replace note into NoteTags table"); m_insertOrReplaceNoteIntoNoteTagsQuery = QSqlQuery(m_sqlDatabase); QString queryString = @@ -8582,8 +8643,8 @@ return res; } -bool LocalStorageManagerPrivate::insertOrReplaceTag(const Tag & tag, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::insertOrReplaceTag( + const Tag & tag, ErrorString & errorDescription) { // NOTE: this method expects to be called after tag is already checked // for sanity of its parameters! @@ -8663,7 +8724,8 @@ } m_getTagCountQuery = QSqlQuery(m_sqlDatabase); - bool res = m_getTagCountQuery.prepare(QStringLiteral("SELECT COUNT(*) FROM Tags")); + bool res = m_getTagCountQuery.prepare( + QStringLiteral("SELECT COUNT(*) FROM Tags")); if (res) { m_getTagCountQueryPrepared = true; } @@ -8695,21 +8757,20 @@ return res; } -bool LocalStorageManagerPrivate::complementTagParentInfo(Tag & tag, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::complementTagParentInfo( + Tag & tag, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::complementTagParentInfo: ") - << tag); + QNDEBUG("LocalStorageManagerPrivate::complementTagParentInfo: " << tag); if (tag.hasParentGuid() && tag.hasParentLocalUid()) { - QNDEBUG(QStringLiteral("The tag has both parent guid and " - "parent local uid, nothing to complement")); + QNDEBUG("The tag has both parent guid and parent local uid, nothing " + "to complement"); return true; } if (!tag.hasParentGuid() && !tag.hasParentLocalUid()) { - QNDEBUG(QStringLiteral("The tag has neither parent guid nor " - "parent local uid, nothing to complement")); + QNDEBUG("The tag has neither parent guid nor parent local uid, nothing " + "to complement"); return true; } @@ -8729,7 +8790,7 @@ QString::fromUtf8("SELECT %1 FROM Tags WHERE %2='%3'") .arg(otherColumn, existingColumn, uid); - QNDEBUG(QStringLiteral("Query string = ") << queryString); + QNDEBUG("Query string = " << queryString); QSqlQuery query(m_sqlDatabase); bool res = query.exec(queryString); @@ -8742,8 +8803,7 @@ } QString otherUid = query.record().value(otherColumn).toString(); - QNTRACE(QStringLiteral("Tag's parent ") << otherColumn - << QStringLiteral(" was retrieved: ") << otherUid); + QNTRACE("Tag's parent " << otherColumn << " was retrieved: " << otherUid); if (tag.hasParentGuid()) { tag.setParentLocalUid(otherUid); @@ -8755,23 +8815,22 @@ return true; } -bool LocalStorageManagerPrivate::insertOrReplaceResource(const Resource & resource, - ErrorString & errorDescription, - const bool setResourceBinaryData, - const bool useSeparateTransaction) +bool LocalStorageManagerPrivate::insertOrReplaceResource( + const Resource & resource, ErrorString & errorDescription, + const bool setResourceBinaryData, const bool useSeparateTransaction) { // NOTE: this method expects to be called after resource is already checked // for sanity of its parameters! - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::insertOrReplaceResource: resource = ") - << resource << QStringLiteral("\nSet resource binary data = ") + QNDEBUG("LocalStorageManagerPrivate::insertOrReplaceResource: resource = " + << resource << "\nSet resource binary data = " << (setResourceBinaryData - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", use separate transaction = ") + ? "true" + : "false") + << ", use separate transaction = " << (useSeparateTransaction - ? QStringLiteral("true") - : QStringLiteral("false"))); + ? "true" + : "false")); ErrorString errorPrefix(QT_TR_NOOP("can't insert or replace resource " "into the local storage database")); @@ -8822,7 +8881,8 @@ { const ResourceRecognitionIndexItem & item = qAsConst(items)[i]; - QVector<ResourceRecognitionIndexItem::TextItem> textItems = item.textItems(); + QVector<ResourceRecognitionIndexItem::TextItem> textItems = + item.textItems(); for(auto it = textItems.constBegin(), end = textItems.constEnd(); it != end; ++it) { @@ -8920,12 +8980,12 @@ return true; } -bool LocalStorageManagerPrivate::writeResourceBinaryDataToFiles(const Resource & resource, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::writeResourceBinaryDataToFiles( + const Resource & resource, ErrorString & errorDescription) { QString resourceLocalUid = resource.localUid(); - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::writeResourceBinaryDataToFiles: " - "resource local uid = ") << resourceLocalUid); + QNDEBUG("LocalStorageManagerPrivate::writeResourceBinaryDataToFiles: " + << "resource local uid = " << resourceLocalUid); ErrorString errorPrefix(QT_TR_NOOP("can't insert or replace resource: failed " "to write resource binary data to files")); @@ -8940,7 +9000,7 @@ } errorDescription.details() += QStringLiteral("resource local uid = "); errorDescription.details() += resourceLocalUid; - QNWARNING(errorDescription << QStringLiteral(", resource: ") << resource); + QNWARNING(errorDescription << ", resource: " << resource); return false; } @@ -8955,7 +9015,7 @@ } errorDescription.details() += QStringLiteral("resource local uid = "); errorDescription.details() += resourceLocalUid; - QNWARNING(errorDescription << QStringLiteral(", resource: ") << resource); + QNWARNING(errorDescription << ", resource: " << resource); return false; } @@ -9086,12 +9146,16 @@ return false; } - QFileInfo backupAlternateDataFileInfo(alternateDataStoragePath + QStringLiteral(".old")); - if (backupAlternateDataFileInfo.exists() && backupAlternateDataFileInfo.isFile() && + QFileInfo backupAlternateDataFileInfo(alternateDataStoragePath + + QStringLiteral(".old")); + if (backupAlternateDataFileInfo.exists() && + backupAlternateDataFileInfo.isFile() && !removeFile(backupAlternateDataFileInfo.absoluteFilePath())) { - errorDescription.setBase(QT_TR_NOOP("failed to remove backup alternate data file")); - errorDescription.details() += backupAlternateDataFileInfo.absoluteFilePath(); + errorDescription.setBase( + QT_TR_NOOP("failed to remove backup alternate data file")); + errorDescription.details() += + backupAlternateDataFileInfo.absoluteFilePath(); QNWARNING(errorDescription); return false; } @@ -9099,24 +9163,21 @@ return true; } -bool LocalStorageManagerPrivate::writeResourceBinaryDataToFile(const QString & resourceLocalUid, - const QString & noteLocalUid, - const QByteArray & dataBody, - const bool isAlternateDataBody, - const bool replaceOriginalFile, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::writeResourceBinaryDataToFile( + const QString & resourceLocalUid, const QString & noteLocalUid, + const QByteArray & dataBody, const bool isAlternateDataBody, + const bool replaceOriginalFile, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::writeResourceBinaryDataToFile: " - "resource local uid = ") << resourceLocalUid - << QStringLiteral(", note local uid = ") << noteLocalUid - << QStringLiteral(", writing") + QNDEBUG("LocalStorageManagerPrivate::writeResourceBinaryDataToFile: " + << "resource local uid = " << resourceLocalUid + << ", note local uid = " << noteLocalUid << ", writing" << (isAlternateDataBody - ? QStringLiteral(" alternate") - : QString()) - << QStringLiteral(" data body; replace original file = ") + ? " alternate" + : "") + << " data body; replace original file = " << (replaceOriginalFile - ? QStringLiteral("true") - : QStringLiteral("false"))); + ? "true" + : "false")); QString storagePath = accountPersistentStoragePath(m_currentAccount); if (isAlternateDataBody) { @@ -9192,9 +9253,11 @@ ErrorString error; bool res = renameFile(newFileName, oldFileName, error); - if (!res) { - errorDescription.setBase(QT_TR_NOOP("failed to atomically replace " - "old resource file with the new one")); + if (!res) + { + errorDescription.setBase( + QT_TR_NOOP("failed to atomically replace " + "old resource file with the new one")); errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); @@ -9206,15 +9269,17 @@ return true; } -bool LocalStorageManagerPrivate::insertOrReplaceResourceAttributes(const QString & localUid, - const qevercloud::ResourceAttributes & attributes, - ErrorString & errorDescription) -{ - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::insertOrReplaceResourceAttributes: " - "local uid = ") << localUid - << QStringLiteral(", resource attributes: ") << attributes); +bool LocalStorageManagerPrivate::insertOrReplaceResourceAttributes( + const QString & localUid, + const qevercloud::ResourceAttributes & attributes, + ErrorString & errorDescription) +{ + QNDEBUG("LocalStorageManagerPrivate::insertOrReplaceResourceAttributes: " + << "local uid = " << localUid << ", resource attributes: " + << attributes); - ErrorString errorPrefix(QT_TR_NOOP("can't insert or replace resource attributes")); + ErrorString errorPrefix( + QT_TR_NOOP("can't insert or replace resource attributes")); QVariant nullValue; @@ -9274,7 +9339,8 @@ DATABASE_CHECK_AND_SET_ERROR() } - // Special treatment for ResourceAttributes.applicationData: keysOnly + fullMap + // Special treatment for ResourceAttributes.applicationData: + // keysOnly + fullMap if (attributes.applicationData.isSet()) { @@ -9309,7 +9375,8 @@ query.bindValue(QStringLiteral(":resourceLocalUid"), localUid); - const QMap<QString, QString> & fullMap = attributes.applicationData->fullMap.ref(); + const QMap<QString, QString> & fullMap = + attributes.applicationData->fullMap.ref(); for(auto it = fullMap.begin(), end = fullMap.end(); it != end; ++it) { const QString & key = it.key(); const QString & value = it.value(); @@ -9324,11 +9391,11 @@ return true; } -bool LocalStorageManagerPrivate::insertOrReplaceResourceMetadata(const Resource & resource, - const bool setResourceDataProperties, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::insertOrReplaceResourceMetadata( + const Resource & resource, const bool setResourceDataProperties, + ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::insertOrReplaceResourceMetadata")); + QNDEBUG("LocalStorageManagerPrivate::insertOrReplaceResourceMetadata"); ErrorString errorPrefix(QT_TR_NOOP("can't insert or replace resource: failed " "to update common resource metadata")); @@ -9412,10 +9479,10 @@ return true; } -bool LocalStorageManagerPrivate::updateNoteResources(const Resource & resource, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::updateNoteResources( + const Resource & resource, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::updateNoteResources")); + QNDEBUG("LocalStorageManagerPrivate::updateNoteResources"); ErrorString errorPrefix(QT_TR_NOOP("can't insert or replace resource: failed " "to update note-resource interconnections")); @@ -9461,12 +9528,12 @@ note.setResources(resources); } -bool LocalStorageManagerPrivate::removeResourceBinaryDataFiles(const Resource & resource, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::removeResourceBinaryDataFiles( + const Resource & resource, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::removeResourceBinaryDataFiles: " - "resource local uid = ") << resource.localUid() - << QStringLiteral(", note local uid = ") + QNDEBUG("LocalStorageManagerPrivate::removeResourceBinaryDataFiles: " + << "resource local uid = " << resource.localUid() + << ", note local uid = " << (resource.hasNoteLocalUid() ? resource.noteLocalUid() : QStringLiteral("<not set>"))); @@ -9545,18 +9612,21 @@ return true; } -bool LocalStorageManagerPrivate::removeResourceBinaryDataFilesForNote(const QString & noteLocalUid, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::removeResourceBinaryDataFilesForNote( + const QString & noteLocalUid, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::removeResourceBinaryDataFilesForNote: " - "note local uid = ") << noteLocalUid); + QNDEBUG("LocalStorageManagerPrivate::removeResourceBinaryDataFilesForNote: " + << "note local uid = " << noteLocalUid); QString accountPath = accountPersistentStoragePath(m_currentAccount); - QString dataPath = accountPath + QStringLiteral("/Resources/data/") + noteLocalUid; - if (!removeDir(dataPath)) { - errorDescription.setBase(QT_TR_NOOP("failed to remove the folder containing " - "note's resource data bodies")); + QString dataPath = accountPath + QStringLiteral("/Resources/data/") + + noteLocalUid; + if (!removeDir(dataPath)) + { + errorDescription.setBase( + QT_TR_NOOP("failed to remove the folder containing " + "note's resource data bodies")); errorDescription.details() = dataPath; QNWARNING(errorDescription); return false; @@ -9564,9 +9634,11 @@ QString alternateDataPath = accountPath + QStringLiteral("/Resources/alternateData/") + noteLocalUid; - if (!removeDir(alternateDataPath)) { - errorDescription.setBase(QT_TR_NOOP("failed to remove the folder containing " - "note's resource alternate data bodies")); + if (!removeDir(alternateDataPath)) + { + errorDescription.setBase( + QT_TR_NOOP("failed to remove the folder containing " + "note's resource alternate data bodies")); errorDescription.details() = alternateDataPath; QNWARNING(errorDescription); return false; @@ -9575,11 +9647,11 @@ return true; } -bool LocalStorageManagerPrivate::removeResourceBinaryDataFilesForNotebook(const Notebook & notebook, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::removeResourceBinaryDataFilesForNotebook( + const Notebook & notebook, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::removeResourceBinaryDataFilesForNotebook: " - "notebook = ") << notebook); + QNDEBUG("LocalStorageManagerPrivate::removeResourceBinaryDataFilesForNotebook: " + << "notebook = " << notebook); ErrorString errorPrefix(QT_TR_NOOP("failed to remove resource data files for " "notebook: cannot list note local uids " @@ -9627,11 +9699,11 @@ return true; } -bool LocalStorageManagerPrivate::removeResourceBinaryDataFilesForLinkedNotebook(const LinkedNotebook & linkedNotebook, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::removeResourceBinaryDataFilesForLinkedNotebook( + const LinkedNotebook & linkedNotebook, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::removeResourceBinaryDataFilesForLinkedNotebook: " - "linked notebook = ") << linkedNotebook); + QNDEBUG("LocalStorageManagerPrivate::removeResourceBinaryDataFilesForLinkedNotebook: " + << "linked notebook = " << linkedNotebook); ErrorString errorPrefix(QT_TR_NOOP("failed to remove resource data files " "for linked notebook: cannot list note " @@ -9641,15 +9713,14 @@ errorDescription.setBase(QT_TR_NOOP("failed to remove resource data files " "for linked notebook: linked notebook " "has no guid set")); - QNWARNING(errorDescription << QStringLiteral(", linked notebook: ") - << linkedNotebook); + QNWARNING(errorDescription << ", linked notebook: " << linkedNotebook); return false; } QString queryString = QString::fromUtf8("SELECT localUid FROM Notes WHERE notebookLocalUid IN " - "(SELECT localUid FROM Notebooks WHERE linkedNotebookGuid = '%1')") - .arg(linkedNotebook.guid()); + "(SELECT localUid FROM Notebooks WHERE " + "linkedNotebookGuid = '%1')").arg(linkedNotebook.guid()); QSqlQuery query(m_sqlDatabase); bool res = query.exec(queryString); @@ -9664,7 +9735,8 @@ QString noteLocalUid = query.value(0).toString(); error.clear(); - if (!removeResourceBinaryDataFilesForNote(noteLocalUid, error)) { + if (!removeResourceBinaryDataFilesForNote(noteLocalUid, error)) + { errorDescription.setBase(QT_TR_NOOP("failed to remove resource data " "files for notebook")); errorDescription.appendBase(error.base()); @@ -9683,7 +9755,7 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to insert or replace the resource with binary data")); + QNDEBUG("Preparing SQL query to insert or replace the resource with binary data"); m_insertOrReplaceResourceMetadataWithDataPropertiesQuery = QSqlQuery(m_sqlDatabase); QString queryString = @@ -9713,7 +9785,7 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to update the resource without binary data")); + QNDEBUG("Preparing SQL query to update the resource without binary data"); m_updateResourceMetadataWithoutDataPropertiesQuery = QSqlQuery(m_sqlDatabase); QString queryString = @@ -9741,8 +9813,8 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to insert or replace resource " - "into NoteResources table")); + QNDEBUG("Preparing SQL query to insert or replace resource " + "into NoteResources table"); m_insertOrReplaceNoteResourceQuery = QSqlQuery(m_sqlDatabase); QString queryString = @@ -9763,8 +9835,8 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to delete resource from " - "ResourceRecognitionData table")); + QNDEBUG("Preparing SQL query to delete resource from " + "ResourceRecognitionData table"); m_deleteResourceFromResourceRecognitionTypesQuery = QSqlQuery(m_sqlDatabase); QString queryString = @@ -9784,8 +9856,8 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to insert or replace resource " - "into ResourceRecognitionData table")); + QNDEBUG("Preparing SQL query to insert or replace resource " + "into ResourceRecognitionData table"); m_insertOrReplaceIntoResourceRecognitionDataQuery = QSqlQuery(m_sqlDatabase); QString queryString = @@ -9807,8 +9879,7 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to delete resource from " - "ResourceAttributes table")); + QNDEBUG("Preparing SQL query to delete resource from ResourceAttributes table"); m_deleteResourceFromResourceAttributesQuery = QSqlQuery(m_sqlDatabase); QString queryString = @@ -9829,8 +9900,8 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to delete Resource from " - "ResourceAttributesApplicationDataKeysOnly table")); + QNDEBUG("Preparing SQL query to delete Resource from " + "ResourceAttributesApplicationDataKeysOnly table"); m_deleteResourceFromResourceAttributesApplicationDataKeysOnlyQuery = QSqlQuery(m_sqlDatabase); @@ -9851,8 +9922,8 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to delete Resource from " - "ResourceAttributesApplicationDataFullMap table")); + QNDEBUG("Preparing SQL query to delete Resource from " + "ResourceAttributesApplicationDataFullMap table"); m_deleteResourceFromResourceAttributesApplicationDataFullMapQuery = QSqlQuery(m_sqlDatabase); @@ -9873,7 +9944,7 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to insert or replace ResourceAttributes")); + QNDEBUG("Preparing SQL query to insert or replace ResourceAttributes"); m_insertOrReplaceResourceAttributesQuery = QSqlQuery(m_sqlDatabase); QString queryString = @@ -9899,8 +9970,8 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to insert or replace resource " - "attribute application data (keys only)")); + QNDEBUG("Preparing SQL query to insert or replace resource " + "attribute application data (keys only)"); m_insertOrReplaceResourceAttributeApplicationDataKeysOnlyQuery = QSqlQuery(m_sqlDatabase); QString queryString = @@ -9921,8 +9992,8 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to insert or replace resource " - "attributes application data (full map)")); + QNDEBUG("Preparing SQL query to insert or replace resource " + "attributes application data (full map)"); m_insertOrReplaceResourceAttributeApplicationDataFullMapQuery = QSqlQuery(m_sqlDatabase); QString queryString = @@ -9943,7 +10014,7 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to get the count of Resources")); + QNDEBUG("Preparing SQL query to get the count of Resources"); m_getResourceCountQuery = QSqlQuery(m_sqlDatabase); QString queryString = QStringLiteral("SELECT COUNT(*) FROM Resources"); @@ -9956,8 +10027,8 @@ return res; } -bool LocalStorageManagerPrivate::insertOrReplaceSavedSearch(const SavedSearch & search, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::insertOrReplaceSavedSearch( + const SavedSearch & search, ErrorString & errorDescription) { // NOTE: this method expects to be called after the search is already checked // for sanity of its parameters! @@ -10045,13 +10116,13 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to insert or replace SavedSearch")); + QNDEBUG("Preparing SQL query to insert or replace SavedSearch"); QString columns = QStringLiteral("localUid, guid, name, nameLower, query, format, " "updateSequenceNumber, isDirty, isLocal, includeAccount, " - "includePersonalLinkedNotebooks, includeBusinessLinkedNotebooks, " - "isFavorited"); + "includePersonalLinkedNotebooks, " + "includeBusinessLinkedNotebooks, isFavorited"); QString valuesNames = QStringLiteral(":localUid, :guid, :name, :nameLower, :query, :format, " @@ -10079,7 +10150,7 @@ return true; } - QNDEBUG(QStringLiteral("Preparing SQL query to get the count of SavedSearches")); + QNDEBUG("Preparing SQL query to get the count of SavedSearches"); m_getSavedSearchCountQuery = QSqlQuery(m_sqlDatabase); QString queryString = QStringLiteral("SELECT COUNT(*) FROM SavedSearches"); @@ -10172,12 +10243,12 @@ return true; } -bool LocalStorageManagerPrivate::readResourceBinaryDataFromFiles(Resource & resource, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::readResourceBinaryDataFromFiles( + Resource & resource, ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::readResourceBinaryDataFromFiles: " - "resource local uid = ") << resource.localUid() - << QStringLiteral(", note local uid = ") + QNDEBUG("LocalStorageManagerPrivate::readResourceBinaryDataFromFiles: " + << "resource local uid = " << resource.localUid() + << ", note local uid = " << (resource.hasNoteLocalUid() ? resource.noteLocalUid() : QStringLiteral("<not set>"))); @@ -10263,20 +10334,18 @@ } LocalStorageManagerPrivate::ReadResourceBinaryDataFromFileStatus::type -LocalStorageManagerPrivate::readResourceBinaryDataFromFile(const QString & resourceLocalUid, - const QString & noteLocalUid, - const bool isAlternateDataBody, - QByteArray & dataBody, - ErrorString & errorDescription) const -{ - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::readResourceBinaryDataFromFile: " - "resource local uid = ") << resourceLocalUid - << QStringLiteral(", note local uid = ") << noteLocalUid - << QStringLiteral(", reading ") +LocalStorageManagerPrivate::readResourceBinaryDataFromFile( + const QString & resourceLocalUid, const QString & noteLocalUid, + const bool isAlternateDataBody, QByteArray & dataBody, + ErrorString & errorDescription) const +{ + QNDEBUG("LocalStorageManagerPrivate::readResourceBinaryDataFromFile: " + << "resource local uid = " << resourceLocalUid + << ", note local uid = " << noteLocalUid << ", reading " << (isAlternateDataBody - ? QStringLiteral("alternate") - : QString()) - << QStringLiteral(" data body")); + ? "alternate" + : "") + << " data body"); QString storagePath = accountPersistentStoragePath(m_currentAccount); if (isAlternateDataBody) { @@ -10286,8 +10355,8 @@ storagePath += QStringLiteral("/Resources/data/"); } - storagePath += - noteLocalUid + QStringLiteral("/") + resourceLocalUid + QStringLiteral(".dat"); + storagePath += noteLocalUid + QStringLiteral("/") + resourceLocalUid + + QStringLiteral(".dat"); QFile resourceDataFile(storagePath); /** @@ -10298,7 +10367,7 @@ if (!resourceDataFile.exists()) { - QNDEBUG(QStringLiteral("Resource data file doesn't exist: ") + QNDEBUG("Resource data file doesn't exist: " << QDir::toNativeSeparators(storagePath)); if (isAlternateDataBody) @@ -10316,16 +10385,14 @@ int res = rename(prevAlternateDataFilePath.toLocal8Bit().constData(), newAlternateDataFilePath.toLocal8Bit().constData()); if (res != 0) { - QNWARNING(QStringLiteral("Failed to recover the previous " - "alternate data file: ") - << prevAlternateDataFilePath << QStringLiteral(": ") + QNWARNING("Failed to recover the previous alternate data file: " + << prevAlternateDataFilePath << ": " << strerror(errno)); return ReadResourceBinaryDataFromFileStatus::FileNotFound; } - QNINFO(QStringLiteral("Recovered alternate resource data from file " - "with \".old\" suffix: ") - << prevAlternateDataFilePath); + QNINFO("Recovered alternate resource data from file " + << "with \".old\" suffix: " << prevAlternateDataFilePath); resourceDataFile.setFileName(storagePath); } } @@ -10351,9 +10418,9 @@ QStringLiteral(".new")); if (newResourceDataFileInfo.exists() && newResourceDataFileInfo.isFile()) { - QNDEBUG(QStringLiteral("Old resource alternate data file exists + " - "resource data file with .new suffix exists " - "=> need to use old resource alternate data file")); + QNDEBUG("Old resource alternate data file exists + " + "resource data file with .new suffix exists " + "=> need to use old resource alternate data file"); resourceDataFile.setFileName(prevAlternateDataFileInfo.absoluteFilePath()); @@ -10365,9 +10432,8 @@ int res = rename(prevAlternateDataFilePath.toLocal8Bit().constData(), newAlternateDataFilePath.toLocal8Bit().constData()); if (res != 0) { - QNWARNING(QStringLiteral("Failed to recover the previous " - "alternate data file: ") - << prevAlternateDataFilePath << QStringLiteral(": ") + QNWARNING("Failed to recover the previous alternate data file: " + << prevAlternateDataFilePath << ": " << strerror(errno)); return ReadResourceBinaryDataFromFileStatus::FileNotFound; } @@ -10378,8 +10444,7 @@ } else { - QNINFO(QStringLiteral("Removing stale leftover resource " - "alternate data file: ") + QNINFO("Removing stale leftover resource alternate data file: " << prevAlternateDataFileInfo.absoluteFilePath()); Q_UNUSED(removeFile(prevAlternateDataFileInfo.absoluteFilePath())); } @@ -10390,7 +10455,7 @@ QFileInfo newDataFileInfo(storagePath + QStringLiteral(".new")); if (newDataFileInfo.exists() && newDataFileInfo.isFile()) { - QNINFO(QStringLiteral("Removing stale leftover resource data file: ") + QNINFO("Removing stale leftover resource data file: " << newDataFileInfo.absoluteFilePath()); Q_UNUSED(removeFile(newDataFileInfo.absoluteFilePath())) } @@ -10408,19 +10473,21 @@ return ReadResourceBinaryDataFromFileStatus::Success; } -void LocalStorageManagerPrivate::fillResourceFromSqlRecord(const QSqlRecord & rec, - Resource & resource) const +void LocalStorageManagerPrivate::fillResourceFromSqlRecord( + const QSqlRecord & rec, Resource & resource) const { -#define CHECK_AND_SET_RESOURCE_PROPERTY(property, type, localType, setter) \ - { \ - int index = rec.indexOf(QStringLiteral(#property)); \ - if (index >= 0) { \ - QVariant value = rec.value(index); \ - if (!value.isNull()) { \ - resource.setter(static_cast<localType>(qvariant_cast<type>(value))); \ - } \ - } \ - } +#define CHECK_AND_SET_RESOURCE_PROPERTY(property, type, localType, setter) \ + { \ + int index = rec.indexOf(QStringLiteral(#property)); \ + if (index >= 0) { \ + QVariant value = rec.value(index); \ + if (!value.isNull()) { \ + resource.setter( \ + static_cast<localType>(qvariant_cast<type>(value))); \ + } \ + } \ + } \ +// CHECK_AND_SET_RESOURCE_PROPERTY CHECK_AND_SET_RESOURCE_PROPERTY(resourceLocalUid, QString, QString, setLocalUid); CHECK_AND_SET_RESOURCE_PROPERTY(resourceIsDirty, int, bool, setDirty); @@ -10465,22 +10532,23 @@ } bool LocalStorageManagerPrivate::fillResourceAttributesFromSqlRecord( - const QSqlRecord & rec, - qevercloud::ResourceAttributes & attributes) const + const QSqlRecord & rec, qevercloud::ResourceAttributes & attributes) const { bool hasSomething = false; -#define CHECK_AND_SET_RESOURCE_ATTRIBUTE(name, property, type, localType) \ - { \ - int index = rec.indexOf(QStringLiteral(#name)); \ - if (index >= 0) { \ - QVariant value = rec.value(index); \ - if (!value.isNull()) { \ - attributes.property = static_cast<localType>(qvariant_cast<type>(value)); \ - hasSomething = true; \ - } \ - } \ - } +#define CHECK_AND_SET_RESOURCE_ATTRIBUTE(name, property, type, localType) \ + { \ + int index = rec.indexOf(QStringLiteral(#name)); \ + if (index >= 0) { \ + QVariant value = rec.value(index); \ + if (!value.isNull()) { \ + attributes.property = \ + static_cast<localType>(qvariant_cast<type>(value)); \ + hasSomething = true; \ + } \ + } \ + } \ +// CHECK_AND_SET_RESOURCE_ATTRIBUTE CHECK_AND_SET_RESOURCE_ATTRIBUTE(resourceSourceURL, sourceURL, QString, QString); CHECK_AND_SET_RESOURCE_ATTRIBUTE(timestamp, timestamp, qint64, qevercloud::Timestamp); @@ -10499,8 +10567,7 @@ } bool LocalStorageManagerPrivate::fillResourceAttributesApplicationDataKeysOnlyFromSqlRecord( - const QSqlRecord & rec, - qevercloud::ResourceAttributes & attributes) const + const QSqlRecord & rec, qevercloud::ResourceAttributes & attributes) const { bool hasSomething = false; @@ -10523,8 +10590,7 @@ } bool LocalStorageManagerPrivate::fillResourceAttributesApplicationDataFullMapFromSqlRecord( - const QSqlRecord & rec, - qevercloud::ResourceAttributes & attributes) const + const QSqlRecord & rec, qevercloud::ResourceAttributes & attributes) const { bool hasSomething = false; @@ -10552,16 +10618,18 @@ void LocalStorageManagerPrivate::fillNoteAttributesFromSqlRecord( const QSqlRecord & rec, qevercloud::NoteAttributes & attributes) const { -#define CHECK_AND_SET_NOTE_ATTRIBUTE(property, type, localType) \ - { \ - int index = rec.indexOf(QStringLiteral(#property)); \ - if (index >= 0) { \ - QVariant value = rec.value(index); \ - if (!value.isNull()) { \ - attributes.property = static_cast<localType>(qvariant_cast<type>(value)); \ - } \ - } \ - } +#define CHECK_AND_SET_NOTE_ATTRIBUTE(property, type, localType) \ + { \ + int index = rec.indexOf(QStringLiteral(#property)); \ + if (index >= 0) { \ + QVariant value = rec.value(index); \ + if (!value.isNull()) { \ + attributes.property = \ + static_cast<localType>(qvariant_cast<type>(value)); \ + } \ + } \ + } \ +// CHECK_AND_SET_NOTE_ATTRIBUTE CHECK_AND_SET_NOTE_ATTRIBUTE(subjectDate, qint64, qevercloud::Timestamp); CHECK_AND_SET_NOTE_ATTRIBUTE(latitude, double, double); @@ -10588,8 +10656,7 @@ } void LocalStorageManagerPrivate::fillNoteAttributesApplicationDataKeysOnlyFromSqlRecord( - const QSqlRecord & rec, - qevercloud::NoteAttributes & attributes) const + const QSqlRecord & rec, qevercloud::NoteAttributes & attributes) const { int keysOnlyIndex = rec.indexOf(QStringLiteral("applicationDataKeysOnly")); if (keysOnlyIndex < 0) { @@ -10653,8 +10720,7 @@ } void LocalStorageManagerPrivate::fillNoteAttributesApplicationDataFullMapFromSqlRecord( - const QSqlRecord & rec, - qevercloud::NoteAttributes & attributes) const + const QSqlRecord & rec, qevercloud::NoteAttributes & attributes) const { int keyIndex = rec.indexOf(QStringLiteral("applicationDataKeysMap")); int valueIndex = rec.indexOf(QStringLiteral("applicationDataValues")); @@ -10758,8 +10824,7 @@ } void LocalStorageManagerPrivate::fillNoteAttributesClassificationsFromSqlRecord( - const QSqlRecord & rec, - qevercloud::NoteAttributes & attributes) const + const QSqlRecord & rec, qevercloud::NoteAttributes & attributes) const { int keyIndex = rec.indexOf(QStringLiteral("classificationKeys")); int valueIndex = rec.indexOf(QStringLiteral("classificationValues")); @@ -10844,29 +10909,30 @@ } } -bool LocalStorageManagerPrivate::fillUserFromSqlRecord(const QSqlRecord & rec, - User & user, - ErrorString & errorDescription) const -{ -#define FIND_AND_SET_USER_PROPERTY(column, setter, type, localType, isRequired) \ - { \ - bool valueFound = false; \ - int index = rec.indexOf(QStringLiteral(#column)); \ - if (index >= 0) { \ - QVariant value = rec.value(QStringLiteral(#column)); \ - if (!value.isNull()) { \ - user.setter(static_cast<localType>(qvariant_cast<type>(value))); \ - valueFound = true; \ - } \ - } \ - \ - if (!valueFound && isRequired) { \ - errorDescription.setBase(QT_TR_NOOP("missing field in the result of SQL query")); \ - errorDescription.details() = QStringLiteral(#column); \ - QNERROR(errorDescription); \ - return false; \ - } \ - } +bool LocalStorageManagerPrivate::fillUserFromSqlRecord( + const QSqlRecord & rec, User & user, ErrorString & errorDescription) const +{ +#define FIND_AND_SET_USER_PROPERTY(column, setter, type, localType, isRequired)\ + { \ + bool valueFound = false; \ + int index = rec.indexOf(QStringLiteral(#column)); \ + if (index >= 0) { \ + QVariant value = rec.value(QStringLiteral(#column)); \ + if (!value.isNull()) { \ + user.setter( \ + static_cast<localType>(qvariant_cast<type>(value))); \ + valueFound = true; \ + } \ + } \ + if (!valueFound && isRequired) { \ + errorDescription.setBase( \ + QT_TR_NOOP("missing field in the result of SQL query")); \ + errorDescription.details() = QStringLiteral(#column); \ + QNERROR(errorDescription); \ + return false; \ + } \ + } \ +// FIND_AND_SET_USER_PROPERTY bool isRequired = true; @@ -10929,17 +10995,19 @@ } } -#define FIND_AND_SET_USER_ATTRIBUTE(column, property, type, localType) \ - { \ - int index = rec.indexOf(QStringLiteral(#column)); \ - if (index >= 0) { \ - QVariant value = rec.value(QStringLiteral(#column)); \ - if (!value.isNull()) { \ - attributes.property = static_cast<localType>(qvariant_cast<type>(value)); \ - foundSomeUserAttribute = true; \ - } \ - } \ - } +#define FIND_AND_SET_USER_ATTRIBUTE(column, property, type, localType) \ + { \ + int index = rec.indexOf(QStringLiteral(#column)); \ + if (index >= 0) { \ + QVariant value = rec.value(QStringLiteral(#column)); \ + if (!value.isNull()) { \ + attributes.property = \ + static_cast<localType>(qvariant_cast<type>(value)); \ + foundSomeUserAttribute = true; \ + } \ + } \ + } \ +// FIND_AND_SET_USER_ATTRIBUTE FIND_AND_SET_USER_ATTRIBUTE(defaultLocationName, defaultLocationName, QString, QString); @@ -10992,17 +11060,19 @@ bool foundSomeAccountingProperty = false; qevercloud::Accounting accounting; -#define FIND_AND_SET_ACCOUNTING_PROPERTY(column, property, type, localType) \ - { \ - int index = rec.indexOf(QStringLiteral(#column)); \ - if (index >= 0) { \ - QVariant value = rec.value(QStringLiteral(#column)); \ - if (!value.isNull()) { \ - accounting.property = static_cast<localType>(qvariant_cast<type>(value)); \ - foundSomeAccountingProperty = true; \ - } \ - } \ - } +#define FIND_AND_SET_ACCOUNTING_PROPERTY(column, property, type, localType) \ + { \ + int index = rec.indexOf(QStringLiteral(#column)); \ + if (index >= 0) { \ + QVariant value = rec.value(QStringLiteral(#column)); \ + if (!value.isNull()) { \ + accounting.property = \ + static_cast<localType>(qvariant_cast<type>(value)); \ + foundSomeAccountingProperty = true; \ + } \ + } \ + } \ +// FIND_AND_SET_ACCOUNTING_PROPERTY FIND_AND_SET_ACCOUNTING_PROPERTY(uploadLimitEnd, uploadLimitEnd, qint64, qevercloud::Timestamp); @@ -11048,17 +11118,19 @@ bool foundSomeAccountLimit = false; qevercloud::AccountLimits accountLimits; -#define FIND_AND_SET_ACCOUNT_LIMIT(property, type, localType) \ - { \ - int index = rec.indexOf(QStringLiteral(#property)); \ - if (index >= 0) { \ - QVariant value = rec.value(QStringLiteral(#property)); \ - if (!value.isNull()) { \ - accountLimits.property = static_cast<localType>(qvariant_cast<type>(value)); \ - foundSomeAccountLimit = true; \ - } \ - } \ - } +#define FIND_AND_SET_ACCOUNT_LIMIT(property, type, localType) \ + { \ + int index = rec.indexOf(QStringLiteral(#property)); \ + if (index >= 0) { \ + QVariant value = rec.value(QStringLiteral(#property)); \ + if (!value.isNull()) { \ + accountLimits.property = \ + static_cast<localType>(qvariant_cast<type>(value)); \ + foundSomeAccountLimit = true; \ + } \ + } \ + } \ +// FIND_AND_SET_ACCOUNT_LIMIT FIND_AND_SET_ACCOUNT_LIMIT(userMailLimitDaily, int, qint32) FIND_AND_SET_ACCOUNT_LIMIT(noteSizeMax, qint64, qint64) @@ -11082,16 +11154,18 @@ qevercloud::BusinessUserInfo businessUserInfo; #define FIND_AND_SET_BUSINESS_USER_INFO_PROPERTY(column, property, type, localType) \ - { \ - int index = rec.indexOf(QStringLiteral(#column)); \ - if (index >= 0) { \ - QVariant value = rec.value(QStringLiteral(#column)); \ - if (!value.isNull()) { \ - businessUserInfo.property = static_cast<localType>(qvariant_cast<type>(value)); \ - foundSomeBusinessUserInfoProperty = true; \ - } \ - } \ - } + { \ + int index = rec.indexOf(QStringLiteral(#column)); \ + if (index >= 0) { \ + QVariant value = rec.value(QStringLiteral(#column)); \ + if (!value.isNull()) { \ + businessUserInfo.property = \ + static_cast<localType>(qvariant_cast<type>(value)); \ + foundSomeBusinessUserInfoProperty = true; \ + } \ + } \ + } \ +// FIND_AND_SET_BUSINESS_USER_INFO_PROPERTY FIND_AND_SET_BUSINESS_USER_INFO_PROPERTY(businessId, businessId, qint32, qint32); @@ -11111,18 +11185,19 @@ return true; } -bool LocalStorageManagerPrivate::fillNoteFromSqlRecord(const QSqlRecord & rec, - Note & note, - ErrorString & errorDescription) const -{ -#define CHECK_AND_SET_NOTE_PROPERTY(propertyLocalName, setter, type, localType) \ - int propertyLocalName##index = rec.indexOf(QStringLiteral(#propertyLocalName)); \ - if (propertyLocalName##index >= 0) { \ - QVariant value = rec.value(propertyLocalName##index); \ - if (!value.isNull()) { \ - note.setter(static_cast<localType>(qvariant_cast<type>(value))); \ - } \ - } +bool LocalStorageManagerPrivate::fillNoteFromSqlRecord( + const QSqlRecord & rec, Note & note, ErrorString & errorDescription) const +{ +#define CHECK_AND_SET_NOTE_PROPERTY(propertyLocalName, setter, type, localType)\ + int propertyLocalName##index = \ + rec.indexOf(QStringLiteral(#propertyLocalName)); \ + if (propertyLocalName##index >= 0) { \ + QVariant value = rec.value(propertyLocalName##index); \ + if (!value.isNull()) { \ + note.setter(static_cast<localType>(qvariant_cast<type>(value))); \ + } \ + } \ +// CHECK_AND_SET_NOTE_PROPERTY CHECK_AND_SET_NOTE_PROPERTY(isDirty, setDirty, int, bool); CHECK_AND_SET_NOTE_PROPERTY(isLocal, setLocal, int, bool); @@ -11155,7 +11230,7 @@ int indexOfThumbnail = rec.indexOf(QStringLiteral("thumbnail")); if (indexOfThumbnail >= 0) { - QNTRACE(QStringLiteral("Found thumbnail data for note within the SQL record")); + QNTRACE("Found thumbnail data for note within the SQL record"); QVariant thumbnailValue = rec.value(indexOfThumbnail); if (!thumbnailValue.isNull()) { @@ -11170,7 +11245,8 @@ QVariant hasAttributesValue = rec.value(hasAttributesIndex); if (!hasAttributesValue.isNull()) { - bool hasAttributes = static_cast<bool>(qvariant_cast<int>(hasAttributesValue)); + bool hasAttributes = + static_cast<bool>(qvariant_cast<int>(hasAttributesValue)); if (hasAttributes) { qevercloud::NoteAttributes & attributes = note.noteAttributes(); @@ -11186,15 +11262,17 @@ bool foundSomeNoteRestriction = false; qevercloud::NoteRestrictions restrictions; -#define CHECK_AND_SET_NOTE_RESTRICTION(column, restriction) \ - int restriction##Index = rec.indexOf(QStringLiteral(#column)); \ - if (restriction##Index >= 0) { \ - QVariant value = rec.value(restriction##Index); \ - if (!value.isNull()) { \ - restrictions.restriction = static_cast<bool>(qvariant_cast<qint32>(value)); \ - foundSomeNoteRestriction = true; \ - } \ - } +#define CHECK_AND_SET_NOTE_RESTRICTION(column, restriction) \ + int restriction##Index = rec.indexOf(QStringLiteral(#column)); \ + if (restriction##Index >= 0) { \ + QVariant value = rec.value(restriction##Index); \ + if (!value.isNull()) { \ + restrictions.restriction = \ + static_cast<bool>(qvariant_cast<qint32>(value)); \ + foundSomeNoteRestriction = true; \ + } \ + } \ +// CHECK_AND_SET_NOTE_RESTRICTION CHECK_AND_SET_NOTE_RESTRICTION(noUpdateNoteTitle, noUpdateTitle) CHECK_AND_SET_NOTE_RESTRICTION(noUpdateNoteContent, noUpdateContent) @@ -11211,15 +11289,16 @@ bool foundSomeNoteLimit = false; qevercloud::NoteLimits limits; -#define CHECK_AND_SET_NOTE_LIMIT(limit, columnType, type) \ - int limit##Index = rec.indexOf(QStringLiteral(#limit)); \ - if (limit##Index >= 0) { \ - QVariant value = rec.value(limit##Index); \ - if (!value.isNull()) { \ - limits.limit = static_cast<type>(qvariant_cast<columnType>(value)); \ - foundSomeNoteLimit = true; \ - } \ - } +#define CHECK_AND_SET_NOTE_LIMIT(limit, columnType, type) \ + int limit##Index = rec.indexOf(QStringLiteral(#limit)); \ + if (limit##Index >= 0) { \ + QVariant value = rec.value(limit##Index); \ + if (!value.isNull()) { \ + limits.limit = static_cast<type>(qvariant_cast<columnType>(value));\ + foundSomeNoteLimit = true; \ + } \ + } \ +// CHECK_AND_SET_NOTE_LIMIT CHECK_AND_SET_NOTE_LIMIT(noteResourceCountMax, qint32, qint32) CHECK_AND_SET_NOTE_LIMIT(uploadLimit, qint64, qint64) @@ -11249,20 +11328,22 @@ return true; } -bool LocalStorageManagerPrivate::fillSharedNoteFromSqlRecord(const QSqlRecord & record, - SharedNote & sharedNote, - ErrorString & errorDescription) const -{ -#define CHECK_AND_SET_SHARED_NOTE_PROPERTY(property, type, localType, setter) \ - { \ - int index = record.indexOf(QStringLiteral(#property)); \ - if (index >= 0) { \ - QVariant value = record.value(index); \ - if (!value.isNull()) { \ - sharedNote.setter(static_cast<localType>(qvariant_cast<type>(value))); \ - } \ - } \ - } +bool LocalStorageManagerPrivate::fillSharedNoteFromSqlRecord( + const QSqlRecord & record, SharedNote & sharedNote, + ErrorString & errorDescription) const +{ +#define CHECK_AND_SET_SHARED_NOTE_PROPERTY(property, type, localType, setter) \ + { \ + int index = record.indexOf(QStringLiteral(#property)); \ + if (index >= 0) { \ + QVariant value = record.value(index); \ + if (!value.isNull()) { \ + sharedNote.setter( \ + static_cast<localType>(qvariant_cast<type>(value))); \ + } \ + } \ + } \ +// CHECK_AND_SET_SHARED_NOTE_PROPERTY CHECK_AND_SET_SHARED_NOTE_PROPERTY(sharedNoteNoteGuid, QString, QString, setNoteGuid) @@ -11332,11 +11413,10 @@ return true; } -bool LocalStorageManagerPrivate::fillNoteTagIdFromSqlRecord(const QSqlRecord & record, - const QString & column, - QList<QPair<QString, int> > & tagIdsAndIndices, - QHash<QString, int> & tagIndexPerId, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::fillNoteTagIdFromSqlRecord( + const QSqlRecord & record, const QString & column, + QList<QPair<QString, int> > & tagIdsAndIndices, + QHash<QString, int> & tagIndexPerId, ErrorString & errorDescription) const { int tagIdIndex = record.indexOf(column); if (tagIdIndex < 0) { @@ -11348,16 +11428,18 @@ return true; } - QVariant tagGuidIndexInNoteValue = record.value(QStringLiteral("tagIndexInNote")); + QVariant tagGuidIndexInNoteValue = + record.value(QStringLiteral("tagIndexInNote")); if (tagGuidIndexInNoteValue.isNull()) { - QNWARNING(QStringLiteral("tag index in note was not found in the result of SQL query")); + QNWARNING("tag index in note was not found in the result of SQL query"); return true; } bool conversionResult = false; int tagIndexInNote = tagGuidIndexInNoteValue.toInt(&conversionResult); if (!conversionResult) { - errorDescription.setBase(QT_TR_NOOP("can't convert tag's index in note to int")); + errorDescription.setBase(QT_TR_NOOP("can't convert tag's index in note " + "to int")); return false; } @@ -11377,28 +11459,29 @@ return true; } -bool LocalStorageManagerPrivate::fillNotebookFromSqlRecord(const QSqlRecord & record, - Notebook & notebook, - ErrorString & errorDescription) const -{ -#define CHECK_AND_SET_NOTEBOOK_ATTRIBUTE(attribute, setter, dbType, trueType, isRequired) \ - { \ - bool valueFound = false; \ - int index = record.indexOf(QStringLiteral( #attribute )); \ - if (index >= 0) { \ - QVariant value = record.value(index); \ - if (!value.isNull()) { \ - notebook.setter(static_cast<trueType>((qvariant_cast<dbType>(value)))); \ - valueFound = true; \ - } \ - } \ - \ - if (!valueFound && isRequired) { \ - errorDescription.setBase(QT_TR_NOOP("missing field in the result of SQL query")); \ - errorDescription.details() = QStringLiteral(#attribute); \ - return false; \ - } \ - } +bool LocalStorageManagerPrivate::fillNotebookFromSqlRecord( + const QSqlRecord & record, Notebook & notebook, + ErrorString & errorDescription) const +{ +#define CHECK_AND_SET_NOTEBOOK_ATTRIBUTE(attribute, setter, dbType, trueType, isRequired) \ + { \ + bool valueFound = false; \ + int index = record.indexOf(QStringLiteral( #attribute )); \ + if (index >= 0) { \ + QVariant value = record.value(index); \ + if (!value.isNull()) { \ + notebook.setter(static_cast<trueType>((qvariant_cast<dbType>(value)))); \ + valueFound = true; \ + } \ + } \ + if (!valueFound && isRequired) { \ + errorDescription.setBase( \ + QT_TR_NOOP("missing field in the result of SQL query")); \ + errorDescription.details() = QStringLiteral(#attribute); \ + return false; \ + } \ + } \ +// CHECK_AND_SET_NOTEBOOK_ATTRIBUTE bool isRequired = true; @@ -11475,12 +11558,14 @@ { if (notebook.hasContact()) { User contact = notebook.contact(); - contact.setId(qvariant_cast<qint32>(record.value(QStringLiteral("contactId")))); + contact.setId( + qvariant_cast<qint32>(record.value(QStringLiteral("contactId")))); notebook.setContact(contact); } else { User contact; - contact.setId(qvariant_cast<qint32>(record.value(QStringLiteral("contactId")))); + contact.setId( + qvariant_cast<qint32>(record.value(QStringLiteral("contactId")))); notebook.setContact(contact); } @@ -11491,16 +11576,17 @@ } } -#define SET_EN_NOTEBOOK_RESTRICTION(notebook_restriction, setter) \ - { \ - int index = record.indexOf(QStringLiteral(#notebook_restriction)); \ - if (index >= 0) { \ - QVariant value = record.value(index); \ - if (!value.isNull()) { \ +#define SET_EN_NOTEBOOK_RESTRICTION(notebook_restriction, setter) \ + { \ + int index = record.indexOf(QStringLiteral(#notebook_restriction)); \ + if (index >= 0) { \ + QVariant value = record.value(index); \ + if (!value.isNull()) { \ notebook.setter(qvariant_cast<int>(value) > 0 ? false : true); \ - } \ - } \ - } + } \ + } \ + } \ +// SET_EN_NOTEBOOK_RESTRICTION SET_EN_NOTEBOOK_RESTRICTION(noReadNotes, setCanReadNotes); SET_EN_NOTEBOOK_RESTRICTION(noCreateNotes, setCanCreateNotes); @@ -11550,20 +11636,22 @@ return true; } -bool LocalStorageManagerPrivate::fillSharedNotebookFromSqlRecord(const QSqlRecord & rec, - SharedNotebook & sharedNotebook, - ErrorString & errorDescription) const -{ -#define CHECK_AND_SET_SHARED_NOTEBOOK_PROPERTY(property, type, localType, setter) \ - { \ - int index = rec.indexOf(QStringLiteral(#property)); \ - if (index >= 0) { \ - QVariant value = rec.value(index); \ - if (!value.isNull()) { \ - sharedNotebook.setter(static_cast<localType>(qvariant_cast<type>(value))); \ - } \ - } \ - } +bool LocalStorageManagerPrivate::fillSharedNotebookFromSqlRecord( + const QSqlRecord & rec, SharedNotebook & sharedNotebook, + ErrorString & errorDescription) const +{ +#define CHECK_AND_SET_SHARED_NOTEBOOK_PROPERTY(property, type, localType, setter) \ + { \ + int index = rec.indexOf(QStringLiteral(#property)); \ + if (index >= 0) { \ + QVariant value = rec.value(index); \ + if (!value.isNull()) { \ + sharedNotebook.setter( \ + static_cast<localType>(qvariant_cast<type>(value))); \ + } \ + } \ + } \ +// CHECK_AND_SET_SHARED_NOTEBOOK_PROPERTY CHECK_AND_SET_SHARED_NOTEBOOK_PROPERTY(sharedNotebookShareId, qint64, qint64, setId) @@ -11621,29 +11709,29 @@ return true; } -bool LocalStorageManagerPrivate::fillLinkedNotebookFromSqlRecord(const QSqlRecord & rec, - LinkedNotebook & linkedNotebook, - ErrorString & errorDescription) const -{ -#define CHECK_AND_SET_LINKED_NOTEBOOK_PROPERTY(property, type, localType, setter, isRequired) \ - { \ - bool valueFound = false; \ - int index = rec.indexOf(QStringLiteral(#property)); \ - if (index >= 0) { \ - QVariant value = rec.value(index); \ - if (!value.isNull()) { \ - linkedNotebook.setter(static_cast<localType>(qvariant_cast<type>(value))); \ - valueFound = true; \ - } \ - } \ - \ - if (!valueFound && isRequired) { \ - errorDescription.setBase(QT_TR_NOOP("missing field in the result of SQL query")); \ - errorDescription.details() = QStringLiteral(#property); \ - QNERROR(errorDescription); \ - return false; \ - } \ - } +bool LocalStorageManagerPrivate::fillLinkedNotebookFromSqlRecord( + const QSqlRecord & rec, LinkedNotebook & linkedNotebook, + ErrorString & errorDescription) const +{ +#define CHECK_AND_SET_LINKED_NOTEBOOK_PROPERTY(property, type, localType, setter, isRequired) \ + { \ + bool valueFound = false; \ + int index = rec.indexOf(QStringLiteral(#property)); \ + if (index >= 0) { \ + QVariant value = rec.value(index); \ + if (!value.isNull()) { \ + linkedNotebook.setter(static_cast<localType>(qvariant_cast<type>(value))); \ + valueFound = true; \ + } \ + } \ + if (!valueFound && isRequired) { \ + errorDescription.setBase(QT_TR_NOOP("missing field in the result of SQL query")); \ + errorDescription.details() = QStringLiteral(#property); \ + QNERROR(errorDescription); \ + return false; \ + } \ + } \ +// CHECK_AND_SET_LINKED_NOTEBOOK_PROPERTY bool isRequired = true; CHECK_AND_SET_LINKED_NOTEBOOK_PROPERTY(guid, QString, QString, setGuid, isRequired); @@ -11678,29 +11766,30 @@ return true; } -bool LocalStorageManagerPrivate::fillSavedSearchFromSqlRecord(const QSqlRecord & rec, - SavedSearch & search, - ErrorString & errorDescription) const -{ -#define CHECK_AND_SET_SAVED_SEARCH_PROPERTY(property, type, localType, setter, isRequired) \ - { \ - bool valueFound = false; \ - int index = rec.indexOf(QStringLiteral(#property)); \ - if (index >= 0) { \ - QVariant value = rec.value(index); \ - if (!value.isNull()) { \ - search.setter(static_cast<localType>(qvariant_cast<type>(value))); \ - valueFound = true; \ - } \ - } \ - \ - if (!valueFound && isRequired) { \ - errorDescription.setBase(QT_TR_NOOP("missing field in the result of SQL query")); \ - errorDescription.details() = QStringLiteral(#property); \ - QNERROR(errorDescription); \ - return false; \ - } \ - } +bool LocalStorageManagerPrivate::fillSavedSearchFromSqlRecord( + const QSqlRecord & rec, SavedSearch & search, + ErrorString & errorDescription) const +{ +#define CHECK_AND_SET_SAVED_SEARCH_PROPERTY(property, type, localType, setter, isRequired) \ + { \ + bool valueFound = false; \ + int index = rec.indexOf(QStringLiteral(#property)); \ + if (index >= 0) { \ + QVariant value = rec.value(index); \ + if (!value.isNull()) { \ + search.setter(static_cast<localType>(qvariant_cast<type>(value))); \ + valueFound = true; \ + } \ + } \ + if (!valueFound && isRequired) { \ + errorDescription.setBase( \ + QT_TR_NOOP("missing field in the result of SQL query")); \ + errorDescription.details() = QStringLiteral(#property); \ + QNERROR(errorDescription); \ + return false; \ + } \ + } \ +// CHECK_AND_SET_SAVED_SEARCH_PROPERTY bool isRequired = false; CHECK_AND_SET_SAVED_SEARCH_PROPERTY(guid, QString, QString, setGuid, isRequired); @@ -11729,29 +11818,29 @@ return true; } -bool LocalStorageManagerPrivate::fillTagFromSqlRecord(const QSqlRecord & rec, - Tag & tag, - ErrorString & errorDescription) const -{ -#define CHECK_AND_SET_TAG_PROPERTY(property, type, localType, setter, isRequired) \ - { \ - bool valueFound = false; \ - int index = rec.indexOf(QStringLiteral(#property)); \ - if (index >= 0) { \ - QVariant value = rec.value(index); \ - if (!value.isNull()) { \ - tag.setter(static_cast<localType>(qvariant_cast<type>(value))); \ - valueFound = true; \ - } \ - } \ - \ - if (!valueFound && isRequired) { \ - errorDescription.setBase(QT_TR_NOOP("missing field in the result of SQL query")); \ - errorDescription.details() = QStringLiteral(#property); \ - QNERROR(errorDescription); \ - return false; \ - } \ - } +bool LocalStorageManagerPrivate::fillTagFromSqlRecord( + const QSqlRecord & rec, Tag & tag, ErrorString & errorDescription) const +{ +#define CHECK_AND_SET_TAG_PROPERTY(property, type, localType, setter, isRequired) \ + { \ + bool valueFound = false; \ + int index = rec.indexOf(QStringLiteral(#property)); \ + if (index >= 0) { \ + QVariant value = rec.value(index); \ + if (!value.isNull()) { \ + tag.setter(static_cast<localType>(qvariant_cast<type>(value))); \ + valueFound = true; \ + } \ + } \ + if (!valueFound && isRequired) { \ + errorDescription.setBase( \ + QT_TR_NOOP("missing field in the result of SQL query")); \ + errorDescription.details() = QStringLiteral(#property); \ + QNERROR(errorDescription); \ + return false; \ + } \ + } \ +// CHECK_AND_SET_TAG_PROPERTY bool isRequired = false; CHECK_AND_SET_TAG_PROPERTY(guid, QString, QString, setGuid, isRequired); @@ -11776,8 +11865,8 @@ return true; } -QList<Tag> LocalStorageManagerPrivate::fillTagsFromSqlQuery(QSqlQuery & query, - ErrorString & errorDescription) const +QList<Tag> LocalStorageManagerPrivate::fillTagsFromSqlQuery( + QSqlQuery & query, ErrorString & errorDescription) const { QList<Tag> tags; tags.reserve(qMax(query.size(), 0)); @@ -11789,7 +11878,8 @@ QString tagLocalUid = query.value(0).toString(); if (tagLocalUid.isEmpty()) { - errorDescription.setBase(QT_TR_NOOP("no tag's local uid in the result of SQL query")); + errorDescription.setBase(QT_TR_NOOP("no tag's local uid in the " + "result of SQL query")); tags.clear(); return tags; } @@ -11806,8 +11896,8 @@ return tags; } -bool LocalStorageManagerPrivate::findAndSetTagIdsPerNote(Note & note, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::findAndSetTagIdsPerNote( + Note & note, ErrorString & errorDescription) const { ErrorString errorPrefix(QT_TR_NOOP("can't find tag guids/local uids per note")); @@ -11867,13 +11957,13 @@ if (!tagGuid.isEmpty() && !checkGuid(tagGuid)) { errorDescription.base() = errorPrefix.base(); - errorDescription.appendBase(QT_TR_NOOP("found invalid tag guid for the requested note")); + errorDescription.appendBase(QT_TR_NOOP("found invalid tag guid for " + "the requested note")); return false; } - QNTRACE(QStringLiteral("Found tag local uid ") << tagLocalUid - << QStringLiteral(" and tag guid ") << tagGuid - << QStringLiteral(" for note with local uid ") << noteLocalUid); + QNTRACE("Found tag local uid " << tagLocalUid << " and tag guid " + << tagGuid << " for note with local uid " << noteLocalUid); int indexInNote = -1; int recordIndex = rec.indexOf(QStringLiteral("tagIndexInNote")); @@ -11961,8 +12051,8 @@ const QString noteLocalUid = note.localUid(); QString queryString = - QString::fromUtf8("SELECT localResource FROM NoteResources WHERE localNote='%1'") - .arg(sqlEscapeString(noteLocalUid)); + QString::fromUtf8("SELECT localResource FROM NoteResources WHERE " + "localNote='%1'").arg(sqlEscapeString(noteLocalUid)); QSqlQuery query(m_sqlDatabase); bool res = query.exec(queryString); @@ -11986,11 +12076,11 @@ QString resourceLocalUid = value.toString(); resourceLocalUids << resourceLocalUid; - QNTRACE(QStringLiteral("Found resource's local uid: ") << resourceLocalUid); + QNTRACE("Found resource's local uid: " << resourceLocalUid); } int numResources = resourceLocalUids.size(); - QNTRACE(QStringLiteral("Found ") << numResources << QStringLiteral(" resources")); + QNTRACE("Found " << numResources << " resources"); ErrorString error; QList<Resource> resources; @@ -12015,8 +12105,8 @@ return false; } - QNTRACE(QStringLiteral("Found resource with local uid ") << resource.localUid() - << QStringLiteral(" for note with local uid ") << noteLocalUid); + QNTRACE("Found resource with local uid " << resource.localUid() + << " for note with local uid " << noteLocalUid); } qSort(resources.begin(), resources.end(), ResourceCompareByIndex()); @@ -12051,9 +12141,9 @@ note.setSharedNotes(sharedNotes); } -bool LocalStorageManagerPrivate::noteSearchQueryToSQL(const NoteSearchQuery & noteSearchQuery, - QString & sql, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::noteSearchQueryToSQL( + const NoteSearchQuery & noteSearchQuery, QString & sql, + ErrorString & errorDescription) const { ErrorString errorPrefix(QT_TR_NOOP("can't convert note search query string into SQL query")); @@ -12457,117 +12547,123 @@ // 6) ============== Processing other better generalizable filters ============= -#define CHECK_AND_PROCESS_ANY_ITEM(hasAnyItem, hasNegatedAnyItem, column) \ - if (noteSearchQuery.hasAnyItem()) { \ - sql += QStringLiteral("(NoteFTS." #column " IS NOT NULL) "); \ - sql += uniteOperator; \ - sql += QStringLiteral(" "); \ - } \ - else if (noteSearchQuery.hasNegatedAnyItem()) { \ - sql += QStringLiteral("(NoteFTS." #column " IS NULL) "); \ - sql += uniteOperator; \ - sql += QStringLiteral(" "); \ - } - -#define CHECK_AND_PROCESS_LIST(list, column, negated, ...) \ - const auto & noteSearchQuery##list##column = noteSearchQuery.list(); \ - if (!noteSearchQuery##list##column.isEmpty()) \ - { \ - sql += QStringLiteral("("); \ - for(auto it = noteSearchQuery##list##column.constBegin(), \ - end = noteSearchQuery##list##column.constEnd(); it != end; ++it) \ - { \ - const auto & item = *it; \ - if (negated) { \ - sql += QStringLiteral("(localUid NOT IN "); \ - } \ - else { \ - sql += QStringLiteral("(localUid IN "); \ - } \ - \ - sql += QStringLiteral("(SELECT localUid FROM NoteFTS WHERE "); \ - sql += QStringLiteral("NoteFTS." #column " MATCH \'"); \ - sql += sqlEscapeString(__VA_ARGS__(item)); \ - sql += QStringLiteral("\')) "); \ - sql += uniteOperator; \ - sql += QStringLiteral(" "); \ - } \ - sql.chop(uniteOperator.length() + 1); \ - sql += QStringLiteral(")"); \ - sql += uniteOperator; \ - sql += QStringLiteral(" "); \ - } - -#define CHECK_AND_PROCESS_NUMERIC_LIST(list, column, negated, ...) \ - const auto & noteSearchQuery##list##column = noteSearchQuery.list(); \ - if (!noteSearchQuery##list##column.isEmpty()) \ - { \ - auto it = noteSearchQuery##list##column.constEnd(); \ - if (queryHasAnyModifier) \ - { \ - if (negated) { \ - it = std::max_element(noteSearchQuery##list##column.constBegin(), \ - noteSearchQuery##list##column.constEnd()); \ - } \ - else { \ - it = std::min_element(noteSearchQuery##list##column.constBegin(), \ - noteSearchQuery##list##column.constEnd()); \ - } \ - } \ - else \ - { \ - if (negated) { \ - it = std::min_element(noteSearchQuery##list##column.constBegin(), \ - noteSearchQuery##list##column.constEnd()); \ - } \ - else { \ - it = std::max_element(noteSearchQuery##list##column.constBegin(), \ - noteSearchQuery##list##column.constEnd()); \ - } \ - } \ - \ - if (it != noteSearchQuery##list##column.constEnd()) \ - { \ - sql += QStringLiteral("(localUid IN (SELECT localUid FROM "); \ - sql += QStringLiteral("Notes WHERE Notes." #column); \ - if (negated) { \ - sql += QStringLiteral(" < "); \ - } \ - else { \ - sql += QStringLiteral(" >= "); \ - } \ - sql += sqlEscapeString(__VA_ARGS__(*it)); \ - sql += QStringLiteral(")) "); \ - sql += uniteOperator; \ - sql += QStringLiteral(" "); \ - } \ - } - -#define CHECK_AND_PROCESS_ITEM(list, negatedList, hasAnyItem, hasNegatedAnyItem, column, ...) \ - CHECK_AND_PROCESS_ANY_ITEM(hasAnyItem, hasNegatedAnyItem, column) \ - else { \ - CHECK_AND_PROCESS_LIST(list, column, !negated, __VA_ARGS__); \ - CHECK_AND_PROCESS_LIST(negatedList, column, negated, __VA_ARGS__); \ - } - -#define CHECK_AND_PROCESS_NUMERIC_ITEM(list, negatedList, hasAnyItem, hasNegatedAnyItem, column, ...) \ - CHECK_AND_PROCESS_ANY_ITEM(hasAnyItem, hasNegatedAnyItem, column) \ - else { \ - CHECK_AND_PROCESS_NUMERIC_LIST(list, column, !negated, __VA_ARGS__); \ - CHECK_AND_PROCESS_NUMERIC_LIST(negatedList, column, negated, __VA_ARGS__); \ - } +#define CHECK_AND_PROCESS_ANY_ITEM(hasAnyItem, hasNegatedAnyItem, column) \ + if (noteSearchQuery.hasAnyItem()) { \ + sql += QStringLiteral("(NoteFTS." #column " IS NOT NULL) "); \ + sql += uniteOperator; \ + sql += QStringLiteral(" "); \ + } \ + else if (noteSearchQuery.hasNegatedAnyItem()) { \ + sql += QStringLiteral("(NoteFTS." #column " IS NULL) "); \ + sql += uniteOperator; \ + sql += QStringLiteral(" "); \ + } \ +// CHECK_AND_PROCESS_ANY_ITEM + +#define CHECK_AND_PROCESS_LIST(list, column, negated, ...) \ + const auto & noteSearchQuery##list##column = noteSearchQuery.list(); \ + if (!noteSearchQuery##list##column.isEmpty()) \ + { \ + sql += QStringLiteral("("); \ + for(auto it = noteSearchQuery##list##column.constBegin(), \ + end = noteSearchQuery##list##column.constEnd(); it != end; ++it) \ + { \ + const auto & item = *it; \ + if (negated) { \ + sql += QStringLiteral("(localUid NOT IN "); \ + } \ + else { \ + sql += QStringLiteral("(localUid IN "); \ + } \ + sql += QStringLiteral("(SELECT localUid FROM NoteFTS WHERE "); \ + sql += QStringLiteral("NoteFTS." #column " MATCH \'"); \ + sql += sqlEscapeString(__VA_ARGS__(item)); \ + sql += QStringLiteral("\')) "); \ + sql += uniteOperator; \ + sql += QStringLiteral(" "); \ + } \ + sql.chop(uniteOperator.length() + 1); \ + sql += QStringLiteral(")"); \ + sql += uniteOperator; \ + sql += QStringLiteral(" "); \ + } \ +// CHECK_AND_PROCESS_LIST + +#define CHECK_AND_PROCESS_NUMERIC_LIST(list, column, negated, ...) \ + const auto & noteSearchQuery##list##column = noteSearchQuery.list(); \ + if (!noteSearchQuery##list##column.isEmpty()) \ + { \ + auto it = noteSearchQuery##list##column.constEnd(); \ + if (queryHasAnyModifier) \ + { \ + if (negated) { \ + it = std::max_element(noteSearchQuery##list##column.constBegin(), \ + noteSearchQuery##list##column.constEnd()); \ + } \ + else { \ + it = std::min_element(noteSearchQuery##list##column.constBegin(), \ + noteSearchQuery##list##column.constEnd()); \ + } \ + } \ + else \ + { \ + if (negated) { \ + it = std::min_element(noteSearchQuery##list##column.constBegin(), \ + noteSearchQuery##list##column.constEnd()); \ + } \ + else { \ + it = std::max_element(noteSearchQuery##list##column.constBegin(), \ + noteSearchQuery##list##column.constEnd()); \ + } \ + } \ + if (it != noteSearchQuery##list##column.constEnd()) \ + { \ + sql += QStringLiteral("(localUid IN (SELECT localUid FROM "); \ + sql += QStringLiteral("Notes WHERE Notes." #column); \ + if (negated) { \ + sql += QStringLiteral(" < "); \ + } \ + else { \ + sql += QStringLiteral(" >= "); \ + } \ + sql += sqlEscapeString(__VA_ARGS__(*it)); \ + sql += QStringLiteral(")) "); \ + sql += uniteOperator; \ + sql += QStringLiteral(" "); \ + } \ + } \ +// CHECK_AND_PROCESS_NUMERIC_LIST + +#define CHECK_AND_PROCESS_ITEM(list, negatedList, hasAnyItem, hasNegatedAnyItem, column, ...) \ + CHECK_AND_PROCESS_ANY_ITEM(hasAnyItem, hasNegatedAnyItem, column) \ + else { \ + CHECK_AND_PROCESS_LIST(list, column, !negated, __VA_ARGS__); \ + CHECK_AND_PROCESS_LIST(negatedList, column, negated, __VA_ARGS__); \ + } \ +// CHECK_AND_PROCESS_ITEM + +#define CHECK_AND_PROCESS_NUMERIC_ITEM(list, negatedList, hasAnyItem, hasNegatedAnyItem, column, ...) \ + CHECK_AND_PROCESS_ANY_ITEM(hasAnyItem, hasNegatedAnyItem, column) \ + else { \ + CHECK_AND_PROCESS_NUMERIC_LIST(list, column, !negated, __VA_ARGS__); \ + CHECK_AND_PROCESS_NUMERIC_LIST(negatedList, column, negated, __VA_ARGS__); \ + } \ +// CHECK_AND_PROCESS_NUMERIC_ITEM bool negated = true; CHECK_AND_PROCESS_ITEM(titleNames, negatedTitleNames, hasAnyTitleName, hasNegatedAnyTitleName, title); CHECK_AND_PROCESS_NUMERIC_ITEM(creationTimestamps, negatedCreationTimestamps, - hasAnyCreationTimestamp, hasNegatedAnyCreationTimestamp, + hasAnyCreationTimestamp, + hasNegatedAnyCreationTimestamp, creationTimestamp, QString::number); - CHECK_AND_PROCESS_NUMERIC_ITEM(modificationTimestamps, negatedModificationTimestamps, + CHECK_AND_PROCESS_NUMERIC_ITEM(modificationTimestamps, + negatedModificationTimestamps, hasAnyModificationTimestamp, hasNegatedAnyModificationTimestamp, modificationTimestamp, QString::number); - CHECK_AND_PROCESS_NUMERIC_ITEM(subjectDateTimestamps, negatedSubjectDateTimestamps, + CHECK_AND_PROCESS_NUMERIC_ITEM(subjectDateTimestamps, + negatedSubjectDateTimestamps, hasAnySubjectDateTimestamp, hasNegatedAnySubjectDateTimestamp, subjectDate, QString::number); @@ -12588,10 +12684,12 @@ hasNegatedAnyContentClass, contentClass); CHECK_AND_PROCESS_ITEM(placeNames, negatedPlaceNames, hasAnyPlaceName, hasNegatedAnyPlaceName, placeName); - CHECK_AND_PROCESS_ITEM(applicationData, negatedApplicationData, hasAnyApplicationData, - hasNegatedAnyApplicationData, applicationDataKeysOnly); - CHECK_AND_PROCESS_ITEM(applicationData, negatedApplicationData, hasAnyApplicationData, - hasNegatedAnyApplicationData, applicationDataKeysMap); + CHECK_AND_PROCESS_ITEM(applicationData, negatedApplicationData, + hasAnyApplicationData, hasNegatedAnyApplicationData, + applicationDataKeysOnly); + CHECK_AND_PROCESS_ITEM(applicationData, negatedApplicationData, + hasAnyApplicationData, hasNegatedAnyApplicationData, + applicationDataKeysMap); CHECK_AND_PROCESS_NUMERIC_ITEM(reminderOrders, negatedReminderOrders, hasAnyReminderOrder, hasNegatedAnyReminderOrder, reminderOrder, QString::number); @@ -12599,7 +12697,8 @@ hasAnyReminderTime, hasNegatedAnyReminderTime, reminderTime, QString::number); CHECK_AND_PROCESS_NUMERIC_ITEM(reminderDoneTimes, negatedReminderDoneTimes, - hasAnyReminderDoneTime, hasNegatedAnyReminderDoneTime, + hasAnyReminderDoneTime, + hasNegatedAnyReminderDoneTime, reminderDoneTime, QString::number); #undef CHECK_AND_PROCESS_ITEM @@ -12672,9 +12771,8 @@ { ErrorString error; QString contentSearchTermsSqlQueryPart; - bool res = noteSearchQueryContentSearchTermsToSQL(noteSearchQuery, - contentSearchTermsSqlQueryPart, - error); + bool res = noteSearchQueryContentSearchTermsToSQL( + noteSearchQuery, contentSearchTermsSqlQueryPart, error); if (!res) { errorDescription.base() = errorPrefix.base(); errorDescription.appendBase(error.base()); @@ -12717,7 +12815,7 @@ sqlPrefix += QStringLiteral("WHERE "); sql.prepend(sqlPrefix); - QNTRACE(QStringLiteral("Prepared SQL query for note search: ") << sql); + QNTRACE("Prepared SQL query for note search: " << sql); return true; } @@ -12725,11 +12823,13 @@ const NoteSearchQuery & noteSearchQuery, QString & sql, ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::noteSearchQueryContentSearchTermsToSQL")); + QNDEBUG("LocalStorageManagerPrivate::noteSearchQueryContentSearchTermsToSQL"); - if (!noteSearchQuery.hasAnyContentSearchTerms()) { - errorDescription.setBase(QT_TR_NOOP("note search query has no advanced search " - "modifiers and no content search terms")); + if (!noteSearchQuery.hasAnyContentSearchTerms()) + { + errorDescription.setBase( + QT_TR_NOOP("note search query has no advanced search " + "modifiers and no content search terms")); errorDescription.details() = noteSearchQuery.queryString(); QNWARNING(errorDescription); return false; @@ -12822,7 +12922,10 @@ m_stringUtils.removeDiacritics(currentSearchTerm); negatedSqlPart += QStringLiteral("("); - contentSearchTermToSQLQueryPart(frontSearchTermModifier, currentSearchTerm, backSearchTermModifier, matchStatement); + contentSearchTermToSQLQueryPart(frontSearchTermModifier, + currentSearchTerm, + backSearchTermModifier, + matchStatement); currentSearchTerm = sqlEscapeString(currentSearchTerm); negatedSqlPart += @@ -12908,14 +13011,14 @@ else { matchStatement = QStringLiteral("MATCH"); - frontSearchTermModifier = QStringLiteral(""); - backSearchTermModifier = QStringLiteral(""); + frontSearchTermModifier = QLatin1String(""); + backSearchTermModifier = QLatin1String(""); } } -bool LocalStorageManagerPrivate::tagNamesToTagLocalUids(const QStringList & tagNames, - QStringList & tagLocalUids, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::tagNamesToTagLocalUids( + const QStringList & tagNames, QStringList & tagLocalUids, + ErrorString & errorDescription) const { ErrorString errorPrefix(QT_TR_NOOP("can't get tag local uids for tag names")); @@ -12956,7 +13059,8 @@ * Unfortunately, stardard SQLite at least from Qt 4.x has standard * query syntax for FTS which does not support whitespaces in search * terms and therefore MATCH function is simply inapplicable here, - * have to use brute-force "equal to X1 or equal to X2 or ... equal to XN + * have to use brute-force "equal to X1 or equal to X2 or ... + * equal to XN" */ queryString = QStringLiteral("SELECT localUid FROM Tags WHERE "); @@ -13015,11 +13119,12 @@ return true; } -bool LocalStorageManagerPrivate::resourceMimeTypesToResourceLocalUids(const QStringList & resourceMimeTypes, - QStringList & resourceLocalUids, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::resourceMimeTypesToResourceLocalUids( + const QStringList & resourceMimeTypes, QStringList & resourceLocalUids, + ErrorString & errorDescription) const { - ErrorString errorPrefix(QT_TR_NOOP("can't get resource mime types for resource local uids")); + ErrorString errorPrefix(QT_TR_NOOP("can't get resource mime types for " + "resource local uids")); resourceLocalUids.clear(); @@ -13061,7 +13166,8 @@ * terms and therefore MATCH function is simply inapplicable here, * have to use brute-force "equal to X1 or equal to X2 or ... equal to XN */ - queryString = QStringLiteral("SELECT resourceLocalUid FROM Resources WHERE "); + queryString = QStringLiteral("SELECT resourceLocalUid FROM " + "Resources WHERE "); for(auto it = resourceMimeTypes.constBegin(), end = resourceMimeTypes.constEnd(); it != end; ++it) @@ -13119,8 +13225,8 @@ return true; } -bool LocalStorageManagerPrivate::complementResourceNoteIds(Resource & resource, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::complementResourceNoteIds( + Resource & resource, ErrorString & errorDescription) const { ErrorString errorPrefix(QT_TR_NOOP("can't complement resource note ids")); @@ -13136,7 +13242,8 @@ DATABASE_CHECK_AND_SET_ERROR() if (query.next()) { - resource.setNoteGuid(query.record().value(QStringLiteral("guid")).toString()); + resource.setNoteGuid( + query.record().value(QStringLiteral("guid")).toString()); } } else if (!resource.hasNoteLocalUid()) @@ -13151,26 +13258,27 @@ DATABASE_CHECK_AND_SET_ERROR() if (query.next()) { - resource.setNoteLocalUid(query.record().value(QStringLiteral("localUid")).toString()); + resource.setNoteLocalUid( + query.record().value(QStringLiteral("localUid")).toString()); } } return true; } -bool LocalStorageManagerPrivate::partialUpdateNoteResources(const QString & noteLocalUid, - const QList<Resource> & updatedNoteResources, - const bool updateResourceBinaryData, - ErrorString & errorDescription) +bool LocalStorageManagerPrivate::partialUpdateNoteResources( + const QString & noteLocalUid, const QList<Resource> & updatedNoteResources, + const bool updateResourceBinaryData, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::partialUpdateNoteResources: " - "note local uid = ") << noteLocalUid - << QStringLiteral(", update resource binary data = ") + QNDEBUG("LocalStorageManagerPrivate::partialUpdateNoteResources: " + "note local uid = " << noteLocalUid + << ", update resource binary data = " << (updateResourceBinaryData - ? QStringLiteral("true") - : QStringLiteral("false"))); + ? "true" + : "false")); - ErrorString errorPrefix(QT_TR_NOOP("can't do the partial update of note's resources")); + ErrorString errorPrefix( + QT_TR_NOOP("can't do the partial update of note's resources")); QString listNoteResourcesQueryString = QString::fromUtf8("SELECT Resources.resourceLocalUid, resourceGuid, " @@ -13198,12 +13306,12 @@ QList<Resource> previousNoteResources; - QNDEBUG(QStringLiteral("Starting to process the query results")); + QNDEBUG("Starting to process the query results"); QString resourceLocalUidProperty = QStringLiteral("resourceLocalUid"); while(query.next()) { - QNDEBUG(QStringLiteral("Processing the query result")); + QNDEBUG("Processing the query result"); QSqlRecord record = query.record(); int resourceLocalUidIndex = record.indexOf(resourceLocalUidProperty); @@ -13211,9 +13319,8 @@ errorDescription.base() = errorPrefix.base(); errorDescription.appendBase(QT_TR_NOOP("can't retrieve the resource " "local uid from the query result")); - QNWARNING(errorDescription << QStringLiteral(", note local uid = ") - << noteLocalUid << QStringLiteral(", note resources: ") - << updatedNoteResources); + QNWARNING(errorDescription << ", note local uid = " << noteLocalUid + << ", note resources: " << updatedNoteResources); return false; } @@ -13248,11 +13355,12 @@ bool changed = false; -#define COMPARE_RESOURCE_PROPERTY(hasProperty, property) \ - changed = changed || \ +#define COMPARE_RESOURCE_PROPERTY(hasProperty, property) \ + changed = changed || \ ( (resource.hasProperty() && previousNoteResource.hasProperty() && \ - (resource.property() != previousNoteResource.property())) || \ - (resource.hasProperty() != previousNoteResource.hasProperty()) ) + (resource.property() != previousNoteResource.property())) || \ + (resource.hasProperty() != previousNoteResource.hasProperty()) )\ +// COMPARE_RESOURCE_PROPERTY COMPARE_RESOURCE_PROPERTY(hasGuid, guid); COMPARE_RESOURCE_PROPERTY(hasNoteGuid, noteGuid); @@ -13339,9 +13447,8 @@ int numAddedResources = addedResources.size(); int numUpdatedResources = updatedResources.size(); - QNDEBUG(QStringLiteral("Number of added resources = ") << numAddedResources - << QStringLiteral(", number of updated resources = ") - << numUpdatedResources); + QNDEBUG("Number of added resources = " << numAddedResources + << ", number of updated resources = " << numUpdatedResources); if (!updateResourceBinaryData && (numAddedResources != 0)) { @@ -13351,13 +13458,15 @@ "contains new resources")); QStringList addedResourcesLocalUids; addedResourcesLocalUids.reserve(numAddedResources); - for(auto it = addedResources.constBegin(), end = addedResources.constEnd(); it != end; ++it) { + for(auto it = addedResources.constBegin(), + end = addedResources.constEnd(); it != end; ++it) + { addedResourcesLocalUids << it->localUid(); } - QNWARNING(errorDescription << QStringLiteral(", note local uid = ") - << noteLocalUid << QStringLiteral(", new resources local uids: ") + QNWARNING(errorDescription << ", note local uid = " + << noteLocalUid << ", new resources local uids: " << addedResourcesLocalUids.join(QStringLiteral(", ")) - << QStringLiteral(", note resources: ") << updatedNoteResources); + << ", note resources: " << updatedNoteResources); return false; } @@ -13374,7 +13483,7 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(errorDescription << QStringLiteral(", resource: ") << resource); + QNWARNING(errorDescription << ", resource: " << resource); return false; } @@ -13389,7 +13498,7 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(errorDescription << QStringLiteral(", resource: ") << resource); + QNWARNING(errorDescription << ", resource: " << resource); return false; } } @@ -13406,7 +13515,7 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(errorDescription << QStringLiteral(", resource: ") << resource); + QNWARNING(errorDescription << ", resource: " << resource); return false; } @@ -13421,7 +13530,7 @@ errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); - QNWARNING(errorDescription << QStringLiteral(", resource: ") << resource); + QNWARNING(errorDescription << ", resource: " << resource); return false; } } @@ -13446,7 +13555,7 @@ void LocalStorageManagerPrivate::clearCachedQueries() { - QNDEBUG(QStringLiteral("LocalStorageManagerPrivate::clearCachedQueries")); + QNDEBUG("LocalStorageManagerPrivate::clearCachedQueries"); m_insertOrReplaceSavedSearchQuery = QSqlQuery(); m_insertOrReplaceSavedSearchQueryPrepared = false; @@ -13893,8 +14002,8 @@ } template <class T> -bool LocalStorageManagerPrivate::fillObjectsFromSqlQuery(QSqlQuery query, QList<T> & objects, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::fillObjectsFromSqlQuery( + QSqlQuery query, QList<T> & objects, ErrorString & errorDescription) const { objects.reserve(std::max(query.size(), 0)); @@ -13915,9 +14024,8 @@ } template <> -bool LocalStorageManagerPrivate::fillObjectsFromSqlQuery(QSqlQuery query, - QList<Note> & notes, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::fillObjectsFromSqlQuery( + QSqlQuery query, QList<Note> & notes, ErrorString & errorDescription) const { QMap<QString, int> indexForLocalUid; @@ -13963,9 +14071,9 @@ } template <> -bool LocalStorageManagerPrivate::fillObjectsFromSqlQuery<Notebook>(QSqlQuery query, - QList<Notebook> & notebooks, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::fillObjectsFromSqlQuery<Notebook>( + QSqlQuery query, QList<Notebook> & notebooks, + ErrorString & errorDescription) const { QMap<QString, int> indexForLocalUid; @@ -14013,33 +14121,31 @@ } template<> -bool LocalStorageManagerPrivate::fillObjectFromSqlRecord<SavedSearch>(const QSqlRecord & rec, - SavedSearch & search, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::fillObjectFromSqlRecord<SavedSearch>( + const QSqlRecord & rec, SavedSearch & search, + ErrorString & errorDescription) const { return fillSavedSearchFromSqlRecord(rec, search, errorDescription); } template<> -bool LocalStorageManagerPrivate::fillObjectFromSqlRecord<Tag>(const QSqlRecord & rec, - Tag & tag, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::fillObjectFromSqlRecord<Tag>( + const QSqlRecord & rec, Tag & tag, ErrorString & errorDescription) const { return fillTagFromSqlRecord(rec, tag, errorDescription); } template<> -bool LocalStorageManagerPrivate::fillObjectFromSqlRecord<LinkedNotebook>(const QSqlRecord & rec, - LinkedNotebook & linkedNotebook, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::fillObjectFromSqlRecord<LinkedNotebook>( + const QSqlRecord & rec, LinkedNotebook & linkedNotebook, + ErrorString & errorDescription) const { return fillLinkedNotebookFromSqlRecord(rec, linkedNotebook, errorDescription); } template <> -bool LocalStorageManagerPrivate::fillObjectFromSqlRecord<Notebook>(const QSqlRecord & rec, - Notebook & notebook, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::fillObjectFromSqlRecord<Notebook>( + const QSqlRecord & rec, Notebook & notebook, ErrorString & errorDescription) const { bool res = fillNotebookFromSqlRecord(rec, notebook, errorDescription); if (!res) { @@ -14051,9 +14157,8 @@ } template<> -bool LocalStorageManagerPrivate::fillObjectFromSqlRecord<Note>(const QSqlRecord & rec, - Note & note, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::fillObjectFromSqlRecord<Note>( + const QSqlRecord & rec, Note & note, ErrorString & errorDescription) const { bool res = fillNoteFromSqlRecord(rec, note, errorDescription); if (!res) { @@ -14065,9 +14170,9 @@ } template <> -bool LocalStorageManagerPrivate::fillObjectsFromSqlQuery(QSqlQuery query, - QList<std::pair<Tag, QStringList> > & tagsWithNoteLocalUids, - ErrorString & errorDescription) const +bool LocalStorageManagerPrivate::fillObjectsFromSqlQuery( + QSqlQuery query, QList<std::pair<Tag, QStringList> > & tagsWithNoteLocalUids, + ErrorString & errorDescription) const { tagsWithNoteLocalUids.reserve(std::max(query.size(), 0)); @@ -14089,16 +14194,16 @@ template <class T, class TOrderBy> -QList<T> LocalStorageManagerPrivate::listObjects(const LocalStorageManager::ListObjectsOptions & flag, - ErrorString & errorDescription, - const size_t limit, - const size_t offset, - const TOrderBy & orderBy, - const LocalStorageManager::OrderDirection::type & orderDirection, - const QString & additionalSqlQueryCondition) const +QList<T> LocalStorageManagerPrivate::listObjects( + const LocalStorageManager::ListObjectsOptions & flag, + ErrorString & errorDescription, const size_t limit, const size_t offset, + const TOrderBy & orderBy, + const LocalStorageManager::OrderDirection::type & orderDirection, + const QString & additionalSqlQueryCondition) const { ErrorString flagError; - QString sqlQueryConditions = listObjectsOptionsToSqlQueryConditions<T>(flag, flagError); + QString sqlQueryConditions = + listObjectsOptionsToSqlQueryConditions<T>(flag, flagError); if (sqlQueryConditions.isEmpty() && !flagError.isEmpty()) { errorDescription = flagError; return QList<T>(); @@ -14159,7 +14264,7 @@ queryString += QStringLiteral(" OFFSET ") + QString::number(offset); } - QNDEBUG(QStringLiteral("SQL query string: ") << queryString); + QNDEBUG("SQL query string: " << queryString); QList<T> objects; @@ -14170,8 +14275,8 @@ bool res = query.exec(queryString); if (!res) { errorDescription.base() = errorPrefix.base(); - QNERROR(errorDescription << QStringLiteral(", last query = ") - << query.lastQuery() << QStringLiteral(", last error = ") + QNERROR(errorDescription << ", last query = " + << query.lastQuery() << ", last error = " << query.lastError()); errorDescription.details() = query.lastError().text(); return objects; @@ -14189,31 +14294,31 @@ return objects; } - QNDEBUG(QStringLiteral("found ") << objects.size() << QStringLiteral(" objects")); + QNDEBUG("found " << objects.size() << " objects"); return objects; } -bool LocalStorageManagerPrivate::SharedNotebookCompareByIndex::operator()(const SharedNotebook & lhs, - const SharedNotebook & rhs) const +bool LocalStorageManagerPrivate::SharedNotebookCompareByIndex::operator()( + const SharedNotebook & lhs, const SharedNotebook & rhs) const { return (lhs.indexInNotebook() < rhs.indexInNotebook()); } -bool LocalStorageManagerPrivate::SharedNoteCompareByIndex::operator()(const SharedNote & lhs, - const SharedNote & rhs) const +bool LocalStorageManagerPrivate::SharedNoteCompareByIndex::operator()( + const SharedNote & lhs, const SharedNote & rhs) const { return (lhs.indexInNote() < rhs.indexInNote()); } -bool LocalStorageManagerPrivate::ResourceCompareByIndex::operator()(const Resource & lhs, - const Resource & rhs) const +bool LocalStorageManagerPrivate::ResourceCompareByIndex::operator()( + const Resource & lhs, const Resource & rhs) const { return (lhs.indexInNote() < rhs.indexInNote()); } -bool LocalStorageManagerPrivate::QStringIntPairCompareByInt::operator()(const QPair<QString, int> & lhs, - const QPair<QString, int> & rhs) const +bool LocalStorageManagerPrivate::QStringIntPairCompareByInt::operator()( + const QPair<QString, int> & lhs, const QPair<QString, int> & rhs) const { return (lhs.second < rhs.second); } diff -Nru libquentier-0.5.0/src/local_storage/LocalStoragePatchManager.cpp libquentier-0.5.0/src/local_storage/LocalStoragePatchManager.cpp --- libquentier-0.5.0/src/local_storage/LocalStoragePatchManager.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/local_storage/LocalStoragePatchManager.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -19,8 +19,10 @@ #include "LocalStoragePatchManager.h" #include "LocalStorageManager_p.h" #include "patches/LocalStoragePatch1To2.h" + #include <quentier/types/ErrorString.h> #include <quentier/logging/QuentierLogger.h> + #include <iterator> namespace quentier { @@ -43,10 +45,10 @@ ErrorString errorDescription; int version = m_localStorageManager.localStorageVersion(errorDescription); if (version <= 0) { - QNWARNING(QStringLiteral("LocalStoragePatchManager::" - "patchInfoForCurrentLocalStorageVersion: " - "unable to determine the current local " - "storage version")); + QNWARNING("LocalStoragePatchManager::" + "patchInfoForCurrentLocalStorageVersion: " + "unable to determine the current local " + "storage version"); return result; } diff -Nru libquentier-0.5.0/src/local_storage/LocalStorageShared.cpp libquentier-0.5.0/src/local_storage/LocalStorageShared.cpp --- libquentier-0.5.0/src/local_storage/LocalStorageShared.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/local_storage/LocalStorageShared.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -17,7 +17,9 @@ */ #include "LocalStorageShared.h" + #include <quentier/utility/Macros.h> + #include <QMap> #include <QVariant> diff -Nru libquentier-0.5.0/src/local_storage/LocalStorageShared.h libquentier-0.5.0/src/local_storage/LocalStorageShared.h --- libquentier-0.5.0/src/local_storage/LocalStorageShared.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/local_storage/LocalStorageShared.h 2019-07-11 10:46:53.000000000 +0000 @@ -23,14 +23,16 @@ namespace quentier { -#define DATABASE_CHECK_AND_SET_ERROR() \ - if (!res) { \ - errorDescription.base() = errorPrefix.base(); \ - errorDescription.details() = query.lastError().text(); \ - QNERROR(errorDescription << QStringLiteral(", last executed query: ") \ - << lastExecutedQuery(query)); \ - return false; \ - } +#define DATABASE_CHECK_AND_SET_ERROR() \ + if (!res) \ + { \ + errorDescription.base() = errorPrefix.base(); \ + errorDescription.details() = query.lastError().text(); \ + QNERROR(errorDescription << ", last executed query: " \ + << lastExecutedQuery(query)); \ + return false; \ + } \ +// DATABASE_CHECK_AND_SET_ERROR QString lastExecutedQuery(const QSqlQuery & query); diff -Nru libquentier-0.5.0/src/local_storage/NoteSearchQuery.cpp libquentier-0.5.0/src/local_storage/NoteSearchQuery.cpp --- libquentier-0.5.0/src/local_storage/NoteSearchQuery.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/local_storage/NoteSearchQuery.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -17,6 +17,7 @@ */ #include <quentier/local_storage/NoteSearchQuery.h> + #include "NoteSearchQueryData.h" namespace quentier { diff -Nru libquentier-0.5.0/src/local_storage/NoteSearchQueryData.cpp libquentier-0.5.0/src/local_storage/NoteSearchQueryData.cpp --- libquentier-0.5.0/src/local_storage/NoteSearchQueryData.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/local_storage/NoteSearchQueryData.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -568,36 +568,42 @@ { const char * indent = " "; - strm << QStringLiteral("NoteSearchQuery: { \n"); - strm << indent << QStringLiteral("query string: ") + strm << "NoteSearchQuery: { \n"; + strm << indent << "query string: " << (m_queryString.isEmpty() ? QStringLiteral("<empty>") : m_queryString) - << QStringLiteral("; \n"); - strm << indent << QStringLiteral("notebookModifier: ") + << "; \n"; + strm << indent << "notebookModifier: " << (m_notebookModifier.isEmpty() ? QStringLiteral("<empty>") : m_notebookModifier) - << QStringLiteral("; \n"); - strm << indent << QStringLiteral("hasAnyModifier: ") - << (m_hasAnyModifier ? QStringLiteral("true") : QStringLiteral("false")) - << QStringLiteral("\n"); - -#define CHECK_AND_PRINT_ANY_ITEM(name) \ - if (m_hasAny##name) { \ - strm << indent << QStringLiteral("hasAny" #name " is true; \n"); \ - } \ - if (m_hasNegatedAny##name) { \ - strm << indent << QStringLiteral("hasNegatedAny" #name "is true; \n"); \ - } - -#define CHECK_AND_PRINT_LIST(name, type, ...) \ - if (m_##name.isEmpty()) { \ - strm << indent << QStringLiteral( #name " is empty; \n"); \ - } \ - else { \ - strm << indent << QStringLiteral( #name ": { \n"); \ - for(auto it = m_##name.constBegin(), end = m_##name.constEnd(); it != end; ++it) { \ - strm << indent << indent << __VA_ARGS__ (*it) << QStringLiteral("; \n"); \ - } \ - strm << indent << "}; \n"; \ - } + << "; \n"; + strm << indent << "hasAnyModifier: " + << (m_hasAnyModifier ? "true" : "false") + << "\n"; + +#define CHECK_AND_PRINT_ANY_ITEM(name) \ + if (m_hasAny##name) { \ + strm << indent << "hasAny" #name " is true; \n"; \ + } \ + if (m_hasNegatedAny##name) { \ + strm << indent << "hasNegatedAny" #name "is true; \n"; \ + } \ +// CHECK_AND_PRINT_ANY_ITEM + +#define CHECK_AND_PRINT_LIST(name, type, ...) \ + if (m_##name.isEmpty()) \ + { \ + strm << indent << #name " is empty; \n"; \ + } \ + else \ + { \ + strm << indent << #name ": { \n"; \ + for(auto it = m_##name.constBegin(), \ + end = m_##name.constEnd(); it != end; ++it) \ + { \ + strm << indent << indent << __VA_ARGS__ (*it) << "; \n"; \ + } \ + strm << indent << "}; \n"; \ + } \ +// CHECK_AND_PRINT_LIST CHECK_AND_PRINT_ANY_ITEM(Tag); CHECK_AND_PRINT_LIST(tagNames, QString); @@ -671,46 +677,32 @@ CHECK_AND_PRINT_LIST(reminderDoneTimes, qint64, QString::number); CHECK_AND_PRINT_LIST(negatedReminderDoneTimes, qint64, QString::number); - strm << indent << QStringLiteral("hasUnfinishedToDo: ") - << (m_hasUnfinishedToDo - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral("; \n"); - strm << indent << QStringLiteral("hasNegatedUnfinishedToDo: ") - << (m_hasNegatedUnfinishedToDo - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral("; \n"); - strm << indent << QStringLiteral("hasFinishedToDo: ") - << (m_hasFinishedToDo - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral("; \n"); - strm << indent << QStringLiteral("hasNegatedFinishedToDo: ") - << (m_hasNegatedFinishedToDo - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral("; \n"); - strm << indent << QStringLiteral("hasAnyToDo: ") - << (m_hasAnyToDo - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral("; \n"); - strm << indent << QStringLiteral("hasNegatedAnyTodo: ") + strm << indent << "hasUnfinishedToDo: " + << (m_hasUnfinishedToDo ? "true" : "false") + << "; \n"; + strm << indent << "hasNegatedUnfinishedToDo: " + << (m_hasNegatedUnfinishedToDo ? "true" : "false") + << "; \n"; + strm << indent << "hasFinishedToDo: " + << (m_hasFinishedToDo ? "true" : "false") + << "; \n"; + strm << indent << "hasNegatedFinishedToDo: " + << (m_hasNegatedFinishedToDo ? "true" : "false") + << "; \n"; + strm << indent << "hasAnyToDo: " + << (m_hasAnyToDo ? "true" : "false") + << "; \n"; + strm << indent << "hasNegatedAnyTodo: " << (m_hasNegatedAnyToDo - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(" \n"); - strm << indent << QStringLiteral("hasEncryption: ") - << (m_hasEncryption - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral("\n"); - strm << indent << QStringLiteral("hasNegatedEncryption: ") - << (m_hasNegatedEncryption - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(" \n"); + ? "true" + : "false") + << " \n"; + strm << indent << "hasEncryption: " + << (m_hasEncryption ? "true" : "false") + << "\n"; + strm << indent << "hasNegatedEncryption: " + << (m_hasNegatedEncryption ? "true" : "false") + << " \n"; CHECK_AND_PRINT_LIST(contentSearchTerms, QString); CHECK_AND_PRINT_LIST(negatedContentSearchTerms, QString); @@ -718,7 +710,7 @@ #undef CHECK_AND_PRINT_LIST #undef CHECK_AND_PRINT_ANY_ITEM - strm << QStringLiteral("}; \n"); + strm << "}; \n"; return strm; } diff -Nru libquentier-0.5.0/src/local_storage/patches/LocalStoragePatch1To2.cpp libquentier-0.5.0/src/local_storage/patches/LocalStoragePatch1To2.cpp --- libquentier-0.5.0/src/local_storage/patches/LocalStoragePatch1To2.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/local_storage/patches/LocalStoragePatch1To2.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -39,17 +39,21 @@ #include <QThread> #include <QPointer> -#define UPGRADE_1_TO_2_PERSISTENCE \ - QStringLiteral("LocalStorageDatabaseUpgradeFromVersion1ToVersion2") - -#define UPGRADE_1_TO_2_ALL_RESOURCE_DATA_COPIED_FROM_TABLE_TO_FILES_KEY \ - QStringLiteral("AllResourceDataCopiedFromTableToFiles") - -#define UPGRADE_1_TO_2_LOCAL_UIDS_FOR_RESOURCES_COPIED_TO_FILES_KEY \ - QStringLiteral("LocalUidsOfResourcesCopiedToFiles") - -#define UPGRADE_1_TO_2_ALL_RESOURCE_DATA_REMOVED_FROM_RESOURCE_TABLE \ - QStringLiteral("AllResourceDataRemovedFromResourceTable") +#define UPGRADE_1_TO_2_PERSISTENCE \ + QStringLiteral("LocalStorageDatabaseUpgradeFromVersion1ToVersion2") \ +// UPGRADE_1_TO_2_PERSISTENCE + +#define UPGRADE_1_TO_2_ALL_RESOURCE_DATA_COPIED_FROM_TABLE_TO_FILES_KEY \ + QStringLiteral("AllResourceDataCopiedFromTableToFiles") \ +// UPGRADE_1_TO_2_ALL_RESOURCE_DATA_COPIED_FROM_TABLE_TO_FILES_KEY + +#define UPGRADE_1_TO_2_LOCAL_UIDS_FOR_RESOURCES_COPIED_TO_FILES_KEY \ + QStringLiteral("LocalUidsOfResourcesCopiedToFiles") \ +// UPGRADE_1_TO_2_LOCAL_UIDS_FOR_RESOURCES_COPIED_TO_FILES_KEY + +#define UPGRADE_1_TO_2_ALL_RESOURCE_DATA_REMOVED_FROM_RESOURCE_TABLE \ + QStringLiteral("AllResourceDataRemovedFromResourceTable") \ +// UPGRADE_1_TO_2_ALL_RESOURCE_DATA_REMOVED_FROM_RESOURCE_TABLE #define RESOURCE_LOCAL_UID QStringLiteral("resourceLocalUid") @@ -92,12 +96,12 @@ ErrorString errorDescription; int numResources = m_localStorageManager.enResourceCount(errorDescription); if (Q_UNLIKELY(numResources < 0)) { - QNWARNING(QStringLiteral("Can't get the number of resources within " - "the local storage database: ") << errorDescription); + QNWARNING("Can't get the number of resources within " + << "the local storage database: " << errorDescription); } else { - QNINFO(QStringLiteral("Before applying local storage 1-to-2 patch: ") - << numResources << QStringLiteral(" resources within the local storage")); + QNINFO("Before applying local storage 1-to-2 patch: " + << numResources << " resources within the local storage"); result += QStringLiteral(" ("); result += QString::number(numResources); result += QStringLiteral(")"); @@ -124,7 +128,7 @@ bool LocalStoragePatch1To2::backupLocalStorage(ErrorString & errorDescription) { - QNINFO(QStringLiteral("LocalStoragePatch1To2::backupLocalStorage")); + QNINFO("LocalStoragePatch1To2::backupLocalStorage"); QString storagePath = accountPersistentStoragePath(m_account); @@ -239,7 +243,7 @@ bool LocalStoragePatch1To2::restoreLocalStorageFromBackup(ErrorString & errorDescription) { - QNINFO(QStringLiteral("LocalStoragePatch1To2::restoreLocalStorageFromBackup")); + QNINFO("LocalStoragePatch1To2::restoreLocalStorageFromBackup"); QString storagePath = accountPersistentStoragePath(m_account); @@ -360,7 +364,7 @@ bool LocalStoragePatch1To2::removeLocalStorageBackup(ErrorString & errorDescription) { - QNINFO(QStringLiteral("LocalStoragePatch1To2::removeLocalStorageBackup")); + QNINFO("LocalStoragePatch1To2::removeLocalStorageBackup"); QString storagePath = accountPersistentStoragePath(m_account); @@ -370,7 +374,7 @@ if (shmDbBackupFileInfo.exists() && !removeFile(shmDbBackupFileInfo.absoluteFilePath())) { - QNDEBUG(QStringLiteral("Failed to remove the SQLite shm file's backup: ") + QNDEBUG("Failed to remove the SQLite shm file's backup: " << shmDbBackupFileInfo.absoluteFilePath()); removedShmDbBackup = false; } @@ -381,7 +385,7 @@ if (walDbBackupFileInfo.exists() && !removeFile(walDbBackupFileInfo.absoluteFilePath())) { - QNDEBUG(QStringLiteral("Failed to remove the SQLite wal file's backup: ") + QNDEBUG("Failed to remove the SQLite wal file's backup: " << walDbBackupFileInfo.absoluteFilePath()); removedWalDbBackup = false; } @@ -391,7 +395,7 @@ if (dbBackupFileInfo.exists() && !removeFile(dbBackupFileInfo.absoluteFilePath())) { - QNWARNING(QStringLiteral("Failed to remove the SQLite database's backup: ") + QNWARNING("Failed to remove the SQLite database's backup: " << dbBackupFileInfo.absoluteFilePath()); removedDbBackup = false; } @@ -408,7 +412,7 @@ bool LocalStoragePatch1To2::apply(ErrorString & errorDescription) { - QNINFO(QStringLiteral("LocalStoragePatch1To2::apply")); + QNINFO("LocalStoragePatch1To2::apply"); ApplicationSettings databaseUpgradeInfo(m_account, UPGRADE_1_TO_2_PERSISTENCE); @@ -481,26 +485,29 @@ QByteArray dataBody; QByteArray alternateDataBody; -#define EXTRACT_ENTRY(name, type) \ - { \ - int index = rec.indexOf(QStringLiteral(#name)); \ - if (index >= 0) { \ - QVariant value = rec.value(index); \ - if (!value.isNull()) { \ - name = qvariant_cast<type>(value); \ - } \ - } \ - else if (required) { \ - errorDescription = errorPrefix; \ - errorDescription.appendBase(QT_TRANSLATE_NOOP("LocalStoragePatch1To2", \ - "failed to get resource " \ - "data from local storage " \ - "database")); \ - errorDescription.details() = QStringLiteral(#name); \ - QNWARNING(errorDescription); \ - return false; \ - } \ - } +#define EXTRACT_ENTRY(name, type) \ + { \ + int index = rec.indexOf(QStringLiteral(#name)); \ + if (index >= 0) \ + { \ + QVariant value = rec.value(index); \ + if (!value.isNull()) { \ + name = qvariant_cast<type>(value); \ + } \ + } \ + else if (required) \ + { \ + errorDescription = errorPrefix; \ + errorDescription.appendBase( \ + QT_TRANSLATE_NOOP("LocalStoragePatch1To2", \ + "failed to get resource data from the local "\ + "storage database")); \ + errorDescription.details() = QStringLiteral(#name); \ + QNWARNING(errorDescription); \ + return false; \ + } \ + } \ +// EXTRACT_ENTRY bool required = true; EXTRACT_ENTRY(noteLocalUid, QString) @@ -585,9 +592,9 @@ databaseUpgradeInfo.setArrayIndex(processedResourceCounter); databaseUpgradeInfo.setValue(RESOURCE_LOCAL_UID, resourceLocalUid); lastProgress += singleResourceProgressFraction; - QNDEBUG(QStringLiteral("Processed resource data (no alternate data) ") - << QStringLiteral("for resource local uid ") - << resourceLocalUid << QStringLiteral("; updated progress to ") + QNDEBUG("Processed resource data (no alternate data) " + << "for resource local uid " + << resourceLocalUid << "; updated progress to " << lastProgress); Q_EMIT progress(lastProgress); continue; @@ -670,16 +677,16 @@ databaseUpgradeInfo.setArrayIndex(processedResourceCounter); databaseUpgradeInfo.setValue(RESOURCE_LOCAL_UID, resourceLocalUid); lastProgress += singleResourceProgressFraction; - QNDEBUG(QStringLiteral("Processed resource data and alternate data ") - << QStringLiteral("for resource local uid ") << resourceLocalUid - << QStringLiteral("; updated progress to ") << lastProgress); + QNDEBUG("Processed resource data and alternate data " + << "for resource local uid " << resourceLocalUid + << "; updated progress to " << lastProgress); Q_EMIT progress(lastProgress); } pProcessedResourceLocalUidsDatabaseUpgradeInfoCloser.reset(Q_NULLPTR); - QNDEBUG(QStringLiteral("Copied data bodies and alternate data bodies of " - "all resources from database to files")); + QNDEBUG("Copied data bodies and alternate data bodies of " + "all resources from database to files"); // Part 4: as data and alternate data for all resources has been written // to files, need to mark that fact in database upgrade persistence @@ -708,8 +715,8 @@ DATABASE_CHECK_AND_SET_ERROR() } - QNDEBUG(QStringLiteral("Set data bodies and alternate data bodies for " - "resources to null in the database table")); + QNDEBUG("Set data bodies and alternate data bodies for " + "resources to null in the database table"); Q_EMIT progress(0.8); // 5.2 Compact the database to reduce its size and make it faster to operate @@ -723,7 +730,7 @@ return false; } - QNDEBUG(QStringLiteral("Compacted the local storage database")); + QNDEBUG("Compacted the local storage database"); Q_EMIT progress(0.9); // 5.3 Mark the removal of resource tables in upgrade persistence @@ -739,7 +746,7 @@ query.exec(QStringLiteral("INSERT OR REPLACE INTO Auxiliary (version) VALUES(2)")); DATABASE_CHECK_AND_SET_ERROR() - QNDEBUG(QStringLiteral("Finished upgrading the local storage from version 1 to version 2")); + QNDEBUG("Finished upgrading the local storage from version 1 to version 2"); return true; } @@ -785,9 +792,8 @@ void LocalStoragePatch1To2::filterResourceLocalUidsForDatabaseUpgradeFromVersion1ToVersion2( QStringList & resourceLocalUids) { - QNDEBUG(QStringLiteral("LocalStoragePatch1To2::" - "filterResourceLocalUidsForDatabaseUpgrade" - "FromVersion1ToVersion2")); + QNDEBUG("LocalStoragePatch1To2::filterResourceLocalUidsForDatabaseUpgrade" + "FromVersion1ToVersion2"); ApplicationSettings databaseUpgradeInfo(m_account, UPGRADE_1_TO_2_PERSISTENCE); @@ -811,8 +817,8 @@ bool LocalStoragePatch1To2::ensureExistenceOfResouceDataDirsForDatabaseUpgradeFromVersion1ToVersion2( ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("LocalStoragePatch1To2::ensureExistenceOfResouceDataDirs" - "ForDatabaseUpgradeFromVersion1ToVersion2")); + QNDEBUG("LocalStoragePatch1To2::ensureExistenceOfResouceDataDirs" + "ForDatabaseUpgradeFromVersion1ToVersion2"); QString storagePath = accountPersistentStoragePath(m_account); @@ -851,7 +857,7 @@ void LocalStoragePatch1To2::startLocalStorageBackup() { - QNDEBUG(QStringLiteral("LocalStoragePatch1To2::startLocalStorageBackup")); + QNDEBUG("LocalStoragePatch1To2::startLocalStorageBackup"); QString storagePath = accountPersistentStoragePath(m_account); QString sourceDbFilePath = storagePath + QStringLiteral("/qn.storage.sqlite"); @@ -861,7 +867,7 @@ void LocalStoragePatch1To2::startLocalStorageRestorationFromBackup() { - QNDEBUG(QStringLiteral("LocalStoragePatch1To2::startLocalStorageRestorationFromBackup")); + QNDEBUG("LocalStoragePatch1To2::startLocalStorageRestorationFromBackup"); QString storagePath = accountPersistentStoragePath(m_account); QString sourceDbFilePath = storagePath + QStringLiteral("/qn.storage.sqlite"); diff -Nru libquentier-0.5.0/src/local_storage/Transaction.cpp libquentier-0.5.0/src/local_storage/Transaction.cpp --- libquentier-0.5.0/src/local_storage/Transaction.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/local_storage/Transaction.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,8 +18,10 @@ #include "Transaction.h" #include "LocalStorageManager_p.h" + #include <quentier/exception/DatabaseSqlErrorException.h> #include <quentier/logging/QuentierLogger.h> + #include <QSqlQuery> #include <QSqlError> @@ -90,7 +92,7 @@ errorDescription.setBase( QT_TRANSLATE_NOOP("Transaction", "Can't commit the SQL transaction")); errorDescription.details() = query.lastError().text(); - QNWARNING(errorDescription << QStringLiteral(", full last query error: ") + QNWARNING(errorDescription << ", full last query error: " << query.lastError()); return false; } @@ -115,7 +117,7 @@ errorDescription.setBase( QT_TRANSLATE_NOOP("Transaction", "Can't rollback the SQL transaction")); errorDescription.details() = query.lastError().text(); - QNWARNING(errorDescription << QStringLiteral(", full last query error: ") + QNWARNING(errorDescription << ", full last query error: " << query.lastError()); return false; } @@ -142,7 +144,7 @@ errorDescription.setBase( QT_TRANSLATE_NOOP("Transaction", "Can't end the SQL transaction")); errorDescription.details() = query.lastError().text(); - QNWARNING(errorDescription << QStringLiteral(", full last query error: ") + QNWARNING(errorDescription << ", full last query error: " << query.lastError()); return false; } @@ -164,8 +166,7 @@ QSqlQuery query(m_db); bool res = query.exec(queryString); if (!res) { - QNERROR(QStringLiteral("Error beginning the SQL transaction: ") - << query.lastError()); + QNERROR("Error beginning the SQL transaction: " << query.lastError()); ErrorString errorDescription( QT_TRANSLATE_NOOP("Transaction", "Can't begin the SQL transaction")); errorDescription.details() = query.lastError().text(); diff -Nru libquentier-0.5.0/src/logging/QuentierLogger.cpp libquentier-0.5.0/src/logging/QuentierLogger.cpp --- libquentier-0.5.0/src/logging/QuentierLogger.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/logging/QuentierLogger.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -1,3 +1,21 @@ +/* + * Copyright 2016-2019 Dmitry Ivanov + * + * This file is part of libquentier + * + * libquentier is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * libquentier 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with libquentier. If not, see <http://www.gnu.org/licenses/>. + */ + #include <quentier/logging/QuentierLogger.h> #include "QuentierLogger_p.h" #include <QCoreApplication> @@ -14,7 +32,8 @@ const QString & message, const LogLevel::type logLevel) { QString relativeSourceFileName = sourceFileName; - int prefixIndex = relativeSourceFileName.indexOf(QStringLiteral("libquentier"), Qt::CaseInsensitive); + int prefixIndex = relativeSourceFileName.indexOf(QStringLiteral("libquentier"), + Qt::CaseInsensitive); if (prefixIndex >= 0) { relativeSourceFileName.remove(0, prefixIndex); } @@ -49,7 +68,8 @@ logEntry += QStringLiteral("Error]: "); break; default: - logEntry += QStringLiteral("Unknown log level: ") + QString::number(logLevel) + QStringLiteral("]: "); + logEntry += QStringLiteral("Unknown log level: ") + + QString::number(logLevel) + QStringLiteral("]: "); break; } diff -Nru libquentier-0.5.0/src/logging/QuentierLogger_p.cpp libquentier-0.5.0/src/logging/QuentierLogger_p.cpp --- libquentier-0.5.0/src/logging/QuentierLogger_p.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/logging/QuentierLogger_p.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -1,3 +1,21 @@ +/* + * Copyright 2016-2019 Dmitry Ivanov + * + * This file is part of libquentier + * + * libquentier is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * libquentier 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with libquentier. If not, see <http://www.gnu.org/licenses/>. + */ + #include "QuentierLogger_p.h" #include <quentier/exception/LoggerInitializationException.h> #include <quentier/utility/StandardPaths.h> @@ -18,9 +36,10 @@ namespace quentier { -QuentierFileLogWriter::QuentierFileLogWriter(const MaxSizeBytes & maxSizeBytes, - const MaxOldLogFilesCount & maxOldLogFilesCount, - QObject * parent) : +QuentierFileLogWriter::QuentierFileLogWriter( + const MaxSizeBytes & maxSizeBytes, + const MaxOldLogFilesCount & maxOldLogFilesCount, + QObject * parent) : IQuentierLogWriter(parent), m_logFile(), m_pStream(), @@ -41,11 +60,13 @@ } } - QString logFileName = logFileDirPath + QStringLiteral("/") + QCoreApplication::applicationName() + + QString logFileName = logFileDirPath + QStringLiteral("/") + + QCoreApplication::applicationName() + QStringLiteral("-log.txt"); m_logFile.setFileName(logFileName); - bool opened = m_logFile.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Unbuffered | QIODevice::Text); + bool opened = m_logFile.open(QIODevice::WriteOnly | QIODevice::Append | + QIODevice::Unbuffered | QIODevice::Text); if (Q_UNLIKELY(!opened)) { ErrorString error(QT_TR_NOOP("Can't open the log file for writing/appending")); error.details() = m_logFile.errorString(); @@ -56,11 +77,14 @@ m_currentLogFileSize = m_logFile.size(); - // Seek for old log files with indices from 1 to m_maxOldLogFilesCount, count the existing ones + // Seek for old log files with indices from 1 to m_maxOldLogFilesCount, + // count the existing ones for(int i = 1; i < m_maxOldLogFilesCount; ++i) { - const QString previousLogFilePath = logFileDirPath + QStringLiteral("/") + QCoreApplication::applicationName() + - QStringLiteral("-log.") + QString::number(i) + QStringLiteral(".txt"); + const QString previousLogFilePath = logFileDirPath + QStringLiteral("/") + + QCoreApplication::applicationName() + + QStringLiteral("-log.") + + QString::number(i) + QStringLiteral(".txt"); if (QFile::exists(previousLogFilePath)) { ++m_currentOldLogFilesCount; } @@ -75,8 +99,11 @@ void QuentierFileLogWriter::write(QString message) { - DateTimePrint::Options options(DateTimePrint::IncludeMilliseconds | DateTimePrint::IncludeTimezone); - message.prepend(printableDateTimeFromTimestamp(QDateTime::currentMSecsSinceEpoch(), options) + QStringLiteral(" ")); + DateTimePrint::Options options(DateTimePrint::IncludeMilliseconds | + DateTimePrint::IncludeTimezone); + message.prepend(printableDateTimeFromTimestamp( + QDateTime::currentMSecsSinceEpoch(), + options) + QStringLiteral(" ")); qint64 messageSize = message.toUtf8().size(); m_currentLogFileSize += messageSize; @@ -137,24 +164,31 @@ // 1) Rename all the existing old log files for(int i = m_currentOldLogFilesCount; i >= 1; --i) { - const QString previousLogFilePath = logFileDirPath + QStringLiteral("/") + QCoreApplication::applicationName() + - QStringLiteral("-log.") + QString::number(i) + QStringLiteral(".txt"); + const QString previousLogFilePath = logFileDirPath + QStringLiteral("/") + + QCoreApplication::applicationName() + + QStringLiteral("-log.") + + QString::number(i) + QStringLiteral(".txt"); QFile previousLogFile(previousLogFilePath); if (Q_UNLIKELY(!previousLogFile.exists())) { continue; } - const QString newLogFilePath = logFileDirPath + QStringLiteral("/") + QCoreApplication::applicationName() + - QStringLiteral("-log.") + QString::number(i+1) + QStringLiteral(".txt"); + const QString newLogFilePath = logFileDirPath + QStringLiteral("/") + + QCoreApplication::applicationName() + + QStringLiteral("-log.") + + QString::number(i + 1) + QStringLiteral(".txt"); // Just-in-case check, shouldn't really do anything in normal circumstances Q_UNUSED(QFile::remove(newLogFilePath)) bool res = previousLogFile.rename(newLogFilePath); if (Q_UNLIKELY(!res)) { - std::cerr << "Can't rename one of previous libquentier log files for log file rotation: attempted to rename from " - << qPrintable(previousLogFilePath) << " to " << qPrintable(newLogFilePath) << ", error: " << qPrintable(previousLogFile.errorString()) - << " (error code " << qPrintable(QString::number(previousLogFile.error())) << ")\n"; + std::cerr << "Can't rename one of previous libquentier log files for " + << "log file rotation: attempted to rename from " + << qPrintable(previousLogFilePath) << " to " + << qPrintable(newLogFilePath) << ", error: " + << qPrintable(previousLogFile.errorString()) << " (error code " + << qPrintable(QString::number(previousLogFile.error())) << ")\n"; } } @@ -163,19 +197,27 @@ m_pStream->setDevice(Q_NULLPTR); } m_logFile.close(); - bool res = m_logFile.rename(logFileDirPath + QStringLiteral("/") + QCoreApplication::applicationName() + QStringLiteral("-log.1.txt")); + bool res = m_logFile.rename(logFileDirPath + QStringLiteral("/") + + QCoreApplication::applicationName() + + QStringLiteral("-log.1.txt")); if (Q_UNLIKELY(!res)) { - std::cerr << "Can't rename the current libquentier log file for log file rotation, error: " << qPrintable(m_logFile.errorString()) - << " (error code " << qPrintable(QString::number(m_logFile.error())) << ")\n"; + std::cerr << "Can't rename the current libquentier log file for log file " + << "rotation, error: " << qPrintable(m_logFile.errorString()) + << " (error code " << qPrintable(QString::number(m_logFile.error())) + << ")\n"; return; } // 3) Open the new file - m_logFile.setFileName(logFileDirPath + QStringLiteral("/") + QCoreApplication::applicationName() + QStringLiteral("-log.txt")); - bool opened = m_logFile.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Unbuffered | QIODevice::Text); + m_logFile.setFileName(logFileDirPath + QStringLiteral("/") + + QCoreApplication::applicationName() + + QStringLiteral("-log.txt")); + bool opened = m_logFile.open(QIODevice::WriteOnly | QIODevice::Append | + QIODevice::Unbuffered | QIODevice::Text); if (Q_UNLIKELY(!opened)) { - std::cerr << "Can't open the renamed/rotated libquentier log file, error: " << qPrintable(m_logFile.errorString()) - << " (error code " << qPrintable(QString::number(m_logFile.error())) << ")\n"; + std::cerr << "Can't open the renamed/rotated libquentier log file, error: " + << qPrintable(m_logFile.errorString()) << " (error code " + << qPrintable(QString::number(m_logFile.error())) << ")\n"; return; } @@ -194,11 +236,15 @@ } // 5) If got here, there are too many old log files, need to remove the oldest one - QString oldestLogFilePath = logFileDirPath + QStringLiteral("/") + QCoreApplication::applicationName() + QStringLiteral("-log.") + - QString::number(m_currentOldLogFilesCount) + QStringLiteral(".txt"); + QString oldestLogFilePath = logFileDirPath + QStringLiteral("/") + + QCoreApplication::applicationName() + + QStringLiteral("-log.") + + QString::number(m_currentOldLogFilesCount) + + QStringLiteral(".txt"); res = QFile::remove(oldestLogFilePath); if (Q_UNLIKELY(!res)) { - std::cerr << "Can't remove the oldest previous libquentier log file: " << qPrintable(oldestLogFilePath) << "\n"; + std::cerr << "Can't remove the oldest previous libquentier log file: " + << qPrintable(oldestLogFilePath) << "\n"; return; } @@ -231,14 +277,16 @@ QObject(parent), m_pImpl(Q_NULLPTR) { - // NOTE: since C++11 static construction is thread-safe so if we use C++11, we don't need to lock anything ourselves + // NOTE: since C++11 static construction is thread-safe so if we use C++11, + // we don't need to lock anything ourselves #if __cplusplus < 201103L QMutexLocker locker(&m_constructionMutex); #endif if (!m_pImpl) { m_pImpl = new QuentierLoggerImpl(this); - addLogWriter(new QuentierFileLogWriter(MaxSizeBytes(104857600), MaxOldLogFilesCount(2))); + addLogWriter(new QuentierFileLogWriter(MaxSizeBytes(104857600), + MaxOldLogFilesCount(2))); } } @@ -249,7 +297,8 @@ void QuentierLogger::addLogWriter(IQuentierLogWriter * pLogWriter) { - for(auto it = m_pImpl->m_logWriterPtrs.constBegin(), end = m_pImpl->m_logWriterPtrs.constEnd(); it != end; ++it) + for(auto it = m_pImpl->m_logWriterPtrs.constBegin(), + end = m_pImpl->m_logWriterPtrs.constEnd(); it != end; ++it) { if (Q_UNLIKELY(it->data() == pLogWriter)) { return; @@ -262,7 +311,8 @@ pLogWriter, QNSLOT(IQuentierLogWriter,write,QString), Qt::QueuedConnection); - QuentierFileLogWriter * pFileLogWriter = qobject_cast<QuentierFileLogWriter*>(pLogWriter); + QuentierFileLogWriter * pFileLogWriter = + qobject_cast<QuentierFileLogWriter*>(pLogWriter); if (pFileLogWriter) { QObject::connect(this, QNSIGNAL(QuentierLogger,sendRestartLoggingRequest), pFileLogWriter, QNSLOT(QuentierFileLogWriter,restartLogging), @@ -276,7 +326,8 @@ void QuentierLogger::removeLogWriter(IQuentierLogWriter * pLogWriter) { bool found = false; - for(auto it = m_pImpl->m_logWriterPtrs.begin(), end = m_pImpl->m_logWriterPtrs.end(); it != end; ++it) + for(auto it = m_pImpl->m_logWriterPtrs.begin(), + end = m_pImpl->m_logWriterPtrs.end(); it != end; ++it) { if (Q_LIKELY(it->data() != pLogWriter)) { continue; @@ -330,8 +381,10 @@ m_minLogLevel(static_cast<int>(LogLevel::InfoLevel)), m_pLogWriteThread(new QThread) { - QObject::connect(m_pLogWriteThread, QNSIGNAL(QThread,finished), m_pLogWriteThread, QNSLOT(QThread,deleteLater)); - QObject::connect(this, QNSIGNAL(QuentierLoggerImpl,destroyed), m_pLogWriteThread, QNSLOT(QThread,quit)); + QObject::connect(m_pLogWriteThread, QNSIGNAL(QThread,finished), + m_pLogWriteThread, QNSLOT(QThread,deleteLater)); + QObject::connect(this, QNSIGNAL(QuentierLoggerImpl,destroyed), + m_pLogWriteThread, QNSLOT(QThread,quit)); m_pLogWriteThread->setObjectName(QStringLiteral("Libquentier-logger-thread")); m_pLogWriteThread->start(QThread::LowPriority); } diff -Nru libquentier-0.5.0/src/logging/QuentierLogger_p.h libquentier-0.5.0/src/logging/QuentierLogger_p.h --- libquentier-0.5.0/src/logging/QuentierLogger_p.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/logging/QuentierLogger_p.h 2019-07-11 10:46:53.000000000 +0000 @@ -1,3 +1,21 @@ +/* + * Copyright 2016-2019 Dmitry Ivanov + * + * This file is part of libquentier + * + * libquentier is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * libquentier 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with libquentier. If not, see <http://www.gnu.org/licenses/>. + */ + #ifndef LIB_QUENTIER_LOGGING_QUENTIER_LOGGER_PRIVATE_H #define LIB_QUENTIER_LOGGING_QUENTIER_LOGGER_PRIVATE_H diff -Nru libquentier-0.5.0/src/note_editor/delegates/AddHyperlinkToSelectedTextDelegate.cpp libquentier-0.5.0/src/note_editor/delegates/AddHyperlinkToSelectedTextDelegate.cpp --- libquentier-0.5.0/src/note_editor/delegates/AddHyperlinkToSelectedTextDelegate.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/delegates/AddHyperlinkToSelectedTextDelegate.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -19,7 +19,9 @@ #include "AddHyperlinkToSelectedTextDelegate.h" #include "../NoteEditor_p.h" #include "../dialogs/EditHyperlinkDialog.h" + #include <quentier/logging/QuentierLogger.h> + #include <QScopedPointer> #ifndef QUENTIER_USE_QT_WEB_ENGINE @@ -28,16 +30,18 @@ namespace quentier { -#define GET_PAGE() \ - NoteEditorPage * page = qobject_cast<NoteEditorPage*>(m_noteEditor.page()); \ - if (Q_UNLIKELY(!page)) { \ - ErrorString error(QT_TRANSLATE_NOOP("AddHyperlinkToSelectedTextDelegate", \ - "Can't add hyperlink to the selected "\ - "text: no note editor page")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } +#define GET_PAGE() \ + NoteEditorPage * page = qobject_cast<NoteEditorPage*>(m_noteEditor.page());\ + if (Q_UNLIKELY(!page)) { \ + ErrorString error( \ + QT_TRANSLATE_NOOP("AddHyperlinkToSelectedTextDelegate", \ + "Can't add hyperlink to the selected " \ + "text: no note editor page")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// GET_PAGE AddHyperlinkToSelectedTextDelegate::AddHyperlinkToSelectedTextDelegate( NoteEditorPrivate & noteEditor, const quint64 hyperlinkIdToAdd) : @@ -51,7 +55,7 @@ void AddHyperlinkToSelectedTextDelegate::start() { - QNDEBUG(QStringLiteral("AddHyperlinkToSelectedTextDelegate::start")); + QNDEBUG("AddHyperlinkToSelectedTextDelegate::start"); if (m_noteEditor.isEditorPageModified()) { @@ -71,9 +75,9 @@ void AddHyperlinkToSelectedTextDelegate::startWithPresetHyperlink( const QString & presetHyperlink, const QString & replacementLinkText) { - QNDEBUG(QStringLiteral("AddHyperlinkToSelectedTextDelegate::") - << QStringLiteral("startWithPresetHyperlink: preset hyperlink = ") - << presetHyperlink << QStringLiteral(", replacement link text = ") + QNDEBUG("AddHyperlinkToSelectedTextDelegate::" + << "startWithPresetHyperlink: preset hyperlink = " + << presetHyperlink << ", replacement link text = " << replacementLinkText); m_shouldGetHyperlinkFromDialog = false; @@ -85,8 +89,8 @@ void AddHyperlinkToSelectedTextDelegate::onOriginalPageConvertedToNote(Note note) { - QNDEBUG(QStringLiteral("AddHyperlinkToSelectedTextDelegate::" - "onOriginalPageConvertedToNote")); + QNDEBUG("AddHyperlinkToSelectedTextDelegate::" + "onOriginalPageConvertedToNote"); Q_UNUSED(note) @@ -101,8 +105,8 @@ void AddHyperlinkToSelectedTextDelegate::addHyperlinkToSelectedText() { - QNDEBUG(QStringLiteral("AddHyperlinkToSelectedTextDelegate::" - "addHyperlinkToSelectedText")); + QNDEBUG("AddHyperlinkToSelectedTextDelegate::" + "addHyperlinkToSelectedText"); if (m_shouldGetHyperlinkFromDialog || m_replacementLinkText.isEmpty()) { @@ -123,8 +127,8 @@ void AddHyperlinkToSelectedTextDelegate::onInitialHyperlinkDataReceived( const QVariant & data) { - QNDEBUG(QStringLiteral("AddHyperlinkToSelectedTextDelegate::") - << QStringLiteral("onInitialHyperlinkDataReceived: ") << data); + QNDEBUG("AddHyperlinkToSelectedTextDelegate::" + << "onInitialHyperlinkDataReceived: " << data); QString initialText = data.toString(); @@ -145,8 +149,8 @@ void AddHyperlinkToSelectedTextDelegate::raiseAddHyperlinkDialog( const QString & initialText) { - QNDEBUG(QStringLiteral("AddHyperlinkToSelectedTextDelegate::") - << QStringLiteral("raiseAddHyperlinkDialog: initial text = ") + QNDEBUG("AddHyperlinkToSelectedTextDelegate::" + << "raiseAddHyperlinkDialog: initial text = " << initialText); QScopedPointer<EditHyperlinkDialog> pEditHyperlinkDialog( @@ -160,10 +164,10 @@ QNSLOT(AddHyperlinkToSelectedTextDelegate, onAddHyperlinkDialogFinished, QString,QUrl,quint64,bool)); - QNTRACE(QStringLiteral("Will exec add hyperlink dialog now")); + QNTRACE("Will exec add hyperlink dialog now"); int res = pEditHyperlinkDialog->exec(); if (res == QDialog::Rejected) { - QNTRACE(QStringLiteral("Cancelled add hyperlink dialog")); + QNTRACE("Cancelled add hyperlink dialog"); Q_EMIT cancelled(); } } @@ -171,9 +175,9 @@ void AddHyperlinkToSelectedTextDelegate::onAddHyperlinkDialogFinished( QString text, QUrl url, quint64 hyperlinkId, bool startupUrlWasEmpty) { - QNDEBUG(QStringLiteral("AddHyperlinkToSelectedTextDelegate::") - << QStringLiteral("onAddHyperlinkDialogFinished: text = ") - << text << QStringLiteral(", url = ") << url); + QNDEBUG("AddHyperlinkToSelectedTextDelegate::" + << "onAddHyperlinkDialogFinished: text = " + << text << ", url = " << url); Q_UNUSED(hyperlinkId); Q_UNUSED(startupUrlWasEmpty); @@ -187,12 +191,12 @@ setHyperlinkToSelection(urlString, text); } -void AddHyperlinkToSelectedTextDelegate::setHyperlinkToSelection(const QString & url, - const QString & text) +void AddHyperlinkToSelectedTextDelegate::setHyperlinkToSelection( + const QString & url, const QString & text) { - QNDEBUG(QStringLiteral("AddHyperlinkToSelectedTextDelegate::") - << QStringLiteral("setHyperlinkToSelection: url = ") << url - << QStringLiteral(", text = ") << text); + QNDEBUG("AddHyperlinkToSelectedTextDelegate::" + << "setHyperlinkToSelection: url = " << url + << ", text = " << text); QString javascript = QStringLiteral("hyperlinkManager.setHyperlinkToSelection('") + text + QStringLiteral("', '") + url + QStringLiteral("', ") + @@ -206,9 +210,10 @@ &AddHyperlinkToSelectedTextDelegate::onHyperlinkSetToSelection)); } -void AddHyperlinkToSelectedTextDelegate::onHyperlinkSetToSelection(const QVariant & data) +void AddHyperlinkToSelectedTextDelegate::onHyperlinkSetToSelection( + const QVariant & data) { - QNDEBUG(QStringLiteral("AddHyperlinkToSelectedTextDelegate::onHyperlinkSetToSelection")); + QNDEBUG("AddHyperlinkToSelectedTextDelegate::onHyperlinkSetToSelection"); QMap<QString,QVariant> resultMap = data.toMap(); diff -Nru libquentier-0.5.0/src/note_editor/delegates/AddHyperlinkToSelectedTextDelegate.h libquentier-0.5.0/src/note_editor/delegates/AddHyperlinkToSelectedTextDelegate.h --- libquentier-0.5.0/src/note_editor/delegates/AddHyperlinkToSelectedTextDelegate.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/delegates/AddHyperlinkToSelectedTextDelegate.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,9 +20,11 @@ #define LIB_QUENTIER_NOTE_EDITOR_DELEGATES_ADD_HYPERLINK_TO_SELECTED_TEXT_DELEGATE_H #include "JsResultCallbackFunctor.hpp" + #include <quentier/utility/Macros.h> #include <quentier/types/ErrorString.h> #include <quentier/types/Note.h> + #include <QObject> #include <QUuid> diff -Nru libquentier-0.5.0/src/note_editor/delegates/AddResourceDelegate.cpp libquentier-0.5.0/src/note_editor/delegates/AddResourceDelegate.cpp --- libquentier-0.5.0/src/note_editor/delegates/AddResourceDelegate.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/delegates/AddResourceDelegate.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -21,11 +21,13 @@ #include "../NoteEditorPage.h" #include "../GenericResourceImageManager.h" #include "../ResourceDataInTemporaryFileStorageManager.h" + #include <quentier/utility/FileIOProcessorAsync.h> #include <quentier/utility/Utility.h> #include <quentier/logging/QuentierLogger.h> #include <quentier/types/Resource.h> #include <quentier/types/Account.h> + #include <QImage> #include <QBuffer> #include <QFileInfo> @@ -38,16 +40,17 @@ namespace quentier { -#define GET_PAGE() \ - NoteEditorPage * page = qobject_cast<NoteEditorPage*>(m_noteEditor.page()); \ - if (Q_UNLIKELY(!page)) { \ - ErrorString error(QT_TRANSLATE_NOOP("AddResourceDelegate", \ - "Can't add attachment: no note "\ - "editor page")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } +#define GET_PAGE() \ + NoteEditorPage * page = qobject_cast<NoteEditorPage*>(m_noteEditor.page());\ + if (Q_UNLIKELY(!page)) { \ + ErrorString error(QT_TRANSLATE_NOOP("AddResourceDelegate", \ + "Can't add attachment: no note " \ + "editor page")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// GET_PAGE AddResourceDelegate::AddResourceDelegate( const QString & filePath, NoteEditorPrivate & noteEditor, @@ -59,7 +62,8 @@ m_noteEditor(noteEditor), m_pResourceDataInTemporaryFileStorageManager(pResourceFileStorageManager), m_pFileIOProcessorAsync(pFileIOProcessorAsync), - m_genericResourceImageFilePathsByResourceHash(genericResourceImageFilePathsByResourceHash), + m_genericResourceImageFilePathsByResourceHash( + genericResourceImageFilePathsByResourceHash), m_pGenericResourceImageManager(pGenericResourceImageManager), m_saveResourceImageRequestId(), m_filePath(filePath), @@ -82,7 +86,8 @@ m_noteEditor(noteEditor), m_pResourceDataInTemporaryFileStorageManager(pResourceFileStorageManager), m_pFileIOProcessorAsync(pFileIOProcessorAsync), - m_genericResourceImageFilePathsByResourceHash(genericResourceImageFilePathsByResourceHash), + m_genericResourceImageFilePathsByResourceHash( + genericResourceImageFilePathsByResourceHash), m_pGenericResourceImageManager(pGenericResourceImageManager), m_saveResourceImageRequestId(), m_filePath(), @@ -98,23 +103,19 @@ if (!m_resourceMimeType.isValid()) { - QNDEBUG(QStringLiteral("The mime type deduced from the mime type name ") - << mimeType - << QStringLiteral(" is invalid, trying to deduce the mime type " - "from the raw data")); + QNDEBUG("Mime type deduced from the mime type name " << mimeType + << " is invalid, trying to deduce mime type from the raw data"); m_resourceMimeType = mimeDatabase.mimeTypeForData(m_data); - QNDEBUG(QStringLiteral("Mime type deduced from the data is ") - << (m_resourceMimeType.isValid() - ? QStringLiteral("valid") - : QStringLiteral("invalid"))); + QNDEBUG("Mime type deduced from the data is " + << (m_resourceMimeType.isValid() ? "valid" : "invalid")); } } void AddResourceDelegate::start() { - QNDEBUG(QStringLiteral("AddResourceDelegate::start")); + QNDEBUG("AddResourceDelegate::start"); if (m_noteEditor.isEditorPageModified()) { @@ -133,7 +134,7 @@ void AddResourceDelegate::onOriginalPageConvertedToNote(Note note) { - QNDEBUG(QStringLiteral("AddResourceDelegate::onOriginalPageConvertedToNote")); + QNDEBUG("AddResourceDelegate::onOriginalPageConvertedToNote"); Q_UNUSED(note) @@ -148,7 +149,7 @@ void AddResourceDelegate::doStart() { - QNDEBUG(QStringLiteral("AddResourceDelegate::doStart")); + QNDEBUG("AddResourceDelegate::doStart"); const Note * pNote = m_noteEditor.notePtr(); if (Q_UNLIKELY(!pNote)) { @@ -182,8 +183,8 @@ bool noteHasLimits = pNote->hasNoteLimits(); if (noteHasLimits) { - QNTRACE(QStringLiteral("Note has its own limits, will use them to check " - "the number of note resources")); + QNTRACE("Note has its own limits, will use them to check " + "the number of note resources"); const qevercloud::NoteLimits & limits = pNote->noteLimits(); if (limits.noteResourceCountMax.isSet() && @@ -198,9 +199,8 @@ } else if (pAccount) { - QNTRACE(QStringLiteral("Note has no limits of its own, will use " - "the account-wise limits to check the number " - "of note resources")); + QNTRACE("Note has no limits of its own, will use account-wise limits " + "to check the number of note resources"); int numNoteResources = pNote->numResources(); ++numNoteResources; @@ -215,8 +215,8 @@ } else { - QNINFO(QStringLiteral("No account when adding the resource to note, " - "can't check account-wise note limits")); + QNINFO("No account when adding the resource to note, " + "can't check account-wise note limits"); } if (!m_filePath.isEmpty()) { @@ -229,26 +229,27 @@ void AddResourceDelegate::doStartUsingFile() { - QNDEBUG(QStringLiteral("AddResourceDelegate::doStartUsingFile")); + QNDEBUG("AddResourceDelegate::doStartUsingFile"); QFileInfo fileInfo(m_filePath); if (!fileInfo.isFile()) { - QNINFO(QStringLiteral("Detected attempt to drop something else rather ") - << QStringLiteral("than file: ") << m_filePath); + QNINFO("Detected attempt to drop something else rather than file: " + << m_filePath); return; } if (!fileInfo.isReadable()) { - QNINFO(QStringLiteral("Detected attempt to drop file which is not readable: ") + QNINFO("Detected attempt to drop file which is not readable: " << m_filePath); return; } const Note * pNote = m_noteEditor.notePtr(); if (Q_UNLIKELY(!pNote)) { - ErrorString error(QT_TR_NOOP("Can't add attachment: no note is set to the editor")); + ErrorString error(QT_TR_NOOP("Can't add attachment: no note is set to " + "the editor")); QNWARNING(error); Q_EMIT notifyError(error); return; @@ -288,21 +289,23 @@ Q_EMIT readFileData(m_filePath, m_readResourceFileRequestId); } -void AddResourceDelegate::onResourceFileRead(bool success, - ErrorString errorDescription, - QByteArray data, QUuid requestId) +void AddResourceDelegate::onResourceFileRead( + bool success, ErrorString errorDescription, + QByteArray data, QUuid requestId) { if (requestId != m_readResourceFileRequestId) { return; } - QNDEBUG(QStringLiteral("AddResourceDelegate::onResourceFileRead: success = ") - << (success ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("AddResourceDelegate::onResourceFileRead: success = " + << (success ? "true" : "false")); QObject::disconnect(this, - QNSIGNAL(AddResourceDelegate,readFileData,QString,QUuid), + QNSIGNAL(AddResourceDelegate,readFileData, + QString,QUuid), m_pFileIOProcessorAsync, - QNSLOT(FileIOProcessorAsync,onReadFileRequest,QString,QUuid)); + QNSLOT(FileIOProcessorAsync,onReadFileRequest, + QString,QUuid)); QObject::disconnect(m_pFileIOProcessorAsync, QNSIGNAL(FileIOProcessorAsync,readFileRequestProcessed, bool,ErrorString,QByteArray,QUuid), @@ -311,7 +314,7 @@ bool,ErrorString,QByteArray,QUuid)); if (Q_UNLIKELY(!success)) { - ErrorString error(QT_TR_NOOP("can't read the contents of the attachment file")); + ErrorString error(QT_TR_NOOP("can't read the attachment file contents")); error.appendBase(errorDescription.base()); error.appendBase(errorDescription.additionalBases()); error.details() = errorDescription.details(); @@ -331,7 +334,7 @@ void AddResourceDelegate::doStartUsingData() { - QNDEBUG(QStringLiteral("AddResourceDelegate::doStartUsingData")); + QNDEBUG("AddResourceDelegate::doStartUsingData"); const Note * pNote = m_noteEditor.notePtr(); if (Q_UNLIKELY(!pNote)) @@ -371,11 +374,11 @@ } } -void AddResourceDelegate::doSaveResourceDataToTemporaryFile(const QByteArray & data, - QString resourceName) +void AddResourceDelegate::doSaveResourceDataToTemporaryFile( + const QByteArray & data, QString resourceName) { - QNDEBUG(QStringLiteral("AddResourceDelegate::doSaveResourceDataToTemporaryFile: ") - << QStringLiteral("resource name = ") << resourceName); + QNDEBUG("AddResourceDelegate::doSaveResourceDataToTemporaryFile: " + << "resource name = " << resourceName); const Note * pNote = m_noteEditor.notePtr(); if (!pNote) @@ -396,7 +399,7 @@ m_resource = m_noteEditor.attachResourceToNote(data, dataHash, m_resourceMimeType, resourceName); - QNTRACE(QStringLiteral("Attached resource to note: ") << m_resource); + QNTRACE("Attached resource to note: " << m_resource); QString resourceLocalUid = m_resource.localUid(); if (Q_UNLIKELY(resourceLocalUid.isEmpty())) { @@ -422,33 +425,34 @@ QNSLOT(AddResourceDelegate,onResourceDataSavedToTemporaryFile, QUuid,QByteArray,ErrorString)); - QNTRACE(QStringLiteral("Emitting the request to save the dropped/pasted resource ") - << QStringLiteral("to a temporary file: generated local uid = ") - << resourceLocalUid << QStringLiteral(", data hash = ") << dataHash.toHex() - << QStringLiteral(", request id = ") + QNTRACE("Emitting the request to save the dropped/pasted resource " + << "to a temporary file: generated local uid = " + << resourceLocalUid << ", data hash = " << dataHash.toHex() + << ", request id = " << m_saveResourceDataToTemporaryFileRequestId - << QStringLiteral(", mime type name = ") << m_resourceMimeType.name()); + << ", mime type name = " << m_resourceMimeType.name()); Q_EMIT saveResourceDataToTemporaryFile(pNote->localUid(), resourceLocalUid, data, dataHash, m_saveResourceDataToTemporaryFileRequestId, /* is image = */ true); } -void AddResourceDelegate::onResourceDataSavedToTemporaryFile(QUuid requestId, - QByteArray dataHash, - ErrorString errorDescription) +void AddResourceDelegate::onResourceDataSavedToTemporaryFile( + QUuid requestId, QByteArray dataHash, ErrorString errorDescription) { if (requestId != m_saveResourceDataToTemporaryFileRequestId) { return; } - QNDEBUG(QStringLiteral("AddResourceDelegate::onResourceDataSavedToTemporaryFile: ") - << QStringLiteral("error description = ") << errorDescription); + QNDEBUG("AddResourceDelegate::onResourceDataSavedToTemporaryFile: " + << "error description = " << errorDescription); const Note * pNote = m_noteEditor.notePtr(); - if (!pNote) { - errorDescription.setBase(QT_TR_NOOP("Can't set up the image corresponding " - "to the resource: no note is set to the editor")); + if (!pNote) + { + errorDescription.setBase( + QT_TR_NOOP("Can't set up the image corresponding " + "to the resource: no note is set to the editor")); QNWARNING(errorDescription); Q_EMIT notifyError(errorDescription); return; @@ -495,16 +499,15 @@ m_noteEditor.replaceResourceInNote(m_resource); } - QNTRACE(QStringLiteral("Done adding the image resource to the note, moving " - "on to adding it to the page")); + QNTRACE("Done adding the image resource to the note, moving " + "on to adding it to the page"); insertNewResourceHtml(); } -void AddResourceDelegate::onGenericResourceImageSaved(bool success, - QByteArray resourceImageDataHash, - QString filePath, - ErrorString errorDescription, - QUuid requestId) +void AddResourceDelegate::onGenericResourceImageSaved( + bool success, QByteArray resourceImageDataHash, + QString filePath, ErrorString errorDescription, + QUuid requestId) { if (requestId != m_saveResourceImageRequestId) { return; @@ -525,13 +528,12 @@ QNSLOT(AddResourceDelegate,onGenericResourceImageSaved, bool,QByteArray,QString,ErrorString,QUuid)); - QNDEBUG(QStringLiteral("AddResourceDelegate::onGenericResourceImageSaved: success = ") - << (success ? QStringLiteral("true") : QStringLiteral("false")) - << QStringLiteral(", file path = ") << filePath); + QNDEBUG("AddResourceDelegate::onGenericResourceImageSaved: success = " + << (success ? "true" : "false") << ", file path = " << filePath); m_genericResourceImageFilePathsByResourceHash[m_resource.dataHash()] = filePath; - QNDEBUG(QStringLiteral("Cached generic resource image file path ") << filePath - << QStringLiteral(" for resource hash ") << m_resource.dataHash().toHex()); + QNDEBUG("Cached generic resource image file path " << filePath + << " for resource hash " << m_resource.dataHash().toHex()); Q_UNUSED(resourceImageDataHash); @@ -551,17 +553,17 @@ insertNewResourceHtml(); } -void AddResourceDelegate::doGenerateGenericResourceImage(const QByteArray & data, - QString resourceName) +void AddResourceDelegate::doGenerateGenericResourceImage( + const QByteArray & data, QString resourceName) { - QNDEBUG(QStringLiteral("AddResourceDelegate::doGenerateGenericResourceImage")); + QNDEBUG("AddResourceDelegate::doGenerateGenericResourceImage"); const Note * pNote = m_noteEditor.notePtr(); if (Q_UNLIKELY(!pNote)) { - ErrorString errorDescription(QT_TR_NOOP("Can't set up the image corresponding " - "to the resource: no note is set " - "to the editor")); + ErrorString errorDescription( + QT_TR_NOOP("Can't set up the image corresponding " + "to the resource: no note is set to the editor")); QNWARNING(errorDescription); Q_EMIT notifyError(errorDescription); return; @@ -612,10 +614,10 @@ QNSLOT(AddResourceDelegate,onGenericResourceImageSaved, bool,QByteArray,QString,ErrorString,QUuid)); - QNDEBUG(QStringLiteral("Emitting request to write generic resource image ") - << QStringLiteral("for new resource with local uid ") - << m_resource.localUid() << QStringLiteral(", request id ") - << m_saveResourceImageRequestId << QStringLiteral(", note local uid = ") + QNDEBUG("Emitting request to write generic resource image " + << "for new resource with local uid " + << m_resource.localUid() << ", request id " + << m_saveResourceImageRequestId << ", note local uid = " << pNote->localUid()); Q_EMIT saveGenericResourceImageToFile(pNote->localUid(), m_resource.localUid(), resourceImageData, QStringLiteral("png"), @@ -625,7 +627,7 @@ void AddResourceDelegate::insertNewResourceHtml() { - QNDEBUG(QStringLiteral("AddResourceDelegate::insertNewResourceHtml")); + QNDEBUG("AddResourceDelegate::insertNewResourceHtml"); ErrorString errorDescription; QString resourceHtml = ENMLConverter::resourceHtml(m_resource, errorDescription); @@ -642,7 +644,7 @@ return; } - QNTRACE(QStringLiteral("Resource html: ") << resourceHtml); + QNTRACE("Resource html: " << resourceHtml); GET_PAGE() page->executeJavaScript( @@ -653,7 +655,7 @@ void AddResourceDelegate::onNewResourceHtmlInserted(const QVariant & data) { - QNDEBUG(QStringLiteral("AddResourceDelegate::onNewResourceHtmlInserted")); + QNDEBUG("AddResourceDelegate::onNewResourceHtmlInserted"); QMap<QString,QVariant> resultMap = data.toMap(); @@ -680,7 +682,8 @@ } else { - error.setBase(QT_TR_NOOP("Can't insert resource html into the note editor")); + error.setBase(QT_TR_NOOP("Can't insert resource html into " + "the note editor")); error.details() = errorIt.value().toString(); } @@ -692,11 +695,10 @@ Q_EMIT finished(m_resource, m_resourceFileStoragePath); } -bool AddResourceDelegate::checkResourceDataSize(const Note & note, - const Account * pAccount, - const qint64 size) +bool AddResourceDelegate::checkResourceDataSize( + const Note & note, const Account * pAccount, const qint64 size) { - QNDEBUG(QStringLiteral("AddResourceDelegate::checkResourceDataSize: size = ") + QNDEBUG("AddResourceDelegate::checkResourceDataSize: size = " << humanReadableSize(static_cast<quint64>(std::max(size, qint64(0))))); bool noteHasLimits = note.hasNoteLimits(); @@ -708,10 +710,11 @@ if (Q_UNLIKELY(violatesNoteResourceSizeMax)) { - ErrorString error(QT_TR_NOOP("Can't add attachment: the resource to be added " - "is too large, max resource size allowed is")); - error.details() = - humanReadableSize(static_cast<quint64>(note.noteLimits().resourceSizeMax.ref())); + ErrorString error(QT_TR_NOOP("Can't add attachment: the resource " + "to be added is too large, max " + "resource size allowed is")); + error.details() = humanReadableSize( + static_cast<quint64>(note.noteLimits().resourceSizeMax.ref())); Q_EMIT notifyError(error); return false; } @@ -724,8 +727,8 @@ ErrorString error(QT_TR_NOOP("Can't add attachment: the addition " "of the resource would violate the max " "resource size which is")); - error.details() = - humanReadableSize(static_cast<quint64>(note.noteLimits().noteSizeMax.ref())); + error.details() = humanReadableSize( + static_cast<quint64>(note.noteLimits().noteSizeMax.ref())); Q_EMIT notifyError(error); return false; } @@ -738,8 +741,8 @@ { ErrorString error(QT_TR_NOOP("Can't add attachment: the resource is " "too large, max resource size allowed is")); - error.details() = - humanReadableSize(static_cast<quint64>(pAccount->resourceSizeMax())); + error.details() = humanReadableSize( + static_cast<quint64>(pAccount->resourceSizeMax())); Q_EMIT notifyError(error); return false; } diff -Nru libquentier-0.5.0/src/note_editor/delegates/AddResourceDelegate.h libquentier-0.5.0/src/note_editor/delegates/AddResourceDelegate.h --- libquentier-0.5.0/src/note_editor/delegates/AddResourceDelegate.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/delegates/AddResourceDelegate.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,10 +20,12 @@ #define LIB_QUENTIER_NOTE_EDITOR_DELEGATES_ADD_RESOURCE_DELEGATE_H #include "JsResultCallbackFunctor.hpp" + #include <quentier/utility/Macros.h> #include <quentier/types/ErrorString.h> #include <quentier/types/Note.h> #include <quentier/types/Resource.h> + #include <QObject> #include <QByteArray> #include <QUuid> @@ -55,16 +57,14 @@ * the resource data is located * @param noteEditor The note editor holding the note to * which the resource is to be added - * @param pResourceDataInTemporaryFileStorageManager The pointer to - * ResourceDataInTemporaryFileStorageManager - * which might be required - * for storing the new resource's - * data in a temporary file - * for the sake of note editor - * page's convenience; it is - * only actually required if - * the added resource is - * an image + * @param pResourceDataManager The pointer to + * ResourceDataInTemporaryFileStorageManager + * which might be required for storing + * the new resource's data in a + * temporary file for the sake of note + * editor page's convenience; it is + * only actually required if the added + * resource is an image * @param pFileIOThreadWorker The pointer to FileIOProcessorAsync * worker performing the actual IO of * file data @@ -80,7 +80,7 @@ explicit AddResourceDelegate( const QString & filePath, NoteEditorPrivate & noteEditor, - ResourceDataInTemporaryFileStorageManager * pResourceDataInTemporaryFileStorageManager, + ResourceDataInTemporaryFileStorageManager * pResourceDataManager, FileIOProcessorAsync * pFileIOThreadWorker, GenericResourceImageManager * pGenericResourceImageManager, QHash<QByteArray, QString> & genericResourceImageFilePathsByResourceHash); @@ -94,17 +94,14 @@ * @param mimeType The mime type of resource data * @param noteEditor The note editor holding the note to * which the resource is to be added - * @param pResourceDataInTemporaryFileStorageManager The pointer to - * ResourceDataInTemporaryFileStorageManager - * which might be required - * for storing the new - * resource's data in - * a temporary file for - * the sake of note editor - * page's convenience; - * it is only actually - * required if the added - * resource is an image + * @param pResourceDataManager The pointer to + * ResourceDataInTemporaryFileStorageManager + * which might be required for storing + * the new resource's data in a + * temporary file for the sake of note + * editor page's convenience; it is + * only actually required if the added + * resource is an image * @param pFileIOThreadWorker The pointer to FileIOProcessorAsync * worker performing the actual IO of * file data @@ -120,7 +117,7 @@ const QByteArray & resourceData, const QString & mimeType, NoteEditorPrivate & noteEditor, - ResourceDataInTemporaryFileStorageManager * pResourceDataInTemporaryFileStorageManager, + ResourceDataInTemporaryFileStorageManager * pResourceDataManager, FileIOProcessorAsync * pFileIOThreadWorker, GenericResourceImageManager * pGenericResourceImageManager, QHash<QByteArray, QString> & genericResourceImageFilePathsByResourceHash); @@ -139,9 +136,11 @@ QUuid requestId, bool isImage); void writeFile(QString filePath, QByteArray data, QUuid requestId); - void saveGenericResourceImageToFile(QString noteLocalUid, QString resourceLocalUid, + void saveGenericResourceImageToFile(QString noteLocalUid, + QString resourceLocalUid, QByteArray data, QString fileSuffix, - QByteArray dataHash, QString fileStoragePath, + QByteArray dataHash, + QString fileStoragePath, QUuid requestId); private Q_SLOTS: diff -Nru libquentier-0.5.0/src/note_editor/delegates/DecryptEncryptedTextDelegate.cpp libquentier-0.5.0/src/note_editor/delegates/DecryptEncryptedTextDelegate.cpp --- libquentier-0.5.0/src/note_editor/delegates/DecryptEncryptedTextDelegate.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/delegates/DecryptEncryptedTextDelegate.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -20,6 +20,7 @@ #include "../NoteEditor_p.h" #include "../NoteEditorPage.h" #include "../dialogs/DecryptionDialog.h" + #include <quentier/utility/EncryptionManager.h> #include <quentier/enml/ENMLConverter.h> #include <quentier/enml/DecryptedTextManager.h> @@ -31,34 +32,40 @@ namespace quentier { -#define CHECK_NOTE_EDITOR() \ - if (Q_UNLIKELY(m_pNoteEditor.isNull())) { \ - QNDEBUG(QStringLiteral("Note editor is null")); \ - return; \ - } - -#define CHECK_ACCOUNT() \ - CHECK_NOTE_EDITOR() \ - if (Q_UNLIKELY(!m_pNoteEditor->accountPtr())) { \ - ErrorString error(QT_TRANSLATE_NOOP("DecryptEncryptedTextDelegate", \ - "Can't decrypt the encrypted text: "\ - "no account is set to the note editor")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } - -#define GET_PAGE() \ - CHECK_NOTE_EDITOR() \ - NoteEditorPage * page = qobject_cast<NoteEditorPage*>(m_pNoteEditor->page()); \ - if (Q_UNLIKELY(!page)) { \ - ErrorString error(QT_TRANSLATE_NOOP("DecryptEncryptedTextDelegate", \ - "Can't decrypt the encrypted text: "\ - "no note editor page")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } +#define CHECK_NOTE_EDITOR() \ + if (Q_UNLIKELY(m_pNoteEditor.isNull())) { \ + QNDEBUG("Note editor is null"); \ + return; \ + } \ +// CHECK_NOTE_EDITOR + +#define CHECK_ACCOUNT() \ + CHECK_NOTE_EDITOR() \ + if (Q_UNLIKELY(!m_pNoteEditor->accountPtr())) { \ + ErrorString error( \ + QT_TRANSLATE_NOOP("DecryptEncryptedTextDelegate", \ + "Can't decrypt the encrypted text: " \ + "no account is set to the note editor")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// CHECK_ACCOUNT + +#define GET_PAGE() \ + CHECK_NOTE_EDITOR() \ + NoteEditorPage * page = \ + qobject_cast<NoteEditorPage*>(m_pNoteEditor->page()); \ + if (Q_UNLIKELY(!page)) { \ + ErrorString error( \ + QT_TRANSLATE_NOOP("DecryptEncryptedTextDelegate", \ + "Can't decrypt the encrypted text: " \ + "no note editor page")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// GET_PAGE DecryptEncryptedTextDelegate::DecryptEncryptedTextDelegate( const QString & encryptedTextId, const QString & encryptedText, @@ -97,14 +104,16 @@ void DecryptEncryptedTextDelegate::start() { - QNDEBUG(QStringLiteral("DecryptEncryptedTextDelegate::start")); + QNDEBUG("DecryptEncryptedTextDelegate::start"); CHECK_NOTE_EDITOR() - if (Q_UNLIKELY(!m_length)) { - ErrorString errorDescription(QT_TR_NOOP("Can't decrypt the encrypted text: " - "can't convert the encryption key " - "length from string to number")); + if (Q_UNLIKELY(!m_length)) + { + ErrorString errorDescription( + QT_TR_NOOP("Can't decrypt the encrypted text: " + "can't convert the encryption key " + "length from string to number")); QNWARNING(errorDescription); Q_EMIT notifyError(errorDescription); return; @@ -125,7 +134,7 @@ void DecryptEncryptedTextDelegate::onOriginalPageConvertedToNote(Note note) { - QNDEBUG(QStringLiteral("DecryptEncryptedTextDelegate::onOriginalPageConvertedToNote")); + QNDEBUG("DecryptEncryptedTextDelegate::onOriginalPageConvertedToNote"); CHECK_NOTE_EDITOR() @@ -142,7 +151,7 @@ void DecryptEncryptedTextDelegate::raiseDecryptionDialog() { - QNDEBUG(QStringLiteral("DecryptEncryptedTextDelegate::raiseDecryptionDialog")); + QNDEBUG("DecryptEncryptedTextDelegate::raiseDecryptionDialog"); CHECK_ACCOUNT() @@ -161,7 +170,7 @@ this, QNSLOT(DecryptEncryptedTextDelegate,onEncryptedTextDecrypted, QString,size_t,QString,QString,QString,bool,bool)); - QNTRACE(QStringLiteral("Will exec decryption dialog now")); + QNTRACE("Will exec decryption dialog now"); int res = pDecryptionDialog->exec(); if (res == QDialog::Rejected) { Q_EMIT cancelled(); @@ -174,12 +183,12 @@ QString passphrase, QString decryptedText, bool rememberForSession, bool decryptPermanently) { - QNDEBUG(QStringLiteral("DecryptEncryptedTextDelegate::onEncryptedTextDecrypted: ") - << QStringLiteral("encrypted text = ") << encryptedText - << QStringLiteral(", remember for session = ") - << (rememberForSession ? QStringLiteral("true") : QStringLiteral("false")) - << QStringLiteral(", decrypt permanently = ") - << (decryptPermanently ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("DecryptEncryptedTextDelegate::onEncryptedTextDecrypted: " + << "encrypted text = " << encryptedText + << ", remember for session = " + << (rememberForSession ? "true" : "false") + << ", decrypt permanently = " + << (decryptPermanently ? "true" : "false")); CHECK_NOTE_EDITOR() @@ -193,10 +202,10 @@ QString decryptedTextHtml; if (!m_decryptPermanently) { - decryptedTextHtml = - ENMLConverter::decryptedTextHtml(m_decryptedText, m_encryptedText, - m_hint, m_cipher, m_length, - m_pNoteEditor->GetFreeDecryptedTextId()); + decryptedTextHtml = ENMLConverter::decryptedTextHtml( + m_decryptedText, m_encryptedText, + m_hint, m_cipher, m_length, + m_pNoteEditor->GetFreeDecryptedTextId()); } else { decryptedTextHtml = m_decryptedText; @@ -212,9 +221,10 @@ JsCallback(*this, &DecryptEncryptedTextDelegate::onDecryptionScriptFinished)); } -void DecryptEncryptedTextDelegate::onDecryptionScriptFinished(const QVariant & data) +void DecryptEncryptedTextDelegate::onDecryptionScriptFinished( + const QVariant & data) { - QNDEBUG(QStringLiteral("DecryptEncryptedTextDelegate::onDecryptionScriptFinished: ") + QNDEBUG("DecryptEncryptedTextDelegate::onDecryptionScriptFinished: " << data); QMap<QString,QVariant> resultMap = data.toMap(); diff -Nru libquentier-0.5.0/src/note_editor/delegates/DecryptEncryptedTextDelegate.h libquentier-0.5.0/src/note_editor/delegates/DecryptEncryptedTextDelegate.h --- libquentier-0.5.0/src/note_editor/delegates/DecryptEncryptedTextDelegate.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/delegates/DecryptEncryptedTextDelegate.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,9 +20,11 @@ #define LIB_QUENTIER_NOTE_EDITOR_DELEGATES_DECRYPT_ENCRYPTED_TEXT_DELEGATE_H #include "JsResultCallbackFunctor.hpp" + #include <quentier/utility/Macros.h> #include <quentier/types/ErrorString.h> #include <quentier/types/Note.h> + #include <QPointer> namespace quentier { @@ -40,13 +42,14 @@ { Q_OBJECT public: - explicit DecryptEncryptedTextDelegate(const QString & encryptedTextId, - const QString & encryptedText, - const QString & cipher, - const QString & length, const QString & hint, - NoteEditorPrivate * pNoteEditor, - QSharedPointer<EncryptionManager> encryptionManager, - QSharedPointer<DecryptedTextManager> decryptedTextManager); + explicit DecryptEncryptedTextDelegate( + const QString & encryptedTextId, + const QString & encryptedText, + const QString & cipher, + const QString & length, const QString & hint, + NoteEditorPrivate * pNoteEditor, + QSharedPointer<EncryptionManager> encryptionManager, + QSharedPointer<DecryptedTextManager> decryptedTextManager); void start(); diff -Nru libquentier-0.5.0/src/note_editor/delegates/EditHyperlinkDelegate.cpp libquentier-0.5.0/src/note_editor/delegates/EditHyperlinkDelegate.cpp --- libquentier-0.5.0/src/note_editor/delegates/EditHyperlinkDelegate.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/delegates/EditHyperlinkDelegate.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -20,33 +20,35 @@ #include "../NoteEditor_p.h" #include "../NoteEditorPage.h" #include "../dialogs/EditHyperlinkDialog.h" + #include <quentier/logging/QuentierLogger.h> + #include <QScopedPointer> #include <QStringList> namespace quentier { -EditHyperlinkDelegate::EditHyperlinkDelegate(NoteEditorPrivate & noteEditor, - const quint64 hyperlinkId) : +EditHyperlinkDelegate::EditHyperlinkDelegate( + NoteEditorPrivate & noteEditor, const quint64 hyperlinkId) : QObject(¬eEditor), m_noteEditor(noteEditor), m_hyperlinkId(hyperlinkId) {} -#define GET_PAGE() \ - NoteEditorPage * page = qobject_cast<NoteEditorPage*>(m_noteEditor.page()); \ - if (Q_UNLIKELY(!page)) { \ - ErrorString error(QT_TRANSLATE_NOOP("EditHyperlinkDelegate", \ - "Can't edit hyperlink: no note "\ - "editor page")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ +#define GET_PAGE() \ + NoteEditorPage * page = qobject_cast<NoteEditorPage*>(m_noteEditor.page());\ + if (Q_UNLIKELY(!page)) { \ + ErrorString error(QT_TRANSLATE_NOOP("EditHyperlinkDelegate", \ + "Can't edit hyperlink: no note " \ + "editor page")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ } void EditHyperlinkDelegate::start() { - QNDEBUG(QStringLiteral("EditHyperlinkDelegate::start")); + QNDEBUG("EditHyperlinkDelegate::start"); if (m_noteEditor.isEditorPageModified()) { @@ -65,7 +67,7 @@ void EditHyperlinkDelegate::onOriginalPageConvertedToNote(Note note) { - QNDEBUG(QStringLiteral("EditHyperlinkDelegate::onOriginalPageConvertedToNote")); + QNDEBUG("EditHyperlinkDelegate::onOriginalPageConvertedToNote"); Q_UNUSED(note) @@ -80,8 +82,7 @@ void EditHyperlinkDelegate::onHyperlinkDataReceived(const QVariant & data) { - QNDEBUG(QStringLiteral("EditHyperlinkDelegate::onHyperlinkDataReceived: data = ") - << data); + QNDEBUG("EditHyperlinkDelegate::onHyperlinkDataReceived: data = " << data); QMap<QString,QVariant> resultMap = data.toMap(); @@ -138,7 +139,7 @@ { ErrorString error(QT_TR_NOOP("Can't edit hyperlink: can't parse hyperlink " "text and link")); - QNWARNING(error << QStringLiteral("; hyperlink data: ") + QNWARNING(error << "; hyperlink data: " << hyperlinkDataList.join(QStringLiteral(","))); Q_EMIT notifyError(error); return; @@ -149,7 +150,7 @@ void EditHyperlinkDelegate::doStart() { - QNDEBUG(QStringLiteral("EditHyperlinkDelegate::doStart")); + QNDEBUG("EditHyperlinkDelegate::doStart"); QString javascript = QStringLiteral("hyperlinkManager.getHyperlinkData(") + QString::number(m_hyperlinkId) + QStringLiteral(");"); @@ -160,11 +161,11 @@ JsCallback(*this, &EditHyperlinkDelegate::onHyperlinkDataReceived)); } -void EditHyperlinkDelegate::raiseEditHyperlinkDialog(const QString & startupHyperlinkText, - const QString & startupHyperlinkUrl) +void EditHyperlinkDelegate::raiseEditHyperlinkDialog( + const QString & startupHyperlinkText, const QString & startupHyperlinkUrl) { - QNDEBUG(QStringLiteral("EditHyperlinkDelegate::raiseEditHyperlinkDialog: original text = ") - << startupHyperlinkText << QStringLiteral(", original url: ") + QNDEBUG("EditHyperlinkDelegate::raiseEditHyperlinkDialog: original text = " + << startupHyperlinkText << ", original url: " << startupHyperlinkUrl); QScopedPointer<EditHyperlinkDialog> pEditHyperlinkDialog( @@ -177,22 +178,21 @@ this, QNSLOT(EditHyperlinkDelegate,onHyperlinkDataEdited, QString,QUrl,quint64,bool)); - QNTRACE(QStringLiteral("Will exec edit hyperlink dialog now")); + QNTRACE("Will exec edit hyperlink dialog now"); int res = pEditHyperlinkDialog->exec(); if (res == QDialog::Rejected) { - QNTRACE(QStringLiteral("Cancelled editing the hyperlink")); + QNTRACE("Cancelled editing the hyperlink"); Q_EMIT cancelled(); return; } } -void EditHyperlinkDelegate::onHyperlinkDataEdited(QString text, QUrl url, - quint64 hyperlinkId, - bool startupUrlWasEmpty) -{ - QNDEBUG(QStringLiteral("EditHyperlinkDelegate::onHyperlinkDataEdited: text = ") - << text << QStringLiteral(", url = ") << url - << QStringLiteral(", hyperlink id = ") << hyperlinkId); +void EditHyperlinkDelegate::onHyperlinkDataEdited( + QString text, QUrl url, quint64 hyperlinkId, bool startupUrlWasEmpty) +{ + QNDEBUG("EditHyperlinkDelegate::onHyperlinkDataEdited: text = " + << text << ", url = " << url + << ", hyperlink id = " << hyperlinkId); Q_UNUSED(hyperlinkId) Q_UNUSED(startupUrlWasEmpty) @@ -216,7 +216,7 @@ void EditHyperlinkDelegate::onHyperlinkModified(const QVariant & data) { - QNDEBUG(QStringLiteral("EditHyperlinkDelegate::onHyperlinkModified")); + QNDEBUG("EditHyperlinkDelegate::onHyperlinkModified"); QMap<QString,QVariant> resultMap = data.toMap(); diff -Nru libquentier-0.5.0/src/note_editor/delegates/EditHyperlinkDelegate.h libquentier-0.5.0/src/note_editor/delegates/EditHyperlinkDelegate.h --- libquentier-0.5.0/src/note_editor/delegates/EditHyperlinkDelegate.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/delegates/EditHyperlinkDelegate.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,9 +20,11 @@ #define LIB_QUENTIER_NOTE_EDITOR_DELEGATES_EDIT_HYPERLINK_DELEGATE_H #include "JsResultCallbackFunctor.hpp" + #include <quentier/utility/Macros.h> #include <quentier/types/ErrorString.h> #include <quentier/types/Note.h> + #include <QObject> namespace quentier { diff -Nru libquentier-0.5.0/src/note_editor/delegates/EncryptSelectedTextDelegate.cpp libquentier-0.5.0/src/note_editor/delegates/EncryptSelectedTextDelegate.cpp --- libquentier-0.5.0/src/note_editor/delegates/EncryptSelectedTextDelegate.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/delegates/EncryptSelectedTextDelegate.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -19,38 +19,44 @@ #include "EncryptSelectedTextDelegate.h" #include "../NoteEditor_p.h" #include "../dialogs/EncryptionDialog.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { -#define CHECK_NOTE_EDITOR() \ - if (Q_UNLIKELY(m_pNoteEditor.isNull())) { \ - QNDEBUG(QStringLiteral("Note editor is null")); \ - return; \ - } - -#define CHECK_ACCOUNT() \ - CHECK_NOTE_EDITOR() \ - if (Q_UNLIKELY(!m_pNoteEditor->accountPtr())) { \ - ErrorString error(QT_TRANSLATE_NOOP("EncryptSelectedTextDelegate", \ - "Can't encrypt the selected text: "\ - "no account is set to the note editor")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } - -#define GET_PAGE() \ - CHECK_NOTE_EDITOR() \ - NoteEditorPage * page = qobject_cast<NoteEditorPage*>(m_pNoteEditor->page()); \ - if (Q_UNLIKELY(!page)) { \ - ErrorString error(QT_TRANSLATE_NOOP("EncryptSelectedTextDelegate", \ +#define CHECK_NOTE_EDITOR() \ + if (Q_UNLIKELY(m_pNoteEditor.isNull())) { \ + QNDEBUG("Note editor is null"); \ + return; \ + } \ +// CHECK_NOTE_EDITOR + +#define CHECK_ACCOUNT() \ + CHECK_NOTE_EDITOR() \ + if (Q_UNLIKELY(!m_pNoteEditor->accountPtr())) { \ + ErrorString error( \ + QT_TRANSLATE_NOOP("EncryptSelectedTextDelegate", \ + "Can't encrypt the selected text: " \ + "no account is set to the note editor")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// CHECK_ACCOUNT + +#define GET_PAGE() \ + CHECK_NOTE_EDITOR() \ + NoteEditorPage * page = \ + qobject_cast<NoteEditorPage*>(m_pNoteEditor->page()); \ + if (Q_UNLIKELY(!page)) { \ + ErrorString error(QT_TRANSLATE_NOOP("EncryptSelectedTextDelegate", \ "Can't encrypt the selected text: "\ - "no note editor page")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } + "no note editor page")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// GET_PAGE EncryptSelectedTextDelegate::EncryptSelectedTextDelegate( NoteEditorPrivate * pNoteEditor, @@ -71,13 +77,13 @@ void EncryptSelectedTextDelegate::start(const QString & selectionHtml) { - QNDEBUG(QStringLiteral("EncryptSelectedTextDelegate::start: selection html = ") + QNDEBUG("EncryptSelectedTextDelegate::start: selection html = " << selectionHtml); CHECK_NOTE_EDITOR() if (Q_UNLIKELY(selectionHtml.isEmpty())) { - QNDEBUG(QStringLiteral("No selection html, nothing to encrypt")); + QNDEBUG("No selection html, nothing to encrypt"); Q_EMIT cancelled(); return; } @@ -89,7 +95,7 @@ void EncryptSelectedTextDelegate::raiseEncryptionDialog() { - QNDEBUG(QStringLiteral("EncryptSelectedTextDelegate::raiseEncryptionDialog")); + QNDEBUG("EncryptSelectedTextDelegate::raiseEncryptionDialog"); CHECK_ACCOUNT() @@ -105,28 +111,23 @@ QNSLOT(EncryptSelectedTextDelegate,onSelectedTextEncrypted, QString,QString,QString,size_t,QString,bool)); int res = pEncryptionDialog->exec(); - QNTRACE(QStringLiteral("Executed encryption dialog: ") - << (res == QDialog::Accepted - ? QStringLiteral("accepted") - : QStringLiteral("rejected"))); + QNTRACE("Executed encryption dialog: " + << (res == QDialog::Accepted ? "accepted" : "rejected")); if (res == QDialog::Rejected) { Q_EMIT cancelled(); return; } } -void EncryptSelectedTextDelegate::onSelectedTextEncrypted(QString selectedText, - QString encryptedText, - QString cipher, - size_t keyLength, - QString hint, - bool rememberForSession) -{ - QNDEBUG(QStringLiteral("EncryptSelectedTextDelegate::onSelectedTextEncrypted: ") - << QStringLiteral("encrypted text = ") << encryptedText - << QStringLiteral(", hint = ") << hint - << QStringLiteral(", remember for session = ") - << (rememberForSession ? QStringLiteral("true") : QStringLiteral("false"))); +void EncryptSelectedTextDelegate::onSelectedTextEncrypted( + QString selectedText, QString encryptedText, + QString cipher, size_t keyLength, + QString hint, bool rememberForSession) +{ + QNDEBUG("EncryptSelectedTextDelegate::onSelectedTextEncrypted: " + << "encrypted text = " << encryptedText + << ", hint = " << hint << ", remember for session = " + << (rememberForSession ? "true" : "false")); CHECK_NOTE_EDITOR() @@ -149,10 +150,11 @@ } else { - m_encryptedTextHtml = - ENMLConverter::encryptedTextHtml(encryptedText, hint, - cipher, keyLength, - m_pNoteEditor->GetFreeEncryptedTextId()); + m_encryptedTextHtml = ENMLConverter::encryptedTextHtml( + encryptedText, hint, + cipher, keyLength, + m_pNoteEditor->GetFreeEncryptedTextId()); + ENMLConverter::escapeString(m_encryptedTextHtml); } @@ -171,7 +173,7 @@ void EncryptSelectedTextDelegate::onOriginalPageConvertedToNote(Note note) { - QNDEBUG(QStringLiteral("EncryptSelectedTextDelegate::onOriginalPageConvertedToNote")); + QNDEBUG("EncryptSelectedTextDelegate::onOriginalPageConvertedToNote"); CHECK_NOTE_EDITOR() @@ -188,7 +190,7 @@ void EncryptSelectedTextDelegate::encryptSelectedText() { - QNDEBUG(QStringLiteral("EncryptSelectedTextDelegate::encryptSelectedText")); + QNDEBUG("EncryptSelectedTextDelegate::encryptSelectedText"); GET_PAGE() @@ -218,8 +220,7 @@ void EncryptSelectedTextDelegate::onEncryptionScriptDone(const QVariant & data) { - QNDEBUG(QStringLiteral("EncryptSelectedTextDelegate::onEncryptionScriptDone: ") - << data); + QNDEBUG("EncryptSelectedTextDelegate::onEncryptionScriptDone: " << data); QMap<QString,QVariant> resultMap = data.toMap(); diff -Nru libquentier-0.5.0/src/note_editor/delegates/EncryptSelectedTextDelegate.h libquentier-0.5.0/src/note_editor/delegates/EncryptSelectedTextDelegate.h --- libquentier-0.5.0/src/note_editor/delegates/EncryptSelectedTextDelegate.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/delegates/EncryptSelectedTextDelegate.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,9 +20,11 @@ #define LIB_QUENTIER_NOTE_EDITOR_DELEGATES_ENCRYPT_SELECTED_TEXT_DELEGATE_H #include "JsResultCallbackFunctor.hpp" + #include <quentier/utility/Macros.h> #include <quentier/types/ErrorString.h> #include <quentier/types/Note.h> + #include <QPointer> namespace quentier { diff -Nru libquentier-0.5.0/src/note_editor/delegates/ImageResourceRotationDelegate.cpp libquentier-0.5.0/src/note_editor/delegates/ImageResourceRotationDelegate.cpp --- libquentier-0.5.0/src/note_editor/delegates/ImageResourceRotationDelegate.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/delegates/ImageResourceRotationDelegate.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,26 +18,31 @@ #include "ImageResourceRotationDelegate.h" #include "../ResourceDataInTemporaryFileStorageManager.h" + #include <quentier/types/Note.h> #include <quentier/types/Resource.h> #include <quentier/logging/QuentierLogger.h> #include <quentier/utility/Utility.h> + #include <QDateTime> #include <QBuffer> + #include <limits> namespace quentier { -#define GET_PAGE() \ - NoteEditorPage * page = qobject_cast<NoteEditorPage*>(m_noteEditor.page()); \ - if (Q_UNLIKELY(!page)) { \ - ErrorString error(QT_TRANSLATE_NOOP("ImageResourceRotationDelegate", \ - "Can't rotate the image attachment: "\ - "no note editor page")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } +#define GET_PAGE() \ + NoteEditorPage * page = qobject_cast<NoteEditorPage*>(m_noteEditor.page());\ + if (Q_UNLIKELY(!page)) { \ + ErrorString error( \ + QT_TRANSLATE_NOOP("ImageResourceRotationDelegate", \ + "Can't rotate the image attachment: " \ + "no note editor page")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// GET_PAGE ImageResourceRotationDelegate::ImageResourceRotationDelegate( const QByteArray & resourceHashBefore, @@ -64,7 +69,7 @@ void ImageResourceRotationDelegate::start() { - QNDEBUG(QStringLiteral("ImageResourceRotationDelegate::start")); + QNDEBUG("ImageResourceRotationDelegate::start"); if (m_noteEditor.isEditorPageModified()) { @@ -83,7 +88,7 @@ void ImageResourceRotationDelegate::onOriginalPageConvertedToNote(Note note) { - QNDEBUG(QStringLiteral("ImageResourceRotationDelegate::onOriginalPageConvertedToNote")); + QNDEBUG("ImageResourceRotationDelegate::onOriginalPageConvertedToNote"); Q_UNUSED(note) @@ -98,7 +103,7 @@ void ImageResourceRotationDelegate::rotateImageResource() { - QNDEBUG(QStringLiteral("ImageResourceRotationDelegate::rotateImageResource")); + QNDEBUG("ImageResourceRotationDelegate::rotateImageResource"); ErrorString error(QT_TR_NOOP("Can't rotate the image attachment")); @@ -124,7 +129,7 @@ if (Q_UNLIKELY(!resource.hasMime())) { error.appendBase(QT_TR_NOOP("The mime type is missing")); - QNWARNING(error << QStringLiteral(", resource: ") << resource); + QNWARNING(error << ", resource: " << resource); Q_EMIT notifyError(error); return; } @@ -133,7 +138,7 @@ { error.appendBase(QT_TR_NOOP("The mime type indicates the attachment " "is not an image")); - QNWARNING(error << QStringLiteral(", resource: ") << resource); + QNWARNING(error << ", resource: " << resource); Q_EMIT notifyError(error); return; } @@ -201,8 +206,7 @@ int height = resourceImage.height(); int width = resourceImage.width(); - QNTRACE(QStringLiteral("Rotated resource's height = ") << height - << QStringLiteral(", width = ") << width); + QNTRACE("Rotated resource's height = " << height << ", width = " << width); if ((height > 0) && (height <= std::numeric_limits<qint16>::max()) && (width > 0) && (width <= std::numeric_limits<qint16>::max())) @@ -241,12 +245,11 @@ onResourceDataSavedToTemporaryFile, QUuid,QByteArray,ErrorString)); - Q_EMIT saveResourceDataToTemporaryFile(m_rotatedResource.noteLocalUid(), - m_rotatedResource.localUid(), - m_rotatedResource.dataBody(), - QByteArray(), - m_saveResourceDataToTemporaryFileRequestId, - /* is image = */ true); + Q_EMIT saveResourceDataToTemporaryFile( + m_rotatedResource.noteLocalUid(), m_rotatedResource.localUid(), + m_rotatedResource.dataBody(), QByteArray(), + m_saveResourceDataToTemporaryFileRequestId, + /* is image = */ true); } void ImageResourceRotationDelegate::onResourceDataSavedToTemporaryFile( @@ -256,9 +259,9 @@ return; } - QNDEBUG(QStringLiteral("ImageResourceRotationDelegate::") - << QStringLiteral("onResourceDataSavedToTemporaryFile: hash = ") - << dataHash.toHex() << QStringLiteral(", error description = ") + QNDEBUG("ImageResourceRotationDelegate::" + << "onResourceDataSavedToTemporaryFile: hash = " + << dataHash.toHex() << ", error description = " << errorDescription); if (Q_UNLIKELY(!errorDescription.isEmpty())) @@ -317,9 +320,9 @@ return; } - QNTRACE(QStringLiteral("Created a link to the original file (") + QNTRACE("Created a link to the original file (" << QDir::toNativeSeparators(fileStoragePath) - << QStringLiteral("): ") << QDir::toNativeSeparators(linkFilePath)); + << "): " << QDir::toNativeSeparators(linkFilePath)); m_resourceFileStoragePathAfter = linkFilePath; @@ -362,13 +365,12 @@ // NOTE: there appears to be a bug in Qt for Windows, QFile::remove // returns false for any *.lnk files even though the files are // actually getting removed - QNTRACE(QStringLiteral("Skipping the reported failure at " - "removing the .lnk file")); + QNTRACE("Skipping the reported failure at removing the .lnk file"); } else { #endif - QNINFO(QStringLiteral("Can't remove stale resource file ") + QNINFO("Can't remove stale resource file " << m_resourceFileStoragePathBefore); #ifdef Q_OS_WIN @@ -389,9 +391,10 @@ JsCallback(*this, &ImageResourceRotationDelegate::onResourceTagHashUpdated)); } -void ImageResourceRotationDelegate::onResourceTagHashUpdated(const QVariant & data) +void ImageResourceRotationDelegate::onResourceTagHashUpdated( + const QVariant & data) { - QNDEBUG(QStringLiteral("ImageResourceRotationDelegate::onResourceTagHashUpdated")); + QNDEBUG("ImageResourceRotationDelegate::onResourceTagHashUpdated"); Q_UNUSED(data) @@ -414,9 +417,10 @@ JsCallback(*this, &ImageResourceRotationDelegate::onResourceTagSrcUpdated)); } -void ImageResourceRotationDelegate::onResourceTagSrcUpdated(const QVariant & data) +void ImageResourceRotationDelegate::onResourceTagSrcUpdated( + const QVariant & data) { - QNDEBUG(QStringLiteral("ImageResourceRotationDelegate::onResourceTagSrcUpdated")); + QNDEBUG("ImageResourceRotationDelegate::onResourceTagSrcUpdated"); Q_UNUSED(data) diff -Nru libquentier-0.5.0/src/note_editor/delegates/ImageResourceRotationDelegate.h libquentier-0.5.0/src/note_editor/delegates/ImageResourceRotationDelegate.h --- libquentier-0.5.0/src/note_editor/delegates/ImageResourceRotationDelegate.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/delegates/ImageResourceRotationDelegate.h 2019-07-11 10:46:53.000000000 +0000 @@ -21,7 +21,9 @@ #include "../NoteEditor_p.h" #include "JsResultCallbackFunctor.hpp" + #include <quentier/types/Resource.h> + #include <QSize> namespace quentier { diff -Nru libquentier-0.5.0/src/note_editor/delegates/InsertHtmlDelegate.cpp libquentier-0.5.0/src/note_editor/delegates/InsertHtmlDelegate.cpp --- libquentier-0.5.0/src/note_editor/delegates/InsertHtmlDelegate.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/delegates/InsertHtmlDelegate.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -20,6 +20,7 @@ #include "../NoteEditor_p.h" #include "../NoteEditorPage.h" #include "../ResourceDataInTemporaryFileStorageManager.h" + #include <quentier/enml/ENMLConverter.h> #include <quentier/types/Account.h> #include <quentier/types/Note.h> @@ -27,6 +28,7 @@ #include <quentier/utility/Utility.h> #include <quentier/logging/QuentierLogger.h> #include <quentier/enml/ENMLConverter.h> + #include <QXmlStreamReader> #include <QXmlStreamWriter> #include <QSet> @@ -37,6 +39,7 @@ #include <QMimeType> #include <QMimeDatabase> #include <QTemporaryFile> + #include <limits> namespace quentier { @@ -69,7 +72,7 @@ void InsertHtmlDelegate::start() { - QNDEBUG(QStringLiteral("InsertHtmlDelegate::start")); + QNDEBUG("InsertHtmlDelegate::start"); if (m_noteEditor.isEditorPageModified()) { @@ -88,7 +91,7 @@ void InsertHtmlDelegate::onOriginalPageConvertedToNote(Note note) { - QNDEBUG(QStringLiteral("InsertHtmlDelegate::onOriginalPageConvertedToNote")); + QNDEBUG("InsertHtmlDelegate::onOriginalPageConvertedToNote"); Q_UNUSED(note) @@ -101,26 +104,25 @@ doStart(); } -void InsertHtmlDelegate::onResourceDataSavedToTemporaryFile(QUuid requestId, - QByteArray dataHash, - ErrorString errorDescription) +void InsertHtmlDelegate::onResourceDataSavedToTemporaryFile( + QUuid requestId, QByteArray dataHash, ErrorString errorDescription) { auto it = m_resourceBySaveDataToTemporaryFileRequestId.find(requestId); if (it == m_resourceBySaveDataToTemporaryFileRequestId.end()) { return; } - QNDEBUG(QStringLiteral("InsertHtmlDelegate::onResourceDataSavedToTemporaryFile: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", data hash = ") << dataHash.toHex() - << QStringLiteral(", error description: ") << errorDescription); + QNDEBUG("InsertHtmlDelegate::onResourceDataSavedToTemporaryFile: " + << "request id = " << requestId + << ", data hash = " << dataHash.toHex() + << ", error description: " << errorDescription); Resource resource = it.value(); Q_UNUSED(m_resourceBySaveDataToTemporaryFileRequestId.erase(it)) if (Q_UNLIKELY(!errorDescription.isEmpty())) { - QNWARNING(QStringLiteral("Failed to save the resource to a temporary file: ") + QNWARNING("Failed to save the resource to a temporary file: " << errorDescription); auto urlIt = m_sourceUrlByResourceLocalUid.find(resource.localUid()); @@ -181,7 +183,7 @@ void InsertHtmlDelegate::onHtmlInserted(const QVariant & responseData) { - QNDEBUG(QStringLiteral("InsertHtmlDelegate::onHtmlInserted")); + QNDEBUG("InsertHtmlDelegate::onHtmlInserted"); QMap<QString,QVariant> resultMap = responseData.toMap(); @@ -237,12 +239,12 @@ if (Q_UNLIKELY(!resource.hasDataHash())) { - QNDEBUG(QStringLiteral("One of added resources has no data hash")); + QNDEBUG("One of added resources has no data hash"); if (Q_UNLIKELY(!resource.hasDataBody())) { - QNDEBUG(QStringLiteral("This resource has no data body as well, " - "will just skip it")); + QNDEBUG("This resource has no data body as well, " + "will just skip it"); continue; } @@ -253,12 +255,12 @@ if (Q_UNLIKELY(!resource.hasDataSize())) { - QNDEBUG(QStringLiteral("One of added resources has no data size")); + QNDEBUG("One of added resources has no data size"); if (Q_UNLIKELY(!resource.hasDataBody())) { - QNDEBUG(QStringLiteral("This resource has no data body as well, " - "will just skip it")); + QNDEBUG("This resource has no data body as well, " + "will just skip it"); continue; } @@ -284,14 +286,14 @@ resourceFileStoragePaths << imgData.m_resourceFileStoragePath; } - QNDEBUG(QStringLiteral("Finished the html insertion, number of added image ") - << QStringLiteral("resources: ") << resources.size()); + QNDEBUG("Finished the html insertion, number of added image " + << "resources: " << resources.size()); Q_EMIT finished(resources, resourceFileStoragePaths); } void InsertHtmlDelegate::doStart() { - QNDEBUG(QStringLiteral("InsertHtmlDelegate::doStart")); + QNDEBUG("InsertHtmlDelegate::doStart"); if (Q_UNLIKELY(m_inputHtml.isEmpty())) { @@ -353,7 +355,7 @@ lastElementName = reader.name().toString(); lastElementAttributes = reader.attributes(); - QNTRACE(QStringLiteral("Start element: ") << lastElementName); + QNTRACE("Start element: " << lastElementName); if ( (lastElementName == QStringLiteral("title")) || (lastElementName == QStringLiteral("head")) ) @@ -369,8 +371,8 @@ else if (lastElementName == QStringLiteral("img")) { if (!lastElementAttributes.hasAttribute(QStringLiteral("src"))) { - QNDEBUG(QStringLiteral("Detected an img tag without src " - "attribute, will skip this tag")); + QNDEBUG("Detected an img tag without src " + "attribute, will skip this tag"); continue; } @@ -378,8 +380,8 @@ lastElementAttributes.value(QStringLiteral("src")).toString(); QUrl url(urlString); if (Q_UNLIKELY(!url.isValid())) { - QNDEBUG(QStringLiteral("Can't convert the img tag's src to a " - "valid URL, will skip this tag; url = ") + QNDEBUG("Can't convert the img tag's src to a " + << "valid URL, will skip this tag; url = " << urlString); continue; } @@ -389,9 +391,9 @@ else if (lastElementName == QStringLiteral("a")) { if (!lastElementAttributes.hasAttribute(QStringLiteral("href"))) { - QNDEBUG(QStringLiteral("Detected an a tag without href attribute, " - "will skip the tag itself but preserving " - "its internal content")); + QNDEBUG("Detected an a tag without href attribute, " + "will skip the tag itself but preserving " + "its internal content"); ++skippedElementWithPreservedContentsNestingCounter; continue; } @@ -400,8 +402,8 @@ lastElementAttributes.value(QStringLiteral("href")).toString(); QUrl url(urlString); if (Q_UNLIKELY(!url.isValid())) { - QNDEBUG(QStringLiteral("Can't convert the a tag's href to " - "a valid URL, will skip this tag; url = ") + QNDEBUG("Can't convert the a tag's href to " + << "a valid URL, will skip this tag; url = " << urlString); ++skippedElementWithPreservedContentsNestingCounter; continue; @@ -411,8 +413,8 @@ writer.writeStartElement(lastElementName); writer.writeAttributes(lastElementAttributes); ++writeElementCounter; - QNTRACE(QStringLiteral("Wrote element: name = ") << lastElementName - << QStringLiteral(" and its attributes")); + QNTRACE("Wrote element: name = " << lastElementName + << " and its attributes"); } if ((writeElementCounter > 0) && reader.isCharacters()) @@ -421,17 +423,17 @@ if (reader.isCDATA()) { writer.writeCDATA(text); - QNTRACE(QStringLiteral("Wrote CDATA: ") << text); + QNTRACE("Wrote CDATA: " << text); } else { writer.writeCharacters(text); - QNTRACE(QStringLiteral("Wrote characters: ") << text); + QNTRACE("Wrote characters: " << text); } } if (reader.isEndElement()) { - QNTRACE(QStringLiteral("End element")); + QNTRACE("End element"); if (writeElementCounter <= 0) { continue; @@ -452,20 +454,20 @@ ErrorString errorDescription(QT_TR_NOOP("Can't insert HTML: unable to " "analyze the HTML")); errorDescription.details() = reader.errorString(); - QNWARNING(QStringLiteral("Error reading html: ") << errorDescription - << QStringLiteral(", HTML: ") << m_cleanedUpHtml); + QNWARNING("Error reading html: " << errorDescription + << ", HTML: " << m_cleanedUpHtml); Q_EMIT notifyError(errorDescription); return; } m_cleanedUpHtml = secondRoundCleanedUpHtml; - QNTRACE(QStringLiteral("HTML after cleaning up bad img and a tags: ") + QNTRACE("HTML after cleaning up bad img and a tags: " << m_cleanedUpHtml); if (m_imageUrls.isEmpty()) { - QNDEBUG(QStringLiteral("Found no images within the input HTML, thus " - "don't need to download them")); + QNDEBUG("Found no images within the input HTML, thus " + "don't need to download them"); insertHtmlIntoEditor(); return; } @@ -473,7 +475,7 @@ QNetworkAccessManager::NetworkAccessibility networkAccessibility = m_networkAccessManager.networkAccessible(); if (networkAccessibility != QNetworkAccessManager::Accessible) { - QNDEBUG(QStringLiteral("The network is not accessible, can't load any image")); + QNDEBUG("The network is not accessible, can't load any image"); m_failingImageUrls = m_imageUrls; checkImageResourcesReady(); return; @@ -495,19 +497,19 @@ const QUrl & url = *it; QNetworkRequest request(url); Q_UNUSED(m_networkAccessManager.get(request)) - QNTRACE(QStringLiteral("Issued get request for url " ) << url); + QNTRACE("Issued get request for url " << url); } } void InsertHtmlDelegate::onImageDataDownloadFinished(QNetworkReply * pReply) { - QNDEBUG(QStringLiteral("InsertHtmlDelegate::onImageDataDownloadFinished: url = ") + QNDEBUG("InsertHtmlDelegate::onImageDataDownloadFinished: url = " << (pReply ? pReply->url().toString() : QStringLiteral("<null>"))); if (Q_UNLIKELY(!pReply)) { - QNWARNING(QStringLiteral("Received null QNetworkReply while trying to " - "download the image from the pasted HTML")); + QNWARNING("Received null QNetworkReply while trying to " + "download the image from the pasted HTML"); checkImageResourcesReady(); return; } @@ -528,8 +530,7 @@ QNetworkRequest request(redirectUrl); Q_UNUSED(m_networkAccessManager.get(request)) - QNTRACE(QStringLiteral("Issued get request for redirect url: ") - << redirectUrl); + QNTRACE("Issued get request for redirect url: " << redirectUrl); pReply->deleteLater(); return; @@ -541,10 +542,9 @@ QNetworkReply::NetworkError error = pReply->error(); if (error != QNetworkReply::NoError) { - QNWARNING(QStringLiteral("Detected error when attempting to download ") - << QStringLiteral("the image from pasted HTML: ") - << pReply->errorString() << QStringLiteral(", error code = ") - << error); + QNWARNING("Detected error when attempting to download " + << "the image from pasted HTML: " + << pReply->errorString() << ", error code = " << error); checkImageResourcesReady(); pReply->deleteLater(); return; @@ -557,45 +557,44 @@ bool res = image.loadFromData(downloadedData); if (Q_UNLIKELY(!res)) { - QNDEBUG(QStringLiteral("Wasn't able to load the image from the downloaded " - "data without format specification")); + QNDEBUG("Wasn't able to load the image from the downloaded " + "data without format specification"); QString format; QString urlString = url.toString(); - int dotIndex = urlString.lastIndexOf(QStringLiteral("."), -1, Qt::CaseInsensitive); + int dotIndex = urlString.lastIndexOf(QStringLiteral("."), -1, + Qt::CaseInsensitive); if (dotIndex >= 0) { format = urlString.mid(dotIndex + 1, urlString.size() - dotIndex - 1); - QNTRACE(QStringLiteral("Trying to load the image with format ") - << format); + QNTRACE("Trying to load the image with format " << format); res = image.loadFromData(downloadedData, format.toUpper().toLocal8Bit().constData()); } else { - QNDEBUG(QStringLiteral("Can't find the last dot within the url, ") - << QStringLiteral("can't deduce the image format; url = ") - << urlString); + QNDEBUG("Can't find the last dot within the url, " + << "can't deduce the image format; url = " << urlString); } if (!res) { - QNTRACE(QStringLiteral("Still can't load the image from the downloaded " - "data, trying to write it to the temporary file " - "first and load from there")); + QNTRACE("Still can't load the image from the downloaded " + "data, trying to write it to the temporary file " + "first and load from there"); QTemporaryFile file; if (file.open()) { Q_UNUSED(file.write(downloadedData)); file.flush(); - QNTRACE(QStringLiteral("Wrote the downloaded data into " - "the temporary file: ") << file.fileName()); + QNTRACE("Wrote the downloaded data into the temporary file: " + << file.fileName()); res = image.load(file.fileName()); if (!res) { - QNTRACE(QStringLiteral("Could not load the image from temporary " - "file without format specification")); + QNTRACE("Could not load the image from temporary " + "file without format specification"); } if (!res && !format.isEmpty()) @@ -603,9 +602,9 @@ res = image.load(file.fileName(), format.toUpper().toLocal8Bit().constData()); if (!res) { - QNTRACE(QStringLiteral("Could not load the image from " - "temporary file with the format " - "specification too: ") << format); + QNTRACE("Could not load the image from " + << "temporary file with the format " + << "specification too: " << format); } } } @@ -618,7 +617,7 @@ } } - QNDEBUG(QStringLiteral("Successfully loaded the image from the downloaded data")); + QNDEBUG("Successfully loaded the image from the downloaded data"); QByteArray pngImageData; QBuffer buffer(&pngImageData); @@ -627,8 +626,8 @@ res = image.save(&buffer, "PNG"); if (Q_UNLIKELY(!res)) { - QNDEBUG(QStringLiteral("Wasn't able to save the downloaded image to PNG " - "format byte array")); + QNDEBUG("Wasn't able to save the downloaded image to PNG " + "format byte array"); Q_UNUSED(m_failingImageUrls.insert(url)) checkImageResourcesReady(); return; @@ -638,31 +637,30 @@ res = addResource(pngImageData, url); if (Q_UNLIKELY(!res)) { - QNDEBUG(QStringLiteral("Wasn't able to add the image to note as a resource")); + QNDEBUG("Wasn't able to add the image to note as a resource"); Q_UNUSED(m_failingImageUrls.insert(url)) checkImageResourcesReady(); return; } - QNDEBUG(QStringLiteral("Successfully added the image to note as a resource")); + QNDEBUG("Successfully added the image to note as a resource"); checkImageResourcesReady(); } void InsertHtmlDelegate::checkImageResourcesReady() { - QNDEBUG(QStringLiteral("InsertHtmlDelegate::checkImageResourcesReady")); + QNDEBUG("InsertHtmlDelegate::checkImageResourcesReady"); if (!m_pendingImageUrls.isEmpty()) { - QNDEBUG(QStringLiteral("Still pending the download of ") - << QString::number(m_pendingImageUrls.size()) - << QStringLiteral(" images")); + QNDEBUG("Still pending the download of " + << QString::number(m_pendingImageUrls.size()) << " images"); return; } if (!m_resourceBySaveDataToTemporaryFileRequestId.isEmpty()) { - QNDEBUG(QStringLiteral("Still pending saving of ") + QNDEBUG("Still pending saving of " << QString::number(m_resourceBySaveDataToTemporaryFileRequestId.size()) - << QStringLiteral(" images")); + << " images"); return; } @@ -676,7 +674,7 @@ bool InsertHtmlDelegate::adjustImgTagsInHtml() { - QNDEBUG(QStringLiteral("InsertHtmlDelegate::adjustImgTagsInHtml")); + QNDEBUG("InsertHtmlDelegate::adjustImgTagsInHtml"); QString supplementedHtml = QStringLiteral("<html><body>"); supplementedHtml += m_cleanedUpHtml; @@ -714,7 +712,7 @@ lastElementName = reader.name().toString(); lastElementAttributes = reader.attributes(); - QNTRACE(QStringLiteral("Start element: ") << lastElementName); + QNTRACE("Start element: " << lastElementName); if ( (lastElementName == QStringLiteral("title")) || (lastElementName == QStringLiteral("head")) ) @@ -730,8 +728,8 @@ else if (lastElementName == QStringLiteral("img")) { if (!lastElementAttributes.hasAttribute(QStringLiteral("src"))) { - QNDEBUG(QStringLiteral("Detected an img tag without src " - "attribute, will skip this img tag")); + QNDEBUG("Detected an img tag without src " + "attribute, will skip this img tag"); continue; } @@ -739,42 +737,42 @@ lastElementAttributes.value(QStringLiteral("src")).toString(); QUrl url(urlString); if (m_failingImageUrls.contains(url)) { - QNDEBUG(QStringLiteral("The image url ") << url - << QStringLiteral(" was marked as a failing one, ") - << QStringLiteral(", will skip this img tag")); + QNDEBUG("The image url " << url + << " was marked as a failing one, " + << ", will skip this img tag"); continue; } auto it = m_imgDataBySourceUrl.find(url); if (Q_UNLIKELY(it == m_imgDataBySourceUrl.end())) { - QNDEBUG(QStringLiteral("Can't find the replacement data for ") - << QStringLiteral("the image url ") << url - << QStringLiteral(", see if it's due to redirect url usage")); + QNDEBUG("Can't find the replacement data for " + << "the image url " << url + << ", see if it's due to redirect url usage"); auto rit = m_urlToRedirectUrl.find(url); if (rit == m_urlToRedirectUrl.end()) { - QNDEBUG(QStringLiteral("Couldn't find the redirect url for url ") - << url << QStringLiteral(", will just skip this img tag")); + QNDEBUG("Couldn't find the redirect url for url " + << url << ", will just skip this img tag"); continue; } const QUrl & redirectUrl = rit.value(); - QNDEBUG(QStringLiteral("Found redirect url for url ") << url - << QStringLiteral(": ") << redirectUrl); + QNDEBUG("Found redirect url for url " << url + << ": " << redirectUrl); it = m_imgDataBySourceUrl.find(redirectUrl); if (it == m_imgDataBySourceUrl.end()) { - QNDEBUG(QStringLiteral("Couldn't find the replacement data ") - << QStringLiteral("for the image's redirect url ") + QNDEBUG("Couldn't find the replacement data " + << "for the image's redirect url " << redirectUrl - << QStringLiteral(", will just skip this img tag")); + << ", will just skip this img tag"); continue; } } - QNDEBUG(QStringLiteral("Successfully found the replacement data " - "for the image url")); + QNDEBUG("Successfully found the replacement data " + "for the image url"); const ImgData & imgData = it.value(); ErrorString resourceHtmlComposingError; QString resourceHtml = @@ -787,7 +785,7 @@ QT_TR_NOOP("Can't insert HTML: can't compose the HTML " "representation of a resource that replaced " "the external image link")); - QNWARNING(errorDescription << QStringLiteral("; resource: ") + QNWARNING(errorDescription << "; resource: " << imgData.m_resource); Q_EMIT notifyError(errorDescription); return false; @@ -828,8 +826,8 @@ QT_TR_NOOP("Can't insert HTML: failed to read the composed " "resource HTML")); errorDescription.details() = resourceHtmlReader.errorString(); - QNWARNING(QStringLiteral("Error reading html: ") << errorDescription - << QStringLiteral(", HTML: ") << m_cleanedUpHtml); + QNWARNING("Error reading html: " << errorDescription + << ", HTML: " << m_cleanedUpHtml); Q_EMIT notifyError(errorDescription); return false; } @@ -842,8 +840,8 @@ writer.writeStartElement(lastElementName); writer.writeAttributes(lastElementAttributes); ++writeElementCounter; - QNTRACE(QStringLiteral("Wrote element: name = ") << lastElementName - << QStringLiteral(" and its attributes")); + QNTRACE("Wrote element: name = " << lastElementName + << " and its attributes"); } if ((writeElementCounter > 0) && reader.isCharacters()) @@ -852,17 +850,17 @@ if (reader.isCDATA()) { writer.writeCDATA(text); - QNTRACE(QStringLiteral("Wrote CDATA: ") << text); + QNTRACE("Wrote CDATA: " << text); } else { writer.writeCharacters(text); - QNTRACE(QStringLiteral("Wrote characters: ") << text); + QNTRACE("Wrote characters: " << text); } } if (reader.isEndElement()) { - QNTRACE(QStringLiteral("End element")); + QNTRACE("End element"); if (writeElementCounter <= 0) { continue; @@ -873,24 +871,26 @@ } } - if (reader.hasError()) { - ErrorString errorDescription(QT_TR_NOOP("Can't insert HTML: failed to read " - "and recompose the cleaned up HTML")); + if (reader.hasError()) + { + ErrorString errorDescription( + QT_TR_NOOP("Can't insert HTML: failed to read " + "and recompose the cleaned up HTML")); errorDescription.details() = reader.errorString(); - QNWARNING(QStringLiteral("Error reading html: ") << errorDescription - << QStringLiteral(", HTML: ") << m_cleanedUpHtml); + QNWARNING("Error reading html: " << errorDescription + << ", HTML: " << m_cleanedUpHtml); Q_EMIT notifyError(errorDescription); return false; } m_cleanedUpHtml = htmlWithAlteredImgTags; - QNTRACE(QStringLiteral("HTML after altering the img tags: ") << m_cleanedUpHtml); + QNTRACE("HTML after altering the img tags: " << m_cleanedUpHtml); return true; } void InsertHtmlDelegate::insertHtmlIntoEditor() { - QNDEBUG(QStringLiteral("InsertHtmlDelegate::insertHtmlIntoEditor")); + QNDEBUG("InsertHtmlDelegate::insertHtmlIntoEditor"); NoteEditorPage * pPage = qobject_cast<NoteEditorPage*>(m_noteEditor.page()); if (Q_UNLIKELY(!pPage)) { @@ -902,9 +902,9 @@ ENMLConverter::escapeString(m_cleanedUpHtml, /* simplify = */ false); m_cleanedUpHtml = m_cleanedUpHtml.trimmed(); - QNTRACE(QStringLiteral("Trimmed HTML: ") << m_cleanedUpHtml); + QNTRACE("Trimmed HTML: " << m_cleanedUpHtml); m_cleanedUpHtml.replace(QStringLiteral("\n"), QStringLiteral("\\n")); - QNTRACE(QStringLiteral("Trimmed HTML with escaped newlines: ") << m_cleanedUpHtml); + QNTRACE("Trimmed HTML with escaped newlines: " << m_cleanedUpHtml); pPage->executeJavaScript( QStringLiteral("htmlInsertionManager.insertHtml('") + @@ -915,12 +915,12 @@ bool InsertHtmlDelegate::addResource(const QByteArray & resourceData, const QUrl & url) { - QNDEBUG(QStringLiteral("InsertHtmlDelegate::addResource")); + QNDEBUG("InsertHtmlDelegate::addResource"); const Note * pNote = m_noteEditor.notePtr(); if (Q_UNLIKELY(!pNote)) { - QNWARNING(QStringLiteral("Can't add image from inserted HTML: no note " - "is set to the editor")); + QNWARNING("Can't add image from inserted HTML: no note " + "is set to the editor"); return false; } @@ -929,45 +929,45 @@ bool noteHasLimits = pNote->hasNoteLimits(); if (noteHasLimits) { - QNTRACE(QStringLiteral("Note has its own limits, will use them to check " - "the number of note resources")); + QNTRACE("Note has its own limits, will use them to check " + "the number of note resources"); const qevercloud::NoteLimits & limits = pNote->noteLimits(); if (limits.noteResourceCountMax.isSet() && (limits.noteResourceCountMax.ref() == pNote->numResources())) { - QNINFO(QStringLiteral("Can't add image from inserted HTML: the note " - "is already at max allowed number of attachments " - "(judging by note limits)")); + QNINFO("Can't add image from inserted HTML: the note " + "is already at max allowed number of attachments " + "(judging by note limits)"); return false; } } else if (pAccount) { - QNTRACE(QStringLiteral("Note has no limits of its own, will use " - "the account-wise limits to check the number " - "of note resources")); + QNTRACE("Note has no limits of its own, will use " + "the account-wise limits to check the number " + "of note resources"); int numNoteResources = pNote->numResources(); ++numNoteResources; if (numNoteResources > pAccount->noteResourceCountMax()) { - QNINFO(QStringLiteral("Can't add image from inserted HTML: the note " - "is already at max allowed number of attachments " - "(judging by account limits)")); + QNINFO("Can't add image from inserted HTML: the note " + "is already at max allowed number of attachments " + "(judging by account limits)"); return false; } } else { - QNINFO(QStringLiteral("No account when adding image from inserted HTML " - "to note, can't check the account-wise note limits")); + QNINFO("No account when adding image from inserted HTML " + "to note, can't check the account-wise note limits"); } QMimeDatabase mimeDatabase; QMimeType mimeType = mimeDatabase.mimeTypeForData(resourceData); if (Q_UNLIKELY(!mimeType.isValid())) { - QNDEBUG(QStringLiteral("Could not deduce the resource data's mime type " - "from the data, fallback to image/png")); + QNDEBUG("Could not deduce the resource data's mime type " + "from the data, fallback to image/png"); mimeType = mimeDatabase.mimeTypeForName(QStringLiteral("image/png")); } @@ -997,11 +997,11 @@ QUuid requestId = QUuid::createUuid(); m_resourceBySaveDataToTemporaryFileRequestId[requestId] = resource; - QNTRACE(QStringLiteral("Emitting the request to save the image resource to ") - << QStringLiteral("a temporary file: request id = ") << requestId - << QStringLiteral(", resource local uid = ") << resource.localUid() - << QStringLiteral(", data hash = ") << dataHash.toHex() - << QStringLiteral(", mime type name = ") << mimeType.name()); + QNTRACE("Emitting the request to save the image resource to " + << "a temporary file: request id = " << requestId + << ", resource local uid = " << resource.localUid() + << ", data hash = " << dataHash.toHex() + << ", mime type name = " << mimeType.name()); Q_EMIT saveResourceDataToTemporaryFile(pNote->localUid(), resource.localUid(), resourceData, dataHash, requestId, /* is image = */ true); @@ -1010,7 +1010,7 @@ void InsertHtmlDelegate::removeAddedResourcesFromNote() { - QNDEBUG(QStringLiteral("InsertHtmlDelegate::removeAddedResourcesFromNote")); + QNDEBUG("InsertHtmlDelegate::removeAddedResourcesFromNote"); for(auto iit = m_imgDataBySourceUrl.constBegin(), iend = m_imgDataBySourceUrl.constEnd(); iit != iend; ++iit) diff -Nru libquentier-0.5.0/src/note_editor/delegates/InsertHtmlDelegate.h libquentier-0.5.0/src/note_editor/delegates/InsertHtmlDelegate.h --- libquentier-0.5.0/src/note_editor/delegates/InsertHtmlDelegate.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/delegates/InsertHtmlDelegate.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,10 +20,12 @@ #define LIB_QUENTIER_NOTE_EDITOR_DELEGATES_INSERT_HTML_DELEGATE_H #include "JsResultCallbackFunctor.hpp" + #include <quentier/utility/Macros.h> #include <quentier/types/Note.h> #include <quentier/types/Resource.h> #include <quentier/types/ErrorString.h> + #include <QObject> #include <QNetworkAccessManager> #include <QNetworkRequest> diff -Nru libquentier-0.5.0/src/note_editor/delegates/RemoveHyperlinkDelegate.cpp libquentier-0.5.0/src/note_editor/delegates/RemoveHyperlinkDelegate.cpp --- libquentier-0.5.0/src/note_editor/delegates/RemoveHyperlinkDelegate.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/delegates/RemoveHyperlinkDelegate.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,20 +18,22 @@ #include "RemoveHyperlinkDelegate.h" #include "../NoteEditor_p.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { -#define GET_PAGE() \ - NoteEditorPage * page = qobject_cast<NoteEditorPage*>(m_noteEditor.page()); \ - if (Q_UNLIKELY(!page)) { \ - ErrorString error(QT_TRANSLATE_NOOP("RemoveHyperlinkDelegate", \ - "Can't remove hyperlink: no note "\ - "editor's page")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } +#define GET_PAGE() \ + NoteEditorPage * page = qobject_cast<NoteEditorPage*>(m_noteEditor.page());\ + if (Q_UNLIKELY(!page)) { \ + ErrorString error(QT_TRANSLATE_NOOP("RemoveHyperlinkDelegate", \ + "Can't remove hyperlink: no note " \ + "editor's page")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// GET_PAGE RemoveHyperlinkDelegate::RemoveHyperlinkDelegate(NoteEditorPrivate & noteEditor) : QObject(¬eEditor), @@ -40,7 +42,7 @@ void RemoveHyperlinkDelegate::start() { - QNDEBUG(QStringLiteral("RemoveHyperlinkDelegate::start")); + QNDEBUG("RemoveHyperlinkDelegate::start"); if (m_noteEditor.isEditorPageModified()) { @@ -59,7 +61,7 @@ void RemoveHyperlinkDelegate::onOriginalPageConvertedToNote(Note note) { - QNDEBUG(QStringLiteral("RemoveHyperlinkDelegate::onOriginalPageConvertedToNote")); + QNDEBUG("RemoveHyperlinkDelegate::onOriginalPageConvertedToNote"); Q_UNUSED(note) @@ -74,7 +76,7 @@ void RemoveHyperlinkDelegate::findIdOfHyperlinkUnderCursor() { - QNDEBUG(QStringLiteral("RemoveHyperlinkDelegate::findIdOfHyperlinkUnderCursor")); + QNDEBUG("RemoveHyperlinkDelegate::findIdOfHyperlinkUnderCursor"); QString javascript = QStringLiteral("hyperlinkManager.findSelectedHyperlinkId();"); GET_PAGE() @@ -85,7 +87,7 @@ void RemoveHyperlinkDelegate::onHyperlinkIdFound(const QVariant & data) { - QNDEBUG(QStringLiteral("RemoveHyperlinkDelegate::onHyperlinkIdFound: ") + QNDEBUG("RemoveHyperlinkDelegate::onHyperlinkIdFound: " << data); QMap<QString,QVariant> resultMap = data.toMap(); @@ -138,7 +140,7 @@ { ErrorString error(QT_TR_NOOP("Can't remove hyperlink under cursor: " "can't convert hyperlink id to a number")); - QNWARNING(error << QStringLiteral(", data from JS: ") << data); + QNWARNING(error << ", data from JS: " << data); Q_EMIT notifyError(error); return; } @@ -148,7 +150,7 @@ void RemoveHyperlinkDelegate::removeHyperlink(const quint64 hyperlinkId) { - QNDEBUG(QStringLiteral("RemoveHyperlinkDelegate::removeHyperlink")); + QNDEBUG("RemoveHyperlinkDelegate::removeHyperlink"); QString javascript = QStringLiteral("hyperlinkManager.removeHyperlink(") + QString::number(hyperlinkId) + QStringLiteral(", false);"); @@ -161,8 +163,7 @@ void RemoveHyperlinkDelegate::onHyperlinkRemoved(const QVariant & data) { - QNDEBUG(QStringLiteral("RemoveHyperlinkDelegate::onHyperlinkRemoved: ") - << data); + QNDEBUG("RemoveHyperlinkDelegate::onHyperlinkRemoved: " << data); QMap<QString,QVariant> resultMap = data.toMap(); diff -Nru libquentier-0.5.0/src/note_editor/delegates/RemoveHyperlinkDelegate.h libquentier-0.5.0/src/note_editor/delegates/RemoveHyperlinkDelegate.h --- libquentier-0.5.0/src/note_editor/delegates/RemoveHyperlinkDelegate.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/delegates/RemoveHyperlinkDelegate.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,6 +20,7 @@ #define LIB_QUENTIER_NOTE_EDITOR_DELEGATE_REMOVE_HYPERLINK_DELEGATE_H #include "JsResultCallbackFunctor.hpp" + #include <quentier/types/Note.h> #include <quentier/types/ErrorString.h> diff -Nru libquentier-0.5.0/src/note_editor/delegates/RemoveResourceDelegate.cpp libquentier-0.5.0/src/note_editor/delegates/RemoveResourceDelegate.cpp --- libquentier-0.5.0/src/note_editor/delegates/RemoveResourceDelegate.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/delegates/RemoveResourceDelegate.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -19,26 +19,29 @@ #include "RemoveResourceDelegate.h" #include "../NoteEditor_p.h" #include "../NoteEditorSettingsNames.h" + #include <quentier/local_storage/LocalStorageManagerAsync.h> #include <quentier/utility/ApplicationSettings.h> #include <quentier/utility/MessageBox.h> #include <quentier/utility/Utility.h> #include <quentier/logging/QuentierLogger.h> + #include <cmath> #include <algorithm> namespace quentier { -#define GET_PAGE() \ - NoteEditorPage * page = qobject_cast<NoteEditorPage*>(m_noteEditor.page()); \ - if (Q_UNLIKELY(!page)) { \ - ErrorString error(QT_TRANSLATE_NOOP("RemoveResourceDelegate", \ - "Can't remove the attachment: "\ - "no note editor page")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } +#define GET_PAGE() \ + NoteEditorPage * page = qobject_cast<NoteEditorPage*>(m_noteEditor.page());\ + if (Q_UNLIKELY(!page)) { \ + ErrorString error(QT_TRANSLATE_NOOP("RemoveResourceDelegate", \ + "Can't remove the attachment: " \ + "no note editor page")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// GET_PAGE RemoveResourceDelegate::RemoveResourceDelegate( const Resource & resourceToRemove, @@ -53,7 +56,7 @@ void RemoveResourceDelegate::start() { - QNDEBUG(QStringLiteral("RemoveResourceDelegate::start")); + QNDEBUG("RemoveResourceDelegate::start"); if (m_noteEditor.isEditorPageModified()) { QObject::connect(&m_noteEditor, @@ -70,7 +73,7 @@ void RemoveResourceDelegate::onOriginalPageConvertedToNote(Note note) { - QNDEBUG(QStringLiteral("RemoveResourceDelegate::onOriginalPageConvertedToNote")); + QNDEBUG("RemoveResourceDelegate::onOriginalPageConvertedToNote"); Q_UNUSED(note) @@ -91,8 +94,8 @@ return; } - QNDEBUG(QStringLiteral("RemoveResourceDelegate::onFindResourceComplete: ") - << QStringLiteral("request id = ") << requestId); + QNDEBUG("RemoveResourceDelegate::onFindResourceComplete: request id = " + << requestId); Q_UNUSED(options) m_findResourceRequestId = QUuid(); @@ -109,9 +112,8 @@ return; } - QNDEBUG(QStringLiteral("RemoveResourceDelegate::onFindResourceFailed: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", error description: ") << errorDescription); + QNDEBUG("RemoveResourceDelegate::onFindResourceFailed: request id = " + << requestId << ", error description: " << errorDescription); Q_UNUSED(resource) Q_UNUSED(options) @@ -122,7 +124,7 @@ void RemoveResourceDelegate::doStart() { - QNDEBUG(QStringLiteral("RemoveResourceDelegate::doStart")); + QNDEBUG("RemoveResourceDelegate::doStart"); if (Q_UNLIKELY(!m_resource.hasDataHash())) { ErrorString error(QT_TR_NOOP("Can't remove the attachment: " @@ -150,8 +152,8 @@ bool conversionResult = false; resourceDataSizeThreshold = threshold.toInt(&conversionResult); if (!conversionResult) { - QNWARNING(QStringLiteral("Failed to convert resource undo data size " - "threshold from persistent settings to int: ") + QNWARNING("Failed to convert resource undo data size " + << "threshold from persistent settings to int: " << threshold); resourceDataSizeThreshold = -1; } @@ -193,9 +195,9 @@ { connectToLocalStorage(); m_findResourceRequestId = QUuid::createUuid(); - QNDEBUG(QStringLiteral("Emitting the request to find resource within ") - << QStringLiteral("the local storage: request id = ") - << m_findResourceRequestId << QStringLiteral(", resource local uid = ") + QNDEBUG("Emitting the request to find resource within " + << "the local storage: request id = " + << m_findResourceRequestId << ", resource local uid = " << m_resource.localUid()); LocalStorageManager::GetResourceOptions options( LocalStorageManager::GetResourceOption::WithBinaryData); @@ -208,7 +210,7 @@ void RemoveResourceDelegate::removeResourceFromNoteEditorPage() { - QNDEBUG(QStringLiteral("RemoveResourceDelegate::removeResourceFromNoteEditorPage")); + QNDEBUG("RemoveResourceDelegate::removeResourceFromNoteEditorPage"); QString javascript = QStringLiteral("resourceManager.removeResource('") + QString::fromLocal8Bit(m_resource.dataHash().toHex()) + @@ -223,7 +225,7 @@ void RemoveResourceDelegate::connectToLocalStorage() { - QNDEBUG(QStringLiteral("RemoveResourceDelegate::connectToLocalStorage")); + QNDEBUG("RemoveResourceDelegate::connectToLocalStorage"); QObject::connect(this, QNSIGNAL(RemoveResourceDelegate,findResource, @@ -252,8 +254,8 @@ void RemoveResourceDelegate::onResourceReferenceRemovedFromNoteContent( const QVariant & data) { - QNDEBUG(QStringLiteral("RemoveResourceDelegate::" - "onResourceReferenceRemovedFromNoteContent")); + QNDEBUG("RemoveResourceDelegate::" + "onResourceReferenceRemovedFromNoteContent"); QMap<QString,QVariant> resultMap = data.toMap(); diff -Nru libquentier-0.5.0/src/note_editor/delegates/RemoveResourceDelegate.h libquentier-0.5.0/src/note_editor/delegates/RemoveResourceDelegate.h --- libquentier-0.5.0/src/note_editor/delegates/RemoveResourceDelegate.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/delegates/RemoveResourceDelegate.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,11 +20,13 @@ #define LIB_QUENTIER_NOTE_EDITOR_DELEGATES_REMOVE_RESOURCE_DELEGATE_H #include "JsResultCallbackFunctor.hpp" + #include <quentier/types/ErrorString.h> #include <quentier/types/Note.h> #include <quentier/types/Resource.h> #include <quentier/local_storage/LocalStorageManager.h> #include <quentier/utility/Macros.h> + #include <QObject> namespace quentier { diff -Nru libquentier-0.5.0/src/note_editor/delegates/RenameResourceDelegate.cpp libquentier-0.5.0/src/note_editor/delegates/RenameResourceDelegate.cpp --- libquentier-0.5.0/src/note_editor/delegates/RenameResourceDelegate.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/delegates/RenameResourceDelegate.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -20,23 +20,26 @@ #include "../NoteEditor_p.h" #include "../GenericResourceImageManager.h" #include "../dialogs/RenameResourceDialog.h" + #include <quentier/logging/QuentierLogger.h> + #include <QScopedPointer> #include <QBuffer> #include <QImage> namespace quentier { -#define GET_PAGE() \ - NoteEditorPage * page = qobject_cast<NoteEditorPage*>(m_noteEditor.page()); \ - if (Q_UNLIKELY(!page)) { \ - ErrorString error(QT_TRANSLATE_NOOP("RenameResourceDelegate", \ - "Can't rename the attachment: "\ - "no note editor page")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } +#define GET_PAGE() \ + NoteEditorPage * page = qobject_cast<NoteEditorPage*>(m_noteEditor.page());\ + if (Q_UNLIKELY(!page)) { \ + ErrorString error(QT_TRANSLATE_NOOP("RenameResourceDelegate", \ + "Can't rename the attachment: " \ + "no note editor page")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// GET_PAGE RenameResourceDelegate::RenameResourceDelegate( const Resource & resource, NoteEditorPrivate & noteEditor, @@ -60,7 +63,7 @@ void RenameResourceDelegate::start() { - QNDEBUG(QStringLiteral("RenameResourceDelegate::start")); + QNDEBUG("RenameResourceDelegate::start"); if (m_noteEditor.isEditorPageModified()) { @@ -77,12 +80,12 @@ } } -void RenameResourceDelegate::startWithPresetNames(const QString & oldResourceName, - const QString & newResourceName) +void RenameResourceDelegate::startWithPresetNames( + const QString & oldResourceName, const QString & newResourceName) { - QNDEBUG(QStringLiteral("RenameResourceDelegate::startWithPresetNames: ") - << QStringLiteral("old resource name = ") << oldResourceName - << QStringLiteral(", new resource name = ") << newResourceName); + QNDEBUG("RenameResourceDelegate::startWithPresetNames: " + << "old resource name = " << oldResourceName + << ", new resource name = " << newResourceName); m_oldResourceName = oldResourceName; m_newResourceName = newResourceName; @@ -93,7 +96,7 @@ void RenameResourceDelegate::onOriginalPageConvertedToNote(Note note) { - QNDEBUG(QStringLiteral("RenameResourceDelegate::onOriginalPageConvertedToNote")); + QNDEBUG("RenameResourceDelegate::onOriginalPageConvertedToNote"); Q_UNUSED(note) @@ -106,21 +109,22 @@ doStart(); } -#define CHECK_NOTE_ACTUALITY() \ - if (m_noteEditor.notePtr() != m_pNote) { \ - ErrorString error(QT_TRANSLATE_NOOP("RenameResourceDelegate", \ - "The note set to the note editor "\ - "was changed during the attachment "\ - "renaming, the action was not "\ - "completed")); \ - QNDEBUG(error); \ - Q_EMIT notifyError(error); \ - return; \ - } +#define CHECK_NOTE_ACTUALITY() \ + if (m_noteEditor.notePtr() != m_pNote) { \ + ErrorString error( \ + QT_TRANSLATE_NOOP("RenameResourceDelegate", \ + "The note set to the note editor was changed " \ + "during the attachment renaming, the action was "\ + "not completed")); \ + QNDEBUG(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// CHECK_NOTE_ACTUALITY void RenameResourceDelegate::doStart() { - QNDEBUG(QStringLiteral("RenameResourceDelegate::doStart")); + QNDEBUG("RenameResourceDelegate::doStart"); CHECK_NOTE_ACTUALITY() @@ -152,7 +156,7 @@ void RenameResourceDelegate::raiseRenameResourceDialog() { - QNDEBUG(QStringLiteral("RenameResourceDelegate::raiseRenameResourceDialog")); + QNDEBUG("RenameResourceDelegate::raiseRenameResourceDialog"); QScopedPointer<RenameResourceDialog> pRenameResourceDialog( new RenameResourceDialog(m_oldResourceName, &m_noteEditor)); @@ -162,31 +166,32 @@ this, QNSLOT(RenameResourceDelegate, onRenameResourceDialogFinished,QString)); - QNTRACE(QStringLiteral("Will exec rename resource dialog now")); + QNTRACE("Will exec rename resource dialog now"); int res = pRenameResourceDialog->exec(); if (res == QDialog::Rejected) { - QNTRACE(QStringLiteral("Cancelled renaming the resource")); + QNTRACE("Cancelled renaming the resource"); Q_EMIT cancelled(); } } -void RenameResourceDelegate::onRenameResourceDialogFinished(QString newResourceName) +void RenameResourceDelegate::onRenameResourceDialogFinished( + QString newResourceName) { - QNDEBUG(QStringLiteral("RenameResourceDelegate::onRenameResourceDialogFinished: ") - << QStringLiteral("new resource name = ") << newResourceName); + QNDEBUG("RenameResourceDelegate::onRenameResourceDialogFinished: " + << "new resource name = " << newResourceName); if (newResourceName.isEmpty()) { - QNTRACE(QStringLiteral("New resource name is empty, treating it " - "as cancellation")); + QNTRACE("New resource name is empty, treating it " + "as cancellation"); Q_EMIT cancelled(); return; } if (newResourceName == m_oldResourceName) { - QNTRACE(QStringLiteral("The new resource name is equal to the old one, " - "treating it as cancellation")); + QNTRACE("The new resource name is equal to the old one, " + "treating it as cancellation"); Q_EMIT cancelled(); return; } @@ -206,7 +211,7 @@ #ifdef QUENTIER_USE_QT_WEB_ENGINE void RenameResourceDelegate::buildAndSaveGenericResourceImage() { - QNDEBUG(QStringLiteral("RenameResourceDelegate::buildAndSaveGenericResourceImage")); + QNDEBUG("RenameResourceDelegate::buildAndSaveGenericResourceImage"); CHECK_NOTE_ACTUALITY() @@ -219,11 +224,11 @@ m_genericResourceImageWriterRequestId = QUuid::createUuid(); - QNDEBUG(QStringLiteral("Emitting request to write generic resource image ") - << QStringLiteral("for resource with local uid ") - << m_resource.localUid() << QStringLiteral(", request id ") + QNDEBUG("Emitting request to write generic resource image " + << "for resource with local uid " + << m_resource.localUid() << ", request id " << m_genericResourceImageWriterRequestId - << QStringLiteral(", note local uid = ") << m_pNote->localUid()); + << ", note local uid = " << m_pNote->localUid()); QObject::connect(this, QNSIGNAL(RenameResourceDelegate,saveGenericResourceImageToFile, @@ -257,15 +262,13 @@ return; } - QNDEBUG(QStringLiteral("RenameResourceDelegate::") - << QStringLiteral("onGenericResourceImageWriterFinished: success = ") - << (success - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", resource hash = ") << resourceHash.toHex() - << QStringLiteral(", file path = ") << filePath - << QStringLiteral(", error description = ") << errorDescription - << QStringLiteral(", request id = ") << requestId); + QNDEBUG("RenameResourceDelegate::" + << "onGenericResourceImageWriterFinished: success = " + << (success ? "true" : "false") + << ", resource hash = " << resourceHash.toHex() + << ", file path = " << filePath + << ", error description = " << errorDescription + << ", request id = " << requestId); QObject::disconnect(this, QNSIGNAL(RenameResourceDelegate, @@ -313,7 +316,7 @@ void RenameResourceDelegate::onGenericResourceImageUpdated(const QVariant & data) { - QNDEBUG(QStringLiteral("RenameResourceDelegate::onGenericResourceImageUpdated")); + QNDEBUG("RenameResourceDelegate::onGenericResourceImageUpdated"); Q_UNUSED(data) diff -Nru libquentier-0.5.0/src/note_editor/delegates/RenameResourceDelegate.h libquentier-0.5.0/src/note_editor/delegates/RenameResourceDelegate.h --- libquentier-0.5.0/src/note_editor/delegates/RenameResourceDelegate.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/delegates/RenameResourceDelegate.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,10 +20,12 @@ #define LIB_QUENTIER_NOTE_EDITOR_DELEGATES_RENAME_RESOURCE_DELEGATE_H #include "JsResultCallbackFunctor.hpp" + #include <quentier/utility/Macros.h> #include <quentier/types/ErrorString.h> #include <quentier/types/Note.h> #include <quentier/types/Resource.h> + #include <QObject> #include <QUuid> #include <QHash> diff -Nru libquentier-0.5.0/src/note_editor/dialogs/DecryptionDialog.cpp libquentier-0.5.0/src/note_editor/dialogs/DecryptionDialog.cpp --- libquentier-0.5.0/src/note_editor/dialogs/DecryptionDialog.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/dialogs/DecryptionDialog.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -19,6 +19,7 @@ #include "DecryptionDialog.h" #include "ui_DecryptionDialog.h" #include "../NoteEditorSettingsNames.h" + #include <quentier/enml/DecryptedTextManager.h> #include <quentier/utility/QuentierCheckPtr.h> #include <quentier/logging/QuentierLogger.h> @@ -124,8 +125,8 @@ ApplicationSettings appSettings(m_account, NOTE_EDITOR_SETTINGS_NAME); if (!appSettings.isWritable()) { - QNINFO(QStringLiteral("Can't persist remember passphrase for session " - "setting: settings are not writable")); + QNINFO("Can't persist remember passphrase for session " + "setting: settings are not writable"); } else { @@ -157,10 +158,10 @@ errorDescription); if (!res && (m_cipher == QStringLiteral("AES")) && (m_keyLength == 128)) { - QNDEBUG(QStringLiteral("The initial attempt to decrypt the text using " - "AES cipher and 128 bit key has failed; checking " - "whether it is old encrypted text area using RC2 " - "encryption and 64 bit key")); + QNDEBUG("The initial attempt to decrypt the text using " + "AES cipher and 128 bit key has failed; checking " + "whether it is old encrypted text area using RC2 " + "encryption and 64 bit key"); res = m_encryptionManager->decrypt(m_encryptedText, passphrase, QStringLiteral("RC2"), 64, m_cachedDecryptedText, @@ -182,15 +183,11 @@ m_decryptedTextManager->addEntry(m_encryptedText, m_cachedDecryptedText, rememberForSession, passphrase, m_cipher, m_keyLength); - QNTRACE(QStringLiteral("Cached decrypted text for encryptedText: ") - << m_encryptedText << QStringLiteral("; remember for session = ") - << (rememberForSession - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral("; decrypt permanently = ") - << (decryptPermanently - ? QStringLiteral("true") - : QStringLiteral("false"))); + QNTRACE("Cached decrypted text for encryptedText: " + << m_encryptedText << "; remember for session = " + << (rememberForSession ? "true" : "false") + << "; decrypt permanently = " + << (decryptPermanently ? "true" : "false")); Q_EMIT accepted(m_cipher, m_keyLength, m_encryptedText, passphrase, m_cachedDecryptedText, rememberForSession, decryptPermanently); diff -Nru libquentier-0.5.0/src/note_editor/dialogs/DecryptionDialog.h libquentier-0.5.0/src/note_editor/dialogs/DecryptionDialog.h --- libquentier-0.5.0/src/note_editor/dialogs/DecryptionDialog.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/dialogs/DecryptionDialog.h 2019-07-11 10:46:53.000000000 +0000 @@ -23,6 +23,7 @@ #include <quentier/utility/Macros.h> #include <quentier/types/ErrorString.h> #include <quentier/types/Account.h> + #include <QDialog> #include <QSharedPointer> diff -Nru libquentier-0.5.0/src/note_editor/dialogs/EditHyperlinkDialog.cpp libquentier-0.5.0/src/note_editor/dialogs/EditHyperlinkDialog.cpp --- libquentier-0.5.0/src/note_editor/dialogs/EditHyperlinkDialog.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/dialogs/EditHyperlinkDialog.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,6 +18,7 @@ #include "EditHyperlinkDialog.h" #include "ui_EditHyperlinkDialog.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { @@ -61,7 +62,7 @@ void EditHyperlinkDialog::accept() { - QNDEBUG(QStringLiteral("EditHyperlinkDialog::accept")); + QNDEBUG("EditHyperlinkDialog::accept"); QUrl url; bool res = validateAndGetUrl(url); @@ -89,12 +90,12 @@ bool EditHyperlinkDialog::validateAndGetUrl(QUrl & url) { - QNDEBUG(QStringLiteral("EditHyperlinkDialog::validateAndGetUrl")); + QNDEBUG("EditHyperlinkDialog::validateAndGetUrl"); url = QUrl(); QString enteredUrl = m_pUI->urlLineEdit->text(); - QNTRACE(QStringLiteral("Entered URL string: ") << enteredUrl); + QNTRACE("Entered URL string: " << enteredUrl); if (enteredUrl.isEmpty()) { m_pUI->urlErrorLabel->setText(tr("No URL is entered")); @@ -103,10 +104,10 @@ } url = QUrl(enteredUrl, QUrl::TolerantMode); - QNTRACE(QStringLiteral("Parsed URL: ") << url << QStringLiteral(", is empty = ") - << (url.isEmpty() ? QStringLiteral("true") : QStringLiteral("false")) - << QStringLiteral(", is valid = ") - << (url.isValid() ? QStringLiteral("true") : QStringLiteral("false"))); + QNTRACE("Parsed URL: " << url << ", is empty = " + << (url.isEmpty() ? "true" : "false") + << ", is valid = " + << (url.isValid() ? "true" : "false")); if (url.isEmpty()) { m_pUI->urlErrorLabel->setText(tr("Entered URL is empty")); diff -Nru libquentier-0.5.0/src/note_editor/dialogs/EditHyperlinkDialog.h libquentier-0.5.0/src/note_editor/dialogs/EditHyperlinkDialog.h --- libquentier-0.5.0/src/note_editor/dialogs/EditHyperlinkDialog.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/dialogs/EditHyperlinkDialog.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,6 +20,7 @@ #define LIB_QUENTIER_NOTE_EDITOR_EDIT_HYPERLINK_DIALOG_H #include <quentier/utility/Macros.h> + #include <QDialog> #include <QUrl> diff -Nru libquentier-0.5.0/src/note_editor/dialogs/EncryptionDialog.cpp libquentier-0.5.0/src/note_editor/dialogs/EncryptionDialog.cpp --- libquentier-0.5.0/src/note_editor/dialogs/EncryptionDialog.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/dialogs/EncryptionDialog.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -19,10 +19,12 @@ #include "EncryptionDialog.h" #include "ui_EncryptionDialog.h" #include "../NoteEditorSettingsNames.h" + #include <quentier/enml/DecryptedTextManager.h> #include <quentier/utility/QuentierCheckPtr.h> #include <quentier/logging/QuentierLogger.h> #include <quentier/utility/ApplicationSettings.h> + #include <QLineEdit> namespace quentier { @@ -97,8 +99,8 @@ ApplicationSettings appSettings(m_account, NOTE_EDITOR_SETTINGS_NAME); if (!appSettings.isWritable()) { - QNINFO(QStringLiteral("Can't persist remember passphrase for session " - "setting: settings are not writable")); + QNINFO("Can't persist remember passphrase for session " + "setting: settings are not writable"); } else { @@ -114,8 +116,8 @@ if (passphrase.isEmpty()) { - QNINFO(QStringLiteral("Attempted to press OK in EncryptionDialog without " - "having a password set")); + QNINFO("Attempted to press OK in EncryptionDialog without " + "having a password set"); ErrorString error(QT_TR_NOOP("Please choose the encryption password")); setError(error); return; diff -Nru libquentier-0.5.0/src/note_editor/dialogs/EncryptionDialog.h libquentier-0.5.0/src/note_editor/dialogs/EncryptionDialog.h --- libquentier-0.5.0/src/note_editor/dialogs/EncryptionDialog.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/dialogs/EncryptionDialog.h 2019-07-11 10:46:53.000000000 +0000 @@ -23,6 +23,7 @@ #include <quentier/utility/Macros.h> #include <quentier/types/ErrorString.h> #include <quentier/types/Account.h> + #include <QDialog> #include <QSharedPointer> diff -Nru libquentier-0.5.0/src/note_editor/dialogs/RenameResourceDialog.cpp libquentier-0.5.0/src/note_editor/dialogs/RenameResourceDialog.cpp --- libquentier-0.5.0/src/note_editor/dialogs/RenameResourceDialog.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/dialogs/RenameResourceDialog.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,6 +18,7 @@ #include "RenameResourceDialog.h" #include "ui_RenameResourceDialog.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { @@ -38,7 +39,7 @@ void RenameResourceDialog::accept() { - QNDEBUG(QStringLiteral("RenameResourceDialog::accept")); + QNDEBUG("RenameResourceDialog::accept"); Q_EMIT accepted(m_pUI->lineEdit->text()); QDialog::accept(); } diff -Nru libquentier-0.5.0/src/note_editor/dialogs/RenameResourceDialog.h libquentier-0.5.0/src/note_editor/dialogs/RenameResourceDialog.h --- libquentier-0.5.0/src/note_editor/dialogs/RenameResourceDialog.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/dialogs/RenameResourceDialog.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,6 +20,7 @@ #define LIB_QUENTIER_NOTE_EDITOR_DIALOGS_RENAME_RESOURCE_DIALOG_H #include <quentier/utility/Macros.h> + #include <QDialog> namespace Ui { diff -Nru libquentier-0.5.0/src/note_editor/EncryptedAreaPlugin.cpp libquentier-0.5.0/src/note_editor/EncryptedAreaPlugin.cpp --- libquentier-0.5.0/src/note_editor/EncryptedAreaPlugin.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/EncryptedAreaPlugin.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -20,13 +20,15 @@ #include "ui_EncryptedAreaPlugin.h" #include "NoteEditorPluginFactory.h" #include "NoteEditor_p.h" + #include <quentier/logging/QuentierLogger.h> + #include <QAction> namespace quentier { -EncryptedAreaPlugin::EncryptedAreaPlugin(NoteEditorPrivate & noteEditor, - QWidget * parent) : +EncryptedAreaPlugin::EncryptedAreaPlugin( + NoteEditorPrivate & noteEditor, QWidget * parent) : QWidget(parent), m_pUI(new Ui::EncryptedAreaPlugin), m_noteEditor(noteEditor), @@ -35,7 +37,7 @@ m_keyLength(), m_id() { - QNDEBUG(QStringLiteral("EncryptedAreaPlugin: constructor")); + QNDEBUG("EncryptedAreaPlugin: constructor"); m_pUI->setupUi(this); @@ -55,7 +57,7 @@ EncryptedAreaPlugin::~EncryptedAreaPlugin() { - QNDEBUG(QStringLiteral("EncryptedAreaPlugin: destructor")); + QNDEBUG("EncryptedAreaPlugin: destructor"); delete m_pUI; } @@ -64,9 +66,9 @@ const NoteEditorPluginFactory & pluginFactory, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("EncryptedAreaPlugin::initialize: parameter names = ") + QNDEBUG("EncryptedAreaPlugin::initialize: parameter names = " << parameterNames.join(QStringLiteral(", ")) - << QStringLiteral(", parameter values = ") + << ", parameter values = " << parameterValues.join(QStringLiteral(", "))); Q_UNUSED(pluginFactory) @@ -97,9 +99,8 @@ } else { m_keyLength = QStringLiteral("128"); - QNDEBUG(QStringLiteral("Using the default value of key length = ") - << m_keyLength - << QStringLiteral(" instead of missing HTML attribute")); + QNDEBUG("Using the default value of key length = " << m_keyLength + << " instead of missing HTML attribute"); } if (cipherIndex >= 0) { @@ -107,9 +108,8 @@ } else { m_cipher = QStringLiteral("AES"); - QNDEBUG(QStringLiteral("Using the default value of cipher = ") - << m_cipher - << QStringLiteral(" instead of missing HTML attribute")); + QNDEBUG("Using the default value of cipher = " << m_cipher + << " instead of missing HTML attribute"); } m_encryptedText = parameterValues[encryptedTextIndex]; @@ -130,11 +130,10 @@ m_id = parameterValues[enCryptIndexIndex]; } - QNTRACE(QStringLiteral("Initialized encrypted area plugin: cipher = ") - << m_cipher << QStringLiteral(", length = ") << m_keyLength - << QStringLiteral(", hint = ") << m_hint - << QStringLiteral(", en-crypt-id = ") << m_id - << QStringLiteral(", encrypted text = ") << m_encryptedText); + QNTRACE("Initialized encrypted area plugin: cipher = " + << m_cipher << ", length = " << m_keyLength + << ", hint = " << m_hint << ", en-crypt-id = " << m_id + << ", encrypted text = " << m_encryptedText); return true; } diff -Nru libquentier-0.5.0/src/note_editor/EncryptedAreaPlugin.h libquentier-0.5.0/src/note_editor/EncryptedAreaPlugin.h --- libquentier-0.5.0/src/note_editor/EncryptedAreaPlugin.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/EncryptedAreaPlugin.h 2019-07-11 10:46:53.000000000 +0000 @@ -21,6 +21,7 @@ #include <quentier/utility/Macros.h> #include <quentier/types/ErrorString.h> + #include <QWidget> namespace Ui { diff -Nru libquentier-0.5.0/src/note_editor/GenericResourceDisplayWidget.cpp libquentier-0.5.0/src/note_editor/GenericResourceDisplayWidget.cpp --- libquentier-0.5.0/src/note_editor/GenericResourceDisplayWidget.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/GenericResourceDisplayWidget.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -20,6 +20,7 @@ #include "ui_GenericResourceDisplayWidget.h" #include "NoteEditorSettingsNames.h" #include "ResourceDataInTemporaryFileStorageManager.h" + #include <quentier/utility/FileIOProcessorAsync.h> #include <quentier/utility/QuentierCheckPtr.h> #include <quentier/utility/Utility.h> @@ -27,6 +28,7 @@ #include <quentier/types/Resource.h> #include <quentier/logging/QuentierLogger.h> #include <quentier/utility/ApplicationSettings.h> + #include <QHBoxLayout> #include <QVBoxLayout> #include <QLabel> @@ -52,13 +54,12 @@ delete m_pUI; } -void GenericResourceDisplayWidget::initialize(const QIcon & icon, - const QString & name, - const QString & size, - const Resource & resource) +void GenericResourceDisplayWidget::initialize( + const QIcon & icon, const QString & name, const QString & size, + const Resource & resource) { - QNDEBUG(QStringLiteral("GenericResourceDisplayWidget::initialize: name = ") - << name << QStringLiteral(", size = ") << size); + QNDEBUG("GenericResourceDisplayWidget::initialize: name = " << name + << ", size = " << size); m_resourceLocalUid = resource.localUid(); @@ -110,7 +111,8 @@ return m_resourceLocalUid; } -void GenericResourceDisplayWidget::updateResourceName(const QString & resourceName) +void GenericResourceDisplayWidget::updateResourceName( + const QString & resourceName) { m_pUI->resourceDisplayNameLabel->setText( QStringLiteral("<html><head/><body><p><span style=\" font-size:8pt;\">") + @@ -127,11 +129,11 @@ void GenericResourceDisplayWidget::onOpenResourceInExternalAppButtonPressed() { - QNDEBUG(QStringLiteral("GenericResourceDisplayWidget::" - "onOpenResourceInExternalAppButtonPressed")); + QNDEBUG("GenericResourceDisplayWidget::" + "onOpenResourceInExternalAppButtonPressed"); if (m_resourceHash.isEmpty()) { - QNDEBUG(QStringLiteral("Can't open resource: resource hash is empty")); + QNDEBUG("Can't open resource: resource hash is empty"); return; } @@ -140,11 +142,11 @@ void GenericResourceDisplayWidget::onSaveResourceDataToFileButtonPressed() { - QNDEBUG(QStringLiteral("GenericResourceDisplayWidget::" - "onSaveResourceDataToFileButtonPressed")); + QNDEBUG("GenericResourceDisplayWidget::" + "onSaveResourceDataToFileButtonPressed"); if (m_resourceHash.isEmpty()) { - QNDEBUG(QStringLiteral("Can't save resource: resource hash is empty")); + QNDEBUG("Can't save resource: resource hash is empty"); return; } diff -Nru libquentier-0.5.0/src/note_editor/GenericResourceDisplayWidget.h libquentier-0.5.0/src/note_editor/GenericResourceDisplayWidget.h --- libquentier-0.5.0/src/note_editor/GenericResourceDisplayWidget.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/GenericResourceDisplayWidget.h 2019-07-11 10:46:53.000000000 +0000 @@ -22,6 +22,7 @@ #include <quentier/utility/Macros.h> #include <quentier/types/ErrorString.h> #include <quentier/types/Account.h> + #include <QWidget> #include <QUuid> diff -Nru libquentier-0.5.0/src/note_editor/GenericResourceImageManager.cpp libquentier-0.5.0/src/note_editor/GenericResourceImageManager.cpp --- libquentier-0.5.0/src/note_editor/GenericResourceImageManager.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/GenericResourceImageManager.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -17,9 +17,11 @@ */ #include "GenericResourceImageManager.h" + #include <quentier/logging/QuentierLogger.h> #include <quentier/utility/Utility.h> #include <quentier/types/Resource.h> + #include <QFile> #include <QFileInfo> #include <QDir> @@ -36,7 +38,7 @@ void GenericResourceImageManager::setStorageFolderPath( const QString & storageFolderPath) { - QNDEBUG(QStringLiteral("GenericResourceImageManager::setStorageFolderPath: ") + QNDEBUG("GenericResourceImageManager::setStorageFolderPath: " << storageFolderPath); m_storageFolderPath = storageFolderPath; } @@ -47,19 +49,21 @@ QByteArray resourceActualHash, QString resourceDisplayName, QUuid requestId) { - QNDEBUG(QStringLiteral("GenericResourceImageManager::") - << QStringLiteral("onGenericResourceImageWriteRequest: note local uid = ") - << noteLocalUid << QStringLiteral(", resource local uid = ") - << resourceLocalUid << QStringLiteral(", resource actual hash = ") - << resourceActualHash.toHex() << QStringLiteral(", request id = ") + QNDEBUG("GenericResourceImageManager::" + << "onGenericResourceImageWriteRequest: note local uid = " + << noteLocalUid << ", resource local uid = " + << resourceLocalUid << ", resource actual hash = " + << resourceActualHash.toHex() << ", request id = " << requestId); -#define RETURN_WITH_ERROR(message) \ - ErrorString errorDescription(message); \ - QNWARNING(errorDescription); \ +#define RETURN_WITH_ERROR(message) \ + ErrorString errorDescription(message); \ + QNWARNING(errorDescription); \ Q_EMIT genericResourceImageWriteReply(/* success = */ false, QByteArray(), \ - QString(), errorDescription, requestId); \ - return + QString(), errorDescription, \ + requestId); \ + return \ +// RETURN_WITH_ERROR if (Q_UNLIKELY(m_storageFolderPath.isEmpty())) { RETURN_WITH_ERROR(QT_TR_NOOP("Storage folder path is empty")); @@ -118,7 +122,7 @@ QByteArray previousResourceHash = resourceHashFile.readAll(); if (resourceActualHash == previousResourceHash) { - QNTRACE(QStringLiteral("Resource hash hasn't changed")); + QNTRACE("Resource hash hasn't changed"); resourceHashChanged = false; } } @@ -138,10 +142,10 @@ if (Q_UNLIKELY(!resourceNameFileInfo.isReadable())) { - QNINFO(QStringLiteral("Helper file with resource name for generic ") - << QStringLiteral("resource image is not readable: ") + QNINFO("Helper file with resource name for generic " + << "resource image is not readable: " << resourceNameFileInfo.absoluteFilePath() - << QStringLiteral(" which is quite strange...")); + << " which is quite strange..."); resourceDisplayNameChanged = true; } else @@ -152,8 +156,8 @@ QString::fromLocal8Bit(resourceNameFile.readAll()); if (resourceDisplayName != previousResourceName) { - QNTRACE(QStringLiteral("Resource display name has changed from ") - << previousResourceName << QStringLiteral(" to ") + QNTRACE("Resource display name has changed from " + << previousResourceName << " to " << resourceDisplayName); resourceDisplayNameChanged = true; } @@ -164,8 +168,8 @@ if (!resourceHashChanged && !resourceDisplayNameChanged && !existingResourceImageFileInfos.isEmpty()) { - QNDEBUG(QStringLiteral("resource hash and display name haven't changed, " - "won't rewrite the resource's image")); + QNDEBUG("resource hash and display name haven't changed, " + "won't rewrite the resource's image"); Q_EMIT genericResourceImageWriteReply( /* success = */ true, resourceActualHash, existingResourceImageFileInfos.front().absoluteFilePath(), @@ -173,13 +177,14 @@ return; } - QNTRACE(QStringLiteral("Writing resource image file and helper files with " - "hash and display name")); + QNTRACE("Writing resource image file and helper files with " + "hash and display name"); - QString resourceImageFilePath = storageDir.absolutePath() + QStringLiteral("/") + - resourceLocalUid + QStringLiteral("_") + - QString::number(QDateTime::currentMSecsSinceEpoch()) + - QStringLiteral(".") + resourceFileSuffix; + QString resourceImageFilePath = + storageDir.absolutePath() + QStringLiteral("/") + + resourceLocalUid + QStringLiteral("_") + + QString::number(QDateTime::currentMSecsSinceEpoch()) + + QStringLiteral(".") + resourceFileSuffix; QFile resourceImageFile(resourceImageFilePath); if (Q_UNLIKELY(!resourceImageFile.open(QIODevice::ReadWrite))) { @@ -202,14 +207,14 @@ resourceNameFile.write(resourceDisplayName.toLocal8Bit()); resourceNameFile.close(); - QNTRACE(QStringLiteral("Successfully wrote resource image file and helper ") - << QStringLiteral("files with hash and display name for request ") - << requestId << QStringLiteral(", resource image file path = ") + QNTRACE("Successfully wrote resource image file and helper " + << "files with hash and display name for request " + << requestId << ", resource image file path = " << resourceImageFilePath); - Q_EMIT genericResourceImageWriteReply(/* success = */ true, resourceActualHash, - resourceImageFilePath, ErrorString(), - requestId); + Q_EMIT genericResourceImageWriteReply( + /* success = */ true, resourceActualHash, + resourceImageFilePath, ErrorString(), requestId); if (!existingResourceImageFileInfos.isEmpty()) { @@ -220,10 +225,9 @@ QFile staleResourceImageFile(staleResourceImageFileInfo.absoluteFilePath()); bool res = staleResourceImageFile.remove(); if (Q_UNLIKELY(!res)) { - QNINFO(QStringLiteral("Can't remove stale generic resource image file: ") + QNINFO("Can't remove stale generic resource image file: " << staleResourceImageFile.errorString() - << QStringLiteral(" (error code = ") - << staleResourceImageFile.error() << QStringLiteral(")")); + << " (error code = " << staleResourceImageFile.error() << ")"); } } } @@ -231,17 +235,17 @@ void GenericResourceImageManager::onCurrentNoteChanged(Note note) { - QNDEBUG(QStringLiteral("GenericResourceImageManager::onCurrentNoteChanged: ") - << QStringLiteral("new note local uid = ") << note.localUid() - << QStringLiteral(", previous note local uid = ") + QNDEBUG("GenericResourceImageManager::onCurrentNoteChanged: " + << "new note local uid = " << note.localUid() + << ", previous note local uid = " << (m_pCurrentNote.isNull() ? QStringLiteral("<null>") : m_pCurrentNote->localUid())); if (!m_pCurrentNote.isNull() && (m_pCurrentNote->localUid() == note.localUid())) { - QNTRACE(QStringLiteral("The current note is the same, only the note " - "object might have changed")); + QNTRACE("The current note is the same, only the note " + "object might have changed"); *m_pCurrentNote = note; removeStaleGenericResourceImageFilesFromCurrentNote(); return; @@ -259,11 +263,11 @@ void GenericResourceImageManager::removeStaleGenericResourceImageFilesFromCurrentNote() { - QNDEBUG(QStringLiteral("GenericResourceImageManager::" - "removeStaleGenericResourceImageFilesFromCurrentNote")); + QNDEBUG("GenericResourceImageManager::" + "removeStaleGenericResourceImageFilesFromCurrentNote"); if (m_pCurrentNote.isNull()) { - QNDEBUG(QStringLiteral("No current note, nothing to do")); + QNDEBUG("No current note, nothing to do"); return; } @@ -271,8 +275,8 @@ QDir storageDir(m_storageFolderPath + QStringLiteral("/") + noteLocalUid); if (!storageDir.exists()) { - QNTRACE(QStringLiteral("Storage dir ") << storageDir.absolutePath() - << QStringLiteral(" does not exist, nothing to do")); + QNTRACE("Storage dir " << storageDir.absolutePath() + << " does not exist, nothing to do"); return; } @@ -282,8 +286,8 @@ QFileInfoList fileInfoList = storageDir.entryInfoList(QDir::Files); int numFiles = fileInfoList.size(); - QNTRACE(QStringLiteral("Will check ") << numFiles - << QStringLiteral(" generic resource image files for staleness")); + QNTRACE("Will check " << numFiles + << " generic resource image files for staleness"); for(int i = 0; i < numFiles; ++i) { @@ -292,21 +296,21 @@ QString fullSuffix = fileInfo.completeSuffix(); if (fullSuffix == QStringLiteral("hash")) { - QNTRACE(QStringLiteral("Skipping .hash helper file ") << filePath); + QNTRACE("Skipping .hash helper file " << filePath); continue; } QString baseName = fileInfo.baseName(); - QNTRACE(QStringLiteral("Checking file with base name ") << baseName); + QNTRACE("Checking file with base name " << baseName); int resourceIndex = -1; for(int j = 0; j < numResources; ++j) { - QNTRACE(QStringLiteral("checking against resource with local uid ") + QNTRACE("checking against resource with local uid " << resources[j].localUid()); if (baseName.startsWith(resources[j].localUid())) { - QNTRACE(QStringLiteral("File ") << fileInfo.fileName() - << QStringLiteral(" appears to correspond to resource ") + QNTRACE("File " << fileInfo.fileName() + << " appears to correspond to resource " << resources[j].localUid()); resourceIndex = j; break; @@ -328,36 +332,35 @@ Q_UNUSED(helperHashFile.open(QIODevice::ReadOnly)) QByteArray storedHash = helperHashFile.readAll(); if (storedHash == resource.dataHash()) { - QNTRACE(QStringLiteral("Resource file ") << filePath - << QStringLiteral(" appears to be still actual, " - "will keep it")); + QNTRACE("Resource file " << filePath + << " appears to be still actual, will keep it"); continue; } else { - QNTRACE(QStringLiteral("The stored hash doesn't match ") - << QStringLiteral("the actual resource data hash: ") - << QStringLiteral("stored = ") << storedHash.toHex() - << QStringLiteral(", actual = ") + QNTRACE("The stored hash doesn't match " + << "the actual resource data hash: " + << "stored = " << storedHash.toHex() + << ", actual = " << resource.dataHash().toHex()); } } else { - QNTRACE(QStringLiteral("Helper hash file ") + QNTRACE("Helper hash file " << helperHashFileInfo.absoluteFilePath() - << QStringLiteral(" does not exist")); + << " does not exist"); } } else { - QNTRACE(QStringLiteral("Resource at index ") << resourceIndex - << QStringLiteral(" doesn't have the data hash, will remove " - "its resource file just in case")); + QNTRACE("Resource at index " << resourceIndex + << " doesn't have the data hash, will remove " + << "its resource file just in case"); } } - QNTRACE(QStringLiteral("Found stale generic resource image file ") - << filePath << QStringLiteral(", removing it")); + QNTRACE("Found stale generic resource image file " + << filePath << ", removing it"); Q_UNUSED(removeFile(filePath)) // Need to also remove the helper .hash file diff -Nru libquentier-0.5.0/src/note_editor/GenericResourceImageManager.h libquentier-0.5.0/src/note_editor/GenericResourceImageManager.h --- libquentier-0.5.0/src/note_editor/GenericResourceImageManager.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/GenericResourceImageManager.h 2019-07-11 10:46:53.000000000 +0000 @@ -22,6 +22,7 @@ #include <quentier/utility/Macros.h> #include <quentier/types/ErrorString.h> #include <quentier/types/Note.h> + #include <QObject> #include <QUuid> #include <QScopedPointer> @@ -44,8 +45,10 @@ void setStorageFolderPath(const QString & storageFolderPath); Q_SIGNALS: - void genericResourceImageWriteReply(bool success, QByteArray resourceHash, - QString filePath, ErrorString errorDescription, + void genericResourceImageWriteReply(bool success, + QByteArray resourceHash, + QString filePath, + ErrorString errorDescription, QUuid requestId); public Q_SLOTS: diff -Nru libquentier-0.5.0/src/note_editor/INoteEditorBackend.cpp libquentier-0.5.0/src/note_editor/INoteEditorBackend.cpp --- libquentier-0.5.0/src/note_editor/INoteEditorBackend.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/INoteEditorBackend.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -19,6 +19,7 @@ #include <quentier/note_editor/INoteEditorBackend.h> #include <quentier/note_editor/NoteEditor.h> #include <quentier/logging/QuentierLogger.h> + #include <QUndoStack> namespace quentier { @@ -30,19 +31,20 @@ m_pNoteEditor(parent) {} -QTextStream & operator<<(QTextStream & strm, - const INoteEditorBackend::Rotation::type rotationDirection) +QTextStream & operator<<( + QTextStream & strm, + const INoteEditorBackend::Rotation::type rotationDirection) { switch(rotationDirection) { case INoteEditorBackend::Rotation::Clockwise: - strm << QStringLiteral("Clockwise"); + strm << "Clockwise"; break; case INoteEditorBackend::Rotation::Counterclockwise: - strm << QStringLiteral("Counterclockwise"); + strm << "Counterclockwise"; break; default: - strm << QStringLiteral("Unknown"); + strm << "Unknown (" << static_cast<qint64>(rotationDirection) << ")"; break; } diff -Nru libquentier-0.5.0/src/note_editor/INoteEditorResourcePlugin.h libquentier-0.5.0/src/note_editor/INoteEditorResourcePlugin.h --- libquentier-0.5.0/src/note_editor/INoteEditorResourcePlugin.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/INoteEditorResourcePlugin.h 2019-07-11 10:46:53.000000000 +0000 @@ -21,6 +21,7 @@ #include <quentier/utility/Macros.h> #include <quentier/types/ErrorString.h> + #include <QWidget> namespace quentier { @@ -77,13 +78,16 @@ /** * @brief mimeTypes The method telling which are the mime types of * the resources the plugin can work with - * @return The list of resource mime types the plugin supports + * @return The list of resource mime types the plugin + * supports */ virtual QStringList mimeTypes() const = 0; /** - * @brief fileExtensions is the method telling which file extensions of the data - * the plugin should be able to handle mapped to mime types the plugin supports as well + * @brief fileExtensions is the method telling which file extensions of + * the data the plugin should be able to handle mapped to mime types + * the plugin supports as well + * * @return The hash of file extensions the plugin supports * per mime types the plugin supports */ diff -Nru libquentier-0.5.0/src/note_editor/javascript_glue/ActionsWatcher.cpp libquentier-0.5.0/src/note_editor/javascript_glue/ActionsWatcher.cpp --- libquentier-0.5.0/src/note_editor/javascript_glue/ActionsWatcher.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/javascript_glue/ActionsWatcher.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -17,6 +17,7 @@ */ #include "ActionsWatcher.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { @@ -27,13 +28,13 @@ void ActionsWatcher::onCutActionToggled() { - QNDEBUG(QStringLiteral("ActionsWatcher::onCutActionToggled")); + QNDEBUG("ActionsWatcher::onCutActionToggled"); Q_EMIT cutActionToggled(); } void ActionsWatcher::onPasteActionToggled() { - QNDEBUG(QStringLiteral("ActionsWatcher::onPasteActionToggled")); + QNDEBUG("ActionsWatcher::onPasteActionToggled"); Q_EMIT pasteActionToggled(); } diff -Nru libquentier-0.5.0/src/note_editor/javascript_glue/ActionsWatcher.h libquentier-0.5.0/src/note_editor/javascript_glue/ActionsWatcher.h --- libquentier-0.5.0/src/note_editor/javascript_glue/ActionsWatcher.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/javascript_glue/ActionsWatcher.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,6 +20,7 @@ #define LIB_QUENTIER_NOTE_EDITOR_JAVASCRIPT_GLUE_ACTIONS_WATCHER_H #include <quentier/utility/Macros.h> + #include <QObject> namespace quentier { diff -Nru libquentier-0.5.0/src/note_editor/javascript_glue/ContextMenuEventJavaScriptHandler.h libquentier-0.5.0/src/note_editor/javascript_glue/ContextMenuEventJavaScriptHandler.h --- libquentier-0.5.0/src/note_editor/javascript_glue/ContextMenuEventJavaScriptHandler.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/javascript_glue/ContextMenuEventJavaScriptHandler.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,6 +20,7 @@ #define LIB_QUENTIER_NOTE_EDITOR_JAVASCRIPT_GLUE_CONTEXT_MENU_EVENT_JAVA_SCRIPT_HANDLER_H #include <quentier/utility/Macros.h> + #include <QObject> #include <QStringList> diff -Nru libquentier-0.5.0/src/note_editor/javascript_glue/EnCryptElementOnClickHandler.h libquentier-0.5.0/src/note_editor/javascript_glue/EnCryptElementOnClickHandler.h --- libquentier-0.5.0/src/note_editor/javascript_glue/EnCryptElementOnClickHandler.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/javascript_glue/EnCryptElementOnClickHandler.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,6 +20,7 @@ #define LIB_QUENTIER_NOTE_EDITOR_JAVASCRIPT_GLUE_EN_CRYPT_ELEMENT_ON_CLICK_HANDLER_H #include <quentier/utility/Macros.h> + #include <QObject> namespace quentier { diff -Nru libquentier-0.5.0/src/note_editor/javascript_glue/GenericResourceImageJavaScriptHandler.cpp libquentier-0.5.0/src/note_editor/javascript_glue/GenericResourceImageJavaScriptHandler.cpp --- libquentier-0.5.0/src/note_editor/javascript_glue/GenericResourceImageJavaScriptHandler.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/javascript_glue/GenericResourceImageJavaScriptHandler.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -17,6 +17,7 @@ */ #include "GenericResourceImageJavaScriptHandler.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { @@ -27,21 +28,20 @@ m_cache(cache) {} -void GenericResourceImageJavaScriptHandler::findGenericResourceImage(QByteArray resourceHash) +void GenericResourceImageJavaScriptHandler::findGenericResourceImage( + QByteArray resourceHash) { - QNDEBUG(QStringLiteral("GenericResourceImageJavaScriptHandler::") - << QStringLiteral("findGenericResourceImage: resource hash = ") + QNDEBUG("GenericResourceImageJavaScriptHandler::" + << "findGenericResourceImage: resource hash = " << resourceHash); auto it = m_cache.find(QByteArray::fromHex(resourceHash)); if (it != m_cache.end()) { - QNTRACE(QStringLiteral("Found generic resouce image, path is ") - << it.value()); + QNTRACE("Found generic resouce image, path is " << it.value()); Q_EMIT genericResourceImageFound(resourceHash, it.value()); } else { - QNINFO(QStringLiteral("Can't find generic resource image for hash ") - << resourceHash); + QNINFO("Can't find generic resource image for hash " << resourceHash); } } diff -Nru libquentier-0.5.0/src/note_editor/javascript_glue/GenericResourceImageJavaScriptHandler.h libquentier-0.5.0/src/note_editor/javascript_glue/GenericResourceImageJavaScriptHandler.h --- libquentier-0.5.0/src/note_editor/javascript_glue/GenericResourceImageJavaScriptHandler.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/javascript_glue/GenericResourceImageJavaScriptHandler.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,6 +20,7 @@ #define LIB_QUENTIER_NOTE_EDITOR_JAVASCRIPT_GLUE_GENERIC_RESOURCE_IMAGE_JAVA_SCRIPT_HANDLER_H #include <quentier/utility/Macros.h> + #include <QObject> #include <QHash> diff -Nru libquentier-0.5.0/src/note_editor/javascript_glue/GenericResourceOpenAndSaveButtonsOnClickHandler.cpp libquentier-0.5.0/src/note_editor/javascript_glue/GenericResourceOpenAndSaveButtonsOnClickHandler.cpp --- libquentier-0.5.0/src/note_editor/javascript_glue/GenericResourceOpenAndSaveButtonsOnClickHandler.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/javascript_glue/GenericResourceOpenAndSaveButtonsOnClickHandler.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -17,6 +17,7 @@ */ #include "GenericResourceOpenAndSaveButtonsOnClickHandler.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { @@ -29,16 +30,16 @@ void GenericResourceOpenAndSaveButtonsOnClickHandler::onOpenResourceButtonPressed( const QString & resourceHash) { - QNDEBUG(QStringLiteral("GenericResourceOpenAndSaveButtonsOnClickHandler::") - << QStringLiteral("onOpenResourceButtonPressed: ") << resourceHash); + QNDEBUG("GenericResourceOpenAndSaveButtonsOnClickHandler::" + << "onOpenResourceButtonPressed: " << resourceHash); Q_EMIT openResourceRequest(QByteArray::fromHex(resourceHash.toLocal8Bit())); } void GenericResourceOpenAndSaveButtonsOnClickHandler::onSaveResourceButtonPressed( const QString & resourceHash) { - QNDEBUG(QStringLiteral("GenericResourceOpenAndSaveButtonsOnClickHandler::") - << QStringLiteral("onSaveResourceButtonPressed: ") << resourceHash); + QNDEBUG("GenericResourceOpenAndSaveButtonsOnClickHandler::" + << "onSaveResourceButtonPressed: " << resourceHash); Q_EMIT saveResourceRequest(QByteArray::fromHex(resourceHash.toLocal8Bit())); } diff -Nru libquentier-0.5.0/src/note_editor/javascript_glue/GenericResourceOpenAndSaveButtonsOnClickHandler.h libquentier-0.5.0/src/note_editor/javascript_glue/GenericResourceOpenAndSaveButtonsOnClickHandler.h --- libquentier-0.5.0/src/note_editor/javascript_glue/GenericResourceOpenAndSaveButtonsOnClickHandler.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/javascript_glue/GenericResourceOpenAndSaveButtonsOnClickHandler.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,6 +20,7 @@ #define LIB_QUENTIER_NOTE_EDITOR_JAVASCRIPT_GLUE_GENERIC_RESOURCE_OPEN_AND_SAVE_BUTTONS_ON_CLICK_HANDLER_H #include <quentier/utility/Macros.h> + #include <QObject> namespace quentier { @@ -28,7 +29,8 @@ { Q_OBJECT public: - explicit GenericResourceOpenAndSaveButtonsOnClickHandler(QObject * parent = Q_NULLPTR); + explicit GenericResourceOpenAndSaveButtonsOnClickHandler( + QObject * parent = Q_NULLPTR); Q_SIGNALS: void openResourceRequest(const QByteArray & resourceHash); diff -Nru libquentier-0.5.0/src/note_editor/javascript_glue/ResizableImageJavaScriptHandler.h libquentier-0.5.0/src/note_editor/javascript_glue/ResizableImageJavaScriptHandler.h --- libquentier-0.5.0/src/note_editor/javascript_glue/ResizableImageJavaScriptHandler.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/javascript_glue/ResizableImageJavaScriptHandler.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,6 +20,7 @@ #define LIB_QUENTIER_NOTE_EDITOR_JAVASCRIPT_GLUE_RESIZABLE_IMAGE_JAVASCRIPT_HANDLER_H #include <quentier/utility/Macros.h> + #include <QObject> namespace quentier { diff -Nru libquentier-0.5.0/src/note_editor/javascript_glue/ResourceInfoJavaScriptHandler.h libquentier-0.5.0/src/note_editor/javascript_glue/ResourceInfoJavaScriptHandler.h --- libquentier-0.5.0/src/note_editor/javascript_glue/ResourceInfoJavaScriptHandler.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/javascript_glue/ResourceInfoJavaScriptHandler.h 2019-07-11 10:46:53.000000000 +0000 @@ -19,10 +19,11 @@ #ifndef LIB_QUENTIER_NOTE_EDITOR_JAVASCRIPT_GLUE_RESOURCE_INFO_JAVASCRIPT_HANDLER_H #define LIB_QUENTIER_NOTE_EDITOR_JAVASCRIPT_GLUE_RESOURCE_INFO_JAVASCRIPT_HANDLER_H +#include <quentier/utility/Macros.h> + #include <QObject> #include <QString> #include <QSize> -#include <quentier/utility/Macros.h> namespace quentier { diff -Nru libquentier-0.5.0/src/note_editor/javascript_glue/SpellCheckerDynamicHelper.cpp libquentier-0.5.0/src/note_editor/javascript_glue/SpellCheckerDynamicHelper.cpp --- libquentier-0.5.0/src/note_editor/javascript_glue/SpellCheckerDynamicHelper.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/javascript_glue/SpellCheckerDynamicHelper.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -17,6 +17,7 @@ */ #include "SpellCheckerDynamicHelper.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { @@ -28,8 +29,7 @@ #ifdef QUENTIER_USE_QT_WEB_ENGINE void SpellCheckerDynamicHelper::setLastEnteredWords(QVariant words) { - QNDEBUG(QStringLiteral("SpellCheckerDynamicHelper::setLastEnteredWords: ") - << words); + QNDEBUG("SpellCheckerDynamicHelper::setLastEnteredWords: " << words); QStringList wordsList = words.toStringList(); Q_EMIT lastEnteredWords(wordsList); @@ -37,8 +37,7 @@ #else void SpellCheckerDynamicHelper::setLastEnteredWords(QVariantList words) { - QNDEBUG(QStringLiteral("SpellCheckerDynamicHelper::setLastEnteredWords: ") - << words); + QNDEBUG("SpellCheckerDynamicHelper::setLastEnteredWords: " << words); QStringList wordsList; for(auto it = words.begin(), end = words.end(); it != end; ++it) { diff -Nru libquentier-0.5.0/src/note_editor/javascript_glue/SpellCheckerDynamicHelper.h libquentier-0.5.0/src/note_editor/javascript_glue/SpellCheckerDynamicHelper.h --- libquentier-0.5.0/src/note_editor/javascript_glue/SpellCheckerDynamicHelper.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/javascript_glue/SpellCheckerDynamicHelper.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,6 +20,7 @@ #define LIB_QUENTIER_NOTE_EDITOR_JAVASCRIPT_GLUE_SPELL_CHECKER_DYNAMIC_HELPER_H #include <quentier/utility/Macros.h> + #include <QObject> #include <QStringList> #include <QVariant> diff -Nru libquentier-0.5.0/src/note_editor/javascript_glue/TableResizeJavaScriptHandler.h libquentier-0.5.0/src/note_editor/javascript_glue/TableResizeJavaScriptHandler.h --- libquentier-0.5.0/src/note_editor/javascript_glue/TableResizeJavaScriptHandler.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/javascript_glue/TableResizeJavaScriptHandler.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,6 +20,7 @@ #define LIB_QUENTIER_NOTE_EDITOR_JAVASCRIPT_GLUE_TABLE_RESIZE_JAVASCRIPT_HANDLER_H #include <quentier/utility/Macros.h> + #include <QObject> namespace quentier { diff -Nru libquentier-0.5.0/src/note_editor/javascript_glue/TextCursorPositionJavaScriptHandler.cpp libquentier-0.5.0/src/note_editor/javascript_glue/TextCursorPositionJavaScriptHandler.cpp --- libquentier-0.5.0/src/note_editor/javascript_glue/TextCursorPositionJavaScriptHandler.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/javascript_glue/TextCursorPositionJavaScriptHandler.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -20,7 +20,8 @@ namespace quentier { -TextCursorPositionJavaScriptHandler::TextCursorPositionJavaScriptHandler(QObject * parent) : +TextCursorPositionJavaScriptHandler::TextCursorPositionJavaScriptHandler( + QObject * parent) : QObject(parent) {} @@ -29,15 +30,15 @@ Q_EMIT textCursorPositionChanged(); } -void TextCursorPositionJavaScriptHandler::setOnImageResourceState(bool state, - QString resourceHash) +void TextCursorPositionJavaScriptHandler::setOnImageResourceState( + bool state, QString resourceHash) { Q_EMIT textCursorPositionOnImageResourceState( state, QByteArray::fromHex(resourceHash.toLocal8Bit())); } -void TextCursorPositionJavaScriptHandler::setOnNonImageResourceState(bool state, - QString resourceHash) +void TextCursorPositionJavaScriptHandler::setOnNonImageResourceState( + bool state, QString resourceHash) { Q_EMIT textCursorPositionOnNonImageResourceState( state, QByteArray::fromHex(resourceHash.toLocal8Bit())); diff -Nru libquentier-0.5.0/src/note_editor/javascript_glue/TextCursorPositionJavaScriptHandler.h libquentier-0.5.0/src/note_editor/javascript_glue/TextCursorPositionJavaScriptHandler.h --- libquentier-0.5.0/src/note_editor/javascript_glue/TextCursorPositionJavaScriptHandler.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/javascript_glue/TextCursorPositionJavaScriptHandler.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,6 +20,7 @@ #define LIB_QUENTIER_NOTE_EDITOR_JAVASCRIPT_GLUE_TEXT_CURSOR_POSITION_JAVASCRIPT_HANDLER_H #include <quentier/utility/Macros.h> + #include <QObject> namespace quentier { diff -Nru libquentier-0.5.0/src/note_editor/javascript_glue/ToDoCheckboxAutomaticInsertionHandler.cpp libquentier-0.5.0/src/note_editor/javascript_glue/ToDoCheckboxAutomaticInsertionHandler.cpp --- libquentier-0.5.0/src/note_editor/javascript_glue/ToDoCheckboxAutomaticInsertionHandler.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/javascript_glue/ToDoCheckboxAutomaticInsertionHandler.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -20,7 +20,8 @@ namespace quentier { -ToDoCheckboxAutomaticInsertionHandler::ToDoCheckboxAutomaticInsertionHandler(QObject * parent) : +ToDoCheckboxAutomaticInsertionHandler::ToDoCheckboxAutomaticInsertionHandler( + QObject * parent) : QObject(parent) {} diff -Nru libquentier-0.5.0/src/note_editor/javascript_glue/ToDoCheckboxAutomaticInsertionHandler.h libquentier-0.5.0/src/note_editor/javascript_glue/ToDoCheckboxAutomaticInsertionHandler.h --- libquentier-0.5.0/src/note_editor/javascript_glue/ToDoCheckboxAutomaticInsertionHandler.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/javascript_glue/ToDoCheckboxAutomaticInsertionHandler.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,6 +20,7 @@ #define LIB_QUENTIER_NOTE_EDITOR_JAVASCRIPT_GLUE_TODO_CHECKBOX_AUTOMATIC_INSERTION_HANDLER_H #include <quentier/utility/Macros.h> + #include <QObject> namespace quentier { diff -Nru libquentier-0.5.0/src/note_editor/javascript_glue/ToDoCheckboxOnClickHandler.cpp libquentier-0.5.0/src/note_editor/javascript_glue/ToDoCheckboxOnClickHandler.cpp --- libquentier-0.5.0/src/note_editor/javascript_glue/ToDoCheckboxOnClickHandler.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/javascript_glue/ToDoCheckboxOnClickHandler.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -17,6 +17,7 @@ */ #include "ToDoCheckboxOnClickHandler.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { @@ -27,7 +28,7 @@ void ToDoCheckboxOnClickHandler::onToDoCheckboxClicked(QString enToDoCheckboxId) { - QNDEBUG(QStringLiteral("ToDoCheckboxOnClickHandler::onToDoCheckboxClicked: ") + QNDEBUG("ToDoCheckboxOnClickHandler::onToDoCheckboxClicked: " << enToDoCheckboxId); bool conversionResult = false; diff -Nru libquentier-0.5.0/src/note_editor/javascript_glue/ToDoCheckboxOnClickHandler.h libquentier-0.5.0/src/note_editor/javascript_glue/ToDoCheckboxOnClickHandler.h --- libquentier-0.5.0/src/note_editor/javascript_glue/ToDoCheckboxOnClickHandler.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/javascript_glue/ToDoCheckboxOnClickHandler.h 2019-07-11 10:46:53.000000000 +0000 @@ -21,6 +21,7 @@ #include <quentier/utility/Macros.h> #include <quentier/types/ErrorString.h> + #include <QObject> namespace quentier { diff -Nru libquentier-0.5.0/src/note_editor/javascript_glue/WebSocketWaiter.cpp libquentier-0.5.0/src/note_editor/javascript_glue/WebSocketWaiter.cpp --- libquentier-0.5.0/src/note_editor/javascript_glue/WebSocketWaiter.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/javascript_glue/WebSocketWaiter.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -17,6 +17,7 @@ */ #include "WebSocketWaiter.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { @@ -27,7 +28,7 @@ void WebSocketWaiter::onReady() { - QNDEBUG(QStringLiteral("WebSocketWaiter::onReady")); + QNDEBUG("WebSocketWaiter::onReady"); Q_EMIT ready(); } diff -Nru libquentier-0.5.0/src/note_editor/javascript_glue/WebSocketWaiter.h libquentier-0.5.0/src/note_editor/javascript_glue/WebSocketWaiter.h --- libquentier-0.5.0/src/note_editor/javascript_glue/WebSocketWaiter.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/javascript_glue/WebSocketWaiter.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,6 +20,7 @@ #define LIB_QUENTIER_NOTE_EDITOR_JAVASCRIPT_GLUE_WEB_SOCKET_WAITER_H #include <quentier/utility/Macros.h> + #include <QObject> namespace quentier { diff -Nru libquentier-0.5.0/src/note_editor/JavaScriptInOrderExecutor.cpp libquentier-0.5.0/src/note_editor/JavaScriptInOrderExecutor.cpp --- libquentier-0.5.0/src/note_editor/JavaScriptInOrderExecutor.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/JavaScriptInOrderExecutor.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -17,6 +17,7 @@ */ #include "JavaScriptInOrderExecutor.h" + #include <quentier/logging/QuentierLogger.h> #ifndef QUENTIER_USE_QT_WEB_ENGINE @@ -25,8 +26,8 @@ namespace quentier { -JavaScriptInOrderExecutor::JavaScriptInOrderExecutor(WebView & view, - QObject * parent) : +JavaScriptInOrderExecutor::JavaScriptInOrderExecutor( + WebView & view, QObject * parent) : QObject(parent), m_view(view), m_javaScriptsQueue(), @@ -34,12 +35,12 @@ m_inProgress(false) {} -void JavaScriptInOrderExecutor::append(const QString &script, - JavaScriptInOrderExecutor::Callback callback) +void JavaScriptInOrderExecutor::append( + const QString &script, JavaScriptInOrderExecutor::Callback callback) { m_javaScriptsQueue.enqueue(QPair<QString, Callback>(script, callback)); - QNTRACE(QStringLiteral("JavaScriptInOrderExecutor: appended new script, there are ") - << m_javaScriptsQueue.size() << QStringLiteral(" to execute now")); + QNTRACE("JavaScriptInOrderExecutor: appended new script, there are " + << m_javaScriptsQueue.size() << " to execute now"); } void JavaScriptInOrderExecutor::start() @@ -63,7 +64,7 @@ void JavaScriptInOrderExecutor::next(const QVariant & data) { - QNTRACE(QStringLiteral("JavaScriptInOrderExecutor::next")); + QNTRACE("JavaScriptInOrderExecutor::next"); if (!m_currentPendingCallback.empty()) { m_currentPendingCallback(data); @@ -71,19 +72,20 @@ } if (m_javaScriptsQueue.empty()) { - QNTRACE(QStringLiteral("JavaScriptInOrderExecutor: done")); + QNTRACE("JavaScriptInOrderExecutor: done"); m_inProgress = false; Q_EMIT finished(); return; } - QNTRACE(QStringLiteral("JavaScriptInOrderExecutor: ") + QNTRACE("JavaScriptInOrderExecutor: " << m_javaScriptsQueue.size() - << QStringLiteral(" more scripts to execute")); + << " more scripts to execute"); start(); } -void JavaScriptInOrderExecutor::JavaScriptCallback::operator()(const QVariant & result) +void JavaScriptInOrderExecutor::JavaScriptCallback::operator()( + const QVariant & result) { m_executor.next(result); } diff -Nru libquentier-0.5.0/src/note_editor/JavaScriptInOrderExecutor.h libquentier-0.5.0/src/note_editor/JavaScriptInOrderExecutor.h --- libquentier-0.5.0/src/note_editor/JavaScriptInOrderExecutor.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/JavaScriptInOrderExecutor.h 2019-07-11 10:46:53.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Copyright 2016 Dmitry Ivanov + * Copyright 2016-2019 Dmitry Ivanov * * This file is part of libquentier * @@ -20,6 +20,7 @@ #define LIB_QUENTIER_NOTE_EDITOR_JAVA_SCRIPT_IN_ORDER_EXECUTOR_H #include <quentier/utility/Macros.h> + #include <QObject> #include <QQueue> @@ -51,7 +52,8 @@ public: typedef boost::function<void (const QVariant&)> Callback; - explicit JavaScriptInOrderExecutor(WebView & view, QObject * parent = Q_NULLPTR); + explicit JavaScriptInOrderExecutor(WebView & view, + QObject * parent = Q_NULLPTR); void append(const QString & script, Callback callback = 0); int size() const { return m_javaScriptsQueue.size(); } diff -Nru libquentier-0.5.0/src/note_editor/NoteEditor.cpp libquentier-0.5.0/src/note_editor/NoteEditor.cpp --- libquentier-0.5.0/src/note_editor/NoteEditor.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/NoteEditor.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -17,9 +17,11 @@ */ #include "NoteEditor_p.h" + #include <quentier/note_editor/NoteEditor.h> #include <quentier/note_editor/INoteEditorBackend.h> #include <quentier/local_storage/LocalStorageManagerAsync.h> + #include <QUndoStack> #include <QFont> #include <QColor> diff -Nru libquentier-0.5.0/src/note_editor/NoteEditorLocalStorageBroker.cpp libquentier-0.5.0/src/note_editor/NoteEditorLocalStorageBroker.cpp --- libquentier-0.5.0/src/note_editor/NoteEditorLocalStorageBroker.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/NoteEditorLocalStorageBroker.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,6 +18,7 @@ #include "NoteEditorLocalStorageBroker.h" #include "../synchronization/SynchronizationShared.h" + #include <quentier/logging/QuentierLogger.h> // 10 Mb @@ -58,10 +59,10 @@ void NoteEditorLocalStorageBroker::setLocalStorageManager( LocalStorageManagerAsync & localStorageManagerAsync) { - QNDEBUG(QStringLiteral("NoteEditorLocalStorageBroker::setLocalStorageManager")); + QNDEBUG("NoteEditorLocalStorageBroker::setLocalStorageManager"); if (m_pLocalStorageManagerAsync == &localStorageManagerAsync) { - QNDEBUG(QStringLiteral("LocalStorageManagerAsync is already set")); + QNDEBUG("LocalStorageManagerAsync is already set"); return; } @@ -75,20 +76,20 @@ void NoteEditorLocalStorageBroker::saveNoteToLocalStorage(const Note & note) { - QNDEBUG(QStringLiteral("NoteEditorLocalStorageBroker::saveNoteToLocalStorage: ") - << QStringLiteral("note local uid = ") << note.localUid()); + QNDEBUG("NoteEditorLocalStorageBroker::saveNoteToLocalStorage: " + << "note local uid = " << note.localUid()); const Note * pCachedNote = m_notesCache.get(note.localUid()); if (!pCachedNote) { - QNTRACE(QStringLiteral("Haven't found the note to be saved within the cache")); + QNTRACE("Haven't found the note to be saved within the cache"); QUuid requestId = QUuid::createUuid(); m_notesPendingSavingByFindNoteRequestIds[requestId] = note; Note dummy; dummy.setLocalUid(note.localUid()); - QNDEBUG(QStringLiteral("Emitting the request to find note for the sake " - "of resource list updates resolution")); + QNDEBUG("Emitting the request to find note for the sake " + "of resource list updates resolution"); LocalStorageManager::GetNoteOptions options( LocalStorageManager::GetNoteOption::WithResourceMetadata); Q_EMIT findNote(dummy, options, requestId); @@ -98,15 +99,16 @@ saveNoteToLocalStorageImpl(*pCachedNote, note); } -void NoteEditorLocalStorageBroker::findNoteAndNotebook(const QString & noteLocalUid) +void NoteEditorLocalStorageBroker::findNoteAndNotebook( + const QString & noteLocalUid) { - QNDEBUG(QStringLiteral("NoteEditorLocalStorageBroker::findNoteAndNotebook: ") - << QStringLiteral("note local uid = ") << noteLocalUid); + QNDEBUG("NoteEditorLocalStorageBroker::findNoteAndNotebook: " + << "note local uid = " << noteLocalUid); const Note * pCachedNote = m_notesCache.get(noteLocalUid); if (!pCachedNote) { - QNDEBUG(QStringLiteral("Note was not found within the cache, looking " - "it up in the local storage")); + QNDEBUG("Note was not found within the cache, looking " + "it up in the local storage"); emitFindNoteRequest(noteLocalUid); return; } @@ -115,9 +117,8 @@ !pCachedNote->hasNotebookGuid())) { Q_UNUSED(m_notesCache.remove(noteLocalUid)) - QNDEBUG(QStringLiteral("The note within the cache contained neither " - "notebook local uid nor notebook guid, looking " - "it up in the local storage")); + QNDEBUG("The note within the cache contained neither notebook local " + "uid nor notebook guid, looking it up in the local storage"); emitFindNoteRequest(noteLocalUid); return; } @@ -126,31 +127,35 @@ { const QString & notebookLocalUid = pCachedNote->notebookLocalUid(); - const Notebook * pCachedNotebook = m_notebooksCache.get(notebookLocalUid); + const Notebook * pCachedNotebook = + m_notebooksCache.get(notebookLocalUid); if (pCachedNotebook) { - QNDEBUG(QStringLiteral("Found both note and notebook within caches")); + QNDEBUG("Found both note and notebook within caches"); Q_EMIT foundNoteAndNotebook(*pCachedNote, *pCachedNotebook); } else { - QNDEBUG(QStringLiteral("Notebook was not found within the cache, " - "looking it up in local storage")); - emitFindNotebookForNoteByLocalUidRequest(notebookLocalUid, *pCachedNote); + QNDEBUG("Notebook was not found within the cache, " + "looking it up in local storage"); + emitFindNotebookForNoteByLocalUidRequest(notebookLocalUid, + *pCachedNote); } return; } - emitFindNotebookForNoteByGuidRequest(pCachedNote->notebookGuid(), *pCachedNote); + emitFindNotebookForNoteByGuidRequest(pCachedNote->notebookGuid(), + *pCachedNote); } -void NoteEditorLocalStorageBroker::findResourceData(const QString & resourceLocalUid) +void NoteEditorLocalStorageBroker::findResourceData( + const QString & resourceLocalUid) { - QNDEBUG(QStringLiteral("NoteEditorLocalStorageBroker::findResourceData: " - "resource local uid = ") << resourceLocalUid); + QNDEBUG("NoteEditorLocalStorageBroker::findResourceData: " + << "resource local uid = " << resourceLocalUid); const Resource * pCachedResource = m_resourcesCache.get(resourceLocalUid); if (pCachedResource) { - QNDEBUG(QStringLiteral("Found cached resource binary data")); + QNDEBUG("Found cached resource binary data"); Q_EMIT foundResourceData(*pCachedResource); return; } @@ -159,8 +164,8 @@ Q_UNUSED(m_findResourceRequestIds.insert(requestId)) Resource resource; resource.setLocalUid(resourceLocalUid); - QNDEBUG(QStringLiteral("Emitting the request to find resource: request id = ") - << requestId << QStringLiteral(", resource local uid = ") + QNDEBUG("Emitting the request to find resource: request id = " + << requestId << ", resource local uid = " << resourceLocalUid); LocalStorageManager::GetResourceOptions options( LocalStorageManager::GetResourceOption::WithBinaryData); @@ -170,10 +175,9 @@ void NoteEditorLocalStorageBroker::onUpdateNoteComplete( Note note, LocalStorageManager::UpdateNoteOptions options, QUuid requestId) { - QNDEBUG(QStringLiteral("NoteEditorLocalStorageBroker::onUpdateNoteComplete: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", options = ") << options - << QStringLiteral(", note: ") << note); + QNDEBUG("NoteEditorLocalStorageBroker::onUpdateNoteComplete: " + << "request id = " << requestId << ", options = " << options + << ", note: " << note); if (m_notesCache.exists(note.localUid())) { @@ -199,7 +203,7 @@ auto it = m_updateNoteRequestIds.find(requestId); if (it != m_updateNoteRequestIds.end()) { - QNDEBUG(QStringLiteral("Note was successfully saved within the local storage")); + QNDEBUG("Note was successfully saved within the local storage"); m_updateNoteRequestIds.erase(it); Q_EMIT noteSavedToLocalStorage(note.localUid()); return; @@ -217,17 +221,17 @@ return; } - QNWARNING(QStringLiteral("Failed to update the note within the local storage: ") - << errorDescription << QStringLiteral(", note: ") << note - << QStringLiteral("\nUpdate options: ") << options - << QStringLiteral(", request id = ") << requestId); + QNWARNING("Failed to update the note within the local storage: " + << errorDescription << ", note: " << note + << "\nUpdate options: " << options + << ", request id = " << requestId); m_updateNoteRequestIds.erase(it); Q_EMIT failedToSaveNoteToLocalStorage(note.localUid(), errorDescription); } -void NoteEditorLocalStorageBroker::onUpdateNotebookComplete(Notebook notebook, - QUuid requestId) +void NoteEditorLocalStorageBroker::onUpdateNotebookComplete( + Notebook notebook, QUuid requestId) { Q_UNUSED(requestId) QString notebookLocalUid = notebook.localUid(); @@ -238,30 +242,33 @@ } void NoteEditorLocalStorageBroker::onFindNoteComplete( - Note foundNote, LocalStorageManager::GetNoteOptions options, QUuid requestId) + Note foundNote, LocalStorageManager::GetNoteOptions options, + QUuid requestId) { auto it = m_findNoteRequestIds.find(requestId); if (it != m_findNoteRequestIds.end()) { - QNDEBUG(QStringLiteral("NoteEditorLocalStorageBroker::onFindNoteComplete: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", with resource metadata = ") + QNDEBUG("NoteEditorLocalStorageBroker::onFindNoteComplete: " + << "request id = " << requestId << ", with resource metadata = " << ((options & LocalStorageManager::GetNoteOption::WithResourceMetadata) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with resource binary data = ") + ? "true" + : "false") + << ", with resource binary data = " << ((options & LocalStorageManager::GetNoteOption::WithResourceBinaryData) - ? QStringLiteral("true") - : QStringLiteral("false"))); + ? "true" + : "false")); m_findNoteRequestIds.erase(it); - if (Q_UNLIKELY(!foundNote.hasNotebookLocalUid() && !foundNote.hasNotebookGuid())) + if (Q_UNLIKELY(!foundNote.hasNotebookLocalUid() && + !foundNote.hasNotebookGuid())) { - ErrorString errorDescription(QT_TR_NOOP("note doesn't belong to any notebook")); + ErrorString errorDescription( + QT_TR_NOOP("note doesn't belong to any notebook")); APPEND_NOTE_DETAILS(errorDescription, foundNote) - QNWARNING(errorDescription << QStringLiteral(", note: ") << foundNote); - Q_EMIT failedToFindNoteOrNotebook(foundNote.localUid(), errorDescription); + QNWARNING(errorDescription << ", note: " << foundNote); + Q_EMIT failedToFindNoteOrNotebook(foundNote.localUid(), + errorDescription); return; } @@ -271,37 +278,39 @@ { const QString & notebookLocalUid = foundNote.notebookLocalUid(); - const Notebook * pCachedNotebook = m_notebooksCache.get(notebookLocalUid); + const Notebook * pCachedNotebook = + m_notebooksCache.get(notebookLocalUid); if (pCachedNotebook) { - QNDEBUG(QStringLiteral("Found notebook within the cache")); + QNDEBUG("Found notebook within the cache"); Q_EMIT foundNoteAndNotebook(foundNote, *pCachedNotebook); } else { - QNDEBUG(QStringLiteral("Notebook was not found within the cache, " - "looking it up in local storage")); - emitFindNotebookForNoteByLocalUidRequest(notebookLocalUid, foundNote); + QNDEBUG("Notebook was not found within the cache, " + "looking it up in local storage"); + emitFindNotebookForNoteByLocalUidRequest(notebookLocalUid, + foundNote); } return; } - emitFindNotebookForNoteByGuidRequest(foundNote.notebookGuid(), foundNote); + emitFindNotebookForNoteByGuidRequest(foundNote.notebookGuid(), + foundNote); return; } auto pit = m_notesPendingSavingByFindNoteRequestIds.find(requestId); if (pit != m_notesPendingSavingByFindNoteRequestIds.end()) { - QNDEBUG(QStringLiteral("NoteEditorLocalStorageBroker::onFindNoteComplete: " - "request id = ") << requestId - << QStringLiteral(", with resource metadata = ") + QNDEBUG("NoteEditorLocalStorageBroker::onFindNoteComplete: request id = " + << requestId << ", with resource metadata = " << ((options & LocalStorageManager::GetNoteOption::WithResourceMetadata) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with resource binary data = ") + ? "true" + : "false") + << ", with resource binary data = " << ((options & LocalStorageManager::GetNoteOption::WithResourceBinaryData) - ? QStringLiteral("true") - : QStringLiteral("false"))); + ? "true" + : "false")); Note updatedNote = pit.value(); Q_UNUSED(m_notesPendingSavingByFindNoteRequestIds.erase(pit)) @@ -319,34 +328,32 @@ return; } - QNWARNING(QStringLiteral("NoteEditorLocalStorageBroker::onFindNoteFailed: " - "request id = ") << requestId - << QStringLiteral(", with resource metadata = ") + QNWARNING("NoteEditorLocalStorageBroker::onFindNoteFailed: request id = " + << requestId << ", with resource metadata = " << ((options & LocalStorageManager::GetNoteOption::WithResourceMetadata) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with resource binary data = ") + ? "true" + : "false") + << ", with resource binary data = " << ((options & LocalStorageManager::GetNoteOption::WithResourceBinaryData) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", error description: ") << errorDescription - << QStringLiteral(", note: ") << note); + ? "true" + : "false") + << ", error description: " << errorDescription << ", note: " + << note); m_findNoteRequestIds.erase(it); Q_EMIT failedToFindNoteOrNotebook(note.localUid(), errorDescription); } -void NoteEditorLocalStorageBroker::onFindNotebookComplete(Notebook foundNotebook, - QUuid requestId) +void NoteEditorLocalStorageBroker::onFindNotebookComplete( + Notebook foundNotebook, QUuid requestId) { auto it = m_findNotebookRequestIds.find(requestId); if (it == m_findNotebookRequestIds.end()) { return; } - QNDEBUG(QStringLiteral("NoteEditorLocalStorageBroker::onFindNotebookComplete: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", notebook: ") << foundNotebook); + QNDEBUG("NoteEditorLocalStorageBroker::onFindNotebookComplete: " + << "request id = " << requestId << ", notebook: " << foundNotebook); m_findNotebookRequestIds.erase(it); @@ -378,9 +385,8 @@ } if (!foundNotesPendingNotebookFinding) { - QNWARNING(QStringLiteral("Found notebook but unable to detect which notes ") - << QStringLiteral("required its finding: notebook = ") - << foundNotebook); + QNWARNING("Found notebook but unable to detect which notes " + << "required its finding: notebook = " << foundNotebook); return; } @@ -388,9 +394,8 @@ for(auto noteIt = notes.constBegin(), noteEnd = notes.constEnd(); noteIt != noteEnd; ++noteIt) { - QNTRACE(QStringLiteral("Found pending note, emitting foundNoteAndNotebook ") - << QStringLiteral("signal: note local uid = ") - << noteIt.value().localUid()); + QNTRACE("Found pending note, emitting foundNoteAndNotebook " + << "signal: note local uid = " << noteIt.value().localUid()); Q_EMIT foundNoteAndNotebook(noteIt.value(), foundNotebook); } @@ -402,19 +407,17 @@ } } -void NoteEditorLocalStorageBroker::onFindNotebookFailed(Notebook notebook, - ErrorString errorDescription, - QUuid requestId) +void NoteEditorLocalStorageBroker::onFindNotebookFailed( + Notebook notebook, ErrorString errorDescription, QUuid requestId) { auto it = m_findNotebookRequestIds.find(requestId); if (it == m_findNotebookRequestIds.end()) { return; } - QNWARNING(QStringLiteral("NoteEditorLocalStorageBroker::onFindNotebookFailed: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", error description: ") << errorDescription - << QStringLiteral(", notebook: ") << notebook); + QNWARNING("NoteEditorLocalStorageBroker::onFindNotebookFailed: " + << "request id = " << requestId << ", error description: " + << errorDescription << ", notebook: " << notebook); m_findNotebookRequestIds.erase(it); @@ -444,8 +447,8 @@ } if (!foundNotesPendingNotebookFinding) { - QNDEBUG(QStringLiteral("Failed to find notebook and unable to determine " - "for which notes it was required - nothing left to do")); + QNDEBUG("Failed to find notebook and unable to determine " + "for which notes it was required - nothing left to do"); return; } @@ -465,26 +468,24 @@ } } -void NoteEditorLocalStorageBroker::onAddResourceComplete(Resource resource, - QUuid requestId) +void NoteEditorLocalStorageBroker::onAddResourceComplete( + Resource resource, QUuid requestId) { auto it = m_noteLocalUidsByAddResourceRequestIds.find(requestId); if (it == m_noteLocalUidsByAddResourceRequestIds.end()) { return; } - QNDEBUG(QStringLiteral("NoteEditorLocalStorageBroker::onAddResourceComplete: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", resource: ") << resource); + QNDEBUG("NoteEditorLocalStorageBroker::onAddResourceComplete: " + << "request id = " << requestId << ", resource: " << resource); QString noteLocalUid = it.value(); m_noteLocalUidsByAddResourceRequestIds.erase(it); auto saveNoteInfoIt = m_saveNoteInfoByNoteLocalUids.find(noteLocalUid); if (Q_UNLIKELY(saveNoteInfoIt == m_saveNoteInfoByNoteLocalUids.end())) { - QNWARNING(QStringLiteral("Unable to find note for which the resource was " - "added to the local storage: resource = ") - << resource); + QNWARNING("Unable to find note for which the resource was " + << "added to the local storage: resource = " << resource); return; } @@ -496,8 +497,7 @@ } if (saveNoteInfo.hasPendingResourceOperations()) { - QNDEBUG(QStringLiteral("Still pending resource data saving: ") - << saveNoteInfo); + QNDEBUG("Still pending resource data saving: " << saveNoteInfo); return; } @@ -505,19 +505,18 @@ m_saveNoteInfoByNoteLocalUids.erase(saveNoteInfoIt); } -void NoteEditorLocalStorageBroker::onAddResourceFailed(Resource resource, - ErrorString errorDescription, - QUuid requestId) +void NoteEditorLocalStorageBroker::onAddResourceFailed( + Resource resource, ErrorString errorDescription, QUuid requestId) { auto it = m_noteLocalUidsByAddResourceRequestIds.find(requestId); if (it == m_noteLocalUidsByAddResourceRequestIds.end()) { return; } - QNWARNING(QStringLiteral("NoteEditorLocalStorageBroker::onAddResourceFailed: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", error description: ") << errorDescription - << QStringLiteral(", resource: ") << resource); + QNWARNING("NoteEditorLocalStorageBroker::onAddResourceFailed: " + << "request id = " << requestId + << ", error description: " << errorDescription + << ", resource: " << resource); QString noteLocalUid = it.value(); m_noteLocalUidsByAddResourceRequestIds.erase(it); @@ -530,8 +529,8 @@ Q_EMIT failedToSaveNoteToLocalStorage(noteLocalUid, errorDescription); } -void NoteEditorLocalStorageBroker::onUpdateResourceComplete(Resource resource, - QUuid requestId) +void NoteEditorLocalStorageBroker::onUpdateResourceComplete( + Resource resource, QUuid requestId) { if (m_resourcesCache.get(resource.localUid())) { m_resourcesCache.put(resource.localUid(), resource); @@ -542,18 +541,18 @@ return; } - QNDEBUG(QStringLiteral("NoteEditorLocalStorageBroker::onUpdateResourceComplete: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", resource: ") << resource); + QNDEBUG("NoteEditorLocalStorageBroker::onUpdateResourceComplete: " + << "request id = " << requestId + << ", resource: " << resource); QString noteLocalUid = it.value(); m_noteLocalUidsByUpdateResourceRequestIds.erase(it); auto saveNoteInfoIt = m_saveNoteInfoByNoteLocalUids.find(noteLocalUid); if (Q_UNLIKELY(saveNoteInfoIt == m_saveNoteInfoByNoteLocalUids.end())) { - QNWARNING(QStringLiteral("Unable to find note for which the resource was " - "updated in the local storage: note local uid = ") - << noteLocalUid << QStringLiteral(", resource = ") << resource); + QNWARNING("Unable to find note for which the resource was " + << "updated in the local storage: note local uid = " + << noteLocalUid << ", resource = " << resource); return; } @@ -565,8 +564,7 @@ } if (saveNoteInfo.hasPendingResourceOperations()) { - QNDEBUG(QStringLiteral("Still pending resource data saving: ") - << saveNoteInfo); + QNDEBUG("Still pending resource data saving: " << saveNoteInfo); return; } @@ -574,19 +572,18 @@ m_saveNoteInfoByNoteLocalUids.erase(saveNoteInfoIt); } -void NoteEditorLocalStorageBroker::onUpdateResourceFailed(Resource resource, - ErrorString errorDescription, - QUuid requestId) +void NoteEditorLocalStorageBroker::onUpdateResourceFailed( + Resource resource, ErrorString errorDescription, QUuid requestId) { auto it = m_noteLocalUidsByUpdateResourceRequestIds.find(requestId); if (it == m_noteLocalUidsByUpdateResourceRequestIds.end()) { return; } - QNWARNING(QStringLiteral("NoteEditorLocalStorageBroker::onUpdateResourceFailed: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", error description: ") << errorDescription - << QStringLiteral(", resource: ") << resource); + QNWARNING("NoteEditorLocalStorageBroker::onUpdateResourceFailed: " + << "request id = " << requestId + << ", error description: " << errorDescription + << ", resource: " << resource); QString noteLocalUid = it.value(); m_noteLocalUidsByUpdateResourceRequestIds.erase(it); @@ -599,8 +596,8 @@ Q_EMIT failedToSaveNoteToLocalStorage(noteLocalUid, errorDescription); } -void NoteEditorLocalStorageBroker::onExpungeResourceComplete(Resource resource, - QUuid requestId) +void NoteEditorLocalStorageBroker::onExpungeResourceComplete( + Resource resource, QUuid requestId) { Q_UNUSED(m_resourcesCache.remove(resource.localUid())) @@ -609,16 +606,15 @@ return; } - QNDEBUG(QStringLiteral("NoteEditorLocalStorageBroker::onExpungeResourceComplete")); + QNDEBUG("NoteEditorLocalStorageBroker::onExpungeResourceComplete"); QString noteLocalUid = it.value(); m_noteLocalUidsByExpungeResourceRequestIds.erase(it); auto saveNoteInfoIt = m_saveNoteInfoByNoteLocalUids.find(noteLocalUid); if (Q_UNLIKELY(saveNoteInfoIt == m_saveNoteInfoByNoteLocalUids.end())) { - QNWARNING(QStringLiteral("Unable to find note which resource was expunged ") - << QStringLiteral("from the local storage: resource = ") - << resource); + QNWARNING("Unable to find note which resource was expunged " + << "from the local storage: resource = " << resource); return; } @@ -630,8 +626,7 @@ } if (saveNoteInfo.hasPendingResourceOperations()) { - QNDEBUG(QStringLiteral("Still pending resource data saving: ") - << saveNoteInfo); + QNDEBUG("Still pending resource data saving: " << saveNoteInfo); return; } @@ -639,19 +634,18 @@ m_saveNoteInfoByNoteLocalUids.erase(saveNoteInfoIt); } -void NoteEditorLocalStorageBroker::onExpungeResourceFailed(Resource resource, - ErrorString errorDescription, - QUuid requestId) +void NoteEditorLocalStorageBroker::onExpungeResourceFailed( + Resource resource, ErrorString errorDescription, QUuid requestId) { auto it = m_noteLocalUidsByExpungeResourceRequestIds.find(requestId); if (it == m_noteLocalUidsByExpungeResourceRequestIds.end()) { return; } - QNWARNING(QStringLiteral("NoteEditorLocalStorageBroker::onExpungeResourceFailed: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", error description: ") << errorDescription - << QStringLiteral(", resource: ") << resource); + QNWARNING("NoteEditorLocalStorageBroker::onExpungeResourceFailed: " + << "request id = " << requestId + << ", error description: " << errorDescription + << ", resource: " << resource); QString noteLocalUid = it.value(); m_noteLocalUidsByExpungeResourceRequestIds.erase(it); @@ -664,7 +658,8 @@ Q_EMIT failedToSaveNoteToLocalStorage(noteLocalUid, errorDescription); } -void NoteEditorLocalStorageBroker::onExpungeNoteComplete(Note note, QUuid requestId) +void NoteEditorLocalStorageBroker::onExpungeNoteComplete( + Note note, QUuid requestId) { Q_UNUSED(requestId) QString noteLocalUid = note.localUid(); @@ -675,9 +670,8 @@ rend = m_resourcesCache.end(); rit != rend; ++rit) { if (Q_UNLIKELY(!rit->second.hasNoteLocalUid())) { - QNTRACE(QStringLiteral("Detected resource without note local uid; ") - << QStringLiteral("will remove it from the cache: ") - << rit->second); + QNTRACE("Detected resource without note local uid; " + << "will remove it from the cache: " << rit->second); resourceLocalUidsToRemoveFromCache << rit->first; continue; } @@ -696,20 +690,20 @@ Q_EMIT noteDeleted(noteLocalUid); } -void NoteEditorLocalStorageBroker::onExpungeNotebookComplete(Notebook notebook, - QUuid requestId) +void NoteEditorLocalStorageBroker::onExpungeNotebookComplete( + Notebook notebook, QUuid requestId) { Q_UNUSED(requestId) QString notebookLocalUid = notebook.localUid(); Q_UNUSED(m_notebooksCache.remove(notebookLocalUid)) QStringList noteLocalUidsToRemoveFromCache; - for(auto it = m_notesCache.begin(), end = m_notesCache.end(); it != end; ++it) + for(auto it = m_notesCache.begin(), + end = m_notesCache.end(); it != end; ++it) { if (Q_UNLIKELY(!it->second.hasNotebookLocalUid())) { - QNTRACE(QStringLiteral("Detected note without notebook local uid; ") - << QStringLiteral("will remove it from the cache: ") - << it->second); + QNTRACE("Detected note without notebook local uid; " + << "will remove it from the cache: " << it->second); noteLocalUidsToRemoveFromCache << it->first; continue; } @@ -745,13 +739,13 @@ return; } - QNDEBUG(QStringLiteral("NoteEditorLocalStorageBroker::onFindResourceComplete: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", with binary data = ") + QNDEBUG("NoteEditorLocalStorageBroker::onFindResourceComplete: " + << "request id = " << requestId + << ", with binary data = " << ((options & LocalStorageManager::GetResourceOption::WithBinaryData) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", resource: ") << resource); + ? "true" + : "false") + << ", resource: " << resource); m_findResourceRequestIds.erase(it); @@ -779,26 +773,23 @@ return; } - QNWARNING(QStringLiteral("NoteEditorLocalStorageBroker::onFindResourceFailed: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", with binary data = ") + QNWARNING("NoteEditorLocalStorageBroker::onFindResourceFailed: " + << "request id = " << requestId << ", with binary data = " << ((options & LocalStorageManager::GetResourceOption::WithBinaryData) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", error description = ") - << errorDescription << QStringLiteral(", resource: ") + ? "true" + : "false") + << ", error description = " << errorDescription << ", resource: " << resource); m_findResourceRequestIds.erase(it); Q_EMIT failedToFindResourceData(resource.localUid(), errorDescription); } -void NoteEditorLocalStorageBroker::onSwitchUserComplete(Account account, - QUuid requestId) +void NoteEditorLocalStorageBroker::onSwitchUserComplete( + Account account, QUuid requestId) { - QNDEBUG(QStringLiteral("NoteEditorLocalStorageBroker::onSwitchUserComplete: ") - << QStringLiteral("account = ") << account - << QStringLiteral("\nRequest id = ") << requestId); + QNDEBUG("NoteEditorLocalStorageBroker::onSwitchUserComplete: " + << "account = " << account << "\nRequest id = " << requestId); m_findNoteRequestIds.clear(); m_findNotebookRequestIds.clear(); @@ -822,7 +813,7 @@ void NoteEditorLocalStorageBroker::createConnections( LocalStorageManagerAsync & localStorageManagerAsync) { - QNDEBUG(QStringLiteral("NoteEditorLocalStorageBroker::createConnections")); + QNDEBUG("NoteEditorLocalStorageBroker::createConnections"); // Local signals to LocalStorageManagerAsync's slots QObject::connect(this, @@ -992,7 +983,7 @@ void NoteEditorLocalStorageBroker::disconnectFromLocalStorage( LocalStorageManagerAsync & localStorageManagerAsync) { - QNDEBUG(QStringLiteral("NoteEditorLocalStorageBroker::disconnectFromLocalStorage")); + QNDEBUG("NoteEditorLocalStorageBroker::disconnectFromLocalStorage"); // Disconnect local signals from LocalStorageManagerAsync's slots QObject::disconnect(this, QNSIGNAL(NoteEditorLocalStorageBroker,updateNote, @@ -1160,14 +1151,15 @@ Account,QUuid)); } -void NoteEditorLocalStorageBroker::emitFindNoteRequest(const QString & noteLocalUid) +void NoteEditorLocalStorageBroker::emitFindNoteRequest( + const QString & noteLocalUid) { QUuid requestId = QUuid::createUuid(); Q_UNUSED(m_findNoteRequestIds.insert(requestId)) Note note; note.setLocalUid(noteLocalUid); - QNDEBUG(QStringLiteral("Emitting the request to find note: request id = ") - << requestId << QStringLiteral(", note local uid = ") << noteLocalUid); + QNDEBUG("Emitting the request to find note: request id = " + << requestId << ", note local uid = " << noteLocalUid); LocalStorageManager::GetNoteOptions options( LocalStorageManager::GetNoteOption::WithResourceMetadata); Q_EMIT findNote(note, options, requestId); @@ -1185,19 +1177,18 @@ LocalStorageManager::UpdateNoteOption::UpdateResourceMetadata); QUuid requestId = QUuid::createUuid(); Q_UNUSED(m_updateNoteRequestIds.insert(requestId)) - QNDEBUG(QStringLiteral("Emitting the request to update note in the local ") - << QStringLiteral("storage: request id = ") << requestId - << QStringLiteral(", note: ") << note); + QNDEBUG("Emitting the request to update note in the local " + << "storage: request id = " << requestId << ", note: " << note); Q_EMIT updateNote(note, options, requestId); } void NoteEditorLocalStorageBroker::emitFindNotebookForNoteByLocalUidRequest( const QString & notebookLocalUid, const Note & note) { - QNDEBUG(QStringLiteral("NoteEditorLocalStorageBroker::") - << QStringLiteral("emitFindNotebookForNoteByLocalUidRequest: ") - << QStringLiteral("notebook local uid = ") << notebookLocalUid - << QStringLiteral(", note local uid = ") << note.localUid()); + QNDEBUG("NoteEditorLocalStorageBroker::" + << "emitFindNotebookForNoteByLocalUidRequest: " + << "notebook local uid = " << notebookLocalUid + << ", note local uid = " << note.localUid()); Notebook notebook; notebook.setLocalUid(notebookLocalUid); @@ -1208,10 +1199,10 @@ void NoteEditorLocalStorageBroker::emitFindNotebookForNoteByGuidRequest( const QString & notebookGuid, const Note & note) { - QNDEBUG(QStringLiteral("NoteEditorLocalStorageBroker::") - << QStringLiteral("emitFindNotebookForNoteByGuidRequest: ") - << QStringLiteral("notebook guid = ") << notebookGuid - << QStringLiteral(", note local uid = ") << note.localUid()); + QNDEBUG("NoteEditorLocalStorageBroker::" + << "emitFindNotebookForNoteByGuidRequest: " + << "notebook guid = " << notebookGuid + << ", note local uid = " << note.localUid()); Notebook notebook; notebook.setGuid(notebookGuid); @@ -1230,11 +1221,9 @@ auto it = notesPendingNotebookFinding.find(id); if (it != notesPendingNotebookFinding.end()) { - QNDEBUG(QStringLiteral("Adding note with local uid ") << noteLocalUid - << QStringLiteral(" to the list of those pending finding notebook with ") - << (notebook.hasGuid() - ? QStringLiteral("guid ") - : QStringLiteral("local uid ")) + QNDEBUG("Adding note with local uid " << noteLocalUid + << " to the list of those pending finding notebook with " + << (notebook.hasGuid() ? "guid " : "local uid ") << id); NotesHash & notes = it.value(); notes[noteLocalUid] = note; @@ -1245,17 +1234,17 @@ Q_UNUSED(m_findNotebookRequestIds.insert(requestId)) NotesHash & notes = notesPendingNotebookFinding[id]; notes[noteLocalUid] = note; - QNDEBUG(QStringLiteral("Emitting the request to find notebook: request id = ") - << requestId << QStringLiteral(", notebook: ") << notebook); + QNDEBUG("Emitting the request to find notebook: request id = " + << requestId << ", notebook: " << notebook); Q_EMIT findNotebook(notebook, requestId); } void NoteEditorLocalStorageBroker::saveNoteToLocalStorageImpl( const Note & previousNoteVersion, const Note & updatedNoteVersion) { - QNDEBUG(QStringLiteral("NoteEditorLocalStorageBroker::saveNoteToLocalStorageImpl")); - QNTRACE(QStringLiteral("Previous version of the note: ") << previousNoteVersion - << QStringLiteral("\nUpdated version of the note: ") << updatedNoteVersion); + QNDEBUG("NoteEditorLocalStorageBroker::saveNoteToLocalStorageImpl"); + QNTRACE("Previous version of the note: " << previousNoteVersion + << "\nUpdated version of the note: " << updatedNoteVersion); QList<Resource> previousNoteResources = previousNoteVersion.resources(); @@ -1263,7 +1252,8 @@ QList<Resource> updatedResources; QList<Resource> resources = updatedNoteVersion.resources(); - for(auto it = resources.constBegin(), end = resources.constEnd(); it != end; ++it) + for(auto it = resources.constBegin(), + end = resources.constEnd(); it != end; ++it) { const Resource & resource = *it; if (!resource.hasDataBody()) { @@ -1329,21 +1319,19 @@ if (foundResourceInPreviousNoteVersion) { if (!resourceDataSizeOrHashChanged) { - QNTRACE(QStringLiteral("Resource with local uid ") - << resource.localUid() - << QStringLiteral(" has not changed since the previous ") - << QStringLiteral("note version")); + QNTRACE("Resource with local uid " << resource.localUid() + << " has not changed since the previous note version"); continue; } - QNTRACE(QStringLiteral("Resource with local uid ") << resource.localUid() - << QStringLiteral(" has changed since the previous note version")); + QNTRACE("Resource with local uid " << resource.localUid() + << " has changed since the previous note version"); updatedResources << resource; } else { - QNTRACE(QStringLiteral("Resource with local uid ") << resource.localUid() - << QStringLiteral(" did not appear in the previous note version")); + QNTRACE("Resource with local uid " << resource.localUid() + << " did not appear in the previous note version"); newResources << resource; } } @@ -1366,10 +1354,8 @@ } if (!foundResource) { - QNTRACE(QStringLiteral("Resource with local uid ") - << previousNoteResourceLocalUid - << QStringLiteral(" no longer appears within the new ") - << QStringLiteral("note version")); + QNTRACE("Resource with local uid " << previousNoteResourceLocalUid + << " no longer appears within the new note version"); expungedResourcesLocalUids << previousNoteResourceLocalUid; } } @@ -1395,8 +1381,8 @@ info.m_pendingExpungeResourceRequests += static_cast<quint32>(std::max(numExpungeResourceRequests, 0)); m_saveNoteInfoByNoteLocalUids[noteLocalUid] = info; - QNTRACE(QStringLiteral("Added pending save note info for note local uid ") - << noteLocalUid << QStringLiteral(": ") << info); + QNTRACE("Added pending save note info for note local uid " << noteLocalUid + << ": " << info); for(auto it = newResources.constBegin(), end = newResources.constEnd(); it != end; ++it) @@ -1405,9 +1391,8 @@ QUuid requestId = QUuid::createUuid(); m_noteLocalUidsByAddResourceRequestIds[requestId] = noteLocalUid; - QNDEBUG(QStringLiteral("Emitting the request to add resource ") - << QStringLiteral("to the local storage: request id = ") - << requestId << QStringLiteral(", resource: ") << resource); + QNDEBUG("Emitting the request to add resource to the local storage: " + << "request id = " << requestId << ", resource: " << resource); Q_EMIT addResource(resource, requestId); } @@ -1418,9 +1403,8 @@ QUuid requestId = QUuid::createUuid(); m_noteLocalUidsByUpdateResourceRequestIds[requestId] = noteLocalUid; - QNDEBUG(QStringLiteral("Emitting the request to update resource ") - << QStringLiteral("in the local storage: request id = ") - << requestId << QStringLiteral(", resource: ") << resource); + QNDEBUG("Emitting the request to update resource in the local storage: " + << "request id = " << requestId << ", resource: " << resource); Q_EMIT updateResource(resource, requestId); } @@ -1432,10 +1416,9 @@ QUuid requestId = QUuid::createUuid(); m_noteLocalUidsByExpungeResourceRequestIds[requestId] = noteLocalUid; - QNDEBUG(QStringLiteral("Emitting the request to expunge resource ") - << QStringLiteral("from the local storage: request id = ") - << requestId << QStringLiteral(", resource local uid = ") - << *it); + QNDEBUG("Emitting the request to expunge resource from the local " + << "storage: request id = " << requestId + << ", resource local uid = " << *it); Q_EMIT expungeResource(dummyResource, requestId); } @@ -1443,19 +1426,23 @@ (numUpdateResourceRequests > 0) || (numExpungeResourceRequests > 0)) { - QNDEBUG(QStringLiteral("Pending note saving: ") << info); + QNDEBUG("Pending note saving: " << info); return; } emitUpdateNoteRequest(updatedNoteVersion); } -QTextStream & NoteEditorLocalStorageBroker::SaveNoteInfo::print(QTextStream & strm) const +QTextStream & NoteEditorLocalStorageBroker::SaveNoteInfo::print( + QTextStream & strm) const { strm << "SaveNoteInfo: \n" - << "pending add resource requests: " << m_pendingAddResourceRequests << "\n" - << ", pending update resource requests: " << m_pendingUpdateResourceRequests << "\n" - << ", pending expunge resource requests: " << m_pendingExpungeResourceRequests << "\n" + << "pending add resource requests: " + << m_pendingAddResourceRequests << "\n" + << ", pending update resource requests: " + << m_pendingUpdateResourceRequests << "\n" + << ", pending expunge resource requests: " + << m_pendingExpungeResourceRequests << "\n" << ", note: " << m_notePendingSaving << "\n"; return strm; @@ -1467,13 +1454,13 @@ (m_pendingUpdateResourceRequests != 0) || (m_pendingExpungeResourceRequests != 0) ) { - QNDEBUG(QStringLiteral("Still pending for ") + QNDEBUG("Still pending for " << m_pendingAddResourceRequests - << QStringLiteral(" add resource requests and/or ") + << " add resource requests and/or " << m_pendingUpdateResourceRequests - << QStringLiteral(" update resource requests and/or ") + << " update resource requests and/or " << m_pendingExpungeResourceRequests - << QStringLiteral(" expunge resource requests for note with local uid ") + << " expunge resource requests for note with local uid " << m_notePendingSaving.localUid()); return true; } diff -Nru libquentier-0.5.0/src/note_editor/NoteEditorLocalStorageBroker.h libquentier-0.5.0/src/note_editor/NoteEditorLocalStorageBroker.h --- libquentier-0.5.0/src/note_editor/NoteEditorLocalStorageBroker.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/NoteEditorLocalStorageBroker.h 2019-07-11 10:46:53.000000000 +0000 @@ -22,6 +22,7 @@ #include <quentier/local_storage/LocalStorageManagerAsync.h> #include <quentier/types/Note.h> #include <quentier/utility/LRUCache.hpp> + #include <QObject> #include <QHash> #include <QSet> @@ -39,7 +40,8 @@ static NoteEditorLocalStorageBroker & instance(); LocalStorageManagerAsync * localStorageManager(); - void setLocalStorageManager(LocalStorageManagerAsync & localStorageManagerAsync); + void setLocalStorageManager( + LocalStorageManagerAsync & localStorageManagerAsync); Q_SIGNALS: void noteSavedToLocalStorage(QString noteLocalUid); @@ -126,22 +128,24 @@ private: void createConnections(LocalStorageManagerAsync & localStorageManagerAsync); - void disconnectFromLocalStorage(LocalStorageManagerAsync & localStorageManagerAsync); + void disconnectFromLocalStorage( + LocalStorageManagerAsync & localStorageManagerAsync); void emitFindNoteRequest(const QString & noteLocalUid); void emitUpdateNoteRequest(const Note & note); - void emitFindNotebookForNoteByLocalUidRequest(const QString & notebookLocalUid, - const Note & note); - void emitFindNotebookForNoteByGuidRequest(const QString & notebookGuid, - const Note & note); + void emitFindNotebookForNoteByLocalUidRequest( + const QString & notebookLocalUid, const Note & note); + + void emitFindNotebookForNoteByGuidRequest( + const QString & notebookGuid, const Note & note); typedef QHash<QString, Note> NotesHash; typedef QHash<QString, NotesHash> NotesPendingNotebookFindingHash; void emitFindNotebookForNoteRequest( - const Notebook & notebook, - const Note & note, - NotesPendingNotebookFindingHash & notesPendingNotebookFinding); + const Notebook & notebook, + const Note & note, + NotesPendingNotebookFindingHash & notesPendingNotebookFinding); void saveNoteToLocalStorageImpl(const Note & previousNoteVersion, diff -Nru libquentier-0.5.0/src/note_editor/NoteEditorPage.cpp libquentier-0.5.0/src/note_editor/NoteEditorPage.cpp --- libquentier-0.5.0/src/note_editor/NoteEditorPage.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/NoteEditorPage.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -19,8 +19,10 @@ #include "NoteEditorPage.h" #include "JavaScriptInOrderExecutor.h" #include "NoteEditor_p.h" + #include <quentier/utility/QuentierCheckPtr.h> #include <quentier/logging/QuentierLogger.h> + #include <QMessageBox> #include <QApplication> #include <QAction> @@ -47,21 +49,19 @@ NoteEditorPage::~NoteEditorPage() { - QNDEBUG(QStringLiteral("NoteEditorPage::~NoteEditorPage")); + QNDEBUG("NoteEditorPage::~NoteEditorPage"); } bool NoteEditorPage::javaScriptQueueEmpty() const { - QNDEBUG(QStringLiteral("NoteEditorPage::javaScriptQueueEmpty: ") - << (m_pJavaScriptInOrderExecutor->empty() - ? QStringLiteral("true") - : QStringLiteral("false"))); + QNDEBUG("NoteEditorPage::javaScriptQueueEmpty: " + << (m_pJavaScriptInOrderExecutor->empty() ? "true" : "false")); return m_pJavaScriptInOrderExecutor->empty(); } void NoteEditorPage::setInactive() { - QNDEBUG(QStringLiteral("NoteEditorPage::setInactive")); + QNDEBUG("NoteEditorPage::setInactive"); #ifndef QUENTIER_USE_QT_WEB_ENGINE NoteEditorPluginFactory * pPluginFactory = @@ -74,7 +74,7 @@ void NoteEditorPage::setActive() { - QNDEBUG(QStringLiteral("NoteEditorPage::setActive")); + QNDEBUG("NoteEditorPage::setActive"); #ifndef QUENTIER_USE_QT_WEB_ENGINE NoteEditorPluginFactory * pPluginFactory = @@ -87,13 +87,13 @@ void NoteEditorPage::stopJavaScriptAutoExecution() { - QNDEBUG(QStringLiteral("NoteEditorPage::stopJavaScriptAutoExecution")); + QNDEBUG("NoteEditorPage::stopJavaScriptAutoExecution"); m_javaScriptAutoExecution = false; } void NoteEditorPage::startJavaScriptAutoExecution() { - QNDEBUG(QStringLiteral("NoteEditorPage::startJavaScriptAutoExecution")); + QNDEBUG("NoteEditorPage::startJavaScriptAutoExecution"); m_javaScriptAutoExecution = true; if (!m_pJavaScriptInOrderExecutor->inProgress()) { m_pJavaScriptInOrderExecutor->start(); @@ -102,7 +102,7 @@ bool NoteEditorPage::shouldInterruptJavaScript() { - QNDEBUG(QStringLiteral("NoteEditorPage::shouldInterruptJavaScript")); + QNDEBUG("NoteEditorPage::shouldInterruptJavaScript"); QString title = tr("Note editor hanged"); QString question = tr("Note editor seems hanged when loading or editing " @@ -112,14 +112,14 @@ QMessageBox::Yes | QMessageBox::No, QMessageBox::No); if (reply == QMessageBox::Yes) { - QNINFO(QStringLiteral("Note load was cancelled due to too long " - "javascript evaluation")); + QNINFO("Note load was cancelled due to too long " + "javascript evaluation"); Q_EMIT noteLoadCancelled(); return true; } else { - QNINFO(QStringLiteral("Note load seems to take a lot of time " - "but user wished to wait more")); + QNINFO("Note load seems to take a lot of time " + "but user wished to wait more"); return false; } } @@ -140,79 +140,78 @@ void NoteEditorPage::onJavaScriptQueueEmpty() { - QNDEBUG(QStringLiteral("NoteEditorPage::onJavaScriptQueueEmpty")); + QNDEBUG("NoteEditorPage::onJavaScriptQueueEmpty"); Q_EMIT javaScriptLoaded(); } #ifndef QUENTIER_USE_QT_WEB_ENGINE void NoteEditorPage::javaScriptAlert(QWebFrame * pFrame, const QString & message) { - QNDEBUG(QStringLiteral("NoteEditorPage::javaScriptAlert, message: ") << message); + QNDEBUG("NoteEditorPage::javaScriptAlert, message: " << message); QWebPage::javaScriptAlert(pFrame, message); } bool NoteEditorPage::javaScriptConfirm(QWebFrame * pFrame, const QString & message) { - QNDEBUG(QStringLiteral("NoteEditorPage::javaScriptConfirm, message: ") << message); + QNDEBUG("NoteEditorPage::javaScriptConfirm, message: " << message); return QWebPage::javaScriptConfirm(pFrame, message); } -void NoteEditorPage::javaScriptConsoleMessage(const QString & message, - int lineNumber, - const QString & sourceID) -{ - QNDEBUG(QStringLiteral("NoteEditorPage::javaScriptConsoleMessage, message: ") - << message << QStringLiteral(", line number: ") - << lineNumber << QStringLiteral(", sourceID = ") << sourceID); +void NoteEditorPage::javaScriptConsoleMessage( + const QString & message, int lineNumber, const QString & sourceID) +{ + QNDEBUG("NoteEditorPage::javaScriptConsoleMessage, message: " + << message << ", line number: " + << lineNumber << ", sourceID = " << sourceID); QWebPage::javaScriptConsoleMessage(message, lineNumber, sourceID); } #else -void NoteEditorPage::javaScriptAlert(const QUrl & securityOrigin, const QString & msg) +void NoteEditorPage::javaScriptAlert( + const QUrl & securityOrigin, const QString & msg) { - QNDEBUG(QStringLiteral("NoteEditorPage::javaScriptAlert, message: ") << msg); + QNDEBUG("NoteEditorPage::javaScriptAlert, message: " << msg); QWebEnginePage::javaScriptAlert(securityOrigin, msg); } -bool NoteEditorPage::javaScriptConfirm(const QUrl & securityOrigin, const QString & msg) +bool NoteEditorPage::javaScriptConfirm( + const QUrl & securityOrigin, const QString & msg) { - QNDEBUG(QStringLiteral("NoteEditorPage::javaScriptConfirm, message: ") << msg); + QNDEBUG("NoteEditorPage::javaScriptConfirm, message: " << msg); return QWebEnginePage::javaScriptConfirm(securityOrigin, msg); } -void NoteEditorPage::javaScriptConsoleMessage(QWebEnginePage::JavaScriptConsoleMessageLevel level, - const QString & message, int lineNumber, - const QString & sourceID) -{ - QNDEBUG(QStringLiteral("NoteEditorPage::javaScriptConsoleMessage, message: ") - << message << QStringLiteral(", level = ") - << level << QStringLiteral(", line number: ") << lineNumber - << QStringLiteral(", sourceID = ") << sourceID); +void NoteEditorPage::javaScriptConsoleMessage( + QWebEnginePage::JavaScriptConsoleMessageLevel level, + const QString & message, int lineNumber, const QString & sourceID) +{ + QNDEBUG("NoteEditorPage::javaScriptConsoleMessage, message: " + << message << ", level = " << level << ", line number: " + << lineNumber << ", sourceID = " << sourceID); QWebEnginePage::javaScriptConsoleMessage(level, message, lineNumber, sourceID); } #endif // QUENTIER_USE_QT_WEB_ENGINE void NoteEditorPage::triggerAction(WebPage::WebAction action, bool checked) { - QNDEBUG(QStringLiteral("NoteEditorPage::triggerAction: action = ") << action - << QStringLiteral(", checked = ") - << (checked ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("NoteEditorPage::triggerAction: action = " << action + << ", checked = " << (checked ? "true" : "false")); if ( (action == WebPage::Paste) || (action == WebPage::Cut) || (action == WebPage::Back) ) { - QNDEBUG(QStringLiteral("Filtering the action away")); + QNDEBUG("Filtering the action away"); return; } if (action == WebPage::Undo) { - QNDEBUG(QStringLiteral("Filtering undo action")); + QNDEBUG("Filtering undo action"); Q_EMIT undoActionRequested(); return; } if (action == WebPage::Redo) { - QNDEBUG(QStringLiteral("Filtering redo action")); + QNDEBUG("Filtering redo action"); Q_EMIT redoActionRequested(); return; } diff -Nru libquentier-0.5.0/src/note_editor/NoteEditorPage.h libquentier-0.5.0/src/note_editor/NoteEditorPage.h --- libquentier-0.5.0/src/note_editor/NoteEditorPage.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/NoteEditorPage.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,6 +20,7 @@ #define LIB_QUENTIER_NOTE_EDITOR_NOTE_EDITOR_PAGE_H #include "JavaScriptInOrderExecutor.h" + #include <quentier/utility/Macros.h> #ifndef QUENTIER_USE_QT_WEB_ENGINE @@ -101,16 +102,21 @@ const QString & message) Q_DECL_OVERRIDE; virtual bool javaScriptConfirm(QWebFrame * pFrame, const QString & message) Q_DECL_OVERRIDE; - virtual void javaScriptConsoleMessage(const QString & message, int lineNumber, - const QString & sourceID) Q_DECL_OVERRIDE; + + virtual void javaScriptConsoleMessage( + const QString & message, + int lineNumber, + const QString & sourceID) Q_DECL_OVERRIDE; #else virtual void javaScriptAlert(const QUrl & securityOrigin, const QString & msg) Q_DECL_OVERRIDE; virtual bool javaScriptConfirm(const QUrl & securityOrigin, const QString & msg) Q_DECL_OVERRIDE; - virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, - const QString & message, int lineNumber, - const QString & sourceID) Q_DECL_OVERRIDE; + + virtual void javaScriptConsoleMessage( + JavaScriptConsoleMessageLevel level, + const QString & message, int lineNumber, + const QString & sourceID) Q_DECL_OVERRIDE; #endif private: diff -Nru libquentier-0.5.0/src/note_editor/NoteEditor_p.cpp libquentier-0.5.0/src/note_editor/NoteEditor_p.cpp --- libquentier-0.5.0/src/note_editor/NoteEditor_p.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/NoteEditor_p.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -22,6 +22,7 @@ #include "GenericResourceImageManager.h" #include "NoteEditorSettingsNames.h" #include "ResourceDataInTemporaryFileStorageManager.h" + #include "delegates/AddResourceDelegate.h" #include "delegates/RemoveResourceDelegate.h" #include "delegates/RenameResourceDelegate.h" @@ -32,6 +33,7 @@ #include "delegates/AddHyperlinkToSelectedTextDelegate.h" #include "delegates/EditHyperlinkDelegate.h" #include "delegates/RemoveHyperlinkDelegate.h" + #include "javascript_glue/ActionsWatcher.h" #include "javascript_glue/ResourceInfoJavaScriptHandler.h" #include "javascript_glue/ResizableImageJavaScriptHandler.h" @@ -42,6 +44,7 @@ #include "javascript_glue/ToDoCheckboxAutomaticInsertionHandler.h" #include "javascript_glue/TableResizeJavaScriptHandler.h" #include "javascript_glue/SpellCheckerDynamicHelper.h" + #include "undo_stack/NoteEditorContentEditUndoCommand.h" #include "undo_stack/EncryptUndoCommand.h" #include "undo_stack/DecryptUndoCommand.h" @@ -64,6 +67,7 @@ #include "undo_stack/SpellCheckIgnoreWordUndoCommand.h" #include "undo_stack/SpellCheckAddToUserWordListUndoCommand.h" #include "undo_stack/TableActionUndoCommand.h" + #include <quentier/local_storage/LocalStorageManager.h> #include <quentier/utility/ApplicationSettings.h> #include <quentier/utility/EventLoopWithExitStatus.h> @@ -89,8 +93,10 @@ #include "javascript_glue/GenericResourceImageJavaScriptHandler.h" #include "javascript_glue/HyperlinkClickJavaScriptHandler.h" #include "javascript_glue/WebSocketWaiter.h" + #include "WebSocketClientWrapper.h" #include "WebSocketTransport.h" + #include <QPainter> #include <QIcon> #include <QFontMetrics> @@ -116,6 +122,7 @@ #include <quentier/utility/FileIOProcessorAsync.h> #include <quentier/utility/QuentierCheckPtr.h> #include <quentier/utility/ShortcutManager.h> + #include <QFile> #include <QFileInfo> #include <QByteArray> @@ -137,40 +144,43 @@ #include <QTransform> #include <QTimer> #include <QCryptographicHash> + #include <cmath> #include <algorithm> -#define NOTE_EDITOR_PAGE_HEADER \ - QStringLiteral("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" "\ - "\"http://www.w3.org/TR/html4/strict.dtd\"><html><head>" \ - "<meta http-equiv=\"Content-Type\" content=\"text/html\" "\ - "charset=\"UTF-8\" />") - -#define NOTE_EDITOR_PAGE_CSS \ - QStringLiteral("<link rel=\"stylesheet\" type=\"text/css\" "\ - "href=\"qrc:/css/jquery-ui.min.css\">" \ - "<link rel=\"stylesheet\" type=\"text/css\" "\ - "href=\"qrc:/css/background.css\">" \ - "<link rel=\"stylesheet\" type=\"text/css\" "\ - "href=\"qrc:/css/en-crypt.css\">" \ - "<link rel=\"stylesheet\" type=\"text/css\" "\ - "href=\"qrc:/css/hover.css\">" \ - "<link rel=\"stylesheet\" type=\"text/css\" "\ - "href=\"qrc:/css/en-decrypted.css\">" \ - "<link rel=\"stylesheet\" type=\"text/css\" "\ - "href=\"qrc:/css/en-media-generic.css\">" \ - "<link rel=\"stylesheet\" type=\"text/css\" "\ - "href=\"qrc:/css/en-media-image.css\">" \ - "<link rel=\"stylesheet\" type=\"text/css\" "\ - "href=\"qrc:/css/image-area-hilitor.css\">" \ - "<link rel=\"stylesheet\" type=\"text/css\" "\ - "href=\"qrc:/css/en-todo.css\">" \ - "<link rel=\"stylesheet\" type=\"text/css\" "\ - "href=\"qrc:/css/link.css\">" \ - "<link rel=\"stylesheet\" type=\"text/css\" "\ - "href=\"qrc:/css/misspell.css\">" \ - "<link rel=\"stylesheet\" type=\"text/css\" "\ - "href=\"qrc:/css/edit_cursor_trick.css\">") +#define NOTE_EDITOR_PAGE_HEADER \ + QStringLiteral("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" " \ + "\"http://www.w3.org/TR/html4/strict.dtd\"><html><head>" \ + "<meta http-equiv=\"Content-Type\" content=\"text/html\" " \ + "charset=\"UTF-8\" />") \ +// NOTE_EDITOR_PAGE_HEADER + +#define NOTE_EDITOR_PAGE_CSS \ + QStringLiteral("<link rel=\"stylesheet\" type=\"text/css\" " \ + "href=\"qrc:/css/jquery-ui.min.css\">" \ + "<link rel=\"stylesheet\" type=\"text/css\" " \ + "href=\"qrc:/css/background.css\">" \ + "<link rel=\"stylesheet\" type=\"text/css\" " \ + "href=\"qrc:/css/en-crypt.css\">" \ + "<link rel=\"stylesheet\" type=\"text/css\" " \ + "href=\"qrc:/css/hover.css\">" \ + "<link rel=\"stylesheet\" type=\"text/css\" " \ + "href=\"qrc:/css/en-decrypted.css\">" \ + "<link rel=\"stylesheet\" type=\"text/css\" " \ + "href=\"qrc:/css/en-media-generic.css\">" \ + "<link rel=\"stylesheet\" type=\"text/css\" " \ + "href=\"qrc:/css/en-media-image.css\">" \ + "<link rel=\"stylesheet\" type=\"text/css\" " \ + "href=\"qrc:/css/image-area-hilitor.css\">" \ + "<link rel=\"stylesheet\" type=\"text/css\" " \ + "href=\"qrc:/css/en-todo.css\">" \ + "<link rel=\"stylesheet\" type=\"text/css\" " \ + "href=\"qrc:/css/link.css\">" \ + "<link rel=\"stylesheet\" type=\"text/css\" " \ + "href=\"qrc:/css/misspell.css\">" \ + "<link rel=\"stylesheet\" type=\"text/css\" " \ + "href=\"qrc:/css/edit_cursor_trick.css\">") \ +// NOTE_EDITOR_PAGE_CSS namespace quentier { @@ -362,7 +372,7 @@ void NoteEditorPrivate::setInitialPageHtml(const QString & html) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setInitialPageHtml: ") << html); + QNDEBUG("NoteEditorPrivate::setInitialPageHtml: " << html); m_initialPageHtml = html; @@ -373,7 +383,7 @@ void NoteEditorPrivate::setNoteNotFoundPageHtml(const QString & html) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setNoteNotFoundPageHtml: ") << html); + QNDEBUG("NoteEditorPrivate::setNoteNotFoundPageHtml: " << html); m_noteNotFoundPageHtml = html; @@ -384,7 +394,7 @@ void NoteEditorPrivate::setNoteDeletedPageHtml(const QString & html) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setNoteDeletedPageHtml: ") << html); + QNDEBUG("NoteEditorPrivate::setNoteDeletedPageHtml: " << html); m_noteDeletedPageHtml = html; @@ -395,7 +405,7 @@ void NoteEditorPrivate::setNoteLoadingPageHtml(const QString & html) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setNoteLoadingPageHtml: ") << html); + QNDEBUG("NoteEditorPrivate::setNoteLoadingPageHtml: " << html); m_noteLoadingPageHtml = html; } @@ -412,11 +422,11 @@ void NoteEditorPrivate::onNoteLoadFinished(bool ok) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onNoteLoadFinished: ok = ") - << (ok ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("NoteEditorPrivate::onNoteLoadFinished: ok = " + << (ok ? "true" : "false")); if (!ok) { - QNDEBUG(QStringLiteral("Note page was not loaded successfully")); + QNDEBUG("Note page was not loaded successfully"); // NOTE: most of the times this callback fires with ok = false shortly // before it fires with ok = true, // so settling with just a debug log entry here @@ -426,13 +436,13 @@ m_pendingNotePageLoad = false; if (Q_UNLIKELY(!m_pNote)) { - QNDEBUG(QStringLiteral("No note is set to the editor")); + QNDEBUG("No note is set to the editor"); setPageEditable(false); return; } if (Q_UNLIKELY(!m_pNotebook)) { - QNDEBUG(QStringLiteral("No notebook is set to the editor")); + QNDEBUG("No notebook is set to the editor"); setPageEditable(false); return; } @@ -444,13 +454,13 @@ bool editable = true; if (m_pNote->hasActive() && !m_pNote->active()) { - QNDEBUG(QStringLiteral("Current note is not active, setting it to " - "read-only state")); + QNDEBUG("Current note is not active, setting it to " + "read-only state"); editable = false; } else if (m_pNote->isInkNote()) { - QNDEBUG(QStringLiteral("Current note is an ink note, setting it to " - "read-only state")); + QNDEBUG("Current note is an ink note, setting it to " + "read-only state"); editable = false; } else if (m_pNotebook->hasRestrictions()) @@ -459,8 +469,8 @@ m_pNotebook->restrictions(); if (restrictions.noUpdateNotes.isSet() && restrictions.noUpdateNotes.ref()) { - QNDEBUG(QStringLiteral("Notebook restrictions forbid the note modification, " - "setting note's content to read-only state")); + QNDEBUG("Notebook restrictions forbid the note modification, " + "setting note's content to read-only state"); editable = false; } } @@ -494,9 +504,12 @@ frame->addToJavaScriptWindowObject(QStringLiteral("toDoCheckboxClickHandler"), m_pToDoCheckboxClickHandler, OwnershipNamespace::QtOwnership); - frame->addToJavaScriptWindowObject(QStringLiteral("toDoCheckboxAutomaticInsertionHandler"), - m_pToDoCheckboxAutomaticInsertionHandler, - OwnershipNamespace::QtOwnership); + + frame->addToJavaScriptWindowObject( + QStringLiteral("toDoCheckboxAutomaticInsertionHandler"), + m_pToDoCheckboxAutomaticInsertionHandler, + OwnershipNamespace::QtOwnership); + frame->addToJavaScriptWindowObject(QStringLiteral("tableResizeHandler"), m_pTableResizeJavaScriptHandler, OwnershipNamespace::QtOwnership); @@ -519,7 +532,7 @@ if (!m_webSocketReady) { - QNDEBUG(QStringLiteral("Waiting for web socket connection")); + QNDEBUG("Waiting for web socket connection"); page->executeJavaScript( QStringLiteral("(function(){window.websocketserverport = ") + @@ -568,7 +581,7 @@ page->executeJavaScript(m_replaceStyleJs); if (m_isPageEditable) { - QNTRACE(QStringLiteral("Note page is editable")); + QNTRACE("Note page is editable"); page->executeJavaScript(m_setupEnToDoTagsJs); page->executeJavaScript(m_flipEnToDoCheckboxStateJs); page->executeJavaScript(m_toDoCheckboxAutomaticInsertionJs); @@ -605,28 +618,28 @@ applySpellCheck(); } - QNTRACE(QStringLiteral("Sent commands to execute all the page's necessary scripts")); + QNTRACE("Sent commands to execute all the page's necessary scripts"); page->startJavaScriptAutoExecution(); } void NoteEditorPrivate::onContentChanged() { - QNTRACE(QStringLiteral("NoteEditorPrivate::onContentChanged")); + QNTRACE("NoteEditorPrivate::onContentChanged"); if (m_pendingNotePageLoad || m_pendingIndexHtmlWritingToFile || m_pendingJavaScriptExecution) { - QNTRACE(QStringLiteral("Skipping the content change as the note page " - "has not fully loaded yet")); + QNTRACE("Skipping the content change as the note page " + "has not fully loaded yet"); return; } if (m_skipPushingUndoCommandOnNextContentChange) { m_skipPushingUndoCommandOnNextContentChange = false; - QNTRACE(QStringLiteral("Skipping the push of edit undo command on " - "this content change")); + QNTRACE("Skipping the push of edit undo command on " + "this content change"); } else { @@ -644,8 +657,8 @@ startTimer(SEC_TO_MSEC(m_secondsToWaitBeforeConversionStart)); m_watchingForContentChange = true; m_contentChangedSinceWatchingStart = false; - QNTRACE(QStringLiteral("Started timer to postpone note editor page's content ") - << QStringLiteral("to ENML conversion: timer id = ") + QNTRACE("Started timer to postpone note editor page's content " + << "to ENML conversion: timer id = " << m_pageToNoteContentPostponeTimerId); } @@ -654,16 +667,16 @@ QByteArray resourceData, QByteArray resourceDataHash) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onResourceFileChanged: ") - << QStringLiteral("resource local uid = ") << resourceLocalUid - << QStringLiteral(", file storage path: ") << fileStoragePath - << QStringLiteral(", new resource data size = ") + QNDEBUG("NoteEditorPrivate::onResourceFileChanged: " + << "resource local uid = " << resourceLocalUid + << ", file storage path: " << fileStoragePath + << ", new resource data size = " << humanReadableSize(static_cast<quint64>(std::max(resourceData.size(), 0))) - << QStringLiteral(", resource data hash = ") << resourceDataHash.toHex()); + << ", resource data hash = " << resourceDataHash.toHex()); if (Q_UNLIKELY(m_pNote.isNull())) { - QNDEBUG(QStringLiteral("Can't process resource file change: no note is " - "set to the editor")); + QNDEBUG("Can't process resource file change: no note is " + "set to the editor"); return; } @@ -680,8 +693,8 @@ } if (Q_UNLIKELY(targetResourceIndex < 0)) { - QNDEBUG(QStringLiteral("Can't process resource file change: can't find " - "the resource by local uid within note's resources")); + QNDEBUG("Can't process resource file change: can't find " + "the resource by local uid within note's resources"); return; } @@ -689,17 +702,15 @@ QByteArray previousResourceHash = (resource.hasDataHash() ? resource.dataHash() : QByteArray()); - QNTRACE(QStringLiteral("Previous resource hash = ") - << previousResourceHash.toHex()); + QNTRACE("Previous resource hash = " << previousResourceHash.toHex()); if (!previousResourceHash.isEmpty() && (previousResourceHash == resourceDataHash) && resource.hasDataSize() && (resource.dataSize() == resourceData.size())) { - QNDEBUG(QStringLiteral("Neither resource hash nor binary data size has " - "changed -> the resource data has not actually " - "changed, nothing to do")); + QNDEBUG("Neither resource hash nor binary data size has changed -> " + "the resource data has not actually changed, nothing to do"); return; } @@ -720,7 +731,7 @@ QString resourceDisplaySize = humanReadableSize(static_cast<quint64>(resourceData.size())); - QNTRACE(QStringLiteral("Updating the resource within the note: ") << resource); + QNTRACE("Updating the resource within the note: " << resource); Q_UNUSED(m_pNote->updateResource(resource)) setModified(); @@ -802,16 +813,16 @@ bool success, QByteArray resourceActualHash, QString filePath, ErrorString errorDescription, QUuid requestId) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onGenericResourceImageSaved: success = ") - << (success ? QStringLiteral("true") : QStringLiteral("false")) - << QStringLiteral(", resource actual hash = ") << resourceActualHash.toHex() - << QStringLiteral(", file path = ") << filePath - << QStringLiteral(", error description = ") << errorDescription - << QStringLiteral(", requestId = ") << requestId); + QNDEBUG("NoteEditorPrivate::onGenericResourceImageSaved: success = " + << (success ? "true" : "false") + << ", resource actual hash = " << resourceActualHash.toHex() + << ", file path = " << filePath + << ", error description = " << errorDescription + << ", requestId = " << requestId); auto it = m_saveGenericResourceImageToFileRequestIds.find(requestId); if (it == m_saveGenericResourceImageToFileRequestIds.end()) { - QNDEBUG(QStringLiteral("Haven't found request id in the cache")); + QNDEBUG("Haven't found request id in the cache"); return; } @@ -827,8 +838,8 @@ } m_genericResourceImageFilePathsByResourceHash[resourceActualHash] = filePath; - QNDEBUG(QStringLiteral("Cached generic resource image file path ") << filePath - << QStringLiteral(" for resource hash ") << resourceActualHash.toHex()); + QNDEBUG("Cached generic resource image file path " << filePath + << " for resource hash " << resourceActualHash.toHex()); if (m_saveGenericResourceImageToFileRequestIds.empty()) { provideSrcForGenericResourceImages(); @@ -843,7 +854,7 @@ void NoteEditorPrivate::onWebSocketReady() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onWebSocketReady")); + QNDEBUG("NoteEditorPrivate::onWebSocketReady"); m_webSocketReady = true; onNoteLoadFinished(true); @@ -860,8 +871,7 @@ void NoteEditorPrivate::onToDoCheckboxClicked(quint64 enToDoCheckboxId) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onToDoCheckboxClicked: ") - << enToDoCheckboxId); + QNDEBUG("NoteEditorPrivate::onToDoCheckboxClicked: " << enToDoCheckboxId); setModified(); @@ -876,15 +886,14 @@ void NoteEditorPrivate::onToDoCheckboxClickHandlerError(ErrorString error) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onToDoCheckboxClickHandlerError: ") - << error); + QNDEBUG("NoteEditorPrivate::onToDoCheckboxClickHandlerError: " << error); Q_EMIT notifyError(error); } void NoteEditorPrivate::onToDoCheckboxInserted( const QVariant & data, const QVector<QPair<QString,QString> > & extraData) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onToDoCheckboxInserted: ") << data); + QNDEBUG("NoteEditorPrivate::onToDoCheckboxInserted: " << data); Q_UNUSED(extraData) @@ -939,7 +948,7 @@ void NoteEditorPrivate::onToDoCheckboxAutomaticInsertion() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onToDoCheckboxAutomaticInsertion")); + QNDEBUG("NoteEditorPrivate::onToDoCheckboxAutomaticInsertion"); ToDoCheckboxAutomaticInsertionUndoCommand * pCommand = new ToDoCheckboxAutomaticInsertionUndoCommand( @@ -963,8 +972,8 @@ void NoteEditorPrivate::onToDoCheckboxAutomaticInsertionUndoRedoFinished( const QVariant & data, const QVector<QPair<QString,QString> > & extraData) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onToDoCheckboxAutomaticInsertion") - << QStringLiteral("UndoRedoFinished: ") << data); + QNDEBUG("NoteEditorPrivate::onToDoCheckboxAutomaticInsertion" + << "UndoRedoFinished: " << data); Q_UNUSED(extraData) @@ -1005,19 +1014,19 @@ void NoteEditorPrivate::onJavaScriptLoaded() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onJavaScriptLoaded")); + QNDEBUG("NoteEditorPrivate::onJavaScriptLoaded"); NoteEditorPage * pSenderPage = qobject_cast<NoteEditorPage*>(sender()); if (Q_UNLIKELY(!pSenderPage)) { - QNWARNING(QStringLiteral("Can't get the pointer to NoteEditor page from " - "which the event of JavaScrupt loading came in")); + QNWARNING("Can't get the pointer to NoteEditor page from " + "which the event of JavaScrupt loading came in"); return; } GET_PAGE() if (page != pSenderPage) { - QNDEBUG(QStringLiteral("Skipping JavaScript loaded event from page " - "which is not the currently set one")); + QNDEBUG("Skipping JavaScript loaded event from page " + "which is not the currently set one"); return; } @@ -1026,14 +1035,14 @@ m_pendingJavaScriptExecution = false; if (Q_UNLIKELY(!m_pNote)) { - QNDEBUG(QStringLiteral("No note is set to the editor, won't retrieve " - "the editor content's html")); + QNDEBUG("No note is set to the editor, won't retrieve " + "the editor content's html"); return; } if (Q_UNLIKELY(!m_pNotebook)) { - QNDEBUG(QStringLiteral("No notebook is set to the editor, won't " - "retrieve the editor content's html")); + QNDEBUG("No notebook is set to the editor, won't " + "retrieve the editor content's html"); return; } @@ -1045,7 +1054,7 @@ this, &NoteEditorPrivate::onPageHtmlReceived)); #endif - QNTRACE(QStringLiteral("Emitting noteLoaded signal")); + QNTRACE("Emitting noteLoaded signal"); Q_EMIT noteLoaded(); } @@ -1057,14 +1066,12 @@ void NoteEditorPrivate::onOpenResourceRequest(const QByteArray & resourceHash) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onOpenResourceRequest: ") - << resourceHash.toHex()); + QNDEBUG("NoteEditorPrivate::onOpenResourceRequest: " << resourceHash.toHex()); if (Q_UNLIKELY(m_pNote.isNull())) { ErrorString error(QT_TR_NOOP("Can't open the resource: no note is set " "to the editor")); - QNWARNING(error << QStringLiteral(", resource hash = ") - << resourceHash.toHex()); + QNWARNING(error << ", resource hash = " << resourceHash.toHex()); Q_EMIT notifyError(error); return; } @@ -1076,7 +1083,7 @@ if (Q_UNLIKELY(resourceIndex < 0)) { ErrorString error(QT_TR_NOOP("The resource to be opened was not found " "within the note")); - QNWARNING(error << QStringLiteral(", resource hash = ") << resourceHash); + QNWARNING(error << ", resource hash = " << resourceHash); Q_EMIT notifyError(error); return; } @@ -1106,7 +1113,7 @@ std::pair<QString,QProgressDialog*>(resourceLocalUid, pProgressDialog)); } - QNTRACE(QStringLiteral("Emitting the request to open resource with local uid ") + QNTRACE("Emitting the request to open resource with local uid " << resourceLocalUid); Q_EMIT openResourceFile(resourceLocalUid); } @@ -1118,7 +1125,7 @@ if (Q_UNLIKELY(m_pNote.isNull())) { ErrorString error(QT_TR_NOOP("Can't save the resource to file: no note " "is set to the editor")); - QNINFO(error << QStringLiteral(", resource hash = ") << resourceHash.toHex()); + QNINFO(error << ", resource hash = " << resourceHash.toHex()); Q_EMIT notifyError(error); return; } @@ -1128,7 +1135,7 @@ if (Q_UNLIKELY(resourceIndex < 0)) { ErrorString error(QT_TR_NOOP("The resource to be saved was not found " "within the note")); - QNINFO(error << QStringLiteral(", resource hash = ") << resourceHash.toHex()); + QNINFO(error << ", resource hash = " << resourceHash.toHex()); return; } @@ -1136,11 +1143,11 @@ if (!resource.hasDataBody() && !resource.hasAlternateDataBody()) { - QNTRACE(QStringLiteral("The resource meant to be saved to a local file " - "has neither data body nor alternate data body, " - "need to request these from the local storage")); + QNTRACE("The resource meant to be saved to a local file " + "has neither data body nor alternate data body, " + "need to request these from the local storage"); Q_UNUSED(m_resourceLocalUidsPendingFindDataInLocalStorageForSavingToFile.insert( - resource.localUid())) + resource.localUid())) Q_EMIT findResourceData(resource.localUid()); return; } @@ -1150,10 +1157,10 @@ void NoteEditorPrivate::contextMenuEvent(QContextMenuEvent * pEvent) { - QNTRACE(QStringLiteral("NoteEditorPrivate::contextMenuEvent")); + QNTRACE("NoteEditorPrivate::contextMenuEvent"); if (Q_UNLIKELY(!pEvent)) { - QNINFO(QStringLiteral("detected null pointer to context menu event")); + QNINFO("detected null pointer to context menu event"); return; } @@ -1162,21 +1169,21 @@ m_pendingJavaScriptExecution || m_pendingNoteImageResourceTemporaryFiles) { - QNINFO(QStringLiteral("Ignoring context menu event for now, " - "until the note is fully loaded...")); + QNINFO("Ignoring context menu event for now, " + "until the note is fully loaded..."); return; } m_lastContextMenuEventGlobalPos = pEvent->globalPos(); m_lastContextMenuEventPagePos = pEvent->pos(); - QNTRACE(QStringLiteral("Context menu event's global pos: x = ") + QNTRACE("Context menu event's global pos: x = " << m_lastContextMenuEventGlobalPos.x() - << QStringLiteral(", y = ") << m_lastContextMenuEventGlobalPos.y() - << QStringLiteral("; pos relative to child widget: x = ") - << m_lastContextMenuEventPagePos.x() << QStringLiteral(", y = ") + << ", y = " << m_lastContextMenuEventGlobalPos.y() + << "; pos relative to child widget: x = " + << m_lastContextMenuEventPagePos.x() << ", y = " << m_lastContextMenuEventPagePos.y() - << QStringLiteral("; context menu sequence number = ") + << "; context menu sequence number = " << m_contextMenuSequenceNumber); determineContextMenuEventTarget(); @@ -1186,18 +1193,18 @@ QString contentType, QString selectedHtml, bool insideDecryptedTextFragment, QStringList extraData, quint64 sequenceNumber) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onContextMenuEventReply: ") - << QStringLiteral("content type = ") << contentType - << QStringLiteral(", selected html = ") << selectedHtml - << QStringLiteral(", inside decrypted text fragment = ") + QNDEBUG("NoteEditorPrivate::onContextMenuEventReply: " + << "content type = " << contentType + << ", selected html = " << selectedHtml + << ", inside decrypted text fragment = " << (insideDecryptedTextFragment - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", extraData: [") << extraData.join(QStringLiteral(", ")) - << QStringLiteral("], sequence number = ") << sequenceNumber); + ? "true" + : "false") + << ", extraData: [" << extraData.join(QStringLiteral(", ")) + << "], sequence number = " << sequenceNumber); if (!checkContextMenuSequenceNumber(sequenceNumber)) { - QNTRACE(QStringLiteral("Sequence number is not valid, not doing anything")); + QNTRACE("Sequence number is not valid, not doing anything"); return; } @@ -1214,18 +1221,21 @@ else if ((contentType == QStringLiteral("ImageResource")) || (contentType == QStringLiteral("NonImageResource"))) { - if (Q_UNLIKELY(extraData.empty())) { - ErrorString error(QT_TR_NOOP("Can't display the resource context menu: " - "the extra data from JavaScript is empty")); + if (Q_UNLIKELY(extraData.empty())) + { + ErrorString error( + QT_TR_NOOP("Can't display the resource context menu: " + "the extra data from JavaScript is empty")); QNWARNING(error); Q_EMIT notifyError(error); return; } - if (Q_UNLIKELY(extraData.size() != 1)) { - ErrorString error(QT_TR_NOOP("Can't display the resource context menu: " - "the extra data from JavaScript has " - "wrong size")); + if (Q_UNLIKELY(extraData.size() != 1)) + { + ErrorString error( + QT_TR_NOOP("Can't display the resource context menu: " + "the extra data from JavaScript has wrong size")); error.details() = QString::number(extraData.size()); QNWARNING(error); Q_EMIT notifyError(error); @@ -1249,9 +1259,10 @@ decryptedText, cipher, keyLength, hint, id, error); - if (Q_UNLIKELY(!res)) { - ErrorString errorDescription(QT_TR_NOOP("Can't display the encrypted " - "text's context menu")); + if (Q_UNLIKELY(!res)) + { + ErrorString errorDescription( + QT_TR_NOOP("Can't display the encrypted text's context menu")); errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); @@ -1264,15 +1275,14 @@ } else { - QNWARNING(QStringLiteral("Unknown content type on context menu event reply: ") - << contentType << QStringLiteral(", sequence number ") - << sequenceNumber); + QNWARNING("Unknown content type on context menu event reply: " + << contentType << ", sequence number " << sequenceNumber); } } void NoteEditorPrivate::onTextCursorPositionChange() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onTextCursorPositionChange")); + QNDEBUG("NoteEditorPrivate::onTextCursorPositionChange"); if (!m_pendingIndexHtmlWritingToFile && !m_pendingNotePageLoad && @@ -1284,8 +1294,8 @@ void NoteEditorPrivate::onTextCursorBoldStateChanged(bool state) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onTextCursorBoldStateChanged: ") - << (state ? QStringLiteral("bold") : QStringLiteral("not bold"))); + QNDEBUG("NoteEditorPrivate::onTextCursorBoldStateChanged: " + << (state ? "bold" : "not bold")); m_currentTextFormattingState.m_bold = state; Q_EMIT textBoldState(state); @@ -1293,8 +1303,8 @@ void NoteEditorPrivate::onTextCursorItalicStateChanged(bool state) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onTextCursorItalicStateChanged: ") - << (state ? QStringLiteral("italic") : QStringLiteral("not italic"))); + QNDEBUG("NoteEditorPrivate::onTextCursorItalicStateChanged: " + << (state ? "italic" : "not italic")); m_currentTextFormattingState.m_italic = state; Q_EMIT textItalicState(state); @@ -1302,10 +1312,8 @@ void NoteEditorPrivate::onTextCursorUnderlineStateChanged(bool state) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onTextCursorUnderlineStateChanged: ") - << (state - ? QStringLiteral("underline") - : QStringLiteral("not underline"))); + QNDEBUG("NoteEditorPrivate::onTextCursorUnderlineStateChanged: " + << (state ? "underline" : "not underline")); m_currentTextFormattingState.m_underline = state; Q_EMIT textUnderlineState(state); @@ -1313,10 +1321,8 @@ void NoteEditorPrivate::onTextCursorStrikethgouthStateChanged(bool state) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onTextCursorStrikethgouthStateChanged: ") - << (state - ? QStringLiteral("strikethrough") - : QStringLiteral("not strikethrough"))); + QNDEBUG("NoteEditorPrivate::onTextCursorStrikethgouthStateChanged: " + << (state ? "strikethrough" : "not strikethrough")); m_currentTextFormattingState.m_strikethrough = state; Q_EMIT textStrikethroughState(state); @@ -1324,8 +1330,8 @@ void NoteEditorPrivate::onTextCursorAlignLeftStateChanged(bool state) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onTextCursorAlignLeftStateChanged: ") - << (state ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("NoteEditorPrivate::onTextCursorAlignLeftStateChanged: " + << (state ? "true" : "false")); if (state) { m_currentTextFormattingState.m_alignment = Alignment::Left; @@ -1336,8 +1342,8 @@ void NoteEditorPrivate::onTextCursorAlignCenterStateChanged(bool state) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onTextCursorAlignCenterStateChanged: ") - << (state ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("NoteEditorPrivate::onTextCursorAlignCenterStateChanged: " + << (state ? "true" : "false")); if (state) { m_currentTextFormattingState.m_alignment = Alignment::Center; @@ -1348,8 +1354,8 @@ void NoteEditorPrivate::onTextCursorAlignRightStateChanged(bool state) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onTextCursorAlignRightStateChanged: ") - << (state ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("NoteEditorPrivate::onTextCursorAlignRightStateChanged: " + << (state ? "true" : "false")); if (state) { m_currentTextFormattingState.m_alignment = Alignment::Right; @@ -1360,8 +1366,8 @@ void NoteEditorPrivate::onTextCursorAlignFullStateChanged(bool state) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onTextCursorAlignFullStateChanged: ") - << (state ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("NoteEditorPrivate::onTextCursorAlignFullStateChanged: " + << (state ? "true" : "false")); if (state) { m_currentTextFormattingState.m_alignment = Alignment::Full; @@ -1372,8 +1378,8 @@ void NoteEditorPrivate::onTextCursorInsideOrderedListStateChanged(bool state) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onTextCursorInsideOrderedListStateChanged: ") - << (state ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("NoteEditorPrivate::onTextCursorInsideOrderedListStateChanged: " + << (state ? "true" : "false")); m_currentTextFormattingState.m_insideOrderedList = state; Q_EMIT textInsideOrderedListState(state); @@ -1381,8 +1387,8 @@ void NoteEditorPrivate::onTextCursorInsideUnorderedListStateChanged(bool state) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onTextCursorInsideUnorderedListStateChanged: ") - << (state ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("NoteEditorPrivate::onTextCursorInsideUnorderedListStateChanged: " + << (state ? "true" : "false")); m_currentTextFormattingState.m_insideUnorderedList = state; Q_EMIT textInsideUnorderedListState(state); @@ -1390,19 +1396,19 @@ void NoteEditorPrivate::onTextCursorInsideTableStateChanged(bool state) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onTextCursorInsideTableStateChanged: ") - << (state ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("NoteEditorPrivate::onTextCursorInsideTableStateChanged: " + << (state ? "true" : "false")); m_currentTextFormattingState.m_insideTable = state; Q_EMIT textInsideTableState(state); } -void NoteEditorPrivate::onTextCursorOnImageResourceStateChanged(bool state, - QByteArray resourceHash) +void NoteEditorPrivate::onTextCursorOnImageResourceStateChanged( + bool state, QByteArray resourceHash) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onTextCursorOnImageResourceStateChanged: ") - << (state ? QStringLiteral("yes") : QStringLiteral("no")) - << QStringLiteral(", resource hash = ") << resourceHash.toHex()); + QNDEBUG("NoteEditorPrivate::onTextCursorOnImageResourceStateChanged: " + << (state ? "yes" : "no") << ", resource hash = " + << resourceHash.toHex()); m_currentTextFormattingState.m_onImageResource = state; if (state) { @@ -1411,12 +1417,12 @@ } } -void NoteEditorPrivate::onTextCursorOnNonImageResourceStateChanged(bool state, - QByteArray resourceHash) +void NoteEditorPrivate::onTextCursorOnNonImageResourceStateChanged( + bool state, QByteArray resourceHash) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onTextCursorOnNonImageResourceStateChanged: ") - << (state ? QStringLiteral("yes") : QStringLiteral("no")) - << QStringLiteral(", resource hash = ") << resourceHash.toHex()); + QNDEBUG("NoteEditorPrivate::onTextCursorOnNonImageResourceStateChanged: " + << (state ? "yes" : "no") + << ", resource hash = " << resourceHash.toHex()); m_currentTextFormattingState.m_onNonImageResource = state; if (state) { @@ -1425,16 +1431,12 @@ } } -void NoteEditorPrivate::onTextCursorOnEnCryptTagStateChanged(bool state, - QString encryptedText, - QString cipher, - QString length) -{ - QNDEBUG(QStringLiteral("NoteEditorPrivate::onTextCursorOnEnCryptTagStateChanged: ") - << (state ? QStringLiteral("yes") : QStringLiteral("no")) - << QStringLiteral(", encrypted text = ") << encryptedText - << QStringLiteral(", cipher = ") << cipher - << QStringLiteral(", length = ") << length); +void NoteEditorPrivate::onTextCursorOnEnCryptTagStateChanged( + bool state, QString encryptedText, QString cipher, QString length) +{ + QNDEBUG("NoteEditorPrivate::onTextCursorOnEnCryptTagStateChanged: " + << (state ? "yes" : "no") << ", encrypted text = " << encryptedText + << ", cipher = " << cipher << ", length = " << length); m_currentTextFormattingState.m_onEnCryptTag = state; if (state) { @@ -1446,27 +1448,26 @@ void NoteEditorPrivate::onTextCursorFontNameChanged(QString fontName) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onTextCursorFontNameChanged: ") - << QStringLiteral("font name = ") << fontName); + QNDEBUG("NoteEditorPrivate::onTextCursorFontNameChanged: " + << "font name = " << fontName); Q_EMIT textFontFamilyChanged(fontName); } void NoteEditorPrivate::onTextCursorFontSizeChanged(int fontSize) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onTextCursorFontSizeChanged: ") - << QStringLiteral("font size = ") << fontSize); + QNDEBUG("NoteEditorPrivate::onTextCursorFontSizeChanged: " + << "font size = " << fontSize); Q_EMIT textFontSizeChanged(fontSize); } -void NoteEditorPrivate::onWriteFileRequestProcessed(bool success, - ErrorString errorDescription, - QUuid requestId) +void NoteEditorPrivate::onWriteFileRequestProcessed( + bool success, ErrorString errorDescription, QUuid requestId) { if (requestId == m_writeNoteHtmlToFileRequestId) { - QNDEBUG(QStringLiteral("Write note html to file completed: success = ") - << (success ? QStringLiteral("true") : QStringLiteral("false")) - << QStringLiteral(", request id = ") << requestId); + QNDEBUG("Write note html to file completed: success = " + << (success ? "true" : "false") << ", request id = " + << requestId); m_writeNoteHtmlToFileRequestId = QUuid(); m_pendingIndexHtmlWritingToFile = false; @@ -1482,27 +1483,27 @@ } QUrl url = QUrl::fromLocalFile(noteEditorPagePath()); - QNDEBUG(QStringLiteral("URL to use for page loading: ") << url); + QNDEBUG("URL to use for page loading: " << url); m_pendingNextPageUrl = url; if (m_pendingNotePageLoadMethodExit) { - QNDEBUG(QStringLiteral("Already loading something into the editor, " - "need to wait for the previous note load " - "to complete")); + QNDEBUG("Already loading something into the editor, need to wait " + "for the previous note load to complete"); return; } while(!m_pendingNextPageUrl.isEmpty()) { /** - * WARNING: the piece of code just below is trickier than it might seem, - * thanks to Qt developers. Make sure to read comments in NoteEditor_p.h - * near the declaration of class members m_pendingNotePageLoadMethodExit - * and m_pendingNextPageUrl to see how it works + * WARNING: the piece of code just below is trickier than it might + * seem, thanks to Qt developers. Make sure to read comments in + * NoteEditor_p.h near the declaration of class members + * m_pendingNotePageLoadMethodExit and m_pendingNextPageUrl to see + * how it works */ - QNDEBUG(QStringLiteral("Setting the pending url: ") << m_pendingNextPageUrl); + QNDEBUG("Setting the pending url: " << m_pendingNextPageUrl); url = m_pendingNextPageUrl; m_pendingNotePageLoad = true; @@ -1513,8 +1514,8 @@ page()->mainFrame()->setUrl(url); #endif m_pendingNotePageLoadMethodExit = false; - QNDEBUG(QStringLiteral("After having started to load the url into ") - << QStringLiteral("the page: ") << url); + QNDEBUG("After having started to load the url into the page: " + << url); /** * Check that while we were within setUrl method, the next URL to be @@ -1532,12 +1533,11 @@ if (manualSaveResourceIt != m_manualSaveResourceToFileRequestIds.end()) { if (success) { - QNDEBUG(QStringLiteral("Successfully saved resource to file for request id ") + QNDEBUG("Successfully saved resource to file for request id " << requestId); } else { - QNWARNING(QStringLiteral("Could not save resource to file: ") - << errorDescription); + QNWARNING("Could not save resource to file: " << errorDescription); } Q_UNUSED(m_manualSaveResourceToFileRequestIds.erase(manualSaveResourceIt)); @@ -1548,13 +1548,14 @@ void NoteEditorPrivate::onSelectionFormattedAsSourceCode( const QVariant & response, const QVector<QPair<QString,QString> > & extraData) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onSelectionFormattedAsSourceCode")); + QNDEBUG("NoteEditorPrivate::onSelectionFormattedAsSourceCode"); Q_UNUSED(extraData) QMap<QString,QVariant> resultMap = response.toMap(); auto statusIt = resultMap.find(QStringLiteral("status")); - if (Q_UNLIKELY(statusIt == resultMap.end())) { + if (Q_UNLIKELY(statusIt == resultMap.end())) + { ErrorString error(QT_TR_NOOP("Can't find the status within the result " "of selection formatting as source code")); QNWARNING(error); @@ -1623,25 +1624,28 @@ convertToNote(); } -void NoteEditorPrivate::onAddResourceDelegateFinished(Resource addedResource, - QString resourceFileStoragePath) +void NoteEditorPrivate::onAddResourceDelegateFinished( + Resource addedResource, QString resourceFileStoragePath) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onAddResourceDelegateFinished: ") - << QStringLiteral("resource file storage path = ") - << resourceFileStoragePath); + QNDEBUG("NoteEditorPrivate::onAddResourceDelegateFinished: " + << "resource file storage path = " << resourceFileStoragePath); QNTRACE(addedResource); - if (Q_UNLIKELY(!addedResource.hasDataHash())) { - ErrorString error(QT_TR_NOOP("The added resource doesn't contain the data hash")); + if (Q_UNLIKELY(!addedResource.hasDataHash())) + { + ErrorString error(QT_TR_NOOP("The added resource doesn't contain " + "the data hash")); QNWARNING(error); removeResourceFromNote(addedResource); Q_EMIT notifyError(error); return; } - if (Q_UNLIKELY(!addedResource.hasDataSize())) { - ErrorString error(QT_TR_NOOP("The added resource doesn't contain the data size")); + if (Q_UNLIKELY(!addedResource.hasDataSize())) + { + ErrorString error(QT_TR_NOOP("The added resource doesn't contain " + "the data size")); QNWARNING(error); removeResourceFromNote(addedResource); Q_EMIT notifyError(error); @@ -1694,8 +1698,7 @@ void NoteEditorPrivate::onAddResourceDelegateError(ErrorString error) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onAddResourceDelegateError: ") - << error); + QNDEBUG("NoteEditorPrivate::onAddResourceDelegateError: " << error); Q_EMIT notifyError(error); @@ -1708,8 +1711,7 @@ void NoteEditorPrivate::onAddResourceUndoRedoFinished( const QVariant & data, const QVector<QPair<QString,QString> > & extraData) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onAddResourceUndoRedoFinished: ") - << data); + QNDEBUG("NoteEditorPrivate::onAddResourceUndoRedoFinished: " << data); Q_UNUSED(extraData); @@ -1717,7 +1719,8 @@ QMap<QString,QVariant> resultMap = data.toMap(); auto statusIt = resultMap.find(QStringLiteral("status")); - if (Q_UNLIKELY(statusIt == resultMap.end())) { + if (Q_UNLIKELY(statusIt == resultMap.end())) + { ErrorString error(QT_TR_NOOP("Can't parse the result of new resource " "html insertion undo/redo from JavaScript")); QNWARNING(error); @@ -1750,12 +1753,12 @@ convertToNote(); } -void NoteEditorPrivate::onRemoveResourceDelegateFinished(Resource removedResource, - bool reversible) +void NoteEditorPrivate::onRemoveResourceDelegateFinished( + Resource removedResource, bool reversible) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onRemoveResourceDelegateFinished: ") - << QStringLiteral("removed resource = ") << removedResource - << QStringLiteral("\nReversible: ") << reversible); + QNDEBUG("NoteEditorPrivate::onRemoveResourceDelegateFinished: " + << "removed resource = " << removedResource + << "\nReversible: " << reversible); if (reversible) { @@ -1772,7 +1775,8 @@ m_pUndoStack->push(pCommand); } - RemoveResourceDelegate * delegate = qobject_cast<RemoveResourceDelegate*>(sender()); + RemoveResourceDelegate * delegate = + qobject_cast<RemoveResourceDelegate*>(sender()); if (Q_LIKELY(delegate)) { delegate->deleteLater(); } @@ -1783,12 +1787,14 @@ convertToNote(); } -void NoteEditorPrivate::onRemoveResourceDelegateCancelled(QString resourceLocalUid) +void NoteEditorPrivate::onRemoveResourceDelegateCancelled( + QString resourceLocalUid) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onRemoveResourceDelegateCancelled: ") - << QStringLiteral("resource local uid = ") << resourceLocalUid); + QNDEBUG("NoteEditorPrivate::onRemoveResourceDelegateCancelled: " + << "resource local uid = " << resourceLocalUid); - RemoveResourceDelegate * delegate = qobject_cast<RemoveResourceDelegate*>(sender()); + RemoveResourceDelegate * delegate = + qobject_cast<RemoveResourceDelegate*>(sender()); if (Q_LIKELY(delegate)) { delegate->deleteLater(); } @@ -1796,11 +1802,11 @@ void NoteEditorPrivate::onRemoveResourceDelegateError(ErrorString error) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onRemoveResourceDelegateError: ") - << error); + QNDEBUG("NoteEditorPrivate::onRemoveResourceDelegateError: " << error); Q_EMIT notifyError(error); - RemoveResourceDelegate * delegate = qobject_cast<RemoveResourceDelegate*>(sender()); + RemoveResourceDelegate * delegate = + qobject_cast<RemoveResourceDelegate*>(sender()); if (Q_LIKELY(delegate)) { delegate->deleteLater(); } @@ -1809,8 +1815,7 @@ void NoteEditorPrivate::onRemoveResourceUndoRedoFinished( const QVariant & data, const QVector<QPair<QString,QString> > & extraData) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onRemoveResourceUndoRedoFinished: ") - << data); + QNDEBUG("NoteEditorPrivate::onRemoveResourceUndoRedoFinished: " << data); Q_UNUSED(extraData) @@ -1829,12 +1834,11 @@ QString oldResourceName, QString newResourceName, Resource resource, bool performingUndo) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onRenameResourceDelegateFinished: ") - << QStringLiteral("old resource name = ") << oldResourceName - << QStringLiteral(", new resource name = ") << newResourceName - << QStringLiteral(", performing undo = ") - << (performingUndo ? QStringLiteral("true") : QStringLiteral("false"))); - QNTRACE(QStringLiteral("Resource: ") << resource); + QNDEBUG("NoteEditorPrivate::onRenameResourceDelegateFinished: " + << "old resource name = " << oldResourceName + << ", new resource name = " << newResourceName + << ", performing undo = " << (performingUndo ? "true" : "false")); + QNTRACE("Resource: " << resource); #ifndef QUENTIER_USE_QT_WEB_ENGINE if (m_pPluginFactory) { @@ -1842,11 +1846,13 @@ } #endif - if (!performingUndo) { - RenameResourceUndoCommand * pCommand = - new RenameResourceUndoCommand(resource, oldResourceName, *this, - m_pGenericResourceImageManager, - m_genericResourceImageFilePathsByResourceHash); + if (!performingUndo) + { + RenameResourceUndoCommand * pCommand = new RenameResourceUndoCommand( + resource, oldResourceName, *this, + m_pGenericResourceImageManager, + m_genericResourceImageFilePathsByResourceHash); + QObject::connect(pCommand, QNSIGNAL(RenameResourceUndoCommand,notifyError,ErrorString), this, @@ -1854,7 +1860,8 @@ m_pUndoStack->push(pCommand); } - RenameResourceDelegate * delegate = qobject_cast<RenameResourceDelegate*>(sender()); + RenameResourceDelegate * delegate = + qobject_cast<RenameResourceDelegate*>(sender()); if (Q_LIKELY(delegate)) { delegate->deleteLater(); } @@ -1867,9 +1874,10 @@ void NoteEditorPrivate::onRenameResourceDelegateCancelled() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onRenameResourceDelegateCancelled")); + QNDEBUG("NoteEditorPrivate::onRenameResourceDelegateCancelled"); - RenameResourceDelegate * delegate = qobject_cast<RenameResourceDelegate*>(sender()); + RenameResourceDelegate * delegate = + qobject_cast<RenameResourceDelegate*>(sender()); if (Q_LIKELY(delegate)) { delegate->deleteLater(); } @@ -1877,12 +1885,12 @@ void NoteEditorPrivate::onRenameResourceDelegateError(ErrorString error) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onRenameResourceDelegateError: ") - << error); + QNDEBUG("NoteEditorPrivate::onRenameResourceDelegateError: " << error); Q_EMIT notifyError(error); - RenameResourceDelegate * delegate = qobject_cast<RenameResourceDelegate*>(sender()); + RenameResourceDelegate * delegate = + qobject_cast<RenameResourceDelegate*>(sender()); if (Q_LIKELY(delegate)) { delegate->deleteLater(); } @@ -1890,14 +1898,15 @@ void NoteEditorPrivate::onImageResourceRotationDelegateFinished( QByteArray resourceDataBefore, QByteArray resourceHashBefore, - QByteArray resourceRecognitionDataBefore, QByteArray resourceRecognitionDataHashBefore, + QByteArray resourceRecognitionDataBefore, + QByteArray resourceRecognitionDataHashBefore, QSize resourceImageSizeBefore, Resource resourceAfter, INoteEditorBackend::Rotation::type rotationDirection) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onImageResourceRotationDelegateFinished: ") - << QStringLiteral("previous resource hash = ") << resourceHashBefore.toHex() - << QStringLiteral(", resource local uid = ") << resourceAfter.localUid() - << QStringLiteral(", rotation direction = ") << rotationDirection); + QNDEBUG("NoteEditorPrivate::onImageResourceRotationDelegateFinished: " + << "previous resource hash = " << resourceHashBefore.toHex() + << ", resource local uid = " << resourceAfter.localUid() + << ", rotation direction = " << rotationDirection); ImageResourceRotationUndoCommand * pCommand = new ImageResourceRotationUndoCommand(resourceDataBefore, resourceHashBefore, @@ -1906,7 +1915,8 @@ resourceImageSizeBefore, resourceAfter, rotationDirection, *this); QObject::connect(pCommand, - QNSIGNAL(ImageResourceRotationUndoCommand,notifyError,ErrorString), + QNSIGNAL(ImageResourceRotationUndoCommand,notifyError, + ErrorString), this, QNSLOT(NoteEditorPrivate,onUndoCommandError,ErrorString)); m_pUndoStack->push(pCommand); @@ -1932,7 +1942,7 @@ void NoteEditorPrivate::onImageResourceRotationDelegateError(ErrorString error) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onImageResourceRotationDelegateError")); + QNDEBUG("NoteEditorPrivate::onImageResourceRotationDelegateError"); Q_EMIT notifyError(error); ImageResourceRotationDelegate * delegate = @@ -1945,8 +1955,7 @@ void NoteEditorPrivate::onHideDecryptedTextFinished( const QVariant & data, const QVector<QPair<QString,QString> > & extraData) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onHideDecryptedTextFinished: ") - << data); + QNDEBUG("NoteEditorPrivate::onHideDecryptedTextFinished: " << data); Q_UNUSED(extraData) @@ -2003,8 +2012,7 @@ void NoteEditorPrivate::onHideDecryptedTextUndoRedoFinished( const QVariant & data, const QVector<QPair<QString,QString> > & extraData) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onHideDecryptedTextUndoRedoFinished: ") - << data); + QNDEBUG("NoteEditorPrivate::onHideDecryptedTextUndoRedoFinished: " << data); Q_UNUSED(extraData) @@ -2046,7 +2054,7 @@ void NoteEditorPrivate::onEncryptSelectedTextDelegateFinished() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onEncryptSelectedTextDelegateFinished")); + QNDEBUG("NoteEditorPrivate::onEncryptSelectedTextDelegateFinished"); EncryptUndoCommand * pCommand = new EncryptUndoCommand( @@ -2078,7 +2086,7 @@ void NoteEditorPrivate::onEncryptSelectedTextDelegateCancelled() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onEncryptSelectedTextDelegateCancelled")); + QNDEBUG("NoteEditorPrivate::onEncryptSelectedTextDelegateCancelled"); EncryptSelectedTextDelegate * delegate = qobject_cast<EncryptSelectedTextDelegate*>(sender()); @@ -2089,8 +2097,7 @@ void NoteEditorPrivate::onEncryptSelectedTextDelegateError(ErrorString error) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onEncryptSelectedTextDelegateError: ") - << error); + QNDEBUG("NoteEditorPrivate::onEncryptSelectedTextDelegateError: " << error); Q_EMIT notifyError(error); EncryptSelectedTextDelegate * delegate = @@ -2103,8 +2110,7 @@ void NoteEditorPrivate::onEncryptSelectedTextUndoRedoFinished( const QVariant & data, const QVector<QPair<QString,QString> > & extraData) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onEncryptSelectedTextUndoRedoFinished: ") - << data); + QNDEBUG("NoteEditorPrivate::onEncryptSelectedTextUndoRedoFinished: " << data); Q_UNUSED(extraData) @@ -2153,7 +2159,7 @@ QString decryptedText, QString passphrase, bool rememberForSession, bool decryptPermanently) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onDecryptEncryptedTextDelegateFinished")); + QNDEBUG("NoteEditorPrivate::onDecryptEncryptedTextDelegateFinished"); setModified(); @@ -2201,7 +2207,7 @@ void NoteEditorPrivate::onDecryptEncryptedTextDelegateCancelled() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onDecryptEncryptedTextDelegateCancelled")); + QNDEBUG("NoteEditorPrivate::onDecryptEncryptedTextDelegateCancelled"); DecryptEncryptedTextDelegate * delegate = qobject_cast<DecryptEncryptedTextDelegate*>(sender()); @@ -2212,8 +2218,7 @@ void NoteEditorPrivate::onDecryptEncryptedTextDelegateError(ErrorString error) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onDecryptEncryptedTextDelegateError: ") - << error); + QNDEBUG("NoteEditorPrivate::onDecryptEncryptedTextDelegateError: " << error); Q_EMIT notifyError(error); @@ -2227,8 +2232,7 @@ void NoteEditorPrivate::onDecryptEncryptedTextUndoRedoFinished( const QVariant & data, const QVector<QPair<QString,QString> > & extraData) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onDecryptEncryptedTextUndoRedoFinished: ") - << data); + QNDEBUG("NoteEditorPrivate::onDecryptEncryptedTextUndoRedoFinished: " << data); setModified(); @@ -2279,7 +2283,7 @@ void NoteEditorPrivate::onAddHyperlinkToSelectedTextDelegateFinished() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onAddHyperlinkToSelectedTextDelegateFinished")); + QNDEBUG("NoteEditorPrivate::onAddHyperlinkToSelectedTextDelegateFinished"); AddHyperlinkUndoCommand * pCommand = new AddHyperlinkUndoCommand( @@ -2307,7 +2311,7 @@ void NoteEditorPrivate::onAddHyperlinkToSelectedTextDelegateCancelled() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onAddHyperlinkToSelectedTextDelegateCancelled")); + QNDEBUG("NoteEditorPrivate::onAddHyperlinkToSelectedTextDelegateCancelled"); AddHyperlinkToSelectedTextDelegate * delegate = qobject_cast<AddHyperlinkToSelectedTextDelegate*>(sender()); @@ -2316,9 +2320,10 @@ } } -void NoteEditorPrivate::onAddHyperlinkToSelectedTextDelegateError(ErrorString error) +void NoteEditorPrivate::onAddHyperlinkToSelectedTextDelegateError( + ErrorString error) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onAddHyperlinkToSelectedTextDelegateError")); + QNDEBUG("NoteEditorPrivate::onAddHyperlinkToSelectedTextDelegateError"); Q_EMIT notifyError(error); AddHyperlinkToSelectedTextDelegate * delegate = @@ -2331,7 +2336,7 @@ void NoteEditorPrivate::onAddHyperlinkToSelectedTextUndoRedoFinished( const QVariant & data, const QVector<QPair<QString,QString> > & extraData) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onAddHyperlinkToSelectedTextUndoRedoFinished: ") + QNDEBUG("NoteEditorPrivate::onAddHyperlinkToSelectedTextUndoRedoFinished: " << data); Q_UNUSED(extraData) @@ -2374,7 +2379,7 @@ void NoteEditorPrivate::onEditHyperlinkDelegateFinished() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onEditHyperlinkDelegateFinished")); + QNDEBUG("NoteEditorPrivate::onEditHyperlinkDelegateFinished"); setModified(); @@ -2402,9 +2407,10 @@ void NoteEditorPrivate::onEditHyperlinkDelegateCancelled() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onEditHyperlinkDelegateCancelled")); + QNDEBUG("NoteEditorPrivate::onEditHyperlinkDelegateCancelled"); - EditHyperlinkDelegate * delegate = qobject_cast<EditHyperlinkDelegate*>(sender()); + EditHyperlinkDelegate * delegate = + qobject_cast<EditHyperlinkDelegate*>(sender()); if (Q_LIKELY(delegate)) { delegate->deleteLater(); } @@ -2412,8 +2418,7 @@ void NoteEditorPrivate::onEditHyperlinkDelegateError(ErrorString error) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onEditHyperlinkDelegateError: ") - << error); + QNDEBUG("NoteEditorPrivate::onEditHyperlinkDelegateError: " << error); Q_EMIT notifyError(error); @@ -2426,8 +2431,7 @@ void NoteEditorPrivate::onEditHyperlinkUndoRedoFinished( const QVariant & data, const QVector<QPair<QString,QString> > & extraData) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onEditHyperlinkUndoRedoFinished: ") - << data); + QNDEBUG("NoteEditorPrivate::onEditHyperlinkUndoRedoFinished: " << data); Q_UNUSED(extraData) @@ -2469,7 +2473,7 @@ void NoteEditorPrivate::onRemoveHyperlinkDelegateFinished() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onRemoveHyperlinkDelegateFinished")); + QNDEBUG("NoteEditorPrivate::onRemoveHyperlinkDelegateFinished"); setModified(); @@ -2496,8 +2500,7 @@ void NoteEditorPrivate::onRemoveHyperlinkDelegateError(ErrorString error) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onRemoveHyperlinkDelegateError: ") - << error); + QNDEBUG("NoteEditorPrivate::onRemoveHyperlinkDelegateError: " << error); Q_EMIT notifyError(error); RemoveHyperlinkDelegate * delegate = qobject_cast<RemoveHyperlinkDelegate*>(sender()); @@ -2509,8 +2512,7 @@ void NoteEditorPrivate::onRemoveHyperlinkUndoRedoFinished( const QVariant & data, const QVector<QPair<QString,QString> > & extraData) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onRemoveHyperlinkUndoRedoFinished: ") - << data); + QNDEBUG("NoteEditorPrivate::onRemoveHyperlinkUndoRedoFinished: " << data); Q_UNUSED(extraData) @@ -2550,24 +2552,24 @@ convertToNote(); } -void NoteEditorPrivate::onInsertHtmlDelegateFinished(QList<Resource> addedResources, - QStringList resourceFileStoragePaths) +void NoteEditorPrivate::onInsertHtmlDelegateFinished( + QList<Resource> addedResources, QStringList resourceFileStoragePaths) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onInsertHtmlDelegateFinished: ") - << QStringLiteral("num added resources = ") << addedResources.size()); + QNDEBUG("NoteEditorPrivate::onInsertHtmlDelegateFinished: " + << "num added resources = " << addedResources.size()); setModified(); if (QuentierIsLogLevelActive(LogLevel::TraceLevel)) { - QNTRACE(QStringLiteral("Added resources: ")); + QNTRACE("Added resources: "); for(auto it = addedResources.constBegin(), end = addedResources.constEnd(); it != end; ++it) { QNTRACE(*it); } - QNTRACE(QStringLiteral("Resource file storage paths: ")); + QNTRACE("Resource file storage paths: "); for(auto it = resourceFileStoragePaths.constBegin(), end = resourceFileStoragePaths.constEnd(); it != end; ++it) { @@ -2600,8 +2602,7 @@ void NoteEditorPrivate::onInsertHtmlDelegateError(ErrorString error) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onInsertHtmlDelegateError: ") - << error); + QNDEBUG("NoteEditorPrivate::onInsertHtmlDelegateError: " << error); Q_EMIT notifyError(error); @@ -2614,8 +2615,7 @@ void NoteEditorPrivate::onInsertHtmlUndoRedoFinished( const QVariant & data, const QVector<QPair<QString,QString> > & extraData) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onInsertHtmlUndoRedoFinished: ") - << data); + QNDEBUG("NoteEditorPrivate::onInsertHtmlUndoRedoFinished: " << data); Q_UNUSED(extraData); @@ -2659,8 +2659,7 @@ void NoteEditorPrivate::onSourceCodeFormatUndoRedoFinished( const QVariant & data, const QVector<QPair<QString,QString> > & extraData) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onSourceCodeFormatUndoRedoFinished: ") - << data); + QNDEBUG("NoteEditorPrivate::onSourceCodeFormatUndoRedoFinished: " << data); Q_UNUSED(extraData) @@ -2700,32 +2699,33 @@ void NoteEditorPrivate::onUndoCommandError(ErrorString error) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onUndoCommandError: ") << error); + QNDEBUG("NoteEditorPrivate::onUndoCommandError: " << error); Q_EMIT notifyError(error); } void NoteEditorPrivate::onSpellCheckerDictionaryEnabledOrDisabled(bool checked) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onSpellCheckerDictionaryEnabledOrDisabled: ") - << QStringLiteral("checked = ") - << (checked ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("NoteEditorPrivate::onSpellCheckerDictionaryEnabledOrDisabled: " + << "checked = " << (checked ? "true" : "false")); QAction * pAction = qobject_cast<QAction*>(sender()); - if (Q_UNLIKELY(!pAction)) { - ErrorString errorDescription(QT_TR_NOOP("Can't change the enabled/disabled " - "state of a spell checker dictionary: " - "internal error, can't cast " - "the slot invoker to QAction")); + if (Q_UNLIKELY(!pAction)) + { + ErrorString errorDescription( + QT_TR_NOOP("Can't change the enabled/disabled state of a spell " + "checker dictionary: internal error, can't cast " + "the slot invoker to QAction")); QNWARNING(errorDescription); Q_EMIT notifyError(errorDescription); return; } - if (Q_UNLIKELY(!m_pSpellChecker)) { - ErrorString errorDescription(QT_TR_NOOP("Can't change the enabled/disabled " - "state of a spell checker dictionary: " - "internal error, the spell checker " - "is not set up for the note editor")); + if (Q_UNLIKELY(!m_pSpellChecker)) + { + ErrorString errorDescription( + QT_TR_NOOP("Can't change the enabled/disabled state of a spell " + "checker dictionary: internal error, the spell checker " + "is not set up for the note editor")); QNWARNING(errorDescription); Q_EMIT notifyError(errorDescription); return; @@ -2742,8 +2742,8 @@ } if (!m_spellCheckerEnabled) { - QNDEBUG(QStringLiteral("The spell checker is not enabled at the moment, " - "won't refresh it")); + QNDEBUG("The spell checker is not enabled at the moment, " + "won't refresh it"); return; } @@ -2755,8 +2755,7 @@ void NoteEditorPrivate::onPageHtmlReceivedForPrinting( const QString & html, const QVector<QPair<QString, QString> > & extraData) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onPageHtmlReceivedForPrinting: ") - << html); + QNDEBUG("NoteEditorPrivate::onPageHtmlReceivedForPrinting: " << html); Q_UNUSED(extraData) m_htmlForPrinting = html; @@ -2766,7 +2765,7 @@ void NoteEditorPrivate::clearCurrentNoteInfo() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::clearCurrentNoteInfo")); + QNDEBUG("NoteEditorPrivate::clearCurrentNoteInfo"); // Remove the no longer needed html file with the note editor page if (!m_pNote.isNull()) @@ -2823,11 +2822,10 @@ void NoteEditorPrivate::reloadCurrentNote() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::reloadCurrentNote")); + QNDEBUG("NoteEditorPrivate::reloadCurrentNote"); if (Q_UNLIKELY(m_noteLocalUid.isEmpty())) { - QNWARNING(QStringLiteral("Can't reload current note - no note is set " - "to the editor")); + QNWARNING("Can't reload current note - no note is set to the editor"); return; } @@ -2846,7 +2844,7 @@ void NoteEditorPrivate::clearPrepareNoteImageResourcesProgressDialog() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::clearPrepareNoteImageResourcesProgressDialog")); + QNDEBUG("NoteEditorPrivate::clearPrepareNoteImageResourcesProgressDialog"); if (!m_pPrepareNoteImageResourcesProgressDialog) { return; @@ -2860,8 +2858,8 @@ void NoteEditorPrivate::clearPrepareResourceForOpeningProgressDialog( const QString & resourceLocalUid) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::clearPrepareResourceForOpeningProgressDialog: ") - << QStringLiteral("resource local uid = ") << resourceLocalUid); + QNDEBUG("NoteEditorPrivate::clearPrepareResourceForOpeningProgressDialog: " + << "resource local uid = " << resourceLocalUid); auto progressDialogIt = m_prepareResourceForOpeningProgressDialogs.end(); for(auto pit = m_prepareResourceForOpeningProgressDialogs.begin(), @@ -2873,8 +2871,10 @@ } } - if (Q_UNLIKELY(progressDialogIt == m_prepareResourceForOpeningProgressDialogs.end())) { - QNDEBUG(QStringLiteral("Haven't found QProgressDialog for this resource")); + if (Q_UNLIKELY(progressDialogIt == + m_prepareResourceForOpeningProgressDialogs.end())) + { + QNDEBUG("Haven't found QProgressDialog for this resource"); return; } @@ -2887,13 +2887,13 @@ void NoteEditorPrivate::timerEvent(QTimerEvent * pEvent) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::timerEvent: ") + QNDEBUG("NoteEditorPrivate::timerEvent: " << (pEvent ? QString::number(pEvent->timerId()) : QStringLiteral("<null>"))); if (Q_UNLIKELY(!pEvent)) { - QNINFO(QStringLiteral("Detected null pointer to timer event")); + QNINFO("Detected null pointer to timer event"); return; } @@ -2901,16 +2901,16 @@ { if (m_contentChangedSinceWatchingStart) { - QNTRACE(QStringLiteral("Note editor page's content has been changed " - "lately, the editing is most likely in progress " - "now, postponing the conversion to ENML")); + QNTRACE("Note editor page's content has been changed " + "lately, the editing is most likely in progress " + "now, postponing the conversion to ENML"); m_contentChangedSinceWatchingStart = false; return; } ErrorString error; - QNTRACE(QStringLiteral("Looks like the note editing has stopped for a while, " - "will convert the note editor page's content to ENML")); + QNTRACE("Looks like the note editing has stopped for a while, " + "will convert the note editor page's content to ENML"); bool res = htmlToNoteContent(error); if (!res) { Q_EMIT notifyError(error); @@ -2927,14 +2927,14 @@ void NoteEditorPrivate::dragMoveEvent(QDragMoveEvent * pEvent) { if (Q_UNLIKELY(!pEvent)) { - QNINFO(QStringLiteral("Detected null pointer to drag move event")); + QNINFO("Detected null pointer to drag move event"); return; } const QMimeData * pMimeData = pEvent->mimeData(); if (Q_UNLIKELY(!pMimeData)) { - QNWARNING(QStringLiteral("Null pointer to mime data from drag move " - "event was detected")); + QNWARNING("Null pointer to mime data from drag move " + "event was detected"); return; } @@ -2954,7 +2954,7 @@ #ifdef QUENTIER_USE_QT_WEB_ENGINE void NoteEditorPrivate::getHtmlForPrinting() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::getHtmlForPrinting")); + QNDEBUG("NoteEditorPrivate::getHtmlForPrinting"); GET_PAGE() page->toHtml( @@ -2969,17 +2969,18 @@ QString resourceLocalUid = resource.localUid(); auto sit = - m_resourceLocalUidsPendingFindDataInLocalStorageForSavingToFile.find(resourceLocalUid); + m_resourceLocalUidsPendingFindDataInLocalStorageForSavingToFile.find( + resourceLocalUid); if (sit != m_resourceLocalUidsPendingFindDataInLocalStorageForSavingToFile.end()) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onFoundResourceData: resource local uid = ") + QNDEBUG("NoteEditorPrivate::onFoundResourceData: resource local uid = " << resourceLocalUid); QNTRACE(resource); Q_UNUSED(m_resourceLocalUidsPendingFindDataInLocalStorageForSavingToFile.erase(sit)) if (Q_UNLIKELY(m_pNote.isNull())) { - QNDEBUG(QStringLiteral("No note is set to the editor")); + QNDEBUG("No note is set to the editor"); return; } @@ -3000,13 +3001,13 @@ "to a file: the attachment " "to be saved was not found " "within the note")); - QNWARNING(errorDescription << QStringLiteral(", resource local uid = ") + QNWARNING(errorDescription << ", resource local uid = " << resourceLocalUid); Q_EMIT notifyError(errorDescription); return; } - QNTRACE(QStringLiteral("Updating the resource within the note")); + QNTRACE("Updating the resource within the note"); resources[resourceIndex] = resource; m_pNote->setResources(resources); Q_EMIT currentNoteChanged(*m_pNote); @@ -3015,27 +3016,28 @@ } auto iit = - m_rotationTypeByResourceLocalUidsPendingFindDataInLocalStorage.find(resourceLocalUid); + m_rotationTypeByResourceLocalUidsPendingFindDataInLocalStorage.find( + resourceLocalUid); if (iit != m_rotationTypeByResourceLocalUidsPendingFindDataInLocalStorage.end()) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onFoundResourceData: ") - << QStringLiteral("resource local uid = ") << resourceLocalUid); + QNDEBUG("NoteEditorPrivate::onFoundResourceData: " + << "resource local uid = " << resourceLocalUid); QNTRACE(resource); Rotation::type rotationDirection = iit.value(); Q_UNUSED(m_rotationTypeByResourceLocalUidsPendingFindDataInLocalStorage.erase(iit)) if (Q_UNLIKELY(m_pNote.isNull())) { - QNDEBUG(QStringLiteral("No note is set to the editor")); + QNDEBUG("No note is set to the editor"); return; } if (Q_UNLIKELY(!resource.hasDataBody() && !resource.hasDataHash())) { - ErrorString errorDescription(QT_TR_NOOP("Can't rotate image attachment: " - "the image attachment has " - "neither data nor data hash")); - QNWARNING(errorDescription << QStringLiteral(", resource: ") << resource); + ErrorString errorDescription( + QT_TR_NOOP("Can't rotate image attachment: the image " + "attachment has neither data nor data hash")); + QNWARNING(errorDescription << ", resource: " << resource); Q_EMIT notifyError(errorDescription); return; } @@ -3053,10 +3055,10 @@ if (Q_UNLIKELY(resourceIndex < 0)) { - ErrorString errorDescription(QT_TR_NOOP("Can't rotate image attachment: " - "the attachment to be rotated " - "was not found within the note")); - QNWARNING(errorDescription << QStringLiteral(", resource local uid = ") + ErrorString errorDescription( + QT_TR_NOOP("Can't rotate image attachment: the attachment to " + "be rotated was not found within the note")); + QNWARNING(errorDescription << ", resource local uid = " << resourceLocalUid); Q_EMIT notifyError(errorDescription); return; @@ -3073,20 +3075,21 @@ } } -void NoteEditorPrivate::onFailedToFindResourceData(QString resourceLocalUid, - ErrorString errorDescription) +void NoteEditorPrivate::onFailedToFindResourceData( + QString resourceLocalUid, ErrorString errorDescription) { auto sit = - m_resourceLocalUidsPendingFindDataInLocalStorageForSavingToFile.find(resourceLocalUid); + m_resourceLocalUidsPendingFindDataInLocalStorageForSavingToFile.find( + resourceLocalUid); if (sit != m_resourceLocalUidsPendingFindDataInLocalStorageForSavingToFile.end()) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onFailedToFindResourceData: ") - << QStringLiteral("resource local uid = ") << resourceLocalUid); + QNDEBUG("NoteEditorPrivate::onFailedToFindResourceData: " + << "resource local uid = " << resourceLocalUid); Q_UNUSED(m_resourceLocalUidsPendingFindDataInLocalStorageForSavingToFile.erase(sit)) if (Q_UNLIKELY(m_pNote.isNull())) { - QNDEBUG(QStringLiteral("No note is set to the editor")); + QNDEBUG("No note is set to the editor"); return; } @@ -3096,22 +3099,22 @@ error.appendBase(errorDescription.base()); error.appendBase(errorDescription.additionalBases()); error.details() = errorDescription.details(); - QNWARNING(error << QStringLiteral(", resource local uid = ") - << resourceLocalUid); + QNWARNING(error << ", resource local uid = " << resourceLocalUid); Q_EMIT notifyError(error); } auto iit = - m_rotationTypeByResourceLocalUidsPendingFindDataInLocalStorage.find(resourceLocalUid); + m_rotationTypeByResourceLocalUidsPendingFindDataInLocalStorage.find( + resourceLocalUid); if (iit != m_rotationTypeByResourceLocalUidsPendingFindDataInLocalStorage.end()) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onFailedToFindResourceData: ") - << QStringLiteral("resource local uid = ") << resourceLocalUid); + QNDEBUG("NoteEditorPrivate::onFailedToFindResourceData: " + << "resource local uid = " << resourceLocalUid); Q_UNUSED(m_rotationTypeByResourceLocalUidsPendingFindDataInLocalStorage.erase(iit)) if (Q_UNLIKELY(m_pNote.isNull())) { - QNDEBUG(QStringLiteral("No note is set to the editor")); + QNDEBUG("No note is set to the editor"); return; } @@ -3120,8 +3123,7 @@ error.appendBase(errorDescription.base()); error.appendBase(errorDescription.additionalBases()); error.details() = errorDescription.details(); - QNWARNING(error << QStringLiteral(", resource local uid = ") - << resourceLocalUid); + QNWARNING(error << ", resource local uid = " << resourceLocalUid); Q_EMIT notifyError(error); } } @@ -3133,10 +3135,10 @@ return; } - QNDEBUG(QStringLiteral("NoteEditorPrivate::onFailedToPutResourceDataInTemporaryFile: ") - << QStringLiteral("resource local uid = ") << resourceLocalUid - << QStringLiteral(", note local uid = ") << noteLocalUid - << QStringLiteral(", error description: ") << errorDescription); + QNDEBUG("NoteEditorPrivate::onFailedToPutResourceDataInTemporaryFile: " + << "resource local uid = " << resourceLocalUid + << ", note local uid = " << noteLocalUid + << ", error description: " << errorDescription); Q_EMIT notifyError(errorDescription); } @@ -3148,13 +3150,12 @@ return; } - QNDEBUG(QStringLiteral("NoteEditorPrivate::onNoteResourceTemporaryFilesPreparationProgress: ") - << QStringLiteral("progress = ") << progress - << QStringLiteral(", note local uid = ") << noteLocalUid); + QNDEBUG("NoteEditorPrivate::onNoteResourceTemporaryFilesPreparationProgress: " + << "progress = " << progress << ", note local uid = " << noteLocalUid); if (Q_UNLIKELY(!m_pPrepareNoteImageResourcesProgressDialog)) { - QNDEBUG(QStringLiteral("Unexpectedly missing prepare note image resources " - "progress dialog, won't do anything")); + QNDEBUG("Unexpectedly missing prepare note image resources " + "progress dialog, won't do anything"); return; } @@ -3173,9 +3174,9 @@ return; } - QNDEBUG(QStringLiteral("NoteEditorPrivate::onNoteResourceTemporaryFilesPreparationError: ") - << QStringLiteral("note local uid = ") << noteLocalUid - << QStringLiteral(", error description: ") << errorDescription); + QNDEBUG("NoteEditorPrivate::onNoteResourceTemporaryFilesPreparationError: " + << "note local uid = " << noteLocalUid + << ", error description: " << errorDescription); clearPrepareNoteImageResourcesProgressDialog(); Q_EMIT notifyError(errorDescription); @@ -3187,43 +3188,46 @@ return; } - QNDEBUG(QStringLiteral("NoteEditorPrivate::onNoteResourceTemporaryFilesReady: ") - << QStringLiteral("note local uid = ") << noteLocalUid); + QNDEBUG("NoteEditorPrivate::onNoteResourceTemporaryFilesReady: " + << "note local uid = " << noteLocalUid); /** - * All note's image resources (if any) were written to temporary files so they - * can now be displayed within the note editor page. However, one more trick - * is required for the case in which the note was updated i.e. previous versions - * of this note's image resources have already been displayed: even though - * the image files are updated with new data, the web engine's cache doesn't - * know about this and the updated data from image files is not reloaded, - * the old data is displayed. The workaround is to create a symlink to each - * resource image file and use that instead of the real path, this way web - * engine's undesired caching is avoided + * All note's image resources (if any) were written to temporary files so + * they can now be displayed within the note editor page. However, one more + * trick is required for the case in which the note was updated i.e. + * previous versions of this note's image resources have already been + * displayed: even though the image files are updated with new data, the + * web engine's cache doesn't know about this and the updated data from + * image files is not reloaded, the old data is displayed. The workaround + * is to create a symlink to each resource image file and use that instead + * of the real path, this way web engine's undesired caching is avoided */ m_pendingNoteImageResourceTemporaryFiles = false; QList<Resource> resources = m_pNote->resources(); QString imageResourceMimePrefix = QStringLiteral("image/"); - for(auto it = resources.constBegin(), end = resources.constEnd(); it != end; ++it) + for(auto it = resources.constBegin(), end = resources.constEnd(); + it != end; ++it) { const Resource & resource = *it; - QNTRACE(QStringLiteral("Processing resource: ") << resource); + QNTRACE("Processing resource: " << resource); if (!resource.hasMime() || !resource.mime().startsWith(imageResourceMimePrefix)) { - QNTRACE(QStringLiteral("Skipping the resource with inappropriate mime type: ") - << (resource.hasMime() ? resource.mime() : QStringLiteral("<not set>"))); + QNTRACE("Skipping the resource with inappropriate mime type: " + << (resource.hasMime() + ? resource.mime() + : QStringLiteral("<not set>"))); continue; } if (Q_UNLIKELY(!resource.hasDataHash())) { - QNTRACE(QStringLiteral("Skipping the resource without data hash")); + QNTRACE("Skipping the resource without data hash"); continue; } if (Q_UNLIKELY(!resource.hasDataSize())) { - QNTRACE(QStringLiteral("Skipping the resource without data size")); + QNTRACE("Skipping the resource without data size"); continue; } @@ -3244,11 +3248,13 @@ linkFilePath = fileStoragePath; } - m_resourceFileStoragePathsByResourceLocalUid[resourceLocalUid] = linkFilePath; + m_resourceFileStoragePathsByResourceLocalUid[resourceLocalUid] = + linkFilePath; QString resourceDisplayName = resource.displayName(); QString resourceDisplaySize = - humanReadableSize(static_cast<quint64>(std::max(resource.dataSize(), qint32(0)))); + humanReadableSize(static_cast<quint64>(std::max(resource.dataSize(), + qint32(0)))); QSize resourceImageSize; if (resource.hasHeight() && resource.hasWidth()) { @@ -3277,14 +3283,15 @@ return; } - QNDEBUG(QStringLiteral("NoteEditorPrivate::onOpenResourceInExternalEditorPreparationProgress: ") - << QStringLiteral("progress = ") << progress - << QStringLiteral(", resource local uid = ") << resourceLocalUid - << QStringLiteral(", note local uid = ") << noteLocalUid); + QNDEBUG("NoteEditorPrivate::onOpenResourceInExternalEditorPreparationProgress: " + << "progress = " << progress + << ", resource local uid = " << resourceLocalUid + << ", note local uid = " << noteLocalUid); auto progressDialogIt = m_prepareResourceForOpeningProgressDialogs.constEnd(); for(auto pit = m_prepareResourceForOpeningProgressDialogs.constBegin(), - pend = m_prepareResourceForOpeningProgressDialogs.constEnd(); pit != pend; ++pit) + pend = m_prepareResourceForOpeningProgressDialogs.constEnd(); + pit != pend; ++pit) { if (pit->first == resourceLocalUid) { progressDialogIt = pit; @@ -3292,8 +3299,10 @@ } } - if (Q_UNLIKELY(progressDialogIt == m_prepareResourceForOpeningProgressDialogs.constEnd())) { - QNDEBUG(QStringLiteral("Haven't found QProgressDialog for this resource")); + if (Q_UNLIKELY(progressDialogIt == + m_prepareResourceForOpeningProgressDialogs.constEnd())) + { + QNDEBUG("Haven't found QProgressDialog for this resource"); return; } @@ -3305,40 +3314,39 @@ progressDialogIt->second->setValue(normalizedProgress); } -void NoteEditorPrivate::onFailedToOpenResourceInExternalEditor(QString resourceLocalUid, - QString noteLocalUid, - ErrorString errorDescription) +void NoteEditorPrivate::onFailedToOpenResourceInExternalEditor( + QString resourceLocalUid, QString noteLocalUid, ErrorString errorDescription) { if (m_pNote.isNull() || (m_pNote->localUid() != noteLocalUid)) { return; } - QNDEBUG(QStringLiteral("NoteEditorPrivate::onFailedToOpenResourceInExternalEditor: ") - << QStringLiteral("resource local uid = ") << resourceLocalUid - << QStringLiteral(", note local uid = ") << noteLocalUid - << QStringLiteral(", error description = ") << errorDescription); + QNDEBUG("NoteEditorPrivate::onFailedToOpenResourceInExternalEditor: " + << "resource local uid = " << resourceLocalUid + << ", note local uid = " << noteLocalUid + << ", error description = " << errorDescription); clearPrepareResourceForOpeningProgressDialog(resourceLocalUid); Q_EMIT notifyError(errorDescription); } -void NoteEditorPrivate::onOpenedResourceInExternalEditor(QString resourceLocalUid, - QString noteLocalUid) +void NoteEditorPrivate::onOpenedResourceInExternalEditor( + QString resourceLocalUid, QString noteLocalUid) { if (m_pNote.isNull() || (m_pNote->localUid() != noteLocalUid)) { return; } - QNDEBUG(QStringLiteral("NoteEditorPrivate::onOpenedResourceInExternalEditor: ") - << QStringLiteral("resource local uid = ") << resourceLocalUid - << QStringLiteral(", note local uid = ") << noteLocalUid); + QNDEBUG("NoteEditorPrivate::onOpenedResourceInExternalEditor: " + << "resource local uid = " << resourceLocalUid + << ", note local uid = " << noteLocalUid); clearPrepareResourceForOpeningProgressDialog(resourceLocalUid); } void NoteEditorPrivate::init() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::init")); + QNDEBUG("NoteEditorPrivate::init"); CHECK_ACCOUNT(QT_TR_NOOP("Can't initialize the note editor")) @@ -3383,7 +3391,7 @@ return; } - QNDEBUG(QStringLiteral("NoteEditorPrivate::onNoteSavedToLocalStorage: note local uid = ") + QNDEBUG("NoteEditorPrivate::onNoteSavedToLocalStorage: note local uid = " << noteLocalUid); m_needSavingNoteInLocalStorage = false; @@ -3398,8 +3406,8 @@ Q_EMIT noteSavedToLocalStorage(noteLocalUid); } -void NoteEditorPrivate::onFailedToSaveNoteToLocalStorage(QString noteLocalUid, - ErrorString errorDescription) +void NoteEditorPrivate::onFailedToSaveNoteToLocalStorage( + QString noteLocalUid, ErrorString errorDescription) { if (!m_pendingNoteSavingInLocalStorage || !m_pNote || @@ -3408,9 +3416,9 @@ return; } - QNDEBUG(QStringLiteral("NoteEditorPrivate::onFailedToSaveNoteToLocalStorage: ") - << QStringLiteral("note local uid = ") << noteLocalUid - << QStringLiteral(", error description: ") << errorDescription); + QNDEBUG("NoteEditorPrivate::onFailedToSaveNoteToLocalStorage: " + << "note local uid = " << noteLocalUid + << ", error description: " << errorDescription); m_pendingNoteSavingInLocalStorage = false; m_shouldRepeatSavingNoteInLocalStorage = false; @@ -3424,8 +3432,8 @@ return; } - QNDEBUG(QStringLiteral("NoteEditorPrivate::onFoundNoteAndNotebook: note = ") - << note << QStringLiteral("\nNotebook = ") << notebook); + QNDEBUG("NoteEditorPrivate::onFoundNoteAndNotebook: note = " + << note << "\nNotebook = " << notebook); m_pNotebook.reset(new Notebook(notebook)); m_pNote.reset(new Note(note)); @@ -3452,7 +3460,7 @@ m_pPluginFactory->setNote(*m_pNote); if (missingPluginFactory) { - QNDEBUG(QStringLiteral("Setting note editor plugin factory to the page")); + QNDEBUG("Setting note editor plugin factory to the page"); pNoteEditorPage->setPluginFactory(m_pPluginFactory); } } @@ -3465,7 +3473,8 @@ QList<Resource> resources = m_pNote->resources(); int numImageResources = 0; QString imageResourcePrefix = QStringLiteral("image"); - for(auto it = resources.constBegin(), end = resources.constEnd(); it != end; ++it) + for(auto it = resources.constBegin(), + end = resources.constEnd(); it != end; ++it) { const Resource & resource = *it; if (!resource.hasMime()) { @@ -3493,19 +3502,19 @@ Q_EMIT currentNoteChanged(*m_pNote); noteToEditorContent(); - QNTRACE(QStringLiteral("Done setting the current note and notebook")); + QNTRACE("Done setting the current note and notebook"); } -void NoteEditorPrivate::onFailedToFindNoteOrNotebook(QString noteLocalUid, - ErrorString errorDescription) +void NoteEditorPrivate::onFailedToFindNoteOrNotebook( + QString noteLocalUid, ErrorString errorDescription) { if (noteLocalUid != m_noteLocalUid) { return; } - QNWARNING(QStringLiteral("NoteEditorPrivate::onFailedToFindNoteOrNotebook: ") - << QStringLiteral("note local uid = ") << noteLocalUid - << QStringLiteral(", error description: ") << errorDescription); + QNWARNING("NoteEditorPrivate::onFailedToFindNoteOrNotebook: " + << "note local uid = " << noteLocalUid + << ", error description: " << errorDescription); m_noteLocalUid.clear(); m_noteWasNotFound = true; @@ -3520,22 +3529,21 @@ return; } - QNDEBUG(QStringLiteral("NoteEditorPrivate::onNoteUpdated: ") << note); + QNDEBUG("NoteEditorPrivate::onNoteUpdated: " << note); if (Q_UNLIKELY(!m_pNote)) { if (m_pNotebook) { - QNDEBUG(QStringLiteral("Current note is unexpectedly empty on note " - "update, acting as if the note has just been " - "found")); + QNDEBUG("Current note is unexpectedly empty on note " + "update, acting as if the note has just been found"); Notebook notebook = *m_pNotebook; onFoundNoteAndNotebook(note, notebook); } else { - QNWARNING(QStringLiteral("Can't handle the update of note: note editor " - "contains neither note nor notebook")); + QNWARNING("Can't handle the update of note: note editor " + "contains neither note nor notebook"); // Trying to recover through re-requesting note and notebook // from the local storage m_noteLocalUid.clear(); @@ -3546,15 +3554,15 @@ } if (Q_UNLIKELY(!note.hasNotebookLocalUid())) { - QNWARNING(QStringLiteral("Can't handle the update of a note: the updated " - "note has no notebook local uid: ") << note); + QNWARNING("Can't handle the update of a note: the updated " + "note has no notebook local uid: " << note); return; } if (Q_UNLIKELY(!m_pNotebook) || (m_pNotebook->localUid() != note.notebookLocalUid())) { - QNDEBUG(QStringLiteral("Note's notebook has changed: new notebook local uid = ") + QNDEBUG("Note's notebook has changed: new notebook local uid = " << note.notebookLocalUid()); // Re-requesting both note and notebook from NoteEditorLocalStorageBroker QString noteLocalUid = m_noteLocalUid; @@ -3601,8 +3609,8 @@ } if (!noteChanged) { - QNDEBUG(QStringLiteral("Haven't found the updates within the note which " - "would be sufficient enough to reload the note editor")); + QNDEBUG("Haven't found the updates within the note which " + "would be sufficient enough to reload the note editor"); *m_pNote = note; return; } @@ -3610,7 +3618,7 @@ // FIXME: if the note was modified, need to let the user choose what to do - // either continue to edit the note or reload it - QNDEBUG(QStringLiteral("Note has changed substantially, need to reload the editor")); + QNDEBUG("Note has changed substantially, need to reload the editor"); reloadCurrentNote(); } @@ -3620,7 +3628,7 @@ return; } - QNDEBUG(QStringLiteral("NoteEditorPrivate::onNotebookUpdated")); + QNDEBUG("NoteEditorPrivate::onNotebookUpdated"); bool restrictionsChanged = false; if (m_pNotebook->hasRestrictions() != notebook.hasRestrictions()) @@ -3647,12 +3655,12 @@ *m_pNotebook = notebook; if (!restrictionsChanged) { - QNDEBUG(QStringLiteral("Detected no change of notebook restrictions")); + QNDEBUG("Detected no change of notebook restrictions"); return; } if (Q_UNLIKELY(!m_pNote)) { - QNWARNING(QStringLiteral("Note editor has notebook but no note")); + QNWARNING("Note editor has notebook but no note"); return; } @@ -3667,7 +3675,7 @@ } if (!canUpdateNote && m_isPageEditable) { - QNDEBUG(QStringLiteral("Note has become non-editable")); + QNDEBUG("Note has become non-editable"); setPageEditable(false); return; } @@ -3675,18 +3683,18 @@ if (canUpdateNote && !m_isPageEditable) { if (m_pNote->hasActive() && !m_pNote->active()) { - QNDEBUG(QStringLiteral("Notebook no longer restricts the update of " - "a note but the note is not active")); + QNDEBUG("Notebook no longer restricts the update of " + "a note but the note is not active"); return; } if (m_pNote->isInkNote()) { - QNDEBUG(QStringLiteral("Notebook no longer restricts the update of " - "a note but the note is an ink note")); + QNDEBUG("Notebook no longer restricts the update of " + "a note but the note is an ink note"); return; } - QNDEBUG(QStringLiteral("Note has become editable")); + QNDEBUG("Note has become editable"); setPageEditable(true); return; } @@ -3698,7 +3706,7 @@ return; } - QNDEBUG(QStringLiteral("NoteEditorPrivate::onNoteDeleted: ") << noteLocalUid); + QNDEBUG("NoteEditorPrivate::onNoteDeleted: " << noteLocalUid); Q_EMIT noteDeleted(m_noteLocalUid); @@ -3721,7 +3729,7 @@ return; } - QNDEBUG(QStringLiteral("NoteEditorPrivate::onNotebookDeleted: ") + QNDEBUG("NoteEditorPrivate::onNotebookDeleted: " << notebookLocalUid); Q_EMIT noteDeleted(m_noteLocalUid); @@ -3742,8 +3750,7 @@ void NoteEditorPrivate::handleHyperlinkClicked(const QUrl & url) { QString urlString = url.toString(); - QNDEBUG(QStringLiteral("NoteEditorPrivate::handleHyperlinkClicked: ") - << urlString); + QNDEBUG("NoteEditorPrivate::handleHyperlinkClicked: " << urlString); if (urlString.startsWith(QStringLiteral("evernote:///"))) { handleInAppLinkClicked(urlString); @@ -3755,8 +3762,7 @@ void NoteEditorPrivate::handleInAppLinkClicked(const QString & urlString) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::handleInAppLinkClicked: ") - << urlString); + QNDEBUG("NoteEditorPrivate::handleInAppLinkClicked: " << urlString); QString userId, shardId, noteGuid; ErrorString errorDescription; @@ -3767,15 +3773,15 @@ return; } - QNTRACE(QStringLiteral("Parsed in-app note link: user id = ") << userId - << QStringLiteral(", shard id = ") << shardId - << QStringLiteral(", note guid = ") << noteGuid); + QNTRACE("Parsed in-app note link: user id = " << userId << ", shard id = " + << shardId << ", note guid = " << noteGuid); Q_EMIT inAppNoteLinkClicked(userId, shardId, noteGuid); } -bool NoteEditorPrivate::parseInAppLink(const QString & urlString, QString & userId, - QString & shardId, QString & noteGuid, - ErrorString & errorDescription) const +bool NoteEditorPrivate::parseInAppLink( + const QString & urlString, QString & userId, + QString & shardId, QString & noteGuid, + ErrorString & errorDescription) const { userId.resize(0); shardId.resize(0); @@ -3784,10 +3790,11 @@ QRegExp regex(QStringLiteral("evernote:///view/([^/]+)/([^/]+)/([^/]+)(/.*)?")); int pos = regex.indexIn(urlString); - if (pos < 0) { - errorDescription.setBase(QT_TR_NOOP("Can't process the in-app note link: " - "failed to parse the note guid from " - "the link")); + if (pos < 0) + { + errorDescription.setBase( + QT_TR_NOOP("Can't process the in-app note link: " + "failed to parse the note guid from the link")); errorDescription.details() = urlString; return false; } @@ -3795,8 +3802,9 @@ QStringList capturedTexts = regex.capturedTexts(); if (capturedTexts.size() != 5) { - errorDescription.setBase(QT_TR_NOOP("Can't process the in-app note link: " - "wrong number of captured texts")); + errorDescription.setBase( + QT_TR_NOOP("Can't process the in-app note link: " + "wrong number of captured texts")); errorDescription.details() = urlString; if (!capturedTexts.isEmpty()) { errorDescription.details() += @@ -3812,15 +3820,16 @@ return true; } -bool NoteEditorPrivate::checkNoteSize(const QString & newNoteContent, - ErrorString & errorDescription) const +bool NoteEditorPrivate::checkNoteSize( + const QString & newNoteContent, ErrorString & errorDescription) const { - QNDEBUG(QStringLiteral("NoteEditorPrivate::checkNoteSize")); + QNDEBUG("NoteEditorPrivate::checkNoteSize"); - if (Q_UNLIKELY(m_pNote.isNull())) { - errorDescription.setBase(QT_TR_NOOP("Internal error: can't check the note " - "size on note editor update: " - "no note is set to the editor")); + if (Q_UNLIKELY(m_pNote.isNull())) + { + errorDescription.setBase( + QT_TR_NOOP("Internal error: can't check the note size on note " + "editor update: no note is set to the editor")); QNWARNING(errorDescription); return false; } @@ -3828,14 +3837,14 @@ qint64 noteSize = noteResourcesSize(); noteSize += newNoteContent.size(); - QNTRACE(QStringLiteral("New note content size = ") << newNoteContent.size() - << QStringLiteral(", total note size = ") << noteSize); + QNTRACE("New note content size = " << newNoteContent.size() + << ", total note size = " << noteSize); if (m_pNote->hasNoteLimits()) { const qevercloud::NoteLimits & noteLimits = m_pNote->noteLimits(); - QNTRACE(QStringLiteral("Note has its own limits, will use them to check ") - << QStringLiteral("the note size: ") << noteLimits); + QNTRACE("Note has its own limits, will use them to check " + << "the note size: " << noteLimits); if (noteLimits.noteSizeMax.isSet() && (Q_UNLIKELY(noteLimits.noteSizeMax.ref() < noteSize))) @@ -3850,8 +3859,8 @@ } else { - QNTRACE(QStringLiteral("Note has no its own limits, will use " - "the account-wise limits to check the note size")); + QNTRACE("Note has no its own limits, will use " + "the account-wise limits to check the note size"); if (Q_UNLIKELY(!m_pAccount)) { @@ -3879,14 +3888,14 @@ void NoteEditorPrivate::pushNoteContentEditUndoCommand() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::pushNoteTextEditUndoCommand")); + QNDEBUG("NoteEditorPrivate::pushNoteTextEditUndoCommand"); - QUENTIER_CHECK_PTR(m_pUndoStack, QStringLiteral("Undo stack for note editor " - "wasn't initialized")); + QUENTIER_CHECK_PTR(m_pUndoStack, + QStringLiteral("Undo stack for note editor " + "wasn't initialized")); if (Q_UNLIKELY(m_pNote.isNull())) { - QNINFO(QStringLiteral("Ignoring the content changed signal as the note " - "pointer is null")); + QNINFO("Ignoring the content changed signal as the note pointer is null"); return; } @@ -3898,7 +3907,8 @@ NoteEditorContentEditUndoCommand * pCommand = new NoteEditorContentEditUndoCommand(*this, resources); QObject::connect(pCommand, - QNSIGNAL(NoteEditorContentEditUndoCommand,notifyError,ErrorString), + QNSIGNAL(NoteEditorContentEditUndoCommand,notifyError, + ErrorString), this, QNSLOT(NoteEditorPrivate,onUndoCommandError,ErrorString)); m_pUndoStack->push(pCommand); @@ -3919,8 +3929,7 @@ void NoteEditorPrivate::onManagedPageActionFinished( const QVariant & result, const QVector<QPair<QString, QString> > & extraData) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onManagedPageActionFinished: ") - << result); + QNDEBUG("NoteEditorPrivate::onManagedPageActionFinished: " << result); Q_UNUSED(extraData) QMap<QString,QVariant> resultMap = result.toMap(); @@ -3957,7 +3966,7 @@ void NoteEditorPrivate::updateJavaScriptBindings() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::updateJavaScriptBindings")); + QNDEBUG("NoteEditorPrivate::updateJavaScriptBindings"); updateColResizableTableBindings(); @@ -3976,14 +3985,14 @@ void NoteEditorPrivate::changeFontSize(const bool increase) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::changeFontSize: increase = ") - << (increase ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("NoteEditorPrivate::changeFontSize: increase = " + << (increase ? "true" : "false")); int fontSize = m_font.pointSize(); if (fontSize < 0) { - QNTRACE(QStringLiteral("Font size is negative which most likely means " - "the font is not set yet, nothing to do. " - "Current font: ") << m_font); + QNTRACE("Font size is negative which most likely means " + << "the font is not set yet, nothing to do. " + << "Current font: " << m_font); return; } @@ -3991,18 +4000,17 @@ QList<int> fontSizes = fontDatabase.pointSizes(m_font.family(), m_font.styleName()); if (fontSizes.isEmpty()) { - QNTRACE(QStringLiteral("Coulnd't find point sizes for font family ") - << m_font.family() - << QStringLiteral(", will use standard sizes instead")); + QNTRACE("Coulnd't find point sizes for font family " + << m_font.family() << ", will use standard sizes instead"); fontSizes = fontDatabase.standardSizes(); } int fontSizeIndex = fontSizes.indexOf(fontSize); if (fontSizeIndex < 0) { - QNTRACE(QStringLiteral("Couldn't find font size ") << fontSize - << QStringLiteral(" within the available sizes, will take " - "the closest one instead")); + QNTRACE("Couldn't find font size " << fontSize + << " within the available sizes, will take " + << "the closest one instead"); const int numFontSizes = fontSizes.size(); int currentSmallestDiscrepancy = 1e5; int currentClosestIndex = -1; @@ -4014,8 +4022,8 @@ if (currentSmallestDiscrepancy > discrepancy) { currentSmallestDiscrepancy = discrepancy; currentClosestIndex = i; - QNTRACE(QStringLiteral("Updated current closest index to ") << i - << QStringLiteral(": font size = ") << value); + QNTRACE("Updated current closest index to " << i + << ": font size = " << value); } } @@ -4033,21 +4041,18 @@ fontSize = fontSizes.at(fontSizeIndex - 1); } else { - QNTRACE(QStringLiteral("Can't ") - << (increase - ? QStringLiteral("increase") - : QStringLiteral("decrease")) - << QStringLiteral(" the font size: hit the boundary of " - "available font sizes")); + QNTRACE("Can't " << (increase ? "increase" : "decrease") + << " the font size: hit the boundary of " + << "available font sizes"); return; } } else { - QNTRACE(QStringLiteral("Wasn't able to find even the closest font size " - "within the available ones, will simply ") - << (increase ? QStringLiteral("increase") : QStringLiteral("decrease")) - << QStringLiteral(" the given font size by 1 pt and see what happens")); + QNTRACE("Wasn't able to find even the closest font size " + << "within the available ones, will simply " + << (increase ? "increase" : "decrease") + << " the given font size by 1 pt and see what happens"); if (increase) { ++fontSize; @@ -4066,8 +4071,8 @@ void NoteEditorPrivate::changeIndentation(const bool increase) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::changeIndentation: increase = ") - << (increase ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("NoteEditorPrivate::changeIndentation: increase = " + << (increase ? "true" : "false")); execJavascriptCommand(increase ? QStringLiteral("indent") : QStringLiteral("outdent")); @@ -4079,11 +4084,11 @@ const bool searchBackward, NoteEditorPage::Callback callback) const { - QNDEBUG(QStringLiteral("NoteEditorPrivate::findText: ") << textToFind - << QStringLiteral("; match case = ") - << (matchCase ? QStringLiteral("true") : QStringLiteral("false")) - << QStringLiteral(", search backward = ") - << (searchBackward ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("NoteEditorPrivate::findText: " << textToFind + << "; match case = " + << (matchCase ? "true" : "false") + << ", search backward = " + << (searchBackward ? "true" : "false")); GET_PAGE() @@ -4135,11 +4140,10 @@ const bool matchCase, const bool force) const { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setSearchHighlight: ") - << textToFind << QStringLiteral("; match case = ") - << (matchCase ? QStringLiteral("true") : QStringLiteral("false")) - << QStringLiteral("; force = ") - << (force ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("NoteEditorPrivate::setSearchHighlight: " + << textToFind << "; match case = " + << (matchCase ? "true" : "false") + << "; force = " << (force ? "true" : "false")); if ( !force && (textToFind.compare(m_lastSearchHighlightedText, @@ -4148,8 +4152,8 @@ : Qt::CaseInsensitive)) == 0) && (m_lastSearchHighlightedTextCaseSensitivity == matchCase) ) { - QNTRACE(QStringLiteral("The text to find matches the one highlighted " - "the last time as well as its case sensitivity")); + QNTRACE("The text to find matches the one highlighted " + "the last time as well as its case sensitivity"); return; } @@ -4170,16 +4174,17 @@ highlightRecognizedImageAreas(textToFind, matchCase); } -void NoteEditorPrivate::highlightRecognizedImageAreas(const QString & textToFind, - const bool matchCase) const +void NoteEditorPrivate::highlightRecognizedImageAreas( + const QString & textToFind, const bool matchCase) const { - QNDEBUG(QStringLiteral("NoteEditorPrivate::highlightRecognizedImageAreas")); + QNDEBUG("NoteEditorPrivate::highlightRecognizedImageAreas"); GET_PAGE() - page->executeJavaScript(QStringLiteral("imageAreasHilitor.clearImageHilitors();")); + page->executeJavaScript( + QStringLiteral("imageAreasHilitor.clearImageHilitors();")); if (m_lastSearchHighlightedText.isEmpty()) { - QNTRACE(QStringLiteral("Last search highlighted text is empty")); + QNTRACE("Last search highlighted text is empty"); return; } @@ -4187,7 +4192,7 @@ escapeStringForJavaScript(escapedTextToFind); if (escapedTextToFind.isEmpty()) { - QNTRACE(QStringLiteral("Escaped search highlighted text is empty")); + QNTRACE("Escaped search highlighted text is empty"); return; } @@ -4196,7 +4201,7 @@ { const QByteArray & resourceHash = it.key(); const ResourceRecognitionIndices & recoIndices = it.value(); - QNTRACE(QStringLiteral("Processing recognition data for resource hash ") + QNTRACE("Processing recognition data for resource hash " << resourceHash.toHex()); QVector<ResourceRecognitionIndexItem> recoIndexItems = recoIndices.items(); @@ -4211,14 +4216,15 @@ bool matchFound = false; for(int k = 0; k < numTextItems; ++k) { - const ResourceRecognitionIndexItem::TextItem & textItem = textItems[k]; + const ResourceRecognitionIndexItem::TextItem & textItem = + textItems[k]; if (textItem.m_text.contains(textToFind, (matchCase ? Qt::CaseSensitive : Qt::CaseInsensitive))) { - QNTRACE(QStringLiteral("Found text item matching with " - "the text to find: ") << textItem.m_text); + QNTRACE("Found text item matching with the text to find: " + << textItem.m_text); matchFound = true; } } @@ -4237,11 +4243,11 @@ } } -void NoteEditorPrivate::clearEditorContent(const BlankPageKind::type kind, - const ErrorString & errorDescription) +void NoteEditorPrivate::clearEditorContent( + const BlankPageKind::type kind, const ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::clearEditorContent: blank page kind = ") - << kind << QStringLiteral(", error description = ") << errorDescription); + QNDEBUG("NoteEditorPrivate::clearEditorContent: blank page kind = " + << kind << ", error description = " << errorDescription); if (m_pageToNoteContentPostponeTimerId != 0) { killTimer(m_pageToNoteContentPostponeTimerId); @@ -4291,10 +4297,10 @@ void NoteEditorPrivate::noteToEditorContent() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::noteToEditorContent")); + QNDEBUG("NoteEditorPrivate::noteToEditorContent"); if (m_pNote.isNull()) { - QNDEBUG(QStringLiteral("No note has been set yet")); + QNDEBUG("No note has been set yet"); clearEditorContent(); return; } @@ -4309,8 +4315,8 @@ noteContent = m_pNote->content(); } else { - QNDEBUG(QStringLiteral("Note without content was inserted into the NoteEditor, " - "setting up the empty note content")); + QNDEBUG("Note without content was inserted into the NoteEditor, " + "setting up the empty note content"); noteContent = QStringLiteral("<en-note><div></div></en-note>"); } @@ -4340,8 +4346,8 @@ { ErrorString error(QT_TR_NOOP("Can't find <body> tag in the result of note " "to HTML conversion")); - QNWARNING(error << QStringLiteral(", note content: ") << m_pNote->content() - << QStringLiteral(", html: ") << m_htmlCachedMemory); + QNWARNING(error << ", note content: " << m_pNote->content() + << ", html: " << m_htmlCachedMemory); clearEditorContent(BlankPageKind::InternalError, error); Q_EMIT notifyError(error); return; @@ -4355,8 +4361,8 @@ { error.setBase(QT_TR_NOOP("Can't find </body> tag in the result of note " "to HTML conversion")); - QNWARNING(error << QStringLiteral(", note content: ") << m_pNote->content() - << QStringLiteral(", html: ") << m_htmlCachedMemory); + QNWARNING(error << ", note content: " << m_pNote->content() + << ", html: " << m_htmlCachedMemory); clearEditorContent(BlankPageKind::InternalError, error); Q_EMIT notifyError(error); return; @@ -4365,13 +4371,13 @@ m_htmlCachedMemory.insert(bodyClosingTagIndex + 7, QStringLiteral("</html>")); // Webkit-specific fix m_htmlCachedMemory.replace(QStringLiteral("<br></br>"), QStringLiteral("</br>")); - QNTRACE(QStringLiteral("Note page HTML: ") << m_htmlCachedMemory); + QNTRACE("Note page HTML: " << m_htmlCachedMemory); writeNotePageFile(m_htmlCachedMemory); } void NoteEditorPrivate::updateColResizableTableBindings() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::updateColResizableTableBindings")); + QNDEBUG("NoteEditorPrivate::updateColResizableTableBindings"); bool readOnly = !isPageEditable(); @@ -4389,7 +4395,7 @@ void NoteEditorPrivate::inkNoteToEditorContent() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::inkNoteToEditorContent")); + QNDEBUG("NoteEditorPrivate::inkNoteToEditorContent"); m_lastFreeEnToDoIdNumber = 1; m_lastFreeHyperlinkIdNumber = 1; @@ -4408,17 +4414,17 @@ const Resource & resource = resources[i]; if (!resource.hasGuid()) { - QNWARNING(QStringLiteral("Detected ink note which has at least one ") - << QStringLiteral("resource without guid: note = ") - << *m_pNote << QStringLiteral("\nResource: ") << resource); + QNWARNING("Detected ink note which has at least one " + << "resource without guid: note = " << *m_pNote + << "\nResource: " << resource); problemDetected = true; break; } if (!resource.hasDataHash()) { - QNWARNING(QStringLiteral("Detected ink note which has at least one ") - << QStringLiteral("resource without data hash: note = ") - << *m_pNote << QStringLiteral("\nResource: ") << resource); + QNWARNING("Detected ink note which has at least one " + << "resource without data hash: note = " << *m_pNote + << "\nResource: " << resource); problemDetected = true; break; } @@ -4430,8 +4436,8 @@ !inkNoteImageFileInfo.isFile() || !inkNoteImageFileInfo.isReadable()) { - QNWARNING(QStringLiteral("Detected broken or nonexistent ink note ") - << QStringLiteral("image file, check file at path ") + QNWARNING("Detected broken or nonexistent ink note " + << "image file, check file at path " << inkNoteImageFileInfo.absoluteFilePath()); problemDetected = true; break; @@ -4439,8 +4445,9 @@ QString inkNoteImageFilePath = inkNoteImageFileInfo.absoluteFilePath(); escapeStringForJavaScript(inkNoteImageFilePath); - if (Q_UNLIKELY(inkNoteImageFilePath.isEmpty())) { - QNWARNING(QStringLiteral("Unable to escape the ink note image file path: ") + if (Q_UNLIKELY(inkNoteImageFilePath.isEmpty())) + { + QNWARNING("Unable to escape the ink note image file path: " << inkNoteImageFileInfo.absoluteFilePath()); problemDetected = true; break; @@ -4474,13 +4481,13 @@ inkNoteHtml += QStringLiteral("</div></body></html>"); } - QNTRACE(QStringLiteral("Ink note html: ") << inkNoteHtml); + QNTRACE("Ink note html: " << inkNoteHtml); writeNotePageFile(inkNoteHtml); } bool NoteEditorPrivate::htmlToNoteContent(ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::htmlToNoteContent")); + QNDEBUG("NoteEditorPrivate::htmlToNoteContent"); if (m_pNote.isNull()) { errorDescription.setBase(QT_TR_NOOP("No note was set to note editor")); @@ -4492,10 +4499,10 @@ if (m_pNote->hasActive() && !m_pNote->active()) { errorDescription.setBase(QT_TR_NOOP("Current note is marked as read-only, " "the changes won't be saved")); - QNINFO(errorDescription << QStringLiteral(", note: local uid = ") - << m_pNote->localUid() << QStringLiteral(", guid = ") + QNINFO(errorDescription << ", note: local uid = " + << m_pNote->localUid() << ", guid = " << (m_pNote->hasGuid() ? m_pNote->guid() : QStringLiteral("<null>")) - << QStringLiteral(", title = ") + << ", title = " << (m_pNote->hasTitle() ? m_pNote->title() : QStringLiteral("<null>"))); Q_EMIT cantConvertToNote(errorDescription); return false; @@ -4510,23 +4517,19 @@ "belongs to doesn't allow notes " "modification, the changes won't " "be saved")); - QNINFO(errorDescription - << QStringLiteral(", note: local uid = ") << m_pNote->localUid() - << QStringLiteral(", guid = ") - << (m_pNote->hasGuid() + QNINFO(errorDescription << ", note: local uid = " + << m_pNote->localUid() << ", guid = " << (m_pNote->hasGuid() ? m_pNote->guid() : QStringLiteral("<null>")) - << QStringLiteral(", title = ") - << (m_pNote->hasTitle() + << ", title = " << (m_pNote->hasTitle() ? m_pNote->title() : QStringLiteral("<null>")) - << QStringLiteral(", notebook: local uid = ") - << m_pNotebook->localUid() << QStringLiteral(", guid = ") + << ", notebook: local uid = " << m_pNotebook->localUid() + << ", guid = " << (m_pNotebook->hasGuid() ? m_pNotebook->guid() : QStringLiteral("<null>")) - << QStringLiteral(", name = ") - << (m_pNotebook->hasName() + << ", name = " << (m_pNotebook->hasName() ? m_pNotebook->name() : QStringLiteral("<null>"))); Q_EMIT cantConvertToNote(errorDescription); @@ -4549,11 +4552,11 @@ return true; } -void NoteEditorPrivate::updateHashForResourceTag(const QByteArray & oldResourceHash, - const QByteArray & newResourceHash) +void NoteEditorPrivate::updateHashForResourceTag( + const QByteArray & oldResourceHash, const QByteArray & newResourceHash) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::updateHashForResourceTag: old hash = ") - << oldResourceHash.toHex() << QStringLiteral(", new hash = ") + QNDEBUG("NoteEditorPrivate::updateHashForResourceTag: old hash = " + << oldResourceHash.toHex() << ", new hash = " << newResourceHash.toHex()); GET_PAGE() @@ -4567,7 +4570,7 @@ void NoteEditorPrivate::provideSrcForResourceImgTags() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::provideSrcForResourceImgTags")); + QNDEBUG("NoteEditorPrivate::provideSrcForResourceImgTags"); GET_PAGE() page->executeJavaScript(QStringLiteral("provideSrcForResourceImgTags();")); @@ -4575,13 +4578,13 @@ void NoteEditorPrivate::manualSaveResourceToFile(const Resource & resource) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::manualSaveResourceToFile")); + QNDEBUG("NoteEditorPrivate::manualSaveResourceToFile"); if (Q_UNLIKELY(!resource.hasDataBody() && !resource.hasAlternateDataBody())) { ErrorString error(QT_TR_NOOP("Can't save resource to file: resource has " "neither data body nor alternate data body")); - QNINFO(error << QStringLiteral(", resource: ") << resource); + QNINFO(error << ", resource: " << resource); Q_EMIT notifyError(error); return; } @@ -4589,7 +4592,7 @@ if (Q_UNLIKELY(!resource.hasMime())) { ErrorString error(QT_TR_NOOP("Can't save resource to file: resource has " "no mime type")); - QNINFO(error << QStringLiteral(", resource: ") << resource); + QNINFO(error << ", resource: " << resource); Q_EMIT notifyError(error); return; } @@ -4615,7 +4618,7 @@ if (Q_UNLIKELY(!mimeType.isValid())) { ErrorString error(QT_TR_NOOP("Can't save resource to file: can't " "identify resource's mime type")); - QNINFO(error << QStringLiteral(", mime type name: ") << mimeTypeName); + QNINFO(error << ", mime type name: " << mimeTypeName); Q_EMIT notifyError(error); return; } @@ -4672,8 +4675,8 @@ childGroups.indexOf(NOTE_EDITOR_ATTACHMENT_SAVE_LOCATIONS_KEY); if (attachmentsSaveLocGroupIndex >= 0) { - QNTRACE(QStringLiteral("Found cached attachment save location group " - "within application settings")); + QNTRACE("Found cached attachment save location group " + "within application settings"); appSettings.beginGroup(NOTE_EDITOR_ATTACHMENT_SAVE_LOCATIONS_KEY); QStringList cachedFileSuffixes = appSettings.childKeys(); @@ -4683,43 +4686,38 @@ preferredSuffix = preferredSuffixes[i]; int indexInCache = cachedFileSuffixes.indexOf(preferredSuffix); if (indexInCache < 0) { - QNTRACE(QStringLiteral("Haven't found cached attachment save ") - << QStringLiteral("directory for file suffix ") - << preferredSuffix); + QNTRACE("Haven't found cached attachment save " + << "directory for file suffix " << preferredSuffix); continue; } QVariant dirValue = appSettings.value(preferredSuffix); if (dirValue.isNull() || !dirValue.isValid()) { - QNTRACE(QStringLiteral("Found inappropriate attachment save ") - << QStringLiteral("directory for file suffix ") - << preferredSuffix); + QNTRACE("Found inappropriate attachment save " + << "directory for file suffix " << preferredSuffix); continue; } QFileInfo dirInfo(dirValue.toString()); if (!dirInfo.exists()) { - QNTRACE(QStringLiteral("Cached attachment save directory for ") - << QStringLiteral("file suffix ") << preferredSuffix - << QStringLiteral(" does not exist: ") - << dirInfo.absolutePath()); + QNTRACE("Cached attachment save directory for " + << "file suffix " << preferredSuffix + << " does not exist: " << dirInfo.absolutePath()); continue; } else if (!dirInfo.isDir()) { - QNTRACE(QStringLiteral("Cached attachment save directory for ") - << QStringLiteral("file suffix ") << preferredSuffix - << QStringLiteral(" is not a directory: ") - << dirInfo.absolutePath()); + QNTRACE("Cached attachment save directory for " + << "file suffix " << preferredSuffix + << " is not a directory: " << dirInfo.absolutePath()); continue; } else if (!dirInfo.isWritable()) { - QNTRACE(QStringLiteral("Cached attachment save directory for ") - << QStringLiteral("file suffix ") << preferredSuffix - << QStringLiteral(" is not writable: ") - << dirInfo.absolutePath()); + QNTRACE("Cached attachment save directory for " + << "file suffix " << preferredSuffix + << " is not writable: " << dirInfo.absolutePath()); continue; } @@ -4742,7 +4740,7 @@ preferredFolderPath, filterString, pSelectedFilter); if (absoluteFilePath.isEmpty()) { - QNINFO(QStringLiteral("User cancelled saving resource to file")); + QNINFO("User cancelled saving resource to file"); return; } @@ -4770,22 +4768,22 @@ Q_UNUSED(m_manualSaveResourceToFileRequestIds.insert(saveResourceToFileRequestId)); Q_EMIT saveResourceToFile(absoluteFilePath, data, saveResourceToFileRequestId, /* append = */ false); - QNDEBUG(QStringLiteral("Sent request to manually save resource to file, request id = ") - << saveResourceToFileRequestId << QStringLiteral(", resource local uid = ") + QNDEBUG("Sent request to manually save resource to file, request id = " + << saveResourceToFileRequestId << ", resource local uid = " << resource.localUid()); } QImage NoteEditorPrivate::buildGenericResourceImage(const Resource & resource) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::buildGenericResourceImage: ") - << QStringLiteral("resource local uid = ") << resource.localUid()); + QNDEBUG("NoteEditorPrivate::buildGenericResourceImage: " + << "resource local uid = " << resource.localUid()); QString resourceDisplayName = resource.displayName(); if (Q_UNLIKELY(resourceDisplayName.isEmpty())) { resourceDisplayName = tr("Attachment"); } - QNTRACE(QStringLiteral("Resource display name = ") << resourceDisplayName); + QNTRACE("Resource display name = " << resourceDisplayName); QFont font = m_font; font.setPointSize(10); @@ -4836,8 +4834,8 @@ if (!smartReplaceWorked) { - QNTRACE(QStringLiteral("Wasn't able to shorten the resource name nicely, " - "will try to shorten it just somehow")); + QNTRACE("Wasn't able to shorten the resource name nicely, " + "will try to shorten it just somehow"); width = fontMetrics.width(originalResourceDisplayName); int widthOverflow = width - maxResourceDisplayNameWidth; int numCharsToSkip = (widthOverflow + ellipsisWidth) / singleCharWidth + 1; @@ -4852,8 +4850,8 @@ } } - QNTRACE(QStringLiteral("(possibly) shortened resource display name: ") - << resourceDisplayName << QStringLiteral(", width = ") + QNTRACE("(possibly) shortened resource display name: " + << resourceDisplayName << ", width = " << fontMetrics.width(resourceDisplayName)); QString resourceHumanReadableSize; @@ -4877,28 +4875,29 @@ { resourceIcon = QIcon::fromTheme(mimeType.genericIconName()); if (resourceIcon.isNull()) { - QNTRACE(QStringLiteral("Can't get icon from theme by name ") + QNTRACE("Can't get icon from theme by name " << mimeType.genericIconName()); useFallbackGenericResourceIcon = true; } } else { - QNTRACE(QStringLiteral("Can't get valid mime type for name ") + QNTRACE("Can't get valid mime type for name " << resourceMimeTypeName - << QStringLiteral(", will use fallback generic resource icon")); + << ", will use fallback generic resource icon"); useFallbackGenericResourceIcon = true; } } else { - QNINFO(QStringLiteral("Found resource without mime type set: ") << resource); - QNTRACE(QStringLiteral("Will use fallback generic resource icon")); + QNINFO("Found resource without mime type set: " << resource); + QNTRACE("Will use fallback generic resource icon"); useFallbackGenericResourceIcon = true; } if (useFallbackGenericResourceIcon) { - resourceIcon = QIcon(QStringLiteral(":/generic_resource_icons/png/attachment.png")); + resourceIcon = + QIcon(QStringLiteral(":/generic_resource_icons/png/attachment.png")); } QPixmap pixmap(230, 32); @@ -4934,25 +4933,26 @@ } #ifdef QUENTIER_USE_QT_WEB_ENGINE -void NoteEditorPrivate::saveGenericResourceImage(const Resource & resource, - const QImage & image) +void NoteEditorPrivate::saveGenericResourceImage( + const Resource & resource, const QImage & image) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::saveGenericResourceImage: ") - << QStringLiteral("resource local uid = ") << resource.localUid()); + QNDEBUG("NoteEditorPrivate::saveGenericResourceImage: " + << "resource local uid = " << resource.localUid()); if (Q_UNLIKELY(m_pNote.isNull())) { ErrorString error(QT_TR_NOOP("Can't save the generic resource image: " "no note is set to the editor")); - QNWARNING(error << QStringLiteral(", resource: ") << resource); + QNWARNING(error << ", resource: " << resource); Q_EMIT notifyError(error); return; } if (Q_UNLIKELY(!resource.hasDataHash() && !resource.hasAlternateDataHash())) { - ErrorString error(QT_TR_NOOP("Can't save generic resource image: resource " - "has neither data hash nor alternate data hash")); - QNWARNING(error << QStringLiteral(", resource: ") << resource); + ErrorString error(QT_TR_NOOP("Can't save generic resource image: " + "resource has neither data hash nor " + "alternate data hash")); + QNWARNING(error << ", resource: " << resource); Q_EMIT notifyError(error); return; } @@ -4965,9 +4965,9 @@ QUuid requestId = QUuid::createUuid(); Q_UNUSED(m_saveGenericResourceImageToFileRequestIds.insert(requestId)); - QNDEBUG(QStringLiteral("Emitting request to write generic resource image ") - << QStringLiteral("for resource with local uid ") - << resource.localUid() << QStringLiteral(", request id ") << requestId); + QNDEBUG("Emitting request to write generic resource image " + << "for resource with local uid " + << resource.localUid() << ", request id " << requestId); Q_EMIT saveGenericResourceImageToFile(m_pNote->localUid(), resource.localUid(), imageData, QStringLiteral("png"), (resource.hasDataHash() @@ -4978,10 +4978,10 @@ void NoteEditorPrivate::provideSrcAndOnClickScriptForImgEnCryptTags() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::provideSrcAndOnClickScriptForImgEnCryptTags")); + QNDEBUG("NoteEditorPrivate::provideSrcAndOnClickScriptForImgEnCryptTags"); if (Q_UNLIKELY(m_pNote.isNull())) { - QNTRACE(QStringLiteral("No note is set for the editor")); + QNTRACE("No note is set for the editor"); return; } @@ -4996,15 +4996,15 @@ void NoteEditorPrivate::setupGenericResourceImages() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setupGenericResourceImages")); + QNDEBUG("NoteEditorPrivate::setupGenericResourceImages"); if (m_pNote.isNull()) { - QNDEBUG(QStringLiteral("No note to build generic resource images for")); + QNDEBUG("No note to build generic resource images for"); return; } if (!m_pNote->hasResources()) { - QNDEBUG(QStringLiteral("Note has no resources, nothing to do")); + QNDEBUG("Note has no resources, nothing to do"); return; } @@ -5022,7 +5022,7 @@ { mimeTypeName = resource.mime(); if (mimeTypeName.startsWith(QStringLiteral("image/"))) { - QNTRACE(QStringLiteral("Skipping image resource ") << resource); + QNTRACE("Skipping image resource " << resource); continue; } } @@ -5032,32 +5032,31 @@ } if (resourceImagesCounter == 0) { - QNDEBUG(QStringLiteral("No generic resources requiring building custom " - "images were found")); + QNDEBUG("No generic resources requiring building custom images were " + "found"); return; } if (shouldWaitForResourceImagesToSave) { - QNTRACE(QStringLiteral("Some generic resource images are being saved " - "to files, waiting")); + QNTRACE("Some generic resource images are being saved to files, " + "waiting"); return; } - QNTRACE(QStringLiteral("All generic resource images are ready")); + QNTRACE("All generic resource images are ready"); provideSrcForGenericResourceImages(); setupGenericResourceOnClickHandler(); } bool NoteEditorPrivate::findOrBuildGenericResourceImage(const Resource & resource) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::findOrBuildGenericResourceImage: ") - << resource); + QNDEBUG("NoteEditorPrivate::findOrBuildGenericResourceImage: " << resource); if (!resource.hasDataHash() && !resource.hasAlternateDataHash()) { ErrorString errorDescription(QT_TR_NOOP("Found resource without either " "data hash or alternate data hash")); - QNWARNING(errorDescription << QStringLiteral(": ") << resource); + QNWARNING(errorDescription << ": " << resource); Q_EMIT notifyError(errorDescription); return true; } @@ -5068,20 +5067,19 @@ ? resource.dataHash() : resource.alternateDataHash()); - QNTRACE(QStringLiteral("Looking for existing generic resource image file " - "for resource with hash ") << resourceHash.toHex()); + QNTRACE("Looking for existing generic resource image file " + << "for resource with hash " << resourceHash.toHex()); auto it = m_genericResourceImageFilePathsByResourceHash.find(resourceHash); if (it != m_genericResourceImageFilePathsByResourceHash.end()) { - QNTRACE(QStringLiteral("Found generic resource image file path ") - << QStringLiteral("for resource with hash ") << resourceHash.toHex() - << QStringLiteral(" and local uid ") << localUid - << QStringLiteral(": ") << it.value()); + QNTRACE("Found generic resource image file path " + << "for resource with hash " << resourceHash.toHex() + << " and local uid " << localUid << ": " << it.value()); return false; } QImage img = buildGenericResourceImage(resource); if (img.isNull()) { - QNDEBUG(QStringLiteral("Can't build generic resource image")); + QNDEBUG("Can't build generic resource image"); return true; } @@ -5091,7 +5089,7 @@ void NoteEditorPrivate::provideSrcForGenericResourceImages() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::provideSrcForGenericResourceImages")); + QNDEBUG("NoteEditorPrivate::provideSrcForGenericResourceImages"); GET_PAGE() page->executeJavaScript(QStringLiteral("provideSrcForGenericResourceImages();")); @@ -5099,7 +5097,7 @@ void NoteEditorPrivate::setupGenericResourceOnClickHandler() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setupGenericResourceOnClickHandler")); + QNDEBUG("NoteEditorPrivate::setupGenericResourceOnClickHandler"); GET_PAGE() page->executeJavaScript(QStringLiteral("setupGenericResourceOnClickHandler();")); @@ -5107,11 +5105,11 @@ void NoteEditorPrivate::setupWebSocketServer() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setupWebSocketServer")); + QNDEBUG("NoteEditorPrivate::setupWebSocketServer"); if (m_pWebSocketServer->isListening()) { m_pWebSocketServer->close(); - QNDEBUG(QStringLiteral("Closed the already established web socket server")); + QNDEBUG("Closed the already established web socket server"); m_webSocketReady = false; } @@ -5123,7 +5121,7 @@ } m_webSocketServerPort = m_pWebSocketServer->serverPort(); - QNDEBUG(QStringLiteral("Using automatically selected websocket server port ") + QNDEBUG("Using automatically selected websocket server port " << m_webSocketServerPort); QObject::connect(m_pWebSocketClientWrapper, @@ -5135,7 +5133,7 @@ void NoteEditorPrivate::setupJavaScriptObjects() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setupJavaScriptObjects")); + QNDEBUG("NoteEditorPrivate::setupJavaScriptObjects"); QObject::connect(m_pEnCryptElementClickHandler, &EnCryptElementOnClickHandler::decrypt, @@ -5196,14 +5194,14 @@ m_pResizableImageJavaScriptHandler); m_pWebChannel->registerObject(QStringLiteral("spellCheckerDynamicHelper"), m_pSpellCheckerDynamicHandler); - QNDEBUG(QStringLiteral("Registered objects exposed to JavaScript")); + QNDEBUG("Registered objects exposed to JavaScript"); m_setUpJavaScriptObjects = true; } void NoteEditorPrivate::setupTextCursorPositionTracking() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setupTextCursorPositionTracking")); + QNDEBUG("NoteEditorPrivate::setupTextCursorPositionTracking"); QString javascript = QStringLiteral("setupTextCursorPositionTracking();"); @@ -5217,15 +5215,15 @@ const QByteArray & previousResourceHash, Resource updatedResource) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::updateResource: resource local uid = ") - << resourceLocalUid << QStringLiteral(", previous hash = ") - << previousResourceHash.toHex() << QStringLiteral(", updated resource: ") + QNDEBUG("NoteEditorPrivate::updateResource: resource local uid = " + << resourceLocalUid << ", previous hash = " + << previousResourceHash.toHex() << ", updated resource: " << updatedResource); if (Q_UNLIKELY(m_pNote.isNull())) { ErrorString error(QT_TR_NOOP("Can't update the resource: no note " "is set to the editor")); - QNWARNING(error << QStringLiteral(", updated resource: ") << updatedResource); + QNWARNING(error << ", updated resource: " << updatedResource); Q_EMIT notifyError(error); return; } @@ -5233,7 +5231,7 @@ if (Q_UNLIKELY(!updatedResource.hasNoteLocalUid())) { ErrorString error(QT_TR_NOOP("Can't update the resource: the updated " "resource has no note local uid")); - QNWARNING(error << QStringLiteral(", updated resource: ") << updatedResource); + QNWARNING(error << ", updated resource: " << updatedResource); Q_EMIT notifyError(error); return; } @@ -5241,7 +5239,7 @@ if (Q_UNLIKELY(!updatedResource.hasMime())) { ErrorString error(QT_TR_NOOP("Can't update the resource: the updated " "resource has no mime type")); - QNWARNING(error << QStringLiteral(", updated resource: ") << updatedResource); + QNWARNING(error << ", updated resource: " << updatedResource); Q_EMIT notifyError(error); return; } @@ -5249,30 +5247,33 @@ if (Q_UNLIKELY(!updatedResource.hasDataBody())) { ErrorString error(QT_TR_NOOP("Can't update the resource: the updated " "resource contains no data body")); - QNWARNING(error << QStringLiteral(", updated resource: ") << updatedResource); + QNWARNING(error << ", updated resource: " << updatedResource); Q_EMIT notifyError(error); return; } - if (!updatedResource.hasDataHash()) { - updatedResource.setDataHash(QCryptographicHash::hash(updatedResource.dataBody(), - QCryptographicHash::Md5)); - QNDEBUG(QStringLiteral("Set updated resource's data hash to ") + if (!updatedResource.hasDataHash()) + { + updatedResource.setDataHash( + QCryptographicHash::hash(updatedResource.dataBody(), + QCryptographicHash::Md5)); + QNDEBUG("Set updated resource's data hash to " << updatedResource.dataHash().toHex()); } if (!updatedResource.hasDataSize()) { updatedResource.setDataSize(updatedResource.dataBody().size()); - QNDEBUG(QStringLiteral("Set updated resource's data size to ") + QNDEBUG("Set updated resource's data size to " << updatedResource.dataSize()); } bool res = m_pNote->updateResource(updatedResource); - if (Q_UNLIKELY(!res)) { + if (Q_UNLIKELY(!res)) + { ErrorString error(QT_TR_NOOP("Can't update the resource: resource to be " "updated was not found within the note")); - QNWARNING(error << QStringLiteral(", updated resource: ") << updatedResource - << QStringLiteral("\nNote: ") << *m_pNote); + QNWARNING(error << ", updated resource: " << updatedResource + << "\nNote: " << *m_pNote); Q_EMIT notifyError(error); return; } @@ -5296,31 +5297,30 @@ Q_EMIT convertedToNote(*m_pNote); } -void NoteEditorPrivate::setupGenericTextContextMenu(const QStringList & extraData, - const QString & selectedHtml, - bool insideDecryptedTextFragment) -{ - QNDEBUG(QStringLiteral("NoteEditorPrivate::setupGenericTextContextMenu: ") - << QStringLiteral("selected html = ") << selectedHtml - << QStringLiteral("; inside decrypted text fragment = ") - << (insideDecryptedTextFragment - ? QStringLiteral("true") - : QStringLiteral("false"))); +void NoteEditorPrivate::setupGenericTextContextMenu( + const QStringList & extraData, const QString & selectedHtml, + bool insideDecryptedTextFragment) +{ + QNDEBUG("NoteEditorPrivate::setupGenericTextContextMenu: " + << "selected html = " << selectedHtml + << "; inside decrypted text fragment = " + << (insideDecryptedTextFragment ? "true" : "false")); m_lastSelectedHtml = selectedHtml; delete m_pGenericTextContextMenu; m_pGenericTextContextMenu = new QMenu(this); -#define ADD_ACTION_WITH_SHORTCUT(key, name, menu, slot, enabled, ...) \ - { \ - QAction * action = new QAction(name, menu); \ - action->setEnabled(enabled); \ - setupActionShortcut(key, QStringLiteral("" #__VA_ARGS__), *action); \ - QObject::connect(action, QNSIGNAL(QAction,triggered), \ - this, QNSLOT(NoteEditorPrivate,slot)); \ - menu->addAction(action); \ - } +#define ADD_ACTION_WITH_SHORTCUT(key, name, menu, slot, enabled, ...) \ + { \ + QAction * action = new QAction(name, menu); \ + action->setEnabled(enabled); \ + setupActionShortcut(key, QString::fromUtf8("" #__VA_ARGS__), *action); \ + QObject::connect(action, QNSIGNAL(QAction,triggered), \ + this, QNSLOT(NoteEditorPrivate,slot)); \ + menu->addAction(action); \ + } \ +// ADD_ACTION_WITH_SHORTCUT bool enabled = true; @@ -5365,7 +5365,8 @@ QObject::connect(action, QNSIGNAL(QAction,triggered), this, - QNSLOT(NoteEditorPrivate,onSpellCheckCorrectionAction)); + QNSLOT(NoteEditorPrivate, + onSpellCheckCorrectionAction)); m_pGenericTextContextMenu->addAction(action); } @@ -5491,10 +5492,11 @@ m_pGenericTextContextMenu->exec(m_lastContextMenuEventGlobalPos); } -void NoteEditorPrivate::setupImageResourceContextMenu(const QByteArray & resourceHash) +void NoteEditorPrivate::setupImageResourceContextMenu( + const QByteArray & resourceHash) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setupImageResourceContextMenu: ") - << QStringLiteral("resource hash = ") << resourceHash.toHex()); + QNDEBUG("NoteEditorPrivate::setupImageResourceContextMenu: " + << "resource hash = " << resourceHash.toHex()); m_currentContextMenuExtraData.m_resourceHash = resourceHash; @@ -5513,7 +5515,8 @@ ? (m_pAccount->type() != Account::Type::Evernote) : false); ADD_ACTION_WITH_SHORTCUT(ShortcutManager::RemoveAttachment, tr("Remove"), - m_pImageResourceContextMenu, removeAttachmentUnderCursor, + m_pImageResourceContextMenu, + removeAttachmentUnderCursor, canRemoveResource); Q_UNUSED(m_pImageResourceContextMenu->addSeparator()); @@ -5539,10 +5542,11 @@ m_pImageResourceContextMenu->exec(m_lastContextMenuEventGlobalPos); } -void NoteEditorPrivate::setupNonImageResourceContextMenu(const QByteArray & resourceHash) +void NoteEditorPrivate::setupNonImageResourceContextMenu( + const QByteArray & resourceHash) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setupNonImageResourceContextMenu: ") - << QStringLiteral("resource hash = ") << resourceHash.toHex()); + QNDEBUG("NoteEditorPrivate::setupNonImageResourceContextMenu: " + << "resource hash = " << resourceHash.toHex()); m_currentContextMenuExtraData.m_resourceHash = resourceHash; @@ -5570,7 +5574,7 @@ QClipboard * pClipboard = QApplication::clipboard(); if (pClipboard && pClipboard->mimeData(QClipboard::Clipboard)) { - QNTRACE(QStringLiteral("Clipboard buffer has something, adding paste action")); + QNTRACE("Clipboard buffer has something, adding paste action"); ADD_ACTION_WITH_SHORTCUT(QKeySequence::Paste, tr("Paste"), m_pNonImageResourceContextMenu, paste, m_isPageEditable); @@ -5584,12 +5588,10 @@ const QString & encryptedText, const QString & hint, const QString & id) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setupEncryptedTextContextMenu: ") - << QStringLiteral("cipher = ") << cipher - << QStringLiteral(", key length = ") << keyLength - << QStringLiteral(", encrypted text = ") << encryptedText - << QStringLiteral(", hint = ") << hint - << QStringLiteral(", en-crypt-id = ") << id); + QNDEBUG("NoteEditorPrivate::setupEncryptedTextContextMenu: " + << "cipher = " << cipher << ", key length = " << keyLength + << ", encrypted text = " << encryptedText << ", hint = " << hint + << ", en-crypt-id = " << id); m_currentContextMenuExtraData.m_encryptedText = encryptedText; m_currentContextMenuExtraData.m_keyLength = keyLength; @@ -5608,28 +5610,28 @@ m_pEncryptedTextContextMenu->exec(m_lastContextMenuEventGlobalPos); } -void NoteEditorPrivate::setupActionShortcut(const int key, const QString & context, - QAction & action) +void NoteEditorPrivate::setupActionShortcut( + const int key, const QString & context, QAction & action) { if (Q_UNLIKELY(!m_pAccount)) { - QNDEBUG(QStringLiteral("Can't set shortcut to the action: no account " - "is set to the note editor")); + QNDEBUG("Can't set shortcut to the action: no account " + "is set to the note editor"); return; } ShortcutManager shortcutManager; QKeySequence shortcut = shortcutManager.shortcut(key, *m_pAccount, context); if (!shortcut.isEmpty()) { - QNTRACE(QStringLiteral("Setting shortcut ") << shortcut - << QStringLiteral(" for action ") << action.objectName() - << QStringLiteral(" (") << action.text() << QStringLiteral(")")); + QNTRACE("Setting shortcut " << shortcut + << " for action " << action.objectName() + << " (" << action.text() << ")"); action.setShortcut(shortcut); } } void NoteEditorPrivate::setupFileIO() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setupFileIO")); + QNDEBUG("NoteEditorPrivate::setupFileIO"); QObject::connect(this, QNSIGNAL(NoteEditorPrivate,writeNoteHtmlToFile, @@ -5768,7 +5770,7 @@ void NoteEditorPrivate::setupSpellChecker() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setupSpellChecker")); + QNDEBUG("NoteEditorPrivate::setupSpellChecker"); QUENTIER_CHECK_PTR(m_pSpellChecker, QStringLiteral("no spell checker was " "passed to note editor")); @@ -5784,17 +5786,18 @@ void NoteEditorPrivate::setupScripts() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setupScripts")); + QNDEBUG("NoteEditorPrivate::setupScripts"); initNoteEditorResources(); QFile file; -#define SETUP_SCRIPT(scriptPathPart, scriptVarName) \ - file.setFileName(QStringLiteral( ":/" scriptPathPart)); \ - file.open(QIODevice::ReadOnly); \ - scriptVarName = QString::fromUtf8(file.readAll()); \ - file.close() +#define SETUP_SCRIPT(scriptPathPart, scriptVarName) \ + file.setFileName(QStringLiteral( ":/" scriptPathPart)); \ + file.open(QIODevice::ReadOnly); \ + scriptVarName = QString::fromUtf8(file.readAll()); \ + file.close() \ +// SETUP_SCRIPT SETUP_SCRIPT("javascript/jquery/jquery-2.1.3.min.js", m_jQueryJs); SETUP_SCRIPT("javascript/jquery/jquery-ui.min.js", m_jQueryUiJs); @@ -5895,7 +5898,7 @@ void NoteEditorPrivate::setupGeneralSignalSlotConnections() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setupGeneralSignalSlotConnections")); + QNDEBUG("NoteEditorPrivate::setupGeneralSignalSlotConnections"); QObject::connect(m_pTableResizeJavaScriptHandler, QNSIGNAL(TableResizeJavaScriptHandler,tableResized), @@ -6078,7 +6081,7 @@ void NoteEditorPrivate::setupNoteEditorPage() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setupNoteEditorPage")); + QNDEBUG("NoteEditorPrivate::setupNoteEditorPage"); NoteEditorPage * page = new NoteEditorPage(*this); @@ -6137,7 +6140,7 @@ m_pPluginFactory->setNote(*m_pNote); } - QNDEBUG(QStringLiteral("Setting note editor plugin factory to the page")); + QNDEBUG("Setting note editor plugin factory to the page"); page->setPluginFactory(m_pPluginFactory); #endif @@ -6145,12 +6148,12 @@ setupNoteEditorPageConnections(page); setPage(page); - QNTRACE(QStringLiteral("Done setting up new note editor page")); + QNTRACE("Done setting up new note editor page"); } void NoteEditorPrivate::setupNoteEditorPageConnections(NoteEditorPage * page) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setupNoteEditorPageConnections")); + QNDEBUG("NoteEditorPrivate::setupNoteEditorPageConnections"); QObject::connect(page, QNSIGNAL(NoteEditorPage,javaScriptLoaded), this, QNSLOT(NoteEditorPrivate,onJavaScriptLoaded)); @@ -6177,7 +6180,7 @@ void NoteEditorPrivate::setupTextCursorPositionJavaScriptHandlerConnections() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setupTextCursorPositionJavaScriptHandlerConnections")); + QNDEBUG("NoteEditorPrivate::setupTextCursorPositionJavaScriptHandlerConnections"); // Connect JavaScript glue object's signals to slots QObject::connect(m_pTextCursorPositionJavaScriptHandler, @@ -6357,7 +6360,7 @@ void NoteEditorPrivate::setupSkipRulesForHtmlToEnmlConversion() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setupSkipRulesForHtmlToEnmlConversion")); + QNDEBUG("NoteEditorPrivate::setupSkipRulesForHtmlToEnmlConversion"); m_skipRulesForHtmlToEnmlConversion.reserve(7); @@ -6503,7 +6506,7 @@ void NoteEditorPrivate::determineStatesForCurrentTextCursorPosition() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::determineStatesForCurrentTextCursorPosition")); + QNDEBUG("NoteEditorPrivate::determineStatesForCurrentTextCursorPosition"); QString javascript = QStringLiteral("if (typeof window[\"determineStatesForCurrentTextCursorPosition\"]" @@ -6516,7 +6519,7 @@ void NoteEditorPrivate::determineContextMenuEventTarget() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::determineContextMenuEventTarget")); + QNDEBUG("NoteEditorPrivate::determineContextMenuEventTarget"); QString javascript = QStringLiteral("determineContextMenuEventTarget(") + @@ -6531,8 +6534,8 @@ void NoteEditorPrivate::setPageEditable(const bool editable) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setPageEditable: ") - << (editable ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("NoteEditorPrivate::setPageEditable: " + << (editable ? "true" : "false")); GET_PAGE() @@ -6546,15 +6549,16 @@ (editable ? QStringLiteral("on") : QStringLiteral("off")) + QStringLiteral("'; void 0;"); page->executeJavaScript(javascript); - QNTRACE(QStringLiteral("Queued javascript to make page ") - << (editable ? QStringLiteral("editable") : QStringLiteral("non-editable")) - << QStringLiteral(": ") << javascript); + QNTRACE("Queued javascript to make page " + << (editable ? "editable" : "non-editable") + << ": " << javascript); #endif m_isPageEditable = editable; } -bool NoteEditorPrivate::checkContextMenuSequenceNumber(const quint64 sequenceNumber) const +bool NoteEditorPrivate::checkContextMenuSequenceNumber( + const quint64 sequenceNumber) const { return m_contextMenuSequenceNumber == sequenceNumber; } @@ -6562,7 +6566,7 @@ void NoteEditorPrivate::onPageHtmlReceived( const QString & html, const QVector<QPair<QString, QString> > & extraData) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onPageHtmlReceived")); + QNDEBUG("NoteEditorPrivate::onPageHtmlReceived"); Q_UNUSED(extraData) Q_EMIT noteEditorHtmlUpdated(html); @@ -6588,9 +6592,8 @@ if (Q_UNLIKELY(m_pNote->isInkNote())) { m_pendingConversionToNote = false; - QNINFO(QStringLiteral("Currently selected note is an ink note, it's not " - "editable hence won't respond to the unexpected " - "change of its HTML")); + QNINFO("Currently selected note is an ink note, it's not editable " + "hence won't respond to the unexpected change of its HTML"); Q_EMIT convertedToNote(*m_pNote); if (m_pendingConversionToNoteForSavingInLocalStorage) { @@ -6606,9 +6609,10 @@ m_htmlCachedMemory = html; m_enmlCachedMemory.resize(0); ErrorString error; - bool res = m_enmlConverter.htmlToNoteContent(m_htmlCachedMemory, m_enmlCachedMemory, - *m_decryptedTextManager, error, - m_skipRulesForHtmlToEnmlConversion); + bool res = m_enmlConverter.htmlToNoteContent( + m_htmlCachedMemory, m_enmlCachedMemory, + *m_decryptedTextManager, error, + m_skipRulesForHtmlToEnmlConversion); if (!res) { ErrorString errorDescription(QT_TR_NOOP("Can't convert note editor page's " @@ -6665,7 +6669,7 @@ void NoteEditorPrivate::onSelectedTextEncryptionDone( const QVariant & dummy, const QVector<QPair<QString,QString> > & extraData) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onSelectedTextEncryptionDone")); + QNDEBUG("NoteEditorPrivate::onSelectedTextEncryptionDone"); Q_UNUSED(dummy); Q_UNUSED(extraData); @@ -6688,7 +6692,7 @@ void NoteEditorPrivate::onTableActionDone( const QVariant & dummy, const QVector<QPair<QString,QString> > & extraData) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onTableActionDone")); + QNDEBUG("NoteEditorPrivate::onTableActionDone"); Q_UNUSED(dummy); Q_UNUSED(extraData); @@ -6697,10 +6701,10 @@ convertToNote(); } -int NoteEditorPrivate::resourceIndexByHash(const QList<Resource> & resources, - const QByteArray & resourceHash) const +int NoteEditorPrivate::resourceIndexByHash( + const QList<Resource> & resources, const QByteArray & resourceHash) const { - QNDEBUG(QStringLiteral("NoteEditorPrivate::resourceIndexByHash: hash = ") + QNDEBUG("NoteEditorPrivate::resourceIndexByHash: hash = " << resourceHash.toHex()); const int numResources = resources.size(); @@ -6720,8 +6724,8 @@ m_writeNoteHtmlToFileRequestId = QUuid::createUuid(); m_pendingIndexHtmlWritingToFile = true; QString pagePath = noteEditorPagePath(); - QNTRACE(QStringLiteral("Emitting the request to write note html to file: ") - << QStringLiteral("request id = ") << m_writeNoteHtmlToFileRequestId); + QNTRACE("Emitting the request to write note html to file: request id = " + << m_writeNoteHtmlToFileRequestId); Q_EMIT writeNoteHtmlToFile(pagePath, html.toUtf8(), m_writeNoteHtmlToFileRequestId, /* append = */ false); } @@ -6738,7 +6742,8 @@ int extraDataSize = extraData.size(); if (Q_UNLIKELY(extraDataSize != 5) && Q_UNLIKELY(extraDataSize != 6)) { - errorDescription.setBase(QT_TR_NOOP("Extra data from JavaScript has wrong size")); + errorDescription.setBase( + QT_TR_NOOP("Extra data from JavaScript has wrong size")); errorDescription.details() = QString::number(extraDataSize); return false; } @@ -6761,7 +6766,7 @@ void NoteEditorPrivate::setupPasteGenericTextMenuActions() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setupPasteGenericTextMenuActions")); + QNDEBUG("NoteEditorPrivate::setupPasteGenericTextMenuActions"); if (Q_UNLIKELY(!m_pGenericTextContextMenu)) { QNDEBUG("No generic text context menu, nothing to do"); @@ -6793,7 +6798,7 @@ } if (clipboardHasHtml || clipboardHasText || clipboardHasImage || clipboardHasUrls) { - QNTRACE(QStringLiteral("Clipboard buffer has something, adding paste action")); + QNTRACE("Clipboard buffer has something, adding paste action"); ADD_ACTION_WITH_SHORTCUT(QKeySequence::Paste, tr("Paste"), m_pGenericTextContextMenu, paste, m_isPageEditable); @@ -6801,8 +6806,7 @@ if (clipboardHasHtml) { - QNTRACE(QStringLiteral("Clipboard buffer has html, adding paste " - "unformatted action")); + QNTRACE("Clipboard buffer has html, adding paste unformatted action"); ADD_ACTION_WITH_SHORTCUT(ShortcutManager::PasteUnformatted, tr("Paste as unformatted text"), m_pGenericTextContextMenu, pasteUnformatted, @@ -6812,19 +6816,20 @@ Q_UNUSED(m_pGenericTextContextMenu->addSeparator()); } -void NoteEditorPrivate::setupParagraphSubMenuForGenericTextMenu(const QString & selectedHtml) +void NoteEditorPrivate::setupParagraphSubMenuForGenericTextMenu( + const QString & selectedHtml) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setupParagraphSubMenuForGenericTextMenu: ") - << QStringLiteral("selected html = ") << selectedHtml); + QNDEBUG("NoteEditorPrivate::setupParagraphSubMenuForGenericTextMenu: " + << "selected html = " << selectedHtml); if (Q_UNLIKELY(!m_pGenericTextContextMenu)) { - QNDEBUG(QStringLiteral("No generic text context menu, nothing to do")); + QNDEBUG("No generic text context menu, nothing to do"); return; } if (!isPageEditable()) { - QNDEBUG(QStringLiteral("Note is not editable, no paragraph sub-menu " - "actions are allowed")); + QNDEBUG("Note is not editable, no paragraph sub-menu " + "actions are allowed"); return; } @@ -6862,16 +6867,15 @@ void NoteEditorPrivate::setupStyleSubMenuForGenericTextMenu() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setupStyleSubMenuForGenericTextMenu")); + QNDEBUG("NoteEditorPrivate::setupStyleSubMenuForGenericTextMenu"); if (Q_UNLIKELY(!m_pGenericTextContextMenu)) { - QNDEBUG(QStringLiteral("No generic text context menu, nothing to do")); + QNDEBUG("No generic text context menu, nothing to do"); return; } if (!isPageEditable()) { - QNDEBUG(QStringLiteral("Note is not editable, no style sub-menu actions " - "are allowed")); + QNDEBUG("Note is not editable, no style sub-menu actions are allowed"); return; } @@ -6890,22 +6894,23 @@ void NoteEditorPrivate::setupSpellCheckerDictionariesSubMenuForGenericTextMenu() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setupSpellCheckerDictionariesSubMenuForGenericTextMenu")); + QNDEBUG("NoteEditorPrivate::" + "setupSpellCheckerDictionariesSubMenuForGenericTextMenu"); if (Q_UNLIKELY(!m_pGenericTextContextMenu)) { - QNDEBUG(QStringLiteral("No generic text context menu, nothing to do")); + QNDEBUG("No generic text context menu, nothing to do"); return; } if (Q_UNLIKELY(!m_pSpellChecker)) { - QNWARNING(QStringLiteral("No spell checker was set up for the note editor")); + QNWARNING("No spell checker was set up for the note editor"); return; } QVector<QPair<QString,bool> > availableDictionaries = m_pSpellChecker->listAvailableDictionaries(); if (Q_UNLIKELY(availableDictionaries.isEmpty())) { - QNDEBUG(QStringLiteral("The list of available dictionaries is empty")); + QNDEBUG("The list of available dictionaries is empty"); return; } @@ -6931,17 +6936,17 @@ void NoteEditorPrivate::rebuildRecognitionIndicesCache() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::rebuildRecognitionIndicesCache")); + QNDEBUG("NoteEditorPrivate::rebuildRecognitionIndicesCache"); m_recognitionIndicesByResourceHash.clear(); if (Q_UNLIKELY(m_pNote.isNull())) { - QNTRACE(QStringLiteral("No note is set")); + QNTRACE("No note is set"); return; } if (!m_pNote->hasResources()) { - QNTRACE(QStringLiteral("The note has no resources")); + QNTRACE("The note has no resources"); return; } @@ -6951,19 +6956,19 @@ { const Resource & resource = resources[i]; if (Q_UNLIKELY(!resource.hasDataHash())) { - QNDEBUG(QStringLiteral("Skipping the resource without the data hash: ") + QNDEBUG("Skipping the resource without the data hash: " << resource); continue; } if (!resource.hasRecognitionDataBody()) { - QNTRACE(QStringLiteral("Skipping the resource without recognition data body")); + QNTRACE("Skipping the resource without recognition data body"); continue; } ResourceRecognitionIndices recoIndices(resource.recognitionDataBody()); if (recoIndices.isNull() || !recoIndices.isValid()) { - QNTRACE(QStringLiteral("Skipping null/invalid resource recognition indices")); + QNTRACE("Skipping null/invalid resource recognition indices"); continue; } @@ -6973,10 +6978,10 @@ void NoteEditorPrivate::enableSpellCheck() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::enableSpellCheck")); + QNDEBUG("NoteEditorPrivate::enableSpellCheck"); if (!m_pSpellChecker->isReady()) { - QNTRACE(QStringLiteral("Spell checker is not ready")); + QNTRACE("Spell checker is not ready"); Q_EMIT spellCheckerNotReady(); return; } @@ -6988,7 +6993,7 @@ void NoteEditorPrivate::disableSpellCheck() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::disableSpellCheck")); + QNDEBUG("NoteEditorPrivate::disableSpellCheck"); m_currentNoteMisSpelledWords.clear(); removeSpellCheck(); @@ -6997,10 +7002,10 @@ void NoteEditorPrivate::refreshMisSpelledWordsList() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::refreshMisSpelledWordsList")); + QNDEBUG("NoteEditorPrivate::refreshMisSpelledWordsList"); if (m_pNote.isNull()) { - QNDEBUG(QStringLiteral("No note is set to the editor")); + QNDEBUG("No note is set to the editor"); return; } @@ -7023,20 +7028,20 @@ for(auto it = words.constBegin(), end = words.constEnd(); it != end; ++it) { const QString & originalWord = *it; - QNTRACE(QStringLiteral("Checking the word ") << originalWord); + QNTRACE("Checking word \"" << originalWord << "\""); QString word = originalWord; bool conversionResult = false; qint32 integerNumber = word.toInt(&conversionResult); if (conversionResult) { - QNTRACE(QStringLiteral("Skipping the integer number ") << word); + QNTRACE("Skipping the integer number " << word); continue; } qint64 longIntegerNumber = word.toLongLong(&conversionResult); if (conversionResult) { - QNTRACE(QStringLiteral("Skipping the long long integer number ") + QNTRACE("Skipping the long long integer number " << word); continue; } @@ -7046,37 +7051,35 @@ m_stringUtils.removePunctuation(word); if (word.isEmpty()) { - QNTRACE(QStringLiteral("Skipping the word which becomes empty after ") - << QStringLiteral("stripping off the punctuation: ") + QNTRACE("Skipping the word which becomes empty after " + << "stripping off the punctuation: " << originalWord); continue; } word = word.trimmed(); - QNTRACE(QStringLiteral("Checking the spelling of the \"adjusted\" word ") - << word); + QNTRACE("Checking the spelling of the \"adjusted\" word " << word); if (!m_pSpellChecker->checkSpell(word)) { - QNTRACE(QStringLiteral("Misspelled word: \"") << word - << QStringLiteral("\"")); + QNTRACE("Misspelled word: \"" << word << "\""); word = originalWord; m_stringUtils.removePunctuation(word); word = word.trimmed(); m_currentNoteMisSpelledWords << word; - QNTRACE(QStringLiteral("Word added to the list: ") << word); + QNTRACE("Word added to the list: " << word); } } } void NoteEditorPrivate::applySpellCheck(const bool applyToSelection) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::applySpellCheck: apply to selection = ") - << (applyToSelection ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("NoteEditorPrivate::applySpellCheck: apply to selection = " + << (applyToSelection ? "true" : "false")); if (m_currentNoteMisSpelledWords.isEmpty()) { - QNDEBUG(QStringLiteral("The list of current note misspelled words is empty, " - "nothing to apply")); + QNDEBUG("The list of current note misspelled words is empty, " + "nothing to apply"); return; } @@ -7097,7 +7100,7 @@ javascript.chop(3); // Remove trailing ", '"; javascript += QStringLiteral("); }"); - QNTRACE(QStringLiteral("Script: ") << javascript); + QNTRACE("Script: " << javascript); GET_PAGE() page->executeJavaScript( @@ -7109,7 +7112,7 @@ void NoteEditorPrivate::removeSpellCheck() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::removeSpellCheck")); + QNDEBUG("NoteEditorPrivate::removeSpellCheck"); GET_PAGE() page->executeJavaScript( @@ -7121,7 +7124,7 @@ void NoteEditorPrivate::enableDynamicSpellCheck() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::enableDynamicSpellCheck")); + QNDEBUG("NoteEditorPrivate::enableDynamicSpellCheck"); GET_PAGE() page->executeJavaScript( @@ -7131,7 +7134,7 @@ void NoteEditorPrivate::disableDynamicSpellCheck() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::disableDynamicSpellCheck")); + QNDEBUG("NoteEditorPrivate::disableDynamicSpellCheck"); GET_PAGE() page->executeJavaScript( @@ -7142,7 +7145,7 @@ void NoteEditorPrivate::onSpellCheckSetOrCleared( const QVariant & dummy, const QVector<QPair<QString, QString> > & extraData) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onSpellCheckSetOrCleared")); + QNDEBUG("NoteEditorPrivate::onSpellCheckSetOrCleared"); Q_UNUSED(dummy) Q_UNUSED(extraData) @@ -7160,22 +7163,25 @@ void NoteEditorPrivate::replaceDefaultPalette() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::replaceDefaultPalette")); + QNDEBUG("NoteEditorPrivate::replaceDefaultPalette"); QString css = bodyStyleCss(); escapeStringForJavaScript(css); QString javascript = QString::fromUtf8("replaceStyle('%1');").arg(css); - QNTRACE(QStringLiteral("Script: ") << javascript); + QNTRACE("Script: " << javascript); GET_PAGE() - page->executeJavaScript(javascript, NoteEditorCallbackFunctor<QVariant>(this, &NoteEditorPrivate::onDefaultPaletteReplaced)); + page->executeJavaScript(javascript, + NoteEditorCallbackFunctor<QVariant>( + this, + &NoteEditorPrivate::onDefaultPaletteReplaced)); } -void NoteEditorPrivate::onDefaultPaletteReplaced(const QVariant & data, - const QVector<QPair<QString,QString> > & extraData) +void NoteEditorPrivate::onDefaultPaletteReplaced( + const QVariant & data, const QVector<QPair<QString,QString> > & extraData) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onDefaultPaletteReplaced: ") << data); + QNDEBUG("NoteEditorPrivate::onDefaultPaletteReplaced: " << data); Q_UNUSED(extraData) @@ -7183,7 +7189,8 @@ auto statusIt = resultMap.find(QStringLiteral("status")); if (Q_UNLIKELY(statusIt == resultMap.end())) { - ErrorString error(QT_TR_NOOP("Can't parse the result of default palette replacing from JavaScript")); + ErrorString error(QT_TR_NOOP("Can't parse the result of default " + "palette replacing from JavaScript")); QNWARNING(error); Q_EMIT notifyError(error); return; @@ -7196,7 +7203,8 @@ auto errorIt = resultMap.find(QStringLiteral("error")); if (Q_UNLIKELY(errorIt == resultMap.end())) { - error.setBase(QT_TR_NOOP("Can't parse the error of default palette replacing from JavaScript")); + error.setBase(QT_TR_NOOP("Can't parse the error of default " + "palette replacing from JavaScript")); } else { error.setBase(QT_TR_NOOP("Can't replace default palette")); @@ -7211,10 +7219,10 @@ bool NoteEditorPrivate::isNoteReadOnly() const { - QNDEBUG(QStringLiteral("NoteEditorPrivate::isNoteReadOnly")); + QNDEBUG("NoteEditorPrivate::isNoteReadOnly"); if (m_pNote.isNull()) { - QNTRACE(QStringLiteral("No note is set to the editor")); + QNTRACE("No note is set to the editor"); return true; } @@ -7225,18 +7233,18 @@ if (noteRestrictions.noUpdateContent.isSet() && noteRestrictions.noUpdateContent.ref()) { - QNTRACE(QStringLiteral("Note has noUpdateContent restriction set to true")); + QNTRACE("Note has noUpdateContent restriction set to true"); return true; } } if (m_pNotebook.isNull()) { - QNTRACE(QStringLiteral("No notebook is set to the editor")); + QNTRACE("No notebook is set to the editor"); return true; } if (!m_pNotebook->hasRestrictions()) { - QNTRACE(QStringLiteral("Notebook has no restrictions")); + QNTRACE("Notebook has no restrictions"); return false; } @@ -7245,16 +7253,16 @@ if (restrictions.noUpdateNotes.isSet() && restrictions.noUpdateNotes.ref()) { - QNTRACE(QStringLiteral("Restriction on note updating applies")); + QNTRACE("Restriction on note updating applies"); return true; } return false; } -void NoteEditorPrivate::setupAddHyperlinkDelegate(const quint64 hyperlinkId, - const QString & presetHyperlink, - const QString & replacementLinkText) +void NoteEditorPrivate::setupAddHyperlinkDelegate( + const quint64 hyperlinkId, const QString & presetHyperlink, + const QString & replacementLinkText) { AddHyperlinkToSelectedTextDelegate * delegate = new AddHyperlinkToSelectedTextDelegate(*this, hyperlinkId); @@ -7284,48 +7292,52 @@ } } -#define COMMAND_TO_JS(command) \ - QString escapedCommand = command; \ - escapeStringForJavaScript(escapedCommand); \ - QString javascript = \ - QString::fromUtf8("managedPageAction(\"%1\", null)").arg(escapedCommand); \ - QNDEBUG(QStringLiteral("JS command: ") << javascript) - -#define COMMAND_WITH_ARGS_TO_JS(command, args) \ - QString escapedCommand = command; \ - escapeStringForJavaScript(escapedCommand); \ - QString escapedArgs = args; \ - escapeStringForJavaScript(escapedArgs); \ - QString javascript = QString::fromUtf8("managedPageAction('%1', '%2')")\ - .arg(escapedCommand,escapedArgs); \ - QNDEBUG(QStringLiteral("JS command: ") << javascript) +#define COMMAND_TO_JS(command) \ + QString escapedCommand = command; \ + escapeStringForJavaScript(escapedCommand); \ + QString javascript = \ + QString::fromUtf8("managedPageAction(\"%1\", null)") \ + .arg(escapedCommand); \ + QNDEBUG("JS command: " << javascript) \ +// COMMAND_TO_JS + +#define COMMAND_WITH_ARGS_TO_JS(command, args) \ + QString escapedCommand = command; \ + escapeStringForJavaScript(escapedCommand); \ + QString escapedArgs = args; \ + escapeStringForJavaScript(escapedArgs); \ + QString javascript = QString::fromUtf8("managedPageAction('%1', '%2')") \ + .arg(escapedCommand,escapedArgs); \ + QNDEBUG("JS command: " << javascript) \ +// COMMAND_WITH_ARGS_TO_JS #ifndef QUENTIER_USE_QT_WEB_ENGINE -QVariant NoteEditorPrivate::execJavascriptCommandWithResult(const QString & command) +QVariant NoteEditorPrivate::execJavascriptCommandWithResult( + const QString & command) { COMMAND_TO_JS(command); QWebFrame * frame = page()->mainFrame(); QVariant result = frame->evaluateJavaScript(javascript); - QNTRACE(QStringLiteral("Executed javascript command: ") << javascript - << QStringLiteral(", result = ") << result.toString()); + QNTRACE("Executed javascript command: " << javascript + << ", result = " << result.toString()); return result; } -QVariant NoteEditorPrivate::execJavascriptCommandWithResult(const QString & command, - const QString & args) +QVariant NoteEditorPrivate::execJavascriptCommandWithResult( + const QString & command, const QString & args) { COMMAND_WITH_ARGS_TO_JS(command, args); QWebFrame * frame = page()->mainFrame(); QVariant result = frame->evaluateJavaScript(javascript); - QNTRACE(QStringLiteral("Executed javascript command: ") << javascript - << QStringLiteral(", result = ") << result.toString()); + QNTRACE("Executed javascript command: " << javascript + << ", result = " << result.toString()); return result; } #endif void NoteEditorPrivate::execJavascriptCommand(const QString & command) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::execJavascriptCommand: ") << command); + QNDEBUG("NoteEditorPrivate::execJavascriptCommand: " << command); COMMAND_TO_JS(command); @@ -7335,11 +7347,11 @@ page->executeJavaScript(javascript, callback); } -void NoteEditorPrivate::execJavascriptCommand(const QString & command, - const QString & args) +void NoteEditorPrivate::execJavascriptCommand( + const QString & command, const QString & args) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::execJavascriptCommand: ") << command - << QStringLiteral("; args: ") << args); + QNDEBUG("NoteEditorPrivate::execJavascriptCommand: " << command + << "; args: " << args); COMMAND_WITH_ARGS_TO_JS(command, args); @@ -7349,11 +7361,12 @@ page->executeJavaScript(javascript, callback); } -void NoteEditorPrivate::initialize(LocalStorageManagerAsync & localStorageManager, - SpellChecker & spellChecker, const Account & account, - QThread * pBackgroundJobsThread) +void NoteEditorPrivate::initialize( + LocalStorageManagerAsync & localStorageManager, + SpellChecker & spellChecker, const Account & account, + QThread * pBackgroundJobsThread) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::initialize")); + QNDEBUG("NoteEditorPrivate::initialize"); NoteEditorLocalStorageBroker & noteEditorLocalStorageBroker = NoteEditorLocalStorageBroker::instance(); @@ -7370,14 +7383,14 @@ void NoteEditorPrivate::setAccount(const Account & account) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setAccount: ") << account.name()); + QNDEBUG("NoteEditorPrivate::setAccount: " << account.name()); if (!m_pAccount.isNull() && (m_pAccount->type() == account.type()) && (m_pAccount->name() == account.name()) && (m_pAccount->id() == account.id())) { - QNDEBUG(QStringLiteral("The account's type, name and id were not updated " - "so it's the update for the account currently set " - "to the note editor")); + QNDEBUG("The account's type, name and id were not updated " + "so it's the update for the account currently set " + "to the note editor"); *m_pAccount = account; return; } @@ -7396,7 +7409,7 @@ void NoteEditorPrivate::setUndoStack(QUndoStack * pUndoStack) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setUndoStack")); + QNDEBUG("NoteEditorPrivate::setUndoStack"); QUENTIER_CHECK_PTR(pUndoStack, QStringLiteral("null undo stack passed to note editor")); @@ -7405,7 +7418,7 @@ bool NoteEditorPrivate::print(QPrinter & printer, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::print")); + QNDEBUG("NoteEditorPrivate::print"); if (Q_UNLIKELY(!m_pNote)) { errorDescription.setBase(QT_TR_NOOP("Can't print note: no note is set " @@ -7457,7 +7470,8 @@ QString initialXml; QString htmlToXmlError; - bool htmlToXmlRes = htmlCleaner.htmlToXml(initialHtml, initialXml, htmlToXmlError); + bool htmlToXmlRes = htmlCleaner.htmlToXml(initialHtml, initialXml, + htmlToXmlError); if (Q_UNLIKELY(!htmlToXmlRes)) { errorDescription.setBase(QT_TR_NOOP("Can't print note: failed to convert " "the note editor's HTML to XML")); @@ -7531,7 +7545,7 @@ QByteArray hashAttrByteArray = QByteArray::fromHex(hashAttr.toLocal8Bit()); - QNTRACE(QStringLiteral("Will look for resource with hash ") + QNTRACE("Will look for resource with hash " << hashAttrByteArray); const Resource * pTargetResource = Q_NULLPTR; @@ -7539,7 +7553,7 @@ end = resources.constEnd(); it != end; ++it) { const Resource & resource = *it; - QNTRACE(QStringLiteral("Examining resource: data hash = ") + QNTRACE("Examining resource: data hash = " << (resource.hasDataHash() ? QString::fromLocal8Bit(resource.dataHash()) : QStringLiteral("<null>"))); @@ -7554,11 +7568,10 @@ if (Q_UNLIKELY(!pTargetResource)) { - errorDescription.setBase(QT_TR_NOOP("Can't print note: could " - "not find one of resources " - "referenced in the note " - "text within the actual " - "note's resources")); + errorDescription.setBase( + QT_TR_NOOP("Can't print note: could not find one of " + "resources referenced in the note text " + "within the actual note's resources")); errorDescription.details() = QStringLiteral("hash = "); errorDescription.details() += hashAttr; QNWARNING(errorDescription); @@ -7569,9 +7582,9 @@ buildGenericResourceImage(*pTargetResource); if (Q_UNLIKELY(genericResourceImage.isNull())) { - errorDescription.setBase(QT_TR_NOOP("Can't print note: could " - "not generate the generic " - "resource image")); + errorDescription.setBase( + QT_TR_NOOP("Can't print note: could not generate the " + "generic resource image")); QNWARNING(errorDescription); return false; } @@ -7640,13 +7653,11 @@ if (reader.isCDATA()) { writer.writeCDATA(reader.text().toString()); - QNTRACE(QStringLiteral("Wrote CDATA: ") - << reader.text().toString()); + QNTRACE("Wrote CDATA: " << reader.text().toString()); } else { writer.writeCharacters(reader.text().toString()); - QNTRACE(QStringLiteral("Wrote characters: ") - << reader.text().toString()); + QNTRACE("Wrote characters: " << reader.text().toString()); } } @@ -7675,7 +7686,7 @@ "the body tag within the preprocessed " "HTML prepared for conversion to " "QTextDocument")); - QNWARNING(errorDescription << QStringLiteral("; preprocessed HTML: ") + QNWARNING(errorDescription << "; preprocessed HTML: " << preprocessedHtml); return false; } @@ -7688,7 +7699,7 @@ "of the body tag within the preprocessed " "HTML prepared for conversion to " "QTextDocument")); - QNWARNING(errorDescription << QStringLiteral("; preprocessed HTML: ") + QNWARNING(errorDescription << "; preprocessed HTML: " << preprocessedHtml); return false; } @@ -7703,7 +7714,7 @@ "the enclosing body tag within " "the preprocessed HTML prepared " "for conversion to QTextDocument")); - QNWARNING(errorDescription << QStringLiteral("; preprocessed HTML: ") + QNWARNING(errorDescription << "; preprocessed HTML: " << preprocessedHtml); return false; } @@ -7823,10 +7834,10 @@ #endif // QUENTIER_USE_QT_WEB_ENGINE } -bool NoteEditorPrivate::exportToEnex(const QStringList & tagNames, - QString & enex, ErrorString & errorDescription) +bool NoteEditorPrivate::exportToEnex( + const QStringList & tagNames, QString & enex, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::exportToEnex")); + QNDEBUG("NoteEditorPrivate::exportToEnex"); if (Q_UNLIKELY(!m_pNote)) { errorDescription.setBase(QT_TR_NOOP("Can't export note to enex: no note " @@ -7883,7 +7894,7 @@ return false; } - QNDEBUG(QStringLiteral("Successfully saved the edited note")); + QNDEBUG("Successfully saved the edited note"); } QVector<Note> notes; @@ -7916,11 +7927,11 @@ void NoteEditorPrivate::setCurrentNoteLocalUid(const QString & noteLocalUid) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setCurrentNoteLocalUid: ") - << QStringLiteral("note local uid = ") << noteLocalUid); + QNDEBUG("NoteEditorPrivate::setCurrentNoteLocalUid: note local uid = " + << noteLocalUid); if (m_noteLocalUid == noteLocalUid) { - QNDEBUG(QStringLiteral("Already have this note local uid set")); + QNDEBUG("Already have this note local uid set"); return; } @@ -7935,15 +7946,15 @@ : BlankPageKind::NoteLoading); if (!m_noteLocalUid.isEmpty()) { - QNTRACE(QStringLiteral("Emitting the request to find note and notebook ") - << QStringLiteral("for note local uid ") << m_noteLocalUid); + QNTRACE("Emitting the request to find note and notebook " + << "for note local uid " << m_noteLocalUid); Q_EMIT findNoteAndNotebook(m_noteLocalUid); } } void NoteEditorPrivate::clear() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::clear")); + QNDEBUG("NoteEditorPrivate::clear"); m_pNote.reset(Q_NULLPTR); m_pNotebook.reset(Q_NULLPTR); @@ -7953,11 +7964,11 @@ void NoteEditorPrivate::convertToNote() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::convertToNote")); + QNDEBUG("NoteEditorPrivate::convertToNote"); if (m_pendingConversionToNote) { - QNDEBUG(QStringLiteral("Already pending the conversion of " - "note editor page to HTML")); + QNDEBUG("Already pending the conversion of " + "note editor page to HTML"); return; } @@ -7972,7 +7983,7 @@ void NoteEditorPrivate::saveNoteToLocalStorage() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::saveNoteToLocalStorage")); + QNDEBUG("NoteEditorPrivate::saveNoteToLocalStorage"); if (Q_UNLIKELY(!m_pNote)) { ErrorString errorDescription(QT_TR_NOOP("Can't save note to local storage: " @@ -7983,22 +7994,22 @@ } if (Q_UNLIKELY(m_pNote->isInkNote())) { - QNDEBUG(QStringLiteral("Ink notes are read-only so won't save it " - "to the local storage, will just pretend " - "it was saved")); + QNDEBUG("Ink notes are read-only so won't save it to the local " + "storage, will just pretend it was saved"); Q_EMIT noteSavedToLocalStorage(m_noteLocalUid); return; } if (m_pendingNoteSavingInLocalStorage) { - QNDEBUG(QStringLiteral("Note is already being saved to local storage")); + QNDEBUG("Note is already being saved to local storage"); - if (m_needConversionToNote) { - QNDEBUG(QStringLiteral("It appears the note editor content has been " - "changed since save note request was last " - "issued; will repeat the attempt to save " - "the note after the current attemtp is finished")); + if (m_needConversionToNote) + { + QNDEBUG("It appears the note editor content has been changed since " + "save note request was last issued; will repeat the " + "attempt to save the note after the current attemtp is " + "finished"); m_shouldRepeatSavingNoteInLocalStorage = true; } @@ -8012,30 +8023,30 @@ } m_pendingNoteSavingInLocalStorage = true; - QNDEBUG(QStringLiteral("Emitting the request to save the note in local storage")); + QNDEBUG("Emitting the request to save the note in local storage"); QNTRACE(*m_pNote); Q_EMIT saveNoteToLocalStorageRequest(*m_pNote); } void NoteEditorPrivate::setNoteTitle(const QString & noteTitle) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setNoteTitle: ") << noteTitle); + QNDEBUG("NoteEditorPrivate::setNoteTitle: " << noteTitle); if (Q_UNLIKELY(m_pNote.isNull())) { ErrorString error(QT_TR_NOOP("Can't set title to the note: no note " "is set to the editor")); - QNWARNING(error << QStringLiteral(", title to set: ") << noteTitle); + QNWARNING(error << ", title to set: " << noteTitle); Q_EMIT notifyError(error); return; } if (!m_pNote->hasTitle() && noteTitle.isEmpty()) { - QNDEBUG(QStringLiteral("Note title is still empty, nothing to do")); + QNDEBUG("Note title is still empty, nothing to do"); return; } if (m_pNote->hasTitle() && (m_pNote->title() == noteTitle)) { - QNDEBUG(QStringLiteral("Note title hasn't changed, nothing to do")); + QNDEBUG("Note title hasn't changed, nothing to do"); return; } @@ -8049,21 +8060,21 @@ setModified(); } -void NoteEditorPrivate::setTagIds(const QStringList & tagLocalUids, - const QStringList & tagGuids) +void NoteEditorPrivate::setTagIds( + const QStringList & tagLocalUids, const QStringList & tagGuids) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setTagIds: tag local uids: ") + QNDEBUG("NoteEditorPrivate::setTagIds: tag local uids: " << tagLocalUids.join(QStringLiteral(", ")) - << QStringLiteral("; tag guids: ") + << "; tag guids: " << tagGuids.join(QStringLiteral(", "))); if (Q_UNLIKELY(m_pNote.isNull())) { ErrorString error(QT_TR_NOOP("Can't set tags to the note: no note " "is set to the editor")); - QNWARNING(error << QStringLiteral(", tag local uids: ") + QNWARNING(error << ", tag local uids: " << tagLocalUids.join(QStringLiteral(", ")) - << QStringLiteral("; tag guids: ") + << "; tag guids: " << tagGuids.join(QStringLiteral(", "))); Q_EMIT notifyError(error); return; @@ -8078,12 +8089,13 @@ { if (tagLocalUids.size() != tagGuids.size()) { - ErrorString error(QT_TR_NOOP("Can't set tags to the note: the number " - "of tag local uids is different from " - "the number of tag guids")); - QNWARNING(error << QStringLiteral(", tag local uids: ") + ErrorString error( + QT_TR_NOOP("Can't set tags to the note: the number of tag " + "local uids is different from the number of tag " + "guids")); + QNWARNING(error << ", tag local uids: " << tagLocalUids.join(QStringLiteral(", ")) - << QStringLiteral("; tag guids: ") + << "; tag guids: " << tagGuids.join(QStringLiteral(", "))); Q_EMIT notifyError(error); return; @@ -8092,8 +8104,7 @@ if ((tagLocalUids == previousTagLocalUids) && (tagGuids == previousTagGuids)) { - QNDEBUG(QStringLiteral("The list of tag ids hasn't changed, " - "nothing to do")); + QNDEBUG("The list of tag ids hasn't changed, nothing to do"); return; } @@ -8108,8 +8119,7 @@ { if (tagLocalUids == previousTagLocalUids) { - QNDEBUG(QStringLiteral("The list of tag local uids hasn't changed, " - "nothing to do")); + QNDEBUG("The list of tag local uids hasn't changed, nothing to do"); return; } @@ -8124,8 +8134,7 @@ { if (tagGuids == previousTagGuids) { - QNDEBUG(QStringLiteral("The list of tag guids hasn't changed, " - "nothing to do")); + QNDEBUG("The list of tag guids hasn't changed, nothing to do"); return; } @@ -8138,8 +8147,8 @@ if (previousTagLocalUids.isEmpty() && previousTagGuids.isEmpty()) { - QNDEBUG(QStringLiteral("Tag local uids and/or guids were empty and " - "are still empty, nothing to do")); + QNDEBUG("Tag local uids and/or guids were empty and are still empty, " + "nothing to do"); return; } @@ -8150,13 +8159,13 @@ void NoteEditorPrivate::updateFromNote() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::updateFromNote")); + QNDEBUG("NoteEditorPrivate::updateFromNote"); noteToEditorContent(); } void NoteEditorPrivate::setNoteHtml(const QString & html) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setNoteHtml")); + QNDEBUG("NoteEditorPrivate::setNoteHtml"); m_pendingConversionToNote = true; onPageHtmlReceived(html); @@ -8166,13 +8175,13 @@ void NoteEditorPrivate::addResourceToNote(const Resource & resource) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::addResourceToNote")); + QNDEBUG("NoteEditorPrivate::addResourceToNote"); QNTRACE(resource); if (Q_UNLIKELY(m_pNote.isNull())) { ErrorString error(QT_TR_NOOP("Can't add the resource to note: no note " "is set to the editor")); - QNWARNING(error << QStringLiteral(", resource to add: ") << resource); + QNWARNING(error << ", resource to add: " << resource); Q_EMIT notifyError(error); return; } @@ -8182,7 +8191,7 @@ ResourceRecognitionIndices recoIndices(resource.recognitionDataBody()); if (!recoIndices.isNull() && recoIndices.isValid()) { m_recognitionIndicesByResourceHash[resource.dataHash()] = recoIndices; - QNDEBUG(QStringLiteral("Set recognition indices for new resource: ") + QNDEBUG("Set recognition indices for new resource: " << recoIndices); } } @@ -8193,13 +8202,13 @@ void NoteEditorPrivate::removeResourceFromNote(const Resource & resource) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::removeResourceFromNote")); + QNDEBUG("NoteEditorPrivate::removeResourceFromNote"); QNTRACE(resource); if (Q_UNLIKELY(m_pNote.isNull())) { ErrorString error(QT_TR_NOOP("Can't remove the resource from note: " "no note is set to the editor")); - QNWARNING(error << QStringLiteral(", resource to remove: ") << resource); + QNWARNING(error << ", resource to remove: " << resource); Q_EMIT notifyError(error); return; } @@ -8225,13 +8234,13 @@ void NoteEditorPrivate::replaceResourceInNote(const Resource & resource) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::replaceResourceInNote")); + QNDEBUG("NoteEditorPrivate::replaceResourceInNote"); QNTRACE(resource); if (Q_UNLIKELY(m_pNote.isNull())) { ErrorString error(QT_TR_NOOP("Can't replace the resource within note: " "no note is set to the editor")); - QNWARNING(error << QStringLiteral(", replacement resource: ") << resource); + QNWARNING(error << ", replacement resource: " << resource); Q_EMIT notifyError(error); return; } @@ -8239,7 +8248,7 @@ if (Q_UNLIKELY(!m_pNote->hasResources())) { ErrorString error(QT_TR_NOOP("Can't replace the resource within note: " "note has no resources")); - QNWARNING(error << QStringLiteral(", replacement resource: ") << resource); + QNWARNING(error << ", replacement resource: " << resource); Q_EMIT notifyError(error); return; } @@ -8259,7 +8268,7 @@ if (Q_UNLIKELY(resourceIndex < 0)) { ErrorString error(QT_TR_NOOP("Can't replace the resource within note: " "can't find the resource to be replaced")); - QNWARNING(error << QStringLiteral(", replacement resource: ") << resource); + QNWARNING(error << ", replacement resource: " << resource); Q_EMIT notifyError(error); return; } @@ -8275,7 +8284,7 @@ void NoteEditorPrivate::setNoteResources(const QList<Resource> & resources) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setNoteResources")); + QNDEBUG("NoteEditorPrivate::setNoteResources"); if (Q_UNLIKELY(m_pNote.isNull())) { ErrorString error(QT_TR_NOOP("Can't set the resources to the note: " @@ -8303,16 +8312,16 @@ void NoteEditorPrivate::setFocusToEditor() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setFocusToEditor")); + QNDEBUG("NoteEditorPrivate::setFocusToEditor"); #ifdef QUENTIER_USE_QT_WEB_ENGINE #if QT_VERSION < QT_VERSION_CHECK(5, 9, 0) - QNDEBUG(QStringLiteral("Working around the Qt bug " - "https://bugreports.qt.io/browse/QTBUG-58515")); + QNDEBUG("Working around the Qt bug " + "https://bugreports.qt.io/browse/QTBUG-58515"); QWidget * pFocusWidget = qApp->focusWidget(); if (pFocusWidget) { - QNDEBUG(QStringLiteral("Removing focus from widget: ") << pFocusWidget); + QNDEBUG("Removing focus from widget: " << pFocusWidget); pFocusWidget->clearFocus(); } #endif @@ -8330,9 +8339,8 @@ mapToGlobal(bottomRight), Qt::LeftButton, Qt::MouseButtons(Qt::LeftButton), Qt::NoModifier, Qt::MouseEventNotSynthesized); - QNDEBUG(QStringLiteral("Sending QMouseEvent to the note editor: point x = ") - << bottomRight.x() - << QStringLiteral(", y = ") << bottomRight.y()); + QNDEBUG("Sending QMouseEvent to the note editor: point x = " + << bottomRight.x() << ", y = " << bottomRight.y()); QApplication::sendEvent(this, &event); #endif #endif @@ -8340,27 +8348,27 @@ void NoteEditorPrivate::setModified() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setModified")); + QNDEBUG("NoteEditorPrivate::setModified"); if (!m_pNote) { - QNDEBUG(QStringLiteral("No note is set to the editor")); + QNDEBUG("No note is set to the editor"); return; } if (!m_needConversionToNote && !m_needSavingNoteInLocalStorage ) { m_needConversionToNote = true; m_needSavingNoteInLocalStorage = true; - QNTRACE(QStringLiteral("Emitting noteModified signal")); + QNTRACE("Emitting noteModified signal"); Q_EMIT noteModified(); } } QString NoteEditorPrivate::noteEditorPagePath() const { - QNDEBUG(QStringLiteral("NoteEditorPrivate::noteEditorPagePath")); + QNDEBUG("NoteEditorPrivate::noteEditorPagePath"); if (m_pNote.isNull()) { - QNDEBUG(QStringLiteral("No note is set to the editor")); + QNDEBUG("No note is set to the editor"); return m_noteEditorPageFolderPath + QStringLiteral("/index.html"); } @@ -8390,12 +8398,12 @@ void NoteEditorPrivate::removeSymlinksToImageResourceFile(const QString & resourceLocalUid) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::removeSymlinksToImageResourceFile: ") - << QStringLiteral("resource local uid = ") << resourceLocalUid); + QNDEBUG("NoteEditorPrivate::removeSymlinksToImageResourceFile: " + << "resource local uid = " << resourceLocalUid); if (Q_UNLIKELY(m_pNote.isNull())) { - QNDEBUG(QStringLiteral("Can't remove symlinks to resource image file: " - "no note is set to the editor")); + QNDEBUG("Can't remove symlinks to resource image file: " + "no note is set to the editor"); return; } @@ -8406,16 +8414,15 @@ resourceLocalUid; QDir dir(fileStorageDirPath); - QNTRACE(QStringLiteral("Resource file storage dir ") + QNTRACE("Resource file storage dir " << (dir.exists() - ? QStringLiteral("exists") - : QStringLiteral("doesn't exist"))); + ? "exists" + : "doesn't exist")); QFileInfoList entryList = dir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot); const int numEntries = entryList.size(); - QNTRACE(QStringLiteral("Found ") << numEntries - << QStringLiteral(" files in the image resources folder: ") + QNTRACE("Found " << numEntries << " files in the image resources folder: " << QDir::toNativeSeparators(fileStorageDirPath)); QString entryFilePath; @@ -8428,8 +8435,8 @@ } entryFilePath = entry.absoluteFilePath(); - QNTRACE(QStringLiteral("See if we need to remove the symlink to resource ") - << QStringLiteral("image file ") << entryFilePath); + QNTRACE("See if we need to remove the symlink to resource image file " + << entryFilePath); if (!entryFilePath.startsWith(fileStoragePathPrefix)) { continue; @@ -8439,13 +8446,13 @@ } } -QString NoteEditorPrivate::createSymlinkToImageResourceFile(const QString & fileStoragePath, - const QString & localUid, - ErrorString & errorDescription) -{ - QNDEBUG(QStringLiteral("NoteEditorPrivate::createSymlinkToImageResourceFile: ") - << QStringLiteral("file storage path = ") << fileStoragePath - << QStringLiteral(", local uid = ") << localUid); +QString NoteEditorPrivate::createSymlinkToImageResourceFile( + const QString & fileStoragePath, const QString & localUid, + ErrorString & errorDescription) +{ + QNDEBUG("NoteEditorPrivate::createSymlinkToImageResourceFile: " + << "file storage path = " << fileStoragePath + << ", local uid = " << localUid); QString linkFilePath = fileStoragePath; linkFilePath.remove(linkFilePath.size() - 4, 4); @@ -8458,7 +8465,7 @@ linkFilePath += QStringLiteral(".png"); #endif - QNTRACE(QStringLiteral("Link file path = ") << linkFilePath); + QNTRACE("Link file path = " << linkFilePath); removeSymlinksToImageResourceFile(localUid); @@ -8480,17 +8487,16 @@ void NoteEditorPrivate::onDropEvent(QDropEvent * pEvent) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onDropEvent")); + QNDEBUG("NoteEditorPrivate::onDropEvent"); if (Q_UNLIKELY(!pEvent)) { - QNWARNING(QStringLiteral("Null pointer to drop event was detected")); + QNWARNING("Null pointer to drop event was detected"); return; } const QMimeData * pMimeData = pEvent->mimeData(); if (Q_UNLIKELY(!pMimeData)) { - QNWARNING(QStringLiteral("Null pointer to mime data from drop event " - "was detected")); + QNWARNING("Null pointer to mime data from drop event was detected"); return; } @@ -8515,16 +8521,15 @@ return m_pAccount.data(); } -const Resource NoteEditorPrivate::attachResourceToNote(const QByteArray & data, - const QByteArray & dataHash, - const QMimeType & mimeType, - const QString & filename, - const QString & sourceUrl) -{ - QNDEBUG(QStringLiteral("NoteEditorPrivate::attachResourceToNote: hash = ") - << dataHash.toHex() << QStringLiteral(", mime type = ") << mimeType.name() - << QStringLiteral(", filename = ") << filename - << QStringLiteral(", source url = ") << sourceUrl); +const Resource NoteEditorPrivate::attachResourceToNote( + const QByteArray & data, const QByteArray & dataHash, + const QMimeType & mimeType, const QString & filename, + const QString & sourceUrl) +{ + QNDEBUG("NoteEditorPrivate::attachResourceToNote: hash = " + << dataHash.toHex() << ", mime type = " << mimeType.name() + << ", filename = " << filename + << ", source url = " << sourceUrl); Resource resource; QString resourceLocalUid = resource.localUid(); @@ -8533,8 +8538,8 @@ resource.setLocalUid(QString()); if (Q_UNLIKELY(m_pNote.isNull())) { - QNINFO(QStringLiteral("Can't attach resource to note editor: no actual " - "note was selected")); + QNINFO("Can't attach resource to note editor: no actual " + "note was selected"); return resource; } @@ -8583,9 +8588,9 @@ } template <typename T> -QString NoteEditorPrivate::composeHtmlTable(const T width, const T singleColumnWidth, - const int rows, const int columns, - const bool relative) +QString NoteEditorPrivate::composeHtmlTable( + const T width, const T singleColumnWidth, + const int rows, const int columns, const bool relative) { // Table header QString htmlTable = QStringLiteral("<div><table style=\"border-collapse: " @@ -8638,7 +8643,7 @@ void NoteEditorPrivate::undo() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::undo")); + QNDEBUG("NoteEditorPrivate::undo"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't perform undo")) @@ -8650,7 +8655,7 @@ void NoteEditorPrivate::redo() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::redo")); + QNDEBUG("NoteEditorPrivate::redo"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't perform redo")) @@ -8662,7 +8667,7 @@ void NoteEditorPrivate::undoPageAction() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::undoPageAction")); + QNDEBUG("NoteEditorPrivate::undoPageAction"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't undo page action")) @@ -8674,7 +8679,7 @@ void NoteEditorPrivate::redoPageAction() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::redoPageAction")); + QNDEBUG("NoteEditorPrivate::redoPageAction"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't redo page action")) @@ -8686,8 +8691,7 @@ void NoteEditorPrivate::flipEnToDoCheckboxState(const quint64 enToDoIdNumber) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::flipEnToDoCheckboxState: ") - << enToDoIdNumber); + QNDEBUG("NoteEditorPrivate::flipEnToDoCheckboxState: " << enToDoIdNumber); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't flip the todo checkbox state")) @@ -8700,15 +8704,15 @@ qint64 NoteEditorPrivate::noteResourcesSize() const { - QNTRACE(QStringLiteral("NoteEditorPrivate::noteResourcesSize")); + QNTRACE("NoteEditorPrivate::noteResourcesSize"); if (Q_UNLIKELY(!m_pNote)) { - QNTRACE(QStringLiteral("No note - returning zero")); + QNTRACE("No note - returning zero"); return qint64(0); } if (Q_UNLIKELY(!m_pNote->hasResources())) { - QNTRACE(QStringLiteral("Note has no resources - returning zero")); + QNTRACE("Note has no resources - returning zero"); return qint64(0); } @@ -8718,8 +8722,7 @@ end = resources.constEnd(); it != end; ++it) { const Resource & resource = *it; - QNTRACE(QStringLiteral("Computing size contributions for resource: ") - << resource); + QNTRACE("Computing size contributions for resource: " << resource); if (resource.hasDataSize()) { size += resource.dataSize(); @@ -8734,7 +8737,7 @@ } } - QNTRACE(QStringLiteral("Computed note resources size: ") << size); + QNTRACE("Computed note resources size: " << size); return size; } @@ -8758,10 +8761,10 @@ void NoteEditorPrivate::onSpellCheckCorrectionAction() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onSpellCheckCorrectionAction")); + QNDEBUG("NoteEditorPrivate::onSpellCheckCorrectionAction"); if (!m_spellCheckerEnabled) { - QNDEBUG(QStringLiteral("Not enabled, won't do anything")); + QNDEBUG("Not enabled, won't do anything"); return; } @@ -8776,7 +8779,7 @@ QString correction = pAction->text(); if (Q_UNLIKELY(correction.isEmpty())) { - QNWARNING(QStringLiteral("No correction specified")); + QNWARNING("No correction specified"); return; } @@ -8792,15 +8795,15 @@ void NoteEditorPrivate::onSpellCheckIgnoreWordAction() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onSpellCheckIgnoreWordAction")); + QNDEBUG("NoteEditorPrivate::onSpellCheckIgnoreWordAction"); if (!m_spellCheckerEnabled) { - QNDEBUG(QStringLiteral("Not enabled, won't do anything")); + QNDEBUG("Not enabled, won't do anything"); return; } if (Q_UNLIKELY(!m_pSpellChecker)) { - QNDEBUG(QStringLiteral("Spell checker is null, won't do anything")); + QNDEBUG("Spell checker is null, won't do anything"); return; } @@ -8822,15 +8825,15 @@ void NoteEditorPrivate::onSpellCheckAddWordToUserDictionaryAction() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onSpellCheckAddWordToUserDictionaryAction")); + QNDEBUG("NoteEditorPrivate::onSpellCheckAddWordToUserDictionaryAction"); if (!m_spellCheckerEnabled) { - QNDEBUG(QStringLiteral("Not enabled, won't do anything")); + QNDEBUG("Not enabled, won't do anything"); return; } if (Q_UNLIKELY(!m_pSpellChecker)) { - QNDEBUG(QStringLiteral("Spell checker is null, won't do anything")); + QNDEBUG("Spell checker is null, won't do anything"); return; } @@ -8853,8 +8856,7 @@ void NoteEditorPrivate::onSpellCheckCorrectionActionDone( const QVariant & data, const QVector<QPair<QString,QString> > & extraData) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onSpellCheckCorrectionActionDone: ") - << data); + QNDEBUG("NoteEditorPrivate::onSpellCheckCorrectionActionDone: " << data); Q_UNUSED(extraData) @@ -8909,7 +8911,7 @@ void NoteEditorPrivate::onSpellCheckCorrectionUndoRedoFinished( const QVariant & data, const QVector<QPair<QString,QString> > & extraData) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onSpellCheckCorrectionUndoRedoFinished")); + QNDEBUG("NoteEditorPrivate::onSpellCheckCorrectionUndoRedoFinished"); Q_UNUSED(extraData) @@ -8949,16 +8951,16 @@ void NoteEditorPrivate::onSpellCheckerDynamicHelperUpdate(QStringList words) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onSpellCheckerDynamicHelperUpdate: ") + QNDEBUG("NoteEditorPrivate::onSpellCheckerDynamicHelperUpdate: " << words.join(QStringLiteral(";"))); if (!m_spellCheckerEnabled) { - QNTRACE(QStringLiteral("No spell checking is enabled, nothing to do")); + QNTRACE("No spell checking is enabled, nothing to do"); return; } if (Q_UNLIKELY(!m_pSpellChecker)) { - QNDEBUG(QStringLiteral("Spell checker is null, won't do anything")); + QNDEBUG("Spell checker is null, won't do anything"); return; } @@ -8969,7 +8971,7 @@ m_stringUtils.removePunctuation(word); if (m_pSpellChecker->checkSpell(word)) { - QNTRACE(QStringLiteral("No misspelling detected")); + QNTRACE("No misspelling detected"); continue; } @@ -8978,7 +8980,7 @@ } } - QNTRACE(QStringLiteral("Current note's misspelled words: ") + QNTRACE("Current note's misspelled words: " << m_currentNoteMisSpelledWords.join(QStringLiteral(", "))); applySpellCheck(/* apply to selection = */ true); @@ -8986,7 +8988,7 @@ void NoteEditorPrivate::onSpellCheckerReady() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onSpellCheckerReady")); + QNDEBUG("NoteEditorPrivate::onSpellCheckerReady"); QObject::disconnect(m_pSpellChecker, QNSIGNAL(SpellChecker,ready), this, QNSLOT(NoteEditorPrivate,onSpellCheckerReady)); @@ -9003,8 +9005,8 @@ void NoteEditorPrivate::onImageResourceResized(bool pushUndoCommand) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onImageResourceResized: push undo command = ") - << (pushUndoCommand ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("NoteEditorPrivate::onImageResourceResized: push undo command = " + << (pushUndoCommand ? "true" : "false")); if (pushUndoCommand) { ImageResizeUndoCommand * pCommand = new ImageResizeUndoCommand(*this); @@ -9020,14 +9022,14 @@ void NoteEditorPrivate::copy() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::copy")); + QNDEBUG("NoteEditorPrivate::copy"); GET_PAGE() page->triggerAction(WebPage::Copy); } void NoteEditorPrivate::paste() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::paste")); + QNDEBUG("NoteEditorPrivate::paste"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't paste")) @@ -9035,8 +9037,8 @@ QClipboard * pClipboard = QApplication::clipboard(); if (Q_UNLIKELY(!pClipboard)) { - QNWARNING(QStringLiteral("Can't access the application clipboard " - "to analyze the pasted content")); + QNWARNING("Can't access the application clipboard " + "to analyze the pasted content"); execJavascriptCommand(QStringLiteral("insertText")); setModified(); return; @@ -9045,21 +9047,12 @@ const QMimeData * pMimeData = pClipboard->mimeData(QClipboard::Clipboard); if (pMimeData) { - QNTRACE(QStringLiteral("Mime data to paste: ") << pMimeData - << QStringLiteral("\nMime data has html: ") - << (pMimeData->hasHtml() - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", html: ") << pMimeData->html() - << QStringLiteral(", mime data has text: ") - << (pMimeData->hasText() - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", text: ") << pMimeData->text() - << QStringLiteral(", mime data has image: ") - << (pMimeData->hasImage() - ? QStringLiteral("true") - : QStringLiteral("false"))); + QNTRACE("Mime data to paste: " << pMimeData << "\nMime data has html: " + << (pMimeData->hasHtml() ? "true" : "false") + << ", html: " << pMimeData->html() << ", mime data has text: " + << (pMimeData->hasText() ? "true" : "false") + << ", text: " << pMimeData->text() << ", mime data has image: " + << (pMimeData->hasImage() ? "true" : "false")); if (pMimeData->hasImage()) { pasteImageData(*pMimeData); @@ -9069,13 +9062,14 @@ if (pMimeData->hasHtml()) { QString html = pMimeData->html(); - QNDEBUG(QStringLiteral("HTML from mime data: ") << html); + QNDEBUG("HTML from mime data: " << html); + + InsertHtmlDelegate * pInsertHtmlDelegate = new InsertHtmlDelegate( + html, *this, m_enmlConverter, + m_pResourceDataInTemporaryFileStorageManager, + m_resourceFileStoragePathsByResourceLocalUid, + m_resourceInfo, this); - InsertHtmlDelegate * pInsertHtmlDelegate = - new InsertHtmlDelegate(html, *this, m_enmlConverter, - m_pResourceDataInTemporaryFileStorageManager, - m_resourceFileStoragePathsByResourceLocalUid, - m_resourceInfo, this); QObject::connect(pInsertHtmlDelegate, QNSIGNAL(InsertHtmlDelegate,finished, QList<Resource>,QStringList), @@ -9094,14 +9088,14 @@ } else { - QNDEBUG(QStringLiteral("Unable to retrieve the mime data from the clipboard")); + QNDEBUG("Unable to retrieve the mime data from the clipboard"); } QString textToPaste = pClipboard->text(); - QNTRACE(QStringLiteral("Text to paste: ") << textToPaste); + QNTRACE("Text to paste: " << textToPaste); if (textToPaste.isEmpty()) { - QNDEBUG(QStringLiteral("The text to paste is empty")); + QNDEBUG("The text to paste is empty"); return; } @@ -9114,8 +9108,8 @@ if (!shouldBeHyperlink && !shouldBeAttachment && !shouldBeInAppLink) { - QNTRACE(QStringLiteral("The pasted text doesn't appear to be a url " - "of hyperlink or attachment")); + QNTRACE("The pasted text doesn't appear to be a url " + "of hyperlink or attachment"); execJavascriptCommand(QStringLiteral("insertText"), textToPaste); return; } @@ -9125,9 +9119,8 @@ { if (!url.isValid()) { - QNTRACE(QStringLiteral("The pasted text seemed like file url but " - "the url isn't valid after all, fallback " - "to simple paste")); + QNTRACE("The pasted text seemed like file url but the url isn't " + "valid after all, fallback to simple paste"); execJavascriptCommand(QStringLiteral("insertText"), textToPaste); setModified(); } @@ -9144,14 +9137,13 @@ } if (!url.isValid()) { - QNDEBUG(QStringLiteral("It appears we don't paste a url")); + QNDEBUG("It appears we don't paste a url"); execJavascriptCommand(QStringLiteral("insertText"), textToPaste); setModified(); return; } - QNDEBUG(QStringLiteral("Was able to create the url from pasted text, " - "inserting a hyperlink")); + QNDEBUG("Was able to create the url from pasted text, inserting a hyperlink"); if (shouldBeInAppLink) { @@ -9175,9 +9167,8 @@ return; } - QNTRACE(QStringLiteral("Parsed in-app note link: user id = ") << userId - << QStringLiteral(", shard id = ") << shardId - << QStringLiteral(", note guid = ") << noteGuid); + QNTRACE("Parsed in-app note link: user id = " << userId + << ", shard id = " << shardId << ", note guid = " << noteGuid); Q_EMIT inAppNoteLinkPasteRequested(textToPaste, userId, shardId, noteGuid); return; } @@ -9194,21 +9185,21 @@ void NoteEditorPrivate::pasteUnformatted() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::pasteUnformatted")); + QNDEBUG("NoteEditorPrivate::pasteUnformatted"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't paste the unformatted text")); QClipboard * pClipboard = QApplication::clipboard(); if (Q_UNLIKELY(!pClipboard)) { - QNWARNING(QStringLiteral("Can't access the application clipboard " - "to analyze the pasted content")); + QNWARNING("Can't access the application clipboard " + "to analyze the pasted content"); execJavascriptCommand(QStringLiteral("insertText")); setModified(); return; } QString textToPaste = pClipboard->text(); - QNTRACE(QStringLiteral("Text to paste: ") << textToPaste); + QNTRACE("Text to paste: " << textToPaste); if (textToPaste.isEmpty()) { return; } @@ -9219,14 +9210,14 @@ void NoteEditorPrivate::selectAll() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::selectAll")); + QNDEBUG("NoteEditorPrivate::selectAll"); GET_PAGE() page->triggerAction(WebPage::SelectAll); } void NoteEditorPrivate::formatSelectionAsSourceCode() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::formatSelectionAsSourceCode")); + QNDEBUG("NoteEditorPrivate::formatSelectionAsSourceCode"); GET_PAGE() page->executeJavaScript( QStringLiteral("sourceCodeFormatter.format()"), @@ -9236,7 +9227,7 @@ void NoteEditorPrivate::fontMenu() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::fontMenu")); + QNDEBUG("NoteEditorPrivate::fontMenu"); bool fontWasChosen = false; QFont chosenFont = QFontDialog::getFont(&fontWasChosen, m_font, this); @@ -9261,7 +9252,7 @@ void NoteEditorPrivate::cut() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::cut")); + QNDEBUG("NoteEditorPrivate::cut"); GET_PAGE() CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't cut note content")) @@ -9275,7 +9266,7 @@ void NoteEditorPrivate::textBold() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::textBold")); + QNDEBUG("NoteEditorPrivate::textBold"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't toggle bold text")) execJavascriptCommand(QStringLiteral("bold")); setModified(); @@ -9283,7 +9274,7 @@ void NoteEditorPrivate::textItalic() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::textItalic")); + QNDEBUG("NoteEditorPrivate::textItalic"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't toggle italic text")) execJavascriptCommand(QStringLiteral("italic")); setModified(); @@ -9291,7 +9282,7 @@ void NoteEditorPrivate::textUnderline() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::textUnderline")); + QNDEBUG("NoteEditorPrivate::textUnderline"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't toggle underline text")) execJavascriptCommand(QStringLiteral("underline")); setModified(); @@ -9299,7 +9290,7 @@ void NoteEditorPrivate::textStrikethrough() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::textStrikethrough")); + QNDEBUG("NoteEditorPrivate::textStrikethrough"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't toggle strikethrough text")) execJavascriptCommand(QStringLiteral("strikethrough")); setModified(); @@ -9307,7 +9298,7 @@ void NoteEditorPrivate::textHighlight() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::textHighlight")); + QNDEBUG("NoteEditorPrivate::textHighlight"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't highlight text")) setBackgroundColor(QColor(255, 255, 127)); @@ -9316,7 +9307,7 @@ void NoteEditorPrivate::alignLeft() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::alignLeft")); + QNDEBUG("NoteEditorPrivate::alignLeft"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't justify the text to the left")) execJavascriptCommand(QStringLiteral("justifyleft")); setModified(); @@ -9324,7 +9315,7 @@ void NoteEditorPrivate::alignCenter() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::alignCenter")); + QNDEBUG("NoteEditorPrivate::alignCenter"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't justify the text to the center")) execJavascriptCommand(QStringLiteral("justifycenter")); setModified(); @@ -9332,7 +9323,7 @@ void NoteEditorPrivate::alignRight() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::alignRight")); + QNDEBUG("NoteEditorPrivate::alignRight"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't justify the text to the right")) execJavascriptCommand(QStringLiteral("justifyright")); setModified(); @@ -9340,7 +9331,7 @@ void NoteEditorPrivate::alignFull() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::alignFull")); + QNDEBUG("NoteEditorPrivate::alignFull"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't do full text justification")) execJavascriptCommand(QStringLiteral("justifyfull")); setModified(); @@ -9358,18 +9349,16 @@ void NoteEditorPrivate::findNext(const QString & text, const bool matchCase) const { - QNDEBUG(QStringLiteral("NoteEditorPrivate::findNext: ") << text - << QStringLiteral("; match case = ") - << (matchCase ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("NoteEditorPrivate::findNext: " << text + << "; match case = " << (matchCase ? "true" : "false")); findText(text, matchCase); } void NoteEditorPrivate::findPrevious(const QString & text, const bool matchCase) const { - QNDEBUG(QStringLiteral("NoteEditorPrivate::findPrevious: ") << text - << QStringLiteral("; match case = ") - << (matchCase ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("NoteEditorPrivate::findPrevious: " << text + << "; match case = " << (matchCase ? "true" : "false")); findText(text, matchCase, /* search backward = */ true); } @@ -9378,10 +9367,10 @@ const QString & replacementText, const bool matchCase) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::replace: text to replace = ") - << textToReplace << QStringLiteral("; replacement text = ") - << replacementText << QStringLiteral("; match case = ") - << (matchCase ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("NoteEditorPrivate::replace: text to replace = " + << textToReplace << "; replacement text = " + << replacementText << "; match case = " + << (matchCase ? "true" : "false")); GET_PAGE() CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't replace text")) @@ -9415,10 +9404,10 @@ const QString & replacementText, const bool matchCase) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::replaceAll: text to replace = ") - << textToReplace << QStringLiteral("; replacement text = ") - << replacementText << QStringLiteral("; match case = ") - << (matchCase ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("NoteEditorPrivate::replaceAll: text to replace = " + << textToReplace << "; replacement text = " + << replacementText << "; match case = " + << (matchCase ? "true" : "false")); GET_PAGE() CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't replace all occurrences")) @@ -9449,7 +9438,7 @@ void NoteEditorPrivate::onReplaceJavaScriptDone(const QVariant & data) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onReplaceJavaScriptDone")); + QNDEBUG("NoteEditorPrivate::onReplaceJavaScriptDone"); Q_UNUSED(data) @@ -9459,7 +9448,7 @@ void NoteEditorPrivate::insertToDoCheckbox() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::insertToDoCheckbox")); + QNDEBUG("NoteEditorPrivate::insertToDoCheckbox"); GET_PAGE() CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't insert checkbox")) @@ -9479,9 +9468,9 @@ const QString & noteGuid, const QString & linkText) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::insertInAppNoteLink: user id = ") - << userId << QStringLiteral(", shard id = ") << shardId - << QStringLiteral(", note guid = ") << noteGuid); + QNDEBUG("NoteEditorPrivate::insertInAppNoteLink: user id = " + << userId << ", shard id = " << shardId + << ", note guid = " << noteGuid); QString urlString = QStringLiteral("evernote:///view/") + userId + QStringLiteral("/") + shardId + QStringLiteral("/") + @@ -9493,11 +9482,11 @@ void NoteEditorPrivate::setSpellcheck(const bool enabled) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setSpellcheck: enabled = ") - << (enabled ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("NoteEditorPrivate::setSpellcheck: enabled = " + << (enabled ? "true" : "false")); if (m_spellCheckerEnabled == enabled) { - QNTRACE(QStringLiteral("Spell checker enabled flag didn't change")); + QNTRACE("Spell checker enabled flag didn't change"); return; } @@ -9517,13 +9506,13 @@ void NoteEditorPrivate::setFont(const QFont & font) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setFont: ") << font.family() - << QStringLiteral(", point size = ") << font.pointSize() - << QStringLiteral(", previous font family = ") << m_font.family() - << QStringLiteral(", previous font point size = ") << m_font.pointSize()); + QNDEBUG("NoteEditorPrivate::setFont: " << font.family() + << ", point size = " << font.pointSize() + << ", previous font family = " << m_font.family() + << ", previous font point size = " << m_font.pointSize()); if (m_font.family() == font.family()) { - QNTRACE(QStringLiteral("Font family hasn't changed, nothing to to do")); + QNTRACE("Font family hasn't changed, nothing to to do"); return; } @@ -9541,7 +9530,7 @@ void NoteEditorPrivate::setFontHeight(const int height) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setFontHeight: ") << height); + QNDEBUG("NoteEditorPrivate::setFontHeight: " << height); if (height <= 0) { ErrorString error(QT_TR_NOOP("Detected incorrect font size")); @@ -9566,8 +9555,8 @@ void NoteEditorPrivate::setFontColor(const QColor & color) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setFontColor: ") << color.name() - << QStringLiteral(", rgb: ") << QString::number(color.rgb(), 16)); + QNDEBUG("NoteEditorPrivate::setFontColor: " << color.name() + << ", rgb: " << QString::number(color.rgb(), 16)); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't set the font color")) @@ -9588,8 +9577,8 @@ void NoteEditorPrivate::setBackgroundColor(const QColor & color) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::setBackgroundColor: ") - << color.name() << QStringLiteral(", rgb: ") + QNDEBUG("NoteEditorPrivate::setBackgroundColor: " + << color.name() << ", rgb: " << QString::number(color.rgb(), 16)); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't set the background color")) @@ -9641,7 +9630,7 @@ void NoteEditorPrivate::setDefaultPalette(const QPalette & pal) { - QNINFO(QStringLiteral("NoteEditorPrivate::setDefaultPalette")); + QNINFO("NoteEditorPrivate::setDefaultPalette"); if (m_pPalette.isNull()) { @@ -9650,7 +9639,7 @@ else { if (*m_pPalette == pal) { - QNTRACE(QStringLiteral("Palette did not change")); + QNTRACE("Palette did not change"); return; } @@ -9661,7 +9650,9 @@ return; } - if (m_pendingNotePageLoad || m_pendingIndexHtmlWritingToFile || m_pendingJavaScriptExecution) { + if (m_pendingNotePageLoad || m_pendingIndexHtmlWritingToFile || + m_pendingJavaScriptExecution) + { m_pendingDefaultPaletteReplacement = true; return; } @@ -9671,7 +9662,7 @@ void NoteEditorPrivate::insertHorizontalLine() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::insertHorizontalLine")); + QNDEBUG("NoteEditorPrivate::insertHorizontalLine"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't insert a horizontal line")) execJavascriptCommand(QStringLiteral("insertHorizontalRule")); @@ -9700,7 +9691,7 @@ void NoteEditorPrivate::insertBulletedList() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::insertBulletedList")); + QNDEBUG("NoteEditorPrivate::insertBulletedList"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't insert an unordered list")) execJavascriptCommand(QStringLiteral("insertUnorderedList")); @@ -9709,7 +9700,7 @@ void NoteEditorPrivate::insertNumberedList() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::insertNumberedList")); + QNDEBUG("NoteEditorPrivate::insertNumberedList"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't insert a numbered list")) execJavascriptCommand(QStringLiteral("insertOrderedList")); @@ -9718,42 +9709,45 @@ void NoteEditorPrivate::insertTableDialog() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::insertTableDialog")); + QNDEBUG("NoteEditorPrivate::insertTableDialog"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't insert a table")) Q_EMIT insertTableDialogRequested(); } -#define CHECK_NUM_COLUMNS() \ - if (columns <= 0) { \ - ErrorString error(QT_TRANSLATE_NOOP("NoteEditorPrivate", \ - "Detected attempt to insert a table "\ - "with negative or zero number "\ - "of columns")); \ - error.details() = QString::number(columns); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } - -#define CHECK_NUM_ROWS() \ - if (rows <= 0) { \ - ErrorString error(QT_TRANSLATE_NOOP("NoteEditorPrivate", \ - "Detected attempt to insert a table "\ - "with negative or zero number of rows")); \ - error.details() = QString::number(rows); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } +#define CHECK_NUM_COLUMNS() \ + if (columns <= 0) { \ + ErrorString error(QT_TRANSLATE_NOOP("NoteEditorPrivate", \ + "Detected attempt to insert a " \ + "table with negative or zero " \ + "number of columns")); \ + error.details() = QString::number(columns); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// CHECK_NUM_COLUMNS + +#define CHECK_NUM_ROWS() \ + if (rows <= 0) { \ + ErrorString error(QT_TRANSLATE_NOOP("NoteEditorPrivate", \ + "Detected attempt to insert a " \ + "table with negative or zero " \ + "number of rows")); \ + error.details() = QString::number(rows); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// CHECK_NUM_ROWS void NoteEditorPrivate::insertFixedWidthTable(const int rows, const int columns, const int widthInPixels) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::insertFixedWidthTable: rows = ") - << rows << QStringLiteral(", columns = ") << columns - << QStringLiteral(", width in pixels = ") << widthInPixels); + QNDEBUG("NoteEditorPrivate::insertFixedWidthTable: rows = " + << rows << ", columns = " << columns + << ", width in pixels = " << widthInPixels); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't insert a fixed width table")) @@ -9778,9 +9772,11 @@ } int singleColumnWidth = widthInPixels / columns; - if (singleColumnWidth == 0) { - ErrorString error(QT_TR_NOOP("Can't insert table, bad width for specified " - "number of columns (single column width is zero)")); + if (singleColumnWidth == 0) + { + ErrorString error( + QT_TR_NOOP("Can't insert table, bad width for specified " + "number of columns (single column width is zero)")); error.details() = QString::number(widthInPixels); error.details() += QStringLiteral(", "); error.details() += QString::number(columns); @@ -9801,9 +9797,9 @@ const int columns, const double relativeWidth) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::insertRelativeWidthTable: rows = ") - << rows << QStringLiteral(", columns = ") << columns - << QStringLiteral(", relative width = ") << relativeWidth); + QNDEBUG("NoteEditorPrivate::insertRelativeWidthTable: rows = " + << rows << ", columns = " << columns + << ", relative width = " << relativeWidth); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't insert a relative width table")) @@ -9812,7 +9808,8 @@ if (relativeWidth <= 0.01) { - ErrorString error(QT_TR_NOOP("Can't insert table, relative width is too small")); + ErrorString error(QT_TR_NOOP("Can't insert table, relative width is " + "too small")); error.details() = QString::number(relativeWidth); error.details() += QStringLiteral("%"); QNWARNING(error); @@ -9821,7 +9818,8 @@ } else if (relativeWidth > 100.0 + 1.0e-9) { - ErrorString error(QT_TR_NOOP("Can't insert table, relative width is too large")); + ErrorString error(QT_TR_NOOP("Can't insert table, relative width is " + "too large")); error.details() = QString::number(relativeWidth); error.details() += QStringLiteral("%"); QNWARNING(error); @@ -9839,7 +9837,7 @@ void NoteEditorPrivate::insertTableRow() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::insertTableRow")); + QNDEBUG("NoteEditorPrivate::insertTableRow"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't insert a table row")) @@ -9847,14 +9845,15 @@ this, &NoteEditorPrivate::onTableActionDone); GET_PAGE() - page->executeJavaScript(QStringLiteral("tableManager.insertRow();"), callback); + page->executeJavaScript(QStringLiteral("tableManager.insertRow();"), + callback); pushTableActionUndoCommand(tr("Insert row"), callback); } void NoteEditorPrivate::insertTableColumn() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::insertTableColumn")); + QNDEBUG("NoteEditorPrivate::insertTableColumn"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't insert a table column")) @@ -9862,14 +9861,15 @@ this, &NoteEditorPrivate::onTableActionDone); GET_PAGE() - page->executeJavaScript(QStringLiteral("tableManager.insertColumn();"), callback); + page->executeJavaScript(QStringLiteral("tableManager.insertColumn();"), + callback); pushTableActionUndoCommand(tr("Insert column"), callback); } void NoteEditorPrivate::removeTableRow() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::removeTableRow")); + QNDEBUG("NoteEditorPrivate::removeTableRow"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't remove the table row")) @@ -9877,14 +9877,15 @@ this, &NoteEditorPrivate::onTableActionDone); GET_PAGE() - page->executeJavaScript(QStringLiteral("tableManager.removeRow();"), callback); + page->executeJavaScript(QStringLiteral("tableManager.removeRow();"), + callback); pushTableActionUndoCommand(tr("Remove row"), callback); } void NoteEditorPrivate::removeTableColumn() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::removeTableColumn")); + QNDEBUG("NoteEditorPrivate::removeTableColumn"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't remove the table column")) @@ -9892,14 +9893,15 @@ this, &NoteEditorPrivate::onTableActionDone); GET_PAGE() - page->executeJavaScript(QStringLiteral("tableManager.removeColumn();"), callback); + page->executeJavaScript(QStringLiteral("tableManager.removeColumn();"), + callback); pushTableActionUndoCommand(tr("Remove column"), callback); } void NoteEditorPrivate::addAttachmentDialog() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::addAttachmentDialog")); + QNDEBUG("NoteEditorPrivate::addAttachmentDialog"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't add an attachment")) @@ -9912,20 +9914,19 @@ appSettings.value(NOTE_EDITOR_LAST_ATTACHMENT_ADD_LOCATION_KEY); if (!lastAttachmentAddLocation.isNull() && lastAttachmentAddLocation.isValid()) { - QNTRACE(QStringLiteral("Found last attachment add location: ") + QNTRACE("Found last attachment add location: " << lastAttachmentAddLocation); QFileInfo lastAttachmentAddDirInfo(lastAttachmentAddLocation.toString()); if (!lastAttachmentAddDirInfo.exists()) { - QNTRACE(QStringLiteral("Cached last attachment add directory " - "does not exist")); + QNTRACE("Cached last attachment add directory does not exist"); } else if (!lastAttachmentAddDirInfo.isDir()) { - QNTRACE(QStringLiteral("Cached last attachment add directory path " - "is not a directory really")); + QNTRACE("Cached last attachment add directory path " + "is not a directory really"); } else if (!lastAttachmentAddDirInfo.isWritable()) { - QNTRACE(QStringLiteral("Cached last attachment add directory path " - "is not writable")); + QNTRACE("Cached last attachment add directory path " + "is not writable"); } else { addAttachmentInitialFolderPath = lastAttachmentAddDirInfo.absolutePath(); @@ -9937,20 +9938,18 @@ tr("Add attachment") + QStringLiteral("..."), addAttachmentInitialFolderPath); if (absoluteFilePath.isEmpty()) { - QNTRACE(QStringLiteral("User cancelled adding the attachment")); + QNTRACE("User cancelled adding the attachment"); return; } - QNTRACE(QStringLiteral("Absolute file path of chosen attachment: ") - << absoluteFilePath); + QNTRACE("Absolute file path of chosen attachment: " << absoluteFilePath); QFileInfo fileInfo(absoluteFilePath); QString absoluteDirPath = fileInfo.absoluteDir().absolutePath(); if (!absoluteDirPath.isEmpty()) { appSettings.setValue(NOTE_EDITOR_LAST_ATTACHMENT_ADD_LOCATION_KEY, absoluteDirPath); - QNTRACE(QStringLiteral("Updated last attachment add location to ") - << absoluteDirPath); + QNTRACE("Updated last attachment add location to " << absoluteDirPath); } dropFile(absoluteFilePath); @@ -9958,20 +9957,20 @@ void NoteEditorPrivate::saveAttachmentDialog(const QByteArray & resourceHash) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::saveAttachmentDialog")); + QNDEBUG("NoteEditorPrivate::saveAttachmentDialog"); onSaveResourceRequest(resourceHash); } void NoteEditorPrivate::saveAttachmentUnderCursor() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::saveAttachmentUnderCursor")); + QNDEBUG("NoteEditorPrivate::saveAttachmentUnderCursor"); if ((m_currentContextMenuExtraData.m_contentType != QStringLiteral("ImageResource")) && (m_currentContextMenuExtraData.m_contentType != QStringLiteral("NonImageResource"))) { ErrorString error(QT_TR_NOOP("can't save attachment under cursor: wrong " "current context menu extra data's content type")); - QNWARNING(error << QStringLiteral(": content type = ") + QNWARNING(error << ": content type = " << m_currentContextMenuExtraData.m_contentType); Q_EMIT notifyError(error); return; @@ -9984,7 +9983,7 @@ void NoteEditorPrivate::openAttachment(const QByteArray & resourceHash) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::openAttachment")); + QNDEBUG("NoteEditorPrivate::openAttachment"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't open the attachment")) onOpenResourceRequest(resourceHash); @@ -9992,7 +9991,7 @@ void NoteEditorPrivate::openAttachmentUnderCursor() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::openAttachmentUnderCursor")); + QNDEBUG("NoteEditorPrivate::openAttachmentUnderCursor"); if ((m_currentContextMenuExtraData.m_contentType != QStringLiteral("ImageResource")) && (m_currentContextMenuExtraData.m_contentType != QStringLiteral("NonImageResource"))) @@ -10000,7 +9999,7 @@ ErrorString error(QT_TR_NOOP("Can't open attachment under cursor: wrong " "current context menu extra data's content type")); error.details() = m_currentContextMenuExtraData.m_contentType; - QNWARNING(error << QStringLiteral(": content type = ") + QNWARNING(error << ": content type = " << m_currentContextMenuExtraData.m_contentType); Q_EMIT notifyError(error); return; @@ -10027,8 +10026,7 @@ { ErrorString error(QT_TR_NOOP("The attachment to be copied was not found " "within the note")); - QNWARNING(error << QStringLiteral(", resource hash = ") - << resourceHash.toHex()); + QNWARNING(error << ", resource hash = " << resourceHash.toHex()); Q_EMIT notifyError(error); return; } @@ -10039,14 +10037,14 @@ { ErrorString error(QT_TR_NOOP("Can't copy the attachment as it has neither " "data body nor alternate data body")); - QNWARNING(error << QStringLiteral(", resource hash = ") << resourceHash.toHex()); + QNWARNING(error << ", resource hash = " << resourceHash.toHex()); Q_EMIT notifyError(error); return; } if (Q_UNLIKELY(!resource.hasMime())) { ErrorString error(QT_TR_NOOP("Can't copy the attachment as it has no mime type")); - QNWARNING(error << QStringLiteral(", resource hash = ") << resourceHash.toHex()); + QNWARNING(error << ", resource hash = " << resourceHash.toHex()); Q_EMIT notifyError(error); return; } @@ -10073,7 +10071,7 @@ void NoteEditorPrivate::copyAttachmentUnderCursor() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::copyAttachmentUnderCursor")); + QNDEBUG("NoteEditorPrivate::copyAttachmentUnderCursor"); if ((m_currentContextMenuExtraData.m_contentType != QStringLiteral("ImageResource")) && (m_currentContextMenuExtraData.m_contentType != QStringLiteral("NonImageResource"))) @@ -10094,7 +10092,7 @@ void NoteEditorPrivate::removeAttachment(const QByteArray & resourceHash) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::removeAttachment: hash = ") + QNDEBUG("NoteEditorPrivate::removeAttachment: hash = " << resourceHash.toHex()); if (Q_UNLIKELY(m_pNote.isNull())) { @@ -10166,7 +10164,7 @@ void NoteEditorPrivate::removeAttachmentUnderCursor() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::removeAttachmentUnderCursor")); + QNDEBUG("NoteEditorPrivate::removeAttachmentUnderCursor"); if ((m_currentContextMenuExtraData.m_contentType != QStringLiteral("ImageResource")) && (m_currentContextMenuExtraData.m_contentType != QStringLiteral("NonImageResource"))) @@ -10187,7 +10185,7 @@ void NoteEditorPrivate::renameAttachmentUnderCursor() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::renameAttachmentUnderCursor")); + QNDEBUG("NoteEditorPrivate::renameAttachmentUnderCursor"); if (m_currentContextMenuExtraData.m_contentType != QStringLiteral("NonImageResource")) { @@ -10207,7 +10205,7 @@ void NoteEditorPrivate::renameAttachment(const QByteArray & resourceHash) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::renameAttachment: resource hash = ") + QNDEBUG("NoteEditorPrivate::renameAttachment: resource hash = " << resourceHash.toHex()); ErrorString errorPrefix(QT_TR_NOOP("Can't rename the attachment")); @@ -10255,7 +10253,7 @@ if (Q_UNLIKELY(!resource.hasDataHash())) { ErrorString error = errorPrefix; error.appendBase(QT_TR_NOOP("The resource doesn't have the data hash set")); - QNWARNING(error << QStringLiteral(", resource: ") << resource); + QNWARNING(error << ", resource: " << resource); Q_EMIT notifyError(error); return; } @@ -10271,11 +10269,11 @@ delegate->start(); } -void NoteEditorPrivate::rotateImageAttachment(const QByteArray & resourceHash, - const Rotation::type rotationDirection) +void NoteEditorPrivate::rotateImageAttachment( + const QByteArray & resourceHash, const Rotation::type rotationDirection) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::rotateImageAttachment: resource hash = ") - << resourceHash.toHex() << QStringLiteral(", rotation: ") + QNDEBUG("NoteEditorPrivate::rotateImageAttachment: resource hash = " + << resourceHash.toHex() << ", rotation: " << rotationDirection); ErrorString errorPrefix(QT_TR_NOOP("Can't rotate the image attachment")); @@ -10304,7 +10302,7 @@ ErrorString error = errorPrefix; error.appendBase(QT_TR_NOOP("The corresponding attachment's " "mime type is not set")); - QNWARNING(error << QStringLiteral(", resource: ") << resource); + QNWARNING(error << ", resource: " << resource); Q_EMIT notifyError(error); return; } @@ -10315,7 +10313,7 @@ error.appendBase(QT_TR_NOOP("The corresponding attachment's mime type " "indicates it is not an image")); error.details() = resource.mime(); - QNWARNING(error << QStringLiteral(", resource: ") << resource); + QNWARNING(error << ", resource: " << resource); Q_EMIT notifyError(error); return; } @@ -10337,8 +10335,8 @@ Resource & resource = resources[targetResourceIndex]; if (!resource.hasDataBody()) { - QNDEBUG(QStringLiteral("The resource to be rotated doesn't have data body " - "set, requesting it from NoteEditorLocalStorageBroker")); + QNDEBUG("The resource to be rotated doesn't have data body " + "set, requesting it from NoteEditorLocalStorageBroker"); QString resourceLocalUid = resource.localUid(); m_rotationTypeByResourceLocalUidsPendingFindDataInLocalStorage[resourceLocalUid] = rotationDirection; @@ -10349,7 +10347,7 @@ if (Q_UNLIKELY(!resource.hasDataHash())) { ErrorString error = errorPrefix; error.appendBase(QT_TR_NOOP("The attachment doesn't have the data hash set")); - QNWARNING(error << QStringLiteral(", resource: ") << resource); + QNWARNING(error << ", resource: " << resource); Q_EMIT notifyError(error); return; } @@ -10380,8 +10378,8 @@ void NoteEditorPrivate::rotateImageAttachmentUnderCursor( const Rotation::type rotationDirection) { - QNDEBUG(QStringLiteral("INoteEditorBackend::rotateImageAttachmentUnderCursor: ") - << QStringLiteral("rotation: ") << rotationDirection); + QNDEBUG("NoteEditorPrivate::rotateImageAttachmentUnderCursor: " + << "rotation: " << rotationDirection); if (m_currentContextMenuExtraData.m_contentType != QStringLiteral("ImageResource")) { @@ -10402,26 +10400,27 @@ void NoteEditorPrivate::rotateImageAttachmentUnderCursorClockwise() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::" - "rotateImageAttachmentUnderCursorClockwise")); + QNDEBUG("NoteEditorPrivate::" + "rotateImageAttachmentUnderCursorClockwise"); rotateImageAttachmentUnderCursor(Rotation::Clockwise); } void NoteEditorPrivate::rotateImageAttachmentUnderCursorCounterclockwise() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::" - "rotateImageAttachmentUnderCursorCounterclockwise")); + QNDEBUG("NoteEditorPrivate::" + "rotateImageAttachmentUnderCursorCounterclockwise"); rotateImageAttachmentUnderCursor(Rotation::Counterclockwise); } void NoteEditorPrivate::encryptSelectedText() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::encryptSelectedText")); + QNDEBUG("NoteEditorPrivate::encryptSelectedText"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't encrypt the selected text")) EncryptSelectedTextDelegate * delegate = - new EncryptSelectedTextDelegate(this, m_encryptionManager, m_decryptedTextManager); + new EncryptSelectedTextDelegate(this, m_encryptionManager, + m_decryptedTextManager); QObject::connect(delegate, QNSIGNAL(EncryptSelectedTextDelegate,finished), @@ -10441,9 +10440,10 @@ void NoteEditorPrivate::decryptEncryptedTextUnderCursor() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::decryptEncryptedTextUnderCursor")); + QNDEBUG("NoteEditorPrivate::decryptEncryptedTextUnderCursor"); - if (Q_UNLIKELY(m_currentContextMenuExtraData.m_contentType != QStringLiteral("EncryptedText"))) + if (Q_UNLIKELY(m_currentContextMenuExtraData.m_contentType != + QStringLiteral("EncryptedText"))) { ErrorString error(QT_TR_NOOP("Can't decrypt the encrypted text under " "cursor: wrong current context menu extra " @@ -10467,7 +10467,7 @@ QString length, QString hint, QString enCryptIndex) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::decryptEncryptedText")); + QNDEBUG("NoteEditorPrivate::decryptEncryptedText"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't decrypt the encrypted text")) @@ -10499,9 +10499,10 @@ void NoteEditorPrivate::hideDecryptedTextUnderCursor() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::hideDecryptedTextUnderCursor")); + QNDEBUG("NoteEditorPrivate::hideDecryptedTextUnderCursor"); - if (Q_UNLIKELY(m_currentContextMenuExtraData.m_contentType != QStringLiteral("GenericText"))) + if (Q_UNLIKELY(m_currentContextMenuExtraData.m_contentType != + QStringLiteral("GenericText"))) { ErrorString error(QT_TR_NOOP("Can't hide the decrypted text under cursor: " "wrong current context menu extra data's " @@ -10539,7 +10540,7 @@ QString hint, QString id) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::hideDecryptedText")); + QNDEBUG("NoteEditorPrivate::hideDecryptedText"); bool conversionResult = false; size_t keyLengthInt = static_cast<size_t>(keyLength.toInt(&conversionResult)); @@ -10561,9 +10562,9 @@ rememberForSession); if (foundOriginalDecryptedText && (decryptedText != originalDecryptedText)) { - QNDEBUG(QStringLiteral("The original decrypted text doesn't match " - "the newer one, will return-encrypt " - "the decrypted text")); + QNDEBUG("The original decrypted text doesn't match " + "the newer one, will return-encrypt " + "the decrypted text"); QString newEncryptedText; bool reEncryptedText = m_decryptedTextManager->modifyDecryptedText(encryptedText, @@ -10580,8 +10581,8 @@ return; } - QNDEBUG(QStringLiteral("Old encrypted text = ") << encryptedText - << QStringLiteral(", new encrypted text = ") << newEncryptedText); + QNDEBUG("Old encrypted text = " << encryptedText + << ", new encrypted text = " << newEncryptedText); encryptedText = newEncryptedText; } @@ -10603,7 +10604,7 @@ void NoteEditorPrivate::editHyperlinkDialog() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::editHyperlinkDialog")); + QNDEBUG("NoteEditorPrivate::editHyperlinkDialog"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't edit the hyperlink")) @@ -10620,7 +10621,7 @@ void NoteEditorPrivate::copyHyperlink() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::copyHyperlink")); + QNDEBUG("NoteEditorPrivate::copyHyperlink"); GET_PAGE() page->executeJavaScript( @@ -10631,7 +10632,7 @@ void NoteEditorPrivate::removeHyperlink() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::removeHyperlink")); + QNDEBUG("NoteEditorPrivate::removeHyperlink"); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't remove the hyperlink")) @@ -10651,14 +10652,14 @@ void NoteEditorPrivate::onNoteLoadCancelled() { stop(); - QNINFO(QStringLiteral("Note load has been cancelled")); + QNINFO("Note load has been cancelled"); // TODO: add some overlay widget for NoteEditor to properly indicate visually // that the note load has been cancelled } void NoteEditorPrivate::onTableResized() { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onTableResized")); + QNDEBUG("NoteEditorPrivate::onTableResized"); convertToNote(); } @@ -10666,8 +10667,7 @@ const QVariant & hyperlinkData, const QVector<QPair<QString, QString> > & extraData) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onFoundSelectedHyperlinkId: ") - << hyperlinkData); + QNDEBUG("NoteEditorPrivate::onFoundSelectedHyperlinkId: " << hyperlinkData); Q_UNUSED(extraData) QMap<QString,QVariant> resultMap = hyperlinkData.toMap(); @@ -10685,8 +10685,8 @@ bool res = statusIt.value().toBool(); if (!res) { - QNTRACE(QStringLiteral("No hyperlink id under cursor was found, assuming " - "we're adding the new hyperlink to the selected text")); + QNTRACE("No hyperlink id under cursor was found, assuming " + "we're adding the new hyperlink to the selected text"); GET_PAGE() @@ -10717,7 +10717,7 @@ return; } - QNTRACE(QStringLiteral("Will edit the hyperlink with id ") << hyperlinkId); + QNTRACE("Will edit the hyperlink with id " << hyperlinkId); EditHyperlinkDelegate * delegate = new EditHyperlinkDelegate(*this, hyperlinkId); QObject::connect(delegate, QNSIGNAL(EditHyperlinkDelegate,finished), @@ -10739,13 +10739,13 @@ const QVariant & hyperlinkData, const QVector<QPair<QString, QString> > & extraData) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::onFoundHyperlinkToCopy: ") + QNDEBUG("NoteEditorPrivate::onFoundHyperlinkToCopy: " << hyperlinkData); Q_UNUSED(extraData); QStringList hyperlinkDataList = hyperlinkData.toStringList(); if (hyperlinkDataList.isEmpty()) { - QNTRACE(QStringLiteral("Hyperlink data to copy was not found")); + QNTRACE("Hyperlink data to copy was not found"); return; } @@ -10760,7 +10760,7 @@ QClipboard * pClipboard = QApplication::clipboard(); if (Q_UNLIKELY(!pClipboard)) { - QNWARNING(QStringLiteral("Unable to get window system clipboard")); + QNWARNING("Unable to get window system clipboard"); } else { pClipboard->setText(hyperlinkDataList[1]); @@ -10769,7 +10769,7 @@ void NoteEditorPrivate::dropFile(const QString & filePath) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::dropFile: ") << filePath); + QNDEBUG("NoteEditorPrivate::dropFile: " << filePath); CHECK_NOTE_EDITABLE(QT_TR_NOOP("Can't add the attachment via drag'n'drop")) @@ -10794,7 +10794,7 @@ void NoteEditorPrivate::pasteImageData(const QMimeData & mimeData) { - QNDEBUG(QStringLiteral("NoteEditorPrivate::pasteImageData")); + QNDEBUG("NoteEditorPrivate::pasteImageData"); QImage image = qvariant_cast<QImage>(mimeData.imageData()); QByteArray data; @@ -10855,5 +10855,5 @@ Q_INIT_RESOURCE(scripts); Q_INIT_RESOURCE(hilitor); - QNDEBUG(QStringLiteral("Initialized NoteEditor's qrc resources")); + QNDEBUG("Initialized NoteEditor's qrc resources"); } diff -Nru libquentier-0.5.0/src/note_editor/NoteEditor_p.h libquentier-0.5.0/src/note_editor/NoteEditor_p.h --- libquentier-0.5.0/src/note_editor/NoteEditor_p.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/NoteEditor_p.h 2019-07-11 10:46:53.000000000 +0000 @@ -21,6 +21,7 @@ #include "ResourceInfo.h" #include "NoteEditorPage.h" + #include <quentier/note_editor/INoteEditorBackend.h> #include <quentier/note_editor/NoteEditor.h> #include <quentier/enml/DecryptedTextManager.h> @@ -30,6 +31,7 @@ #include <quentier/types/ErrorString.h> #include <quentier/types/Notebook.h> #include <quentier/types/ResourceRecognitionIndices.h> + #include <QObject> #include <QMimeType> #include <QFont> @@ -47,6 +49,7 @@ typedef QWebEnginePage WebPage; #else #include "NoteEditorPluginFactory.h" + #include <QWebView> typedef QWebView WebView; typedef QWebPage WebPage; @@ -133,7 +136,8 @@ void noteLoaded(); - // Signals to notify anyone interested of the formatting at the current cursor position + // Signals to notify anyone interested of the formatting at the current + // cursor position void textBoldState(bool state); void textItalicState(bool state); void textUnderlineState(bool state); @@ -302,14 +306,16 @@ virtual void insertTableDialog() Q_DECL_OVERRIDE; virtual void insertFixedWidthTable(const int rows, const int columns, const int widthInPixels) Q_DECL_OVERRIDE; - virtual void insertRelativeWidthTable(const int rows, const int columns, - const double relativeWidth) Q_DECL_OVERRIDE; + virtual void insertRelativeWidthTable( + const int rows, const int columns, + const double relativeWidth) Q_DECL_OVERRIDE; virtual void insertTableRow() Q_DECL_OVERRIDE; virtual void insertTableColumn() Q_DECL_OVERRIDE; virtual void removeTableRow() Q_DECL_OVERRIDE; virtual void removeTableColumn() Q_DECL_OVERRIDE; virtual void addAttachmentDialog() Q_DECL_OVERRIDE; - virtual void saveAttachmentDialog(const QByteArray & resourceHash) Q_DECL_OVERRIDE; + virtual void saveAttachmentDialog( + const QByteArray & resourceHash) Q_DECL_OVERRIDE; virtual void saveAttachmentUnderCursor() Q_DECL_OVERRIDE; virtual void openAttachment(const QByteArray & resourceHash) Q_DECL_OVERRIDE; virtual void openAttachmentUnderCursor() Q_DECL_OVERRIDE; @@ -319,8 +325,9 @@ virtual void removeAttachmentUnderCursor() Q_DECL_OVERRIDE; virtual void renameAttachment(const QByteArray & resourceHash) Q_DECL_OVERRIDE; virtual void renameAttachmentUnderCursor() Q_DECL_OVERRIDE; - virtual void rotateImageAttachment(const QByteArray & resourceHash, - const Rotation::type rotationDirection) Q_DECL_OVERRIDE; + virtual void rotateImageAttachment( + const QByteArray & resourceHash, + const Rotation::type rotationDirection) Q_DECL_OVERRIDE; virtual void rotateImageAttachmentUnderCursor( const Rotation::type rotationDirection) Q_DECL_OVERRIDE; @@ -345,13 +352,15 @@ virtual void onNoteLoadCancelled() Q_DECL_OVERRIDE; - virtual bool print(QPrinter & printer, ErrorString & errorDescription) Q_DECL_OVERRIDE; + virtual bool print(QPrinter & printer, + ErrorString & errorDescription) Q_DECL_OVERRIDE; virtual bool exportToPdf(const QString & absoluteFilePath, ErrorString & errorDescription) Q_DECL_OVERRIDE; virtual bool exportToEnex(const QStringList & tagNames, QString & enex, ErrorString & errorDescription) Q_DECL_OVERRIDE; - virtual void setCurrentNoteLocalUid(const QString & noteLocalUid) Q_DECL_OVERRIDE; + virtual void setCurrentNoteLocalUid( + const QString & noteLocalUid) Q_DECL_OVERRIDE; virtual void clear() Q_DECL_OVERRIDE; virtual void setFocusToEditor() Q_DECL_OVERRIDE; virtual void convertToNote() Q_DECL_OVERRIDE; @@ -439,12 +448,16 @@ void onNoteLoadFinished(bool ok); void onContentChanged(); - void onResourceFileChanged(QString resourceLocalUid, QString fileStoragePath, - QByteArray resourceData, QByteArray resourceDataHash); + void onResourceFileChanged(QString resourceLocalUid, + QString fileStoragePath, + QByteArray resourceData, + QByteArray resourceDataHash); #ifdef QUENTIER_USE_QT_WEB_ENGINE - void onGenericResourceImageSaved(bool success, QByteArray resourceActualHash, - QString filePath, ErrorString errorDescription, + void onGenericResourceImageSaved(bool success, + QByteArray resourceActualHash, + QString filePath, + ErrorString errorDescription, QUuid requestId); void onHyperlinkClicked(QString url); @@ -523,17 +536,21 @@ QString resourceFileStoragePath); void onAddResourceDelegateError(ErrorString error); void onAddResourceUndoRedoFinished( - const QVariant & data, const QVector<QPair<QString,QString> > & extraData); + const QVariant & data, + const QVector<QPair<QString,QString> > & extraData); - void onRemoveResourceDelegateFinished(Resource removedResource, bool reversible); + void onRemoveResourceDelegateFinished(Resource removedResource, + bool reversible); void onRemoveResourceDelegateCancelled(QString resourceLocalUid); void onRemoveResourceDelegateError(ErrorString error); void onRemoveResourceUndoRedoFinished( - const QVariant & data, const QVector<QPair<QString,QString> > & extraData); + const QVariant & data, + const QVector<QPair<QString,QString> > & extraData); void onRenameResourceDelegateFinished(QString oldResourceName, QString newResourceName, - Resource resource, bool performingUndo); + Resource resource, + bool performingUndo); void onRenameResourceDelegateCancelled(); void onRenameResourceDelegateError(ErrorString error); @@ -547,16 +564,19 @@ void onImageResourceRotationDelegateError(ErrorString error); void onHideDecryptedTextFinished( - const QVariant & data, const QVector<QPair<QString,QString> > & extraData); + const QVariant & data, + const QVector<QPair<QString,QString> > & extraData); void onHideDecryptedTextUndoRedoFinished( - const QVariant & data, const QVector<QPair<QString,QString> > & extraData); + const QVariant & data, + const QVector<QPair<QString,QString> > & extraData); void onEncryptSelectedTextDelegateFinished(); void onEncryptSelectedTextDelegateCancelled(); void onEncryptSelectedTextDelegateError(ErrorString error); void onEncryptSelectedTextUndoRedoFinished( - const QVariant & data, const QVector<QPair<QString,QString> > & extraData); + const QVariant & data, + const QVector<QPair<QString,QString> > & extraData); void onDecryptEncryptedTextDelegateFinished( QString encryptedText, QString cipher, size_t length, QString hint, @@ -565,33 +585,39 @@ void onDecryptEncryptedTextDelegateCancelled(); void onDecryptEncryptedTextDelegateError(ErrorString error); void onDecryptEncryptedTextUndoRedoFinished( - const QVariant & data, const QVector<QPair<QString,QString> > & extraData); + const QVariant & data, + const QVector<QPair<QString,QString> > & extraData); void onAddHyperlinkToSelectedTextDelegateFinished(); void onAddHyperlinkToSelectedTextDelegateCancelled(); void onAddHyperlinkToSelectedTextDelegateError(ErrorString error); void onAddHyperlinkToSelectedTextUndoRedoFinished( - const QVariant & data, const QVector<QPair<QString,QString> > & extraData); + const QVariant & data, + const QVector<QPair<QString,QString> > & extraData); void onEditHyperlinkDelegateFinished(); void onEditHyperlinkDelegateCancelled(); void onEditHyperlinkDelegateError(ErrorString error); void onEditHyperlinkUndoRedoFinished( - const QVariant & data, const QVector<QPair<QString,QString> > & extraData); + const QVariant & data, + const QVector<QPair<QString,QString> > & extraData); void onRemoveHyperlinkDelegateFinished(); void onRemoveHyperlinkDelegateError(ErrorString error); void onRemoveHyperlinkUndoRedoFinished( - const QVariant & data, const QVector<QPair<QString,QString> > & extraData); + const QVariant & data, + const QVector<QPair<QString,QString> > & extraData); void onInsertHtmlDelegateFinished(QList<Resource> addedResources, QStringList resourceFileStoragePaths); void onInsertHtmlDelegateError(ErrorString error); void onInsertHtmlUndoRedoFinished( - const QVariant & data, const QVector<QPair<QString,QString> > & extraData); + const QVariant & data, + const QVector<QPair<QString,QString> > & extraData); void onSourceCodeFormatUndoRedoFinished( - const QVariant & data, const QVector<QPair<QString,QString> > & extraData); + const QVariant & data, + const QVector<QPair<QString,QString> > & extraData); // Slots for undo command signals void onUndoCommandError(ErrorString error); @@ -653,10 +679,13 @@ template <typename T> QString composeHtmlTable(const T width, const T singleColumnWidth, - const int rows, const int columns, const bool relative); + const int rows, const int columns, + const bool relative); void onManagedPageActionFinished( - const QVariant & result, const QVector<QPair<QString, QString> > & extraData); + const QVariant & result, + const QVector<QPair<QString, QString> > & extraData); + void updateJavaScriptBindings(); void changeFontSize(const bool increase); @@ -681,9 +710,9 @@ */ Initial = 0, /** - * Blank page of "NoteNotFound" kind is displayed if no note corresponding - * to the local uid passed to setCurrentNoteLocalUid slot was found - * within the local storage + * Blank page of "NoteNotFound" kind is displayed if no note + * corresponding to the local uid passed to setCurrentNoteLocalUid + * slot was found * within the local storage */ NoteNotFound, /** @@ -710,11 +739,14 @@ * Reset the page displayed by the note editor to one of "blank" ones * not corresponding to any note * - * @param kind The kind of replacement page for the note editor - * @param errorDescription The description of error used if kind is "InternalError" + * @param kind The kind of replacement page for the note + * editor + * @param errorDescription The description of error used if kind is + * "InternalError" */ - void clearEditorContent(const BlankPageKind::type kind = BlankPageKind::Initial, - const ErrorString & errorDescription = ErrorString()); + void clearEditorContent( + const BlankPageKind::type kind = BlankPageKind::Initial, + const ErrorString & errorDescription = ErrorString()); void noteToEditorContent(); void updateColResizableTableBindings(); @@ -781,14 +813,17 @@ bool checkContextMenuSequenceNumber(const quint64 sequenceNumber) const; void onPageHtmlReceived( - const QString & html, const QVector<QPair<QString,QString> > & extraData = - QVector<QPair<QString,QString> >()); + const QString & html, + const QVector<QPair<QString,QString> > & extraData = + QVector<QPair<QString,QString> >()); void onSelectedTextEncryptionDone( - const QVariant & dummy, const QVector<QPair<QString,QString> > & extraData); + const QVariant & dummy, + const QVector<QPair<QString,QString> > & extraData); void onTableActionDone( - const QVariant & dummy, const QVector<QPair<QString,QString> > & extraData); + const QVariant & dummy, + const QVector<QPair<QString,QString> > & extraData); int resourceIndexByHash(const QList<Resource> & resources, const QByteArray & resourceHash) const; @@ -811,28 +846,34 @@ void disableSpellCheck(); void onSpellCheckSetOrCleared( - const QVariant & dummy, const QVector<QPair<QString,QString> > & extraData); + const QVariant & dummy, + const QVector<QPair<QString,QString> > & extraData); void replaceDefaultPalette(); - void onDefaultPaletteReplaced(const QVariant & data, const QVector<QPair<QString,QString> > & extraData); + void onDefaultPaletteReplaced( + const QVariant & data, + const QVector<QPair<QString,QString> > & extraData); bool isNoteReadOnly() const; - void setupAddHyperlinkDelegate(const quint64 hyperlinkId, - const QString & presetHyperlink = QString(), - const QString & replacementLinkText = QString()); + void setupAddHyperlinkDelegate( + const quint64 hyperlinkId, + const QString & presetHyperlink = QString(), + const QString & replacementLinkText = QString()); #ifdef QUENTIER_USE_QT_WEB_ENGINE void onPageHtmlReceivedForPrinting( - const QString & html, const QVector<QPair<QString,QString> > & extraData = - QVector<QPair<QString,QString> >()); + const QString & html, + const QVector<QPair<QString,QString> > & extraData = + QVector<QPair<QString,QString> >()); #endif void clearCurrentNoteInfo(); void reloadCurrentNote(); void clearPrepareNoteImageResourcesProgressDialog(); - void clearPrepareResourceForOpeningProgressDialog(const QString & resourceLocalUid); + void clearPrepareResourceForOpeningProgressDialog( + const QString & resourceLocalUid); private: // Overrides for some Qt's virtual methods @@ -849,13 +890,16 @@ class Q_DECL_HIDDEN NoteEditorCallbackFunctor { public: - NoteEditorCallbackFunctor(NoteEditorPrivate * pNoteEditor, - void (NoteEditorPrivate::* method)( - const T & result, - const QVector<QPair<QString,QString> > & extraData), - const QVector<QPair<QString,QString> > & extraData = - QVector<QPair<QString,QString> >()) : - m_pNoteEditor(pNoteEditor), m_method(method), m_extraData(extraData) + NoteEditorCallbackFunctor( + NoteEditorPrivate * pNoteEditor, + void (NoteEditorPrivate::* method)( + const T & result, + const QVector<QPair<QString,QString> > & extraData), + const QVector<QPair<QString,QString> > & extraData = + QVector<QPair<QString,QString> >()) : + m_pNoteEditor(pNoteEditor), + m_method(method), + m_extraData(extraData) {} NoteEditorCallbackFunctor(const NoteEditorCallbackFunctor<T> & other) : @@ -864,7 +908,8 @@ m_extraData(other.m_extraData) {} - NoteEditorCallbackFunctor & operator=(const NoteEditorCallbackFunctor<T> & other) + NoteEditorCallbackFunctor & operator=( + const NoteEditorCallbackFunctor<T> & other) { if (this != &other) { m_pNoteEditor = other.m_pNoteEditor; @@ -885,7 +930,8 @@ private: QPointer<NoteEditorPrivate> m_pNoteEditor; void (NoteEditorPrivate::* m_method)( - const T & result, const QVector<QPair<QString,QString> > & extraData); + const T & result, + const QVector<QPair<QString,QString> > & extraData); QVector<QPair<QString, QString> > m_extraData; }; diff -Nru libquentier-0.5.0/src/note_editor/NoteEditorPluginFactory.cpp libquentier-0.5.0/src/note_editor/NoteEditorPluginFactory.cpp --- libquentier-0.5.0/src/note_editor/NoteEditorPluginFactory.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/NoteEditorPluginFactory.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -20,6 +20,7 @@ #include "GenericResourceDisplayWidget.h" #include "EncryptedAreaPlugin.h" #include "NoteEditor_p.h" + #include <quentier/utility/EncryptionManager.h> #include <quentier/enml/DecryptedTextManager.h> #include <quentier/utility/QuentierCheckPtr.h> @@ -28,16 +29,18 @@ #include <quentier/logging/QuentierLogger.h> #include <quentier/types/Note.h> #include <quentier/types/Resource.h> + #include <QFileIconProvider> #include <QDir> #include <QRegExp> + #include <cmath> #include <algorithm> namespace quentier { -NoteEditorPluginFactory::NoteEditorPluginFactory(NoteEditorPrivate & noteEditor, - QObject * parent) : +NoteEditorPluginFactory::NoteEditorPluginFactory( + NoteEditorPrivate & noteEditor, QObject * parent) : QWebPluginFactory(parent), m_noteEditor(noteEditor), m_resourcePlugins(), @@ -50,12 +53,12 @@ m_genericResourceDisplayWidgetPlugins(), m_encryptedAreaPlugins() { - QNDEBUG(QStringLiteral("NoteEditorPluginFactory::NoteEditorPluginFactory")); + QNDEBUG("NoteEditorPluginFactory::NoteEditorPluginFactory"); } NoteEditorPluginFactory::~NoteEditorPluginFactory() { - QNDEBUG(QStringLiteral("NoteEditorPluginFactory::~NoteEditorPluginFactory")); + QNDEBUG("NoteEditorPluginFactory::~NoteEditorPluginFactory"); for(auto it = m_genericResourceDisplayWidgetPlugins.begin(), end = m_genericResourceDisplayWidgetPlugins.end(); it != end; ++it) @@ -84,16 +87,15 @@ } NoteEditorPluginFactory::ResourcePluginIdentifier -NoteEditorPluginFactory::addResourcePlugin(INoteEditorResourcePlugin * plugin, - ErrorString & errorDescription, - const bool forceOverrideTypeKeys) +NoteEditorPluginFactory::addResourcePlugin( + INoteEditorResourcePlugin * plugin, + ErrorString & errorDescription, + const bool forceOverrideTypeKeys) { - QNDEBUG(QStringLiteral("NoteEditorPluginFactory::addResourcePlugin: ") + QNDEBUG("NoteEditorPluginFactory::addResourcePlugin: " << (plugin ? plugin->name() : QStringLiteral("<null>")) - << QStringLiteral(", force override type keys = ") - << (forceOverrideTypeKeys - ? QStringLiteral("true") - : QStringLiteral("false"))); + << ", force override type keys = " + << (forceOverrideTypeKeys ? "true" : "false")); if (!plugin) { errorDescription.setBase(QT_TR_NOOP("Detected attempt to install null " @@ -157,8 +159,8 @@ m_resourcePlugins[pluginId] = plugin; - QNTRACE(QStringLiteral("Assigned id ") << pluginId - << QStringLiteral(" to resource plugin ") << plugin->name()); + QNTRACE("Assigned id " << pluginId << " to resource plugin " + << plugin->name()); return pluginId; } @@ -166,7 +168,7 @@ const NoteEditorPluginFactory::ResourcePluginIdentifier id, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("NoteEditorPluginFactory::removeResourcePlugin: ") << id); + QNDEBUG("NoteEditorPluginFactory::removeResourcePlugin: " << id); auto it = m_resourcePlugins.find(id); if (it == m_resourcePlugins.end()) { @@ -179,7 +181,7 @@ INoteEditorResourcePlugin * plugin = it.value(); QString pluginName = (plugin ? plugin->name() : QStringLiteral("<null>")); - QNTRACE(QStringLiteral("Plugin to remove: ") << pluginName); + QNTRACE("Plugin to remove: " << pluginName); delete plugin; plugin = Q_NULLPTR; @@ -188,8 +190,8 @@ QWebPluginFactory::refreshPlugins(); - QNTRACE(QStringLiteral("Done removing resource plugin ") << id - << QStringLiteral(" (") << pluginName << QStringLiteral(")")); + QNTRACE("Done removing resource plugin " << id + << " (" << pluginName << ")"); return true; } @@ -200,9 +202,10 @@ return (it != m_resourcePlugins.end()); } -bool NoteEditorPluginFactory::hasResourcePluginForMimeType(const QString & mimeType) const +bool NoteEditorPluginFactory::hasResourcePluginForMimeType( + const QString & mimeType) const { - QNDEBUG(QStringLiteral("NoteEditorPluginFactory::hasResourcePluginForMimeType: ") + QNDEBUG("NoteEditorPluginFactory::hasResourcePluginForMimeType: " << mimeType); if (m_resourcePlugins.empty()) { @@ -222,9 +225,10 @@ return false; } -bool NoteEditorPluginFactory::hasResourcePluginForMimeType(const QRegExp & mimeTypeRegex) const +bool NoteEditorPluginFactory::hasResourcePluginForMimeType( + const QRegExp & mimeTypeRegex) const { - QNDEBUG(QStringLiteral("NoteEditorPluginFactory::hasResourcePluginForMimeType: ") + QNDEBUG("NoteEditorPluginFactory::hasResourcePluginForMimeType: " << mimeTypeRegex.pattern()); if (m_resourcePlugins.empty()) { @@ -246,7 +250,7 @@ void NoteEditorPluginFactory::setNote(const Note & note) { - QNDEBUG(QStringLiteral("NoteEditorPluginFactory::setNote: change current note to ") + QNDEBUG("NoteEditorPluginFactory::setNote: change current note to " << (note.hasTitle() ? note.title() : note.toString())); m_pCurrentNote = ¬e; } @@ -258,7 +262,7 @@ void NoteEditorPluginFactory::setInactive() { - QNDEBUG(QStringLiteral("NoteEditorPluginFactory::setInactive")); + QNDEBUG("NoteEditorPluginFactory::setInactive"); for(auto it = m_genericResourceDisplayWidgetPlugins.begin(), end = m_genericResourceDisplayWidgetPlugins.end(); it != end; ++it) @@ -281,7 +285,7 @@ void NoteEditorPluginFactory::setActive() { - QNDEBUG(QStringLiteral("NoteEditorPluginFactory::setActive")); + QNDEBUG("NoteEditorPluginFactory::setActive"); for(auto it = m_genericResourceDisplayWidgetPlugins.begin(), end = m_genericResourceDisplayWidgetPlugins.end(); it != end; ++it) @@ -304,7 +308,7 @@ void NoteEditorPluginFactory::updateResource(const Resource & resource) { - QNDEBUG(QStringLiteral("NoteEditorPluginFactory::updateResource: ") << resource); + QNDEBUG("NoteEditorPluginFactory::updateResource: " << resource); auto it = std::find_if(m_genericResourceDisplayWidgetPlugins.begin(), m_genericResourceDisplayWidgetPlugins.end(), @@ -343,20 +347,19 @@ pWidget->updateResourceSize(resourceDataSize); } -QObject * NoteEditorPluginFactory::create(const QString & pluginType, - const QUrl & url, - const QStringList & argumentNames, - const QStringList & argumentValues) const -{ - QNDEBUG(QStringLiteral("NoteEditorPluginFactory::create: pluginType = ") - << pluginType << QStringLiteral(", url = ") << url.toString() - << QStringLiteral(", argument names: ") - << argumentNames.join(QStringLiteral(", ")) - << QStringLiteral(", argument values: ") +QObject * NoteEditorPluginFactory::create( + const QString & pluginType, const QUrl & url, + const QStringList & argumentNames, + const QStringList & argumentValues) const +{ + QNDEBUG("NoteEditorPluginFactory::create: pluginType = " + << pluginType << ", url = " << url.toString() + << ", argument names: " << argumentNames.join(QStringLiteral(", ")) + << ", argument values: " << argumentValues.join(QStringLiteral(", "))); if (!m_pCurrentNote) { - QNERROR(QStringLiteral("Can't create note editor plugin: no note specified")); + QNERROR("Can't create note editor plugin: no note specified"); return Q_NULLPTR; } @@ -367,39 +370,38 @@ return createEncryptedAreaPlugin(argumentNames, argumentValues); } - QNWARNING(QStringLiteral("Can't create note editor plugin: plugin type ") - << QStringLiteral("is not identified: ") << pluginType); + QNWARNING("Can't create note editor plugin: plugin type " + << "is not identified: " << pluginType); return Q_NULLPTR; } QObject * NoteEditorPluginFactory::createResourcePlugin( const QStringList & argumentNames, const QStringList & argumentValues) const { - QNDEBUG(QStringLiteral("NoteEditorPluginFactory::createResourcePlugin: ") - << QStringLiteral("argument names = ") + QNDEBUG("NoteEditorPluginFactory::createResourcePlugin: argument names = " << argumentNames.join(QStringLiteral(",")) - << QStringLiteral("; argument values = ") + << "; argument values = " << argumentValues.join(QStringLiteral(","))); const Account * pAccount = m_noteEditor.accountPtr(); if (Q_UNLIKELY(!pAccount)) { - QNERROR(QStringLiteral("Can't create note editor resource plugin: " - "no account is set to the note editor")); + QNERROR("Can't create note editor resource plugin: " + "no account is set to the note editor"); return Q_NULLPTR; } int resourceHashIndex = argumentNames.indexOf(QStringLiteral("hash")); if (resourceHashIndex < 0) { - QNERROR(QStringLiteral("Can't create note editor resource plugin: " - "hash argument was not found")); + QNERROR("Can't create note editor resource plugin: " + "hash argument was not found"); return Q_NULLPTR; } int resourceMimeTypeIndex = argumentNames.indexOf(QStringLiteral("resource-mime-type")); if (resourceMimeTypeIndex < 0) { - QNERROR(QStringLiteral("Can't create note editor resource plugin: " - "resource-mime-type argument not found")); + QNERROR("Can't create note editor resource plugin: " + "resource-mime-type argument not found"); return Q_NULLPTR; } @@ -426,13 +428,13 @@ } if (!pCurrentResource) { - QNWARNING(QStringLiteral("Can't find resource in note by data hash: ") + QNWARNING("Can't find resource in note by data hash: " << resourceHash.toHex() << QStringLiteral(", note: ") << *m_pCurrentNote); return Q_NULLPTR; } - QNTRACE(QStringLiteral("Number of installed resource plugins: ") + QNTRACE("Number of installed resource plugins: " << m_resourcePlugins.size()); if (!m_resourcePlugins.isEmpty()) @@ -455,22 +457,21 @@ const INoteEditorResourcePlugin * plugin = it.value(); const QStringList mimeTypes = plugin->mimeTypes(); - QNTRACE(QStringLiteral("Testing resource plugin ") << plugin->name() - << QStringLiteral(" with id ") << it.key() - << QStringLiteral(", mime types: ") + QNTRACE("Testing resource plugin " << plugin->name() + << " with id " << it.key() << ", mime types: " << mimeTypes.join(QStringLiteral("; "))); if (mimeTypes.contains(resourceMimeType)) { - QNTRACE(QStringLiteral("Will use plugin ") << plugin->name()); + QNTRACE("Will use plugin " << plugin->name()); INoteEditorResourcePlugin * newPlugin = plugin->clone(); ErrorString errorDescription; bool res = newPlugin->initialize(resourceMimeType, argumentNames, argumentValues, *this, *pCurrentResource, errorDescription); if (!res) { - QNINFO(QStringLiteral("Can't initialize note editor resource plugin ") - << plugin->name() << QStringLiteral(": ") << errorDescription); + QNINFO("Can't initialize note editor resource plugin " + << plugin->name() << ": " << errorDescription); delete newPlugin; continue; } @@ -480,9 +481,9 @@ } } - QNTRACE(QStringLiteral("Haven't found any installed resource plugin supporting mime type ") + QNTRACE("Haven't found any installed resource plugin supporting mime type " << resourceMimeType - << QStringLiteral(", will use generic resource display plugin for that")); + << ", will use generic resource display plugin for that"); QString resourceDisplayName; if (pCurrentResource->hasResourceAttributes()) @@ -499,7 +500,8 @@ QString resourceDataSize; if (pCurrentResource->hasDataSize()) { - quint64 bytes = static_cast<quint64>(std::max(pCurrentResource->dataSize(), 0)); + quint64 bytes = static_cast<quint64>( + std::max(pCurrentResource->dataSize(), 0)); resourceDataSize = humanReadableSize(bytes); } else if (pCurrentResource->hasDataBody()) { @@ -508,7 +510,8 @@ resourceDataSize = humanReadableSize(bytes); } else if (pCurrentResource->hasAlternateDataSize()) { - quint64 bytes = static_cast<quint64>(std::max(pCurrentResource->alternateDataSize(), 0)); + quint64 bytes = static_cast<quint64>( + std::max(pCurrentResource->alternateDataSize(), 0)); resourceDataSize = humanReadableSize(bytes); } else if (pCurrentResource->hasAlternateDataBody()) { @@ -552,10 +555,11 @@ * the parent) */ - pGenericResourceDisplayWidget->initialize(cachedIconIt.value(), - resourceDisplayName, - resourceDataSize, - *pCurrentResource); + pGenericResourceDisplayWidget->initialize( + cachedIconIt.value(), + resourceDisplayName, + resourceDataSize, + *pCurrentResource); m_genericResourceDisplayWidgetPlugins.push_back( QPointer<GenericResourceDisplayWidget>(pGenericResourceDisplayWidget)); @@ -566,21 +570,21 @@ const QStringList & argumentNames, const QStringList & argumentValues) const { QWidget * pParentWidget = qobject_cast<QWidget*>(parent()); - EncryptedAreaPlugin * pEncryptedAreaPlugin = new EncryptedAreaPlugin(m_noteEditor, - pParentWidget); + EncryptedAreaPlugin * pEncryptedAreaPlugin = + new EncryptedAreaPlugin(m_noteEditor, pParentWidget); ErrorString errorDescription; bool res = pEncryptedAreaPlugin->initialize(argumentNames, argumentValues, *this, errorDescription); if (!res) { - QNINFO(QStringLiteral("Can't initialize note editor encrypted area plugin ") - << pEncryptedAreaPlugin->name() - << QStringLiteral(": ") << errorDescription); + QNINFO("Can't initialize note editor encrypted area plugin " + << pEncryptedAreaPlugin->name() << ": " << errorDescription); delete pEncryptedAreaPlugin; return Q_NULLPTR; } - m_encryptedAreaPlugins.push_back(QPointer<EncryptedAreaPlugin>(pEncryptedAreaPlugin)); + m_encryptedAreaPlugins.push_back( + QPointer<EncryptedAreaPlugin>(pEncryptedAreaPlugin)); return pEncryptedAreaPlugin; } @@ -607,27 +611,28 @@ return plugins; } -QIcon NoteEditorPluginFactory::getIconForMimeType(const QString & mimeTypeName) const +QIcon NoteEditorPluginFactory::getIconForMimeType( + const QString & mimeTypeName) const { - QNDEBUG(QStringLiteral("NoteEditorPluginFactory::getIconForMimeType: mime type name = ") + QNDEBUG("NoteEditorPluginFactory::getIconForMimeType: mime type name = " << mimeTypeName); QMimeType mimeType = m_mimeDatabase.mimeTypeForName(mimeTypeName); if (!mimeType.isValid()) { - QNTRACE(QStringLiteral("Couldn't find valid mime type object for name/alias ") - << mimeTypeName << QStringLiteral(", will use \"unknown\" icon")); + QNTRACE("Couldn't find valid mime type object for name/alias " + << mimeTypeName << ", will use \"unknown\" icon"); return m_fallbackResourceIcon; } QString iconName = mimeType.iconName(); if (QIcon::hasThemeIcon(iconName)) { - QNTRACE(QStringLiteral("Found icon from theme, name = ") << iconName); + QNTRACE("Found icon from theme, name = " << iconName); return QIcon::fromTheme(iconName, m_fallbackResourceIcon); } iconName = mimeType.genericIconName(); if (QIcon::hasThemeIcon(iconName)) { - QNTRACE(QStringLiteral("Found generic icon from theme, name = ") << iconName); + QNTRACE("Found generic icon from theme, name = " << iconName); return QIcon::fromTheme(iconName, m_fallbackResourceIcon); } @@ -643,8 +648,8 @@ const int numSuffixes = suffixes.size(); if (numSuffixes == 0) { - QNDEBUG(QStringLiteral("Can't find any file suffix for mime type ") - << mimeTypeName << QStringLiteral(", will use \"unknown\" icon")); + QNDEBUG("Can't find any file suffix for mime type " + << mimeTypeName << ", will use \"unknown\" icon"); return m_fallbackResourceIcon; } @@ -653,7 +658,7 @@ { const QString & suffix = suffixes[i]; if (suffix.isEmpty()) { - QNTRACE(QStringLiteral("Found empty file suffix within suffixes, skipping it")); + QNTRACE("Found empty file suffix within suffixes, skipping it"); continue; } @@ -662,8 +667,8 @@ } if (!hasNonEmptySuffix) { - QNDEBUG(QStringLiteral("All file suffixes for mime type ") << mimeTypeName - << QStringLiteral(" are empty, will use \"unknown\" icon")); + QNDEBUG("All file suffixes for mime type " << mimeTypeName + << " are empty, will use \"unknown\" icon"); return m_fallbackResourceIcon; } @@ -679,10 +684,10 @@ QDir fakeFilesDir(fakeFilesStoragePath); if (!fakeFilesDir.exists()) { - QNDEBUG(QStringLiteral("Fake files storage path doesn't exist yet, " - "will attempt to create it")); + QNDEBUG("Fake files storage path doesn't exist yet, will attempt to " + "create it"); if (!fakeFilesDir.mkpath(fakeFilesStoragePath)) { - QNWARNING(QStringLiteral("Can't create fake files storage path folder")); + QNWARNING("Can't create fake files storage path folder"); return m_fallbackResourceIcon; } } @@ -702,9 +707,8 @@ if (!fakeFilesDir.rmpath(fakeFilesStoragePath + QStringLiteral("/") + filename + QStringLiteral(".") + suffix)) { - QNWARNING(QStringLiteral("Can't remove directory ") - << fileInfo.absolutePath() - << QStringLiteral(" which should not be here in the first place...")); + QNWARNING("Can't remove directory " << fileInfo.absolutePath() + << " which should not be here in the first place..."); continue; } } @@ -714,9 +718,8 @@ QFile fakeFile(fakeFilesStoragePath + QStringLiteral("/") + filename + QStringLiteral(".") + suffix); if (!fakeFile.open(QIODevice::ReadWrite)) { - QNWARNING(QStringLiteral("Can't open file ") << fakeFilesStoragePath - << QStringLiteral("/") << filename << QStringLiteral(".") - << suffix << QStringLiteral(" for writing ")); + QNWARNING("Can't open file " << fakeFilesStoragePath << "/" + << filename << "." << suffix << " for writing "); continue; } } @@ -724,31 +727,30 @@ QFileIconProvider fileIconProvider; QIcon icon = fileIconProvider.icon(fileInfo); if (icon.isNull()) { - QNTRACE(QStringLiteral("File icon provider returned null icon for ") - << QStringLiteral("file with suffix ") << suffix); + QNTRACE("File icon provider returned null icon for " + << "file with suffix " << suffix); } - QNTRACE(QStringLiteral("Returning the icon from file icon provider for mime type ") + QNTRACE("Returning the icon from file icon provider for mime type " << mimeTypeName); return icon; } - QNTRACE(QStringLiteral("Couldn't find appropriate icon from either icon theme " - "or fake file with QFileIconProvider, using \"unknown\" " - "icon as a last resort")); + QNTRACE("Couldn't find appropriate icon from either icon theme or fake " + "file with QFileIconProvider, using \"unknown\" icon as a last " + "resort"); return m_fallbackResourceIcon; } QStringList NoteEditorPluginFactory::getFileSuffixesForMimeType( const QString & mimeTypeName) const { - QNDEBUG(QStringLiteral("NoteEditorPluginFactory::") - << QStringLiteral("getFileSuffixesForMimeType: mime type name = ") - << mimeTypeName); + QNDEBUG("NoteEditorPluginFactory::getFileSuffixesForMimeType: " + << "mime type name = " << mimeTypeName); QMimeType mimeType = m_mimeDatabase.mimeTypeForName(mimeTypeName); if (!mimeType.isValid()) { - QNTRACE(QStringLiteral("Couldn't find valid mime type object for name/alias ") + QNTRACE("Couldn't find valid mime type object for name/alias " << mimeTypeName); return QStringList(); } @@ -759,12 +761,12 @@ QString NoteEditorPluginFactory::getFilterStringForMimeType( const QString & mimeTypeName) const { - QNDEBUG(QStringLiteral("NoteEditorPluginFactory::getFilterStringForMimeType: ") - << QStringLiteral("mime type name = ") << mimeTypeName); + QNDEBUG("NoteEditorPluginFactory::getFilterStringForMimeType: " + << "mime type name = " << mimeTypeName); QMimeType mimeType = m_mimeDatabase.mimeTypeForName(mimeTypeName); if (!mimeType.isValid()) { - QNTRACE(QStringLiteral("Couldn't find valid mime type object for name/alias ") + QNTRACE("Couldn't find valid mime type object for name/alias " << mimeTypeName); return QString(); } diff -Nru libquentier-0.5.0/src/note_editor/NoteEditorPluginFactory.h libquentier-0.5.0/src/note_editor/NoteEditorPluginFactory.h --- libquentier-0.5.0/src/note_editor/NoteEditorPluginFactory.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/NoteEditorPluginFactory.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,6 +20,7 @@ #define LIB_QUENTIER_NOTE_EDITOR_NOTE_EDITOR_PLUGIN_FACTORY_H #include "INoteEditorResourcePlugin.h" + #include <QWebPluginFactory> #include <QMimeDatabase> #include <QIcon> @@ -29,10 +30,13 @@ QT_FORWARD_DECLARE_CLASS(QRegExp) -#define RESOURCE_PLUGIN_HTML_OBJECT_TYPE \ - QStringLiteral("application/vnd.quentier.resource") -#define ENCRYPTED_AREA_PLUGIN_OBJECT_TYPE \ - QStringLiteral("application/vnd.quentier.encrypt") +#define RESOURCE_PLUGIN_HTML_OBJECT_TYPE \ + QStringLiteral("application/vnd.quentier.resource") \ +// RESOURCE_PLUGIN_HTML_OBJECT_TYPE + +#define ENCRYPTED_AREA_PLUGIN_OBJECT_TYPE \ + QStringLiteral("application/vnd.quentier.encrypt") \ +// ENCRYPTED_AREA_PLUGIN_OBJECT_TYPE namespace quentier { @@ -52,7 +56,8 @@ { Q_OBJECT public: - explicit NoteEditorPluginFactory(NoteEditorPrivate & editor, QObject * parent = Q_NULLPTR); + explicit NoteEditorPluginFactory(NoteEditorPrivate & editor, + QObject * parent = Q_NULLPTR); virtual ~NoteEditorPluginFactory(); /** diff -Nru libquentier-0.5.0/src/note_editor/NoteEditorPrivateMacros.h libquentier-0.5.0/src/note_editor/NoteEditorPrivateMacros.h --- libquentier-0.5.0/src/note_editor/NoteEditorPrivateMacros.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/NoteEditorPrivateMacros.h 2019-07-11 10:46:53.000000000 +0000 @@ -19,39 +19,42 @@ #ifndef LIB_QUENTIER_NOTE_EDITOR_NOTE_EDITOR_PRIVATE_MACROS_H #define LIB_QUENTIER_NOTE_EDITOR_NOTE_EDITOR_PRIVATE_MACROS_H -#define GET_PAGE() \ - NoteEditorPage * page = qobject_cast<NoteEditorPage*>(this->page()); \ - if (Q_UNLIKELY(!page)) { \ - QNERROR(QStringLiteral("Can't get access to note editor's underlying page!")); \ - return; \ - } +#define GET_PAGE() \ + NoteEditorPage * page = qobject_cast<NoteEditorPage*>(this->page()); \ + if (Q_UNLIKELY(!page)) { \ + QNERROR("Can't get access to note editor's underlying page!"); \ + return; \ + } \ +// GET_PAGE -#define CHECK_NOTE_EDITABLE(message) \ - if (Q_UNLIKELY(!isPageEditable())) { \ - ErrorString error(message); \ - error.appendBase(QT_TRANSLATE_NOOP("NoteEditorPrivate", \ - "Note is not editable")); \ - QNINFO(error << QStringLiteral(", note: ") \ - << (m_pNote.isNull() \ - ? QStringLiteral("<null>") \ - : m_pNote->toString()) \ - << QStringLiteral("\nNotebook: ") \ - << (m_pNotebook.isNull() \ - ? QStringLiteral("<null>") \ - : m_pNotebook->toString())); \ - Q_EMIT notifyError(error); \ - return; \ - } +#define CHECK_NOTE_EDITABLE(message) \ + if (Q_UNLIKELY(!isPageEditable())) { \ + ErrorString error(message); \ + error.appendBase(QT_TRANSLATE_NOOP("NoteEditorPrivate", \ + "Note is not editable")); \ + QNINFO(error << ", note: " \ + << (m_pNote.isNull() \ + ? QStringLiteral("<null>") \ + : m_pNote->toString()) \ + << "\nNotebook: " \ + << (m_pNotebook.isNull() \ + ? QStringLiteral("<null>") \ + : m_pNotebook->toString())); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// CHECK_NOTE_EDITABLE -#define CHECK_ACCOUNT(message, ...) \ - if (Q_UNLIKELY(m_pAccount.isNull())) { \ - ErrorString error(message); \ - error.appendBase(QT_TRANSLATE_NOOP("NoteEditorPrivate", \ - "No account is associated with "\ - "the note editor")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return __VA_ARGS__; \ - } +#define CHECK_ACCOUNT(message, ...) \ + if (Q_UNLIKELY(m_pAccount.isNull())) { \ + ErrorString error(message); \ + error.appendBase(QT_TRANSLATE_NOOP("NoteEditorPrivate", \ + "No account is associated with " \ + "the note editor")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return __VA_ARGS__; \ + } \ +// CHECK_ACCOUNT #endif // LIB_QUENTIER_NOTE_EDITOR_NOTE_EDITOR_PRIVATE_MACROS_H diff -Nru libquentier-0.5.0/src/note_editor/NoteEditorSettingsNames.h libquentier-0.5.0/src/note_editor/NoteEditorSettingsNames.h --- libquentier-0.5.0/src/note_editor/NoteEditorSettingsNames.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/NoteEditorSettingsNames.h 2019-07-11 10:46:53.000000000 +0000 @@ -21,17 +21,21 @@ #define NOTE_EDITOR_SETTINGS_NAME QStringLiteral("NoteEditor") -#define NOTE_EDITOR_ATTACHMENT_SAVE_LOCATIONS_KEY \ - QStringLiteral("AttachmentSaveLocations") - -#define NOTE_EDITOR_LAST_ATTACHMENT_ADD_LOCATION_KEY \ - QStringLiteral("LastAttachmentAddLocation") - -#define NOTE_EDITOR_ENCRYPTION_REMEMBER_PASSWORD_FOR_SESSION \ - QStringLiteral("Encryption/rememberPassphraseForSession") - -#define NOTE_EDITOR_REMOVE_RESOURCE_UNDO_DATA_SIZE_THRESHOLD \ - QStringLiteral("RemoveResourceUndoDataSizeThreshold") +#define NOTE_EDITOR_ATTACHMENT_SAVE_LOCATIONS_KEY \ + QStringLiteral("AttachmentSaveLocations") \ +// NOTE_EDITOR_ATTACHMENT_SAVE_LOCATIONS_KEY + +#define NOTE_EDITOR_LAST_ATTACHMENT_ADD_LOCATION_KEY \ + QStringLiteral("LastAttachmentAddLocation") \ +// NOTE_EDITOR_LAST_ATTACHMENT_ADD_LOCATION_KEY + +#define NOTE_EDITOR_ENCRYPTION_REMEMBER_PASSWORD_FOR_SESSION \ + QStringLiteral("Encryption/rememberPassphraseForSession") \ +//NOTE_EDITOR_ENCRYPTION_REMEMBER_PASSWORD_FOR_SESSION + +#define NOTE_EDITOR_REMOVE_RESOURCE_UNDO_DATA_SIZE_THRESHOLD \ + QStringLiteral("RemoveResourceUndoDataSizeThreshold") \ +// NOTE_EDITOR_REMOVE_RESOURCE_UNDO_DATA_SIZE_THRESHOLD // 100 Mb in bytes #define NOTE_EDITOR_REMOVE_RESOURCE_UNDO_DATA_SIZE_DEFAULT_THRESHOLD (104857600) diff -Nru libquentier-0.5.0/src/note_editor/ResourceDataInTemporaryFileStorageManager.cpp libquentier-0.5.0/src/note_editor/ResourceDataInTemporaryFileStorageManager.cpp --- libquentier-0.5.0/src/note_editor/ResourceDataInTemporaryFileStorageManager.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/ResourceDataInTemporaryFileStorageManager.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,11 +18,13 @@ #include "ResourceDataInTemporaryFileStorageManager.h" #include "NoteEditorLocalStorageBroker.h" + #include <quentier/types/Note.h> #include <quentier/types/Resource.h> #include <quentier/logging/QuentierLogger.h> #include <quentier/utility/Utility.h> #include <quentier/utility/StandardPaths.h> + #include <QWidget> #include <QFileInfo> #include <QDir> @@ -30,6 +32,7 @@ #include <QDesktopServices> #include <QCryptographicHash> #include <QThread> + #include <cmath> #include <algorithm> #include <fstream> @@ -68,14 +71,13 @@ QString noteLocalUid, QString resourceLocalUid, QByteArray data, QByteArray dataHash, QUuid requestId, bool isImage) { - QNDEBUG(QStringLiteral("ResourceDataInTemporaryFileStorageManager::") - << QStringLiteral("onSaveResourceDataToTemporaryFileRequest: ") - << QStringLiteral("note local uid = ") << noteLocalUid - << QStringLiteral(", resource local uid = ") << resourceLocalUid - << QStringLiteral(", request id = ") << requestId - << QStringLiteral(", data hash = ") << dataHash.toHex() - << QStringLiteral(", is image = ") - << (isImage ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("ResourceDataInTemporaryFileStorageManager::" + << "onSaveResourceDataToTemporaryFileRequest: " + << "note local uid = " << noteLocalUid + << ", resource local uid = " << resourceLocalUid + << ", request id = " << requestId + << ", data hash = " << dataHash.toHex() + << ", is image = " << (isImage ? "true" : "false")); if (dataHash.isEmpty()) { dataHash = calculateHash(data); @@ -94,8 +96,8 @@ return; } - QNDEBUG(QStringLiteral("Successfully wrote resource data to file: ") - << QStringLiteral("resource local uid = ") << resourceLocalUid); + QNDEBUG("Successfully wrote resource data to file: " + << "resource local uid = " << resourceLocalUid); Q_EMIT saveResourceDataToTemporaryFileCompleted(requestId, dataHash, ErrorString()); } @@ -103,19 +105,20 @@ void ResourceDataInTemporaryFileStorageManager::onReadResourceFromFileRequest( QString fileStoragePath, QString resourceLocalUid, QUuid requestId) { - QNDEBUG(QStringLiteral("ResourceDataInTemporaryFileStorageManager::") - << QStringLiteral("onReadResourceFromFileRequest: resource local uid = ") - << resourceLocalUid << QStringLiteral(", request id = ") << requestId); + QNDEBUG("ResourceDataInTemporaryFileStorageManager::" + << "onReadResourceFromFileRequest: resource local uid = " + << resourceLocalUid << ", request id = " << requestId); if (Q_UNLIKELY(m_nonImageResourceFileStorageLocation.isEmpty())) { - ErrorString errorDescription(QT_TR_NOOP("Resource file storage location is empty")); - QNWARNING(errorDescription << QStringLiteral(", resource local uid = ") - << resourceLocalUid << QStringLiteral(", request id = ") - << requestId); - Q_EMIT readResourceFromFileCompleted(requestId, QByteArray(), QByteArray(), - Errors::NoResourceFileStorageLocation, - errorDescription); + ErrorString errorDescription( + QT_TR_NOOP("Resource file storage location is empty")); + QNWARNING(errorDescription << ", resource local uid = " + << resourceLocalUid << ", request id = " << requestId); + Q_EMIT readResourceFromFileCompleted( + requestId, QByteArray(), QByteArray(), + Errors::NoResourceFileStorageLocation, + errorDescription); return; } @@ -123,20 +126,23 @@ bool open = resourceFile.open(QIODevice::ReadOnly); if (Q_UNLIKELY(!open)) { - ErrorString errorDescription(QT_TR_NOOP("Can't open resource file for reading")); + ErrorString errorDescription( + QT_TR_NOOP("Can't open resource file for reading")); errorDescription.details() = resourceFile.errorString(); int errorCode = resourceFile.error(); - QNWARNING(errorDescription << QStringLiteral(", error code = ") << errorCode - << QStringLiteral(", resource local uid = ") << resourceLocalUid - << QStringLiteral(", request id = ") << requestId); - Q_EMIT readResourceFromFileCompleted(requestId, QByteArray(), QByteArray(), - errorCode, errorDescription); + QNWARNING(errorDescription << ", error code = " << errorCode + << ", resource local uid = " << resourceLocalUid + << ", request id = " << requestId); + Q_EMIT readResourceFromFileCompleted( + requestId, QByteArray(), QByteArray(), + errorCode, errorDescription); return; } QFileInfo resourceFileInfo(fileStoragePath); - QFile resourceHashFile(resourceFileInfo.absolutePath() + QStringLiteral("/") + - resourceLocalUid + QStringLiteral(".hash")); + QFile resourceHashFile(resourceFileInfo.absolutePath() + + QStringLiteral("/") + resourceLocalUid + + QStringLiteral(".hash")); open = resourceHashFile.open(QIODevice::ReadOnly); if (Q_UNLIKELY(!open)) { @@ -144,26 +150,28 @@ "for reading")); errorDescription.details() = resourceHashFile.errorString(); int errorCode = resourceHashFile.error(); - QNWARNING(errorDescription << QStringLiteral(", error code = ") << errorCode - << QStringLiteral(", resource local uid = ") << resourceLocalUid - << QStringLiteral(", request id = ") << requestId); - Q_EMIT readResourceFromFileCompleted(requestId, QByteArray(), QByteArray(), - errorCode, errorDescription); + QNWARNING(errorDescription << ", error code = " << errorCode + << ", resource local uid = " << resourceLocalUid + << ", request id = " << requestId); + Q_EMIT readResourceFromFileCompleted( + requestId, QByteArray(), QByteArray(), + errorCode, errorDescription); return; } QByteArray data = resourceFile.readAll(); QByteArray dataHash = resourceHashFile.readAll(); - QNDEBUG(QStringLiteral("Successfully read resource data and hash from files")); - Q_EMIT readResourceFromFileCompleted(requestId, data, dataHash, 0, ErrorString()); + QNDEBUG("Successfully read resource data and hash from files"); + Q_EMIT readResourceFromFileCompleted(requestId, data, dataHash, + 0, ErrorString()); } void ResourceDataInTemporaryFileStorageManager::onOpenResourceRequest( QString resourceLocalUid) { - QNDEBUG(QStringLiteral("ResourceDataInTemporaryFileStorageManager::") - << QStringLiteral("onOpenResourceRequest: resource local uid = ") + QNDEBUG("ResourceDataInTemporaryFileStorageManager::" + << "onOpenResourceRequest: resource local uid = " << resourceLocalUid); if (Q_UNLIKELY(m_pCurrentNote.isNull())) @@ -213,7 +221,7 @@ "resource has no mime type")); errorDescription.details() = QStringLiteral("resource local uid = ") + resourceLocalUid; - QNWARNING(errorDescription << QStringLiteral(", resource: ") << *pResource); + QNWARNING(errorDescription << ", resource: " << *pResource); Q_EMIT failedToOpenResource(resourceLocalUid, noteLocalUid, errorDescription); return; } @@ -228,11 +236,11 @@ if (pResource->hasDataHash() && checkIfResourceFileExistsAndIsActual(noteLocalUid, resourceLocalUid, - fileStoragePath, pResource->dataHash())) + fileStoragePath, + pResource->dataHash())) { - QNDEBUG(QStringLiteral("Temporary file for resource local uid ") - << resourceLocalUid - << QStringLiteral(" already exists and is actual")); + QNDEBUG("Temporary file for resource local uid " << resourceLocalUid + << " already exists and is actual"); m_resourceLocalUidByFilePath[fileStoragePath] = resourceLocalUid; watchResourceFileForChanges(resourceLocalUid, fileStoragePath); @@ -243,7 +251,7 @@ if (!pResource->hasDataBody()) { Q_UNUSED(m_resourceLocalUidsPendingFindInLocalStorageForWritingToFileForOpening.insert( - resourceLocalUid)) + resourceLocalUid)) requestResourceDataFromLocalStorage(*pResource); return; } @@ -276,17 +284,17 @@ void ResourceDataInTemporaryFileStorageManager::onCurrentNoteChanged(Note note) { - QNDEBUG(QStringLiteral("ResourceDataInTemporaryFileStorageManager::") - << QStringLiteral("onCurrentNoteChanged; new note local uid = ") - << note.localUid() << QStringLiteral(", previous note local uid = ") + QNDEBUG("ResourceDataInTemporaryFileStorageManager::" + << "onCurrentNoteChanged; new note local uid = " + << note.localUid() << ", previous note local uid = " << (m_pCurrentNote.isNull() ? QStringLiteral("<null>") : m_pCurrentNote->localUid())); if (!m_pCurrentNote.isNull() && (m_pCurrentNote->localUid() == note.localUid())) { - QNTRACE(QStringLiteral("The current note is the same, only the note " - "object might have changed")); + QNTRACE("The current note is the same, only the note " + "object might have changed"); QList<Resource> previousResources = m_pCurrentNote->resources(); *m_pCurrentNote = note; @@ -310,7 +318,7 @@ end = m_resourceLocalUidByFilePath.constEnd(); it != end; ++it) { m_fileSystemWatcher.removePath(it.key()); - QNTRACE(QStringLiteral("Stopped watching for file ") << it.key()); + QNTRACE("Stopped watching for file " << it.key()); } m_resourceLocalUidByFilePath.clear(); @@ -322,8 +330,8 @@ } if (!m_pCurrentNote->hasResources()) { - QNTRACE(QStringLiteral("Current note has no resources, emitting " - "noteResourcesReady signal")); + QNTRACE("Current note has no resources, emitting " + "noteResourcesReady signal"); Q_EMIT noteResourcesReady(m_pCurrentNote->localUid()); return; } @@ -341,7 +349,7 @@ } imageResources << resource; - QNDEBUG(QStringLiteral("Will process image resource with local uid ") + QNDEBUG("Will process image resource with local uid " << resource.localUid()); } @@ -362,37 +370,41 @@ } } -void ResourceDataInTemporaryFileStorageManager::onRequestDiagnostics(QUuid requestId) +void ResourceDataInTemporaryFileStorageManager::onRequestDiagnostics( + QUuid requestId) { - QNDEBUG(QStringLiteral("ResourceDataInTemporaryFileStorageManager::") - << QStringLiteral("onRequestDiagnostics: request id = ") << requestId); + QNDEBUG("ResourceDataInTemporaryFileStorageManager::" + << "onRequestDiagnostics: request id = " << requestId); + + QString diagnostics; + QTextStream strm(&diagnostics); - QString diagnostics = - QStringLiteral("ResourceDataInTemporaryFileStorageManager diagnostics: {\n"); + strm << "ResourceDataInTemporaryFileStorageManager diagnostics: {\n"; - diagnostics += QStringLiteral(" Resource local uids by file paths: \n"); + strm << " Resource local uids by file paths: \n"; for(auto it = m_resourceLocalUidByFilePath.constBegin(), end = m_resourceLocalUidByFilePath.constEnd(); it != end; ++it) { - diagnostics += QStringLiteral(" [") + it.key() + QStringLiteral("]: ") + - it.value() + QStringLiteral("\n"); + strm << " [" << it.key() << "]: " << it.value() << "\n"; } - diagnostics += QStringLiteral(" Watched files: \n"); + strm << " Watched files: \n"; QStringList watchedFiles = m_fileSystemWatcher.files(); const int numWatchedFiles = watchedFiles.size(); for(int i = 0; i < numWatchedFiles; ++i) { - diagnostics += QStringLiteral(" ") + watchedFiles[i] + QStringLiteral("\n"); + strm << " " << watchedFiles[i] << "\n"; } - diagnostics += QStringLiteral("}\n"); + strm << "}\n"; + strm.flush(); Q_EMIT diagnosticsCollected(requestId, diagnostics); } -void ResourceDataInTemporaryFileStorageManager::onFileChanged(const QString & path) +void ResourceDataInTemporaryFileStorageManager::onFileChanged( + const QString & path) { - QNDEBUG(QStringLiteral("ResourceDataInTemporaryFileStorageManager::onFileChanged: ") + QNDEBUG("ResourceDataInTemporaryFileStorageManager::onFileChanged: " << path); auto it = m_resourceLocalUidByFilePath.find(path); @@ -405,17 +417,15 @@ } m_fileSystemWatcher.removePath(path); - QNINFO(QStringLiteral("Stopped watching for file ") << path - << QStringLiteral(" as it was deleted")); + QNINFO("Stopped watching for file " << path << " as it was deleted"); return; } if (Q_UNLIKELY(it == m_resourceLocalUidByFilePath.end())) { - QNWARNING(QStringLiteral("Can't process resource local file change ") - << QStringLiteral("properly: can't find resource local uid by ") - << QStringLiteral("file path: ") << path - << QStringLiteral("; stopped watching for that file's changes")); + QNWARNING("Can't process resource local file change " + << "properly: can't find resource local uid by file path: " + << path << "; stopped watching for that file's changes"); m_fileSystemWatcher.removePath(path); return; } @@ -428,7 +438,7 @@ return; } - QNTRACE(QStringLiteral("Size of new resource data: ") + QNTRACE("Size of new resource data: " << humanReadableSize(static_cast<quint64>(std::max(data.size(), 0)))); QByteArray dataHash = calculateHash(data); @@ -439,10 +449,9 @@ errorCode, errorDescription); if (Q_UNLIKELY(!res)) { - QNWARNING(QStringLiteral("Can't process resource local file change ") - << QStringLiteral("properly: can't update the hash for resource ") - << QStringLiteral("file: error code = ") << errorCode - << QStringLiteral(", error description: ") << errorDescription); + QNWARNING("Can't process resource local file change properly: can't " + << "update the hash for resource file: error code = " + << errorCode << ", error description: " << errorDescription); m_fileSystemWatcher.removePath(path); return; } @@ -450,9 +459,10 @@ Q_EMIT resourceFileChanged(it.value(), path, data, dataHash); } -void ResourceDataInTemporaryFileStorageManager::onFileRemoved(const QString & path) +void ResourceDataInTemporaryFileStorageManager::onFileRemoved( + const QString & path) { - QNDEBUG(QStringLiteral("ResourceDataInTemporaryFileStorageManager::onFileRemoved: ") + QNDEBUG("ResourceDataInTemporaryFileStorageManager::onFileRemoved: " << path); auto it = m_resourceLocalUidByFilePath.find(path); @@ -461,22 +471,23 @@ } } -void ResourceDataInTemporaryFileStorageManager::onFoundResourceData(Resource resource) +void ResourceDataInTemporaryFileStorageManager::onFoundResourceData( + Resource resource) { QString resourceLocalUid = resource.localUid(); auto fit = m_resourceLocalUidsPendingFindInLocalStorage.find(resourceLocalUid); if (fit != m_resourceLocalUidsPendingFindInLocalStorage.end()) { - QNDEBUG(QStringLiteral("ResourceDataInTemporaryFileStorageManager::") - << QStringLiteral("onFoundResourceData: ") << resource); + QNDEBUG("ResourceDataInTemporaryFileStorageManager::" + << "onFoundResourceData: " << resource); m_resourceLocalUidsPendingFindInLocalStorage.erase(fit); if (Q_UNLIKELY(m_pCurrentNote.isNull())) { - QNWARNING(QStringLiteral("Received resource data from the local storage " - "but no note is set to " - "ResourceDataInTemporaryFileStorageManager")); + QNWARNING("Received resource data from the local storage " + "but no note is set to " + "ResourceDataInTemporaryFileStorageManager"); return; } @@ -487,10 +498,12 @@ : calculateHash(resource.dataBody())); ErrorString errorDescription; - bool res = writeResourceDataToTemporaryFile(noteLocalUid, resourceLocalUid, - resource.dataBody(), dataHash, - ResourceType::Image, errorDescription, - CheckResourceFileActualityOption::Off); + bool res = writeResourceDataToTemporaryFile( + noteLocalUid, resourceLocalUid, + resource.dataBody(), dataHash, + ResourceType::Image, errorDescription, + CheckResourceFileActualityOption::Off); + if (!res) { Q_EMIT failedToPutResourceDataIntoTemporaryFile(resourceLocalUid, noteLocalUid, @@ -499,18 +512,16 @@ if (m_resourceLocalUidsPendingFindInLocalStorage.empty()) { - QNDEBUG(QStringLiteral("Received and processed all image resources ") - << QStringLiteral("data for the current note, emitting ") - << QStringLiteral("noteResourcesReady signal: note local uid = ") - << noteLocalUid); + QNDEBUG("Received and processed all image resources data for the " + << "current note, emitting noteResourcesReady signal: note " + << "local uid = " << noteLocalUid); Q_EMIT noteResourcesReady(noteLocalUid); } else { - QNDEBUG(QStringLiteral("Still pending ") + QNDEBUG("Still pending " << m_resourceLocalUidsPendingFindInLocalStorage.size() - << QStringLiteral(" resources data to be found within " - "the local storage")); + << " resources data to be found within the local storage"); } return; @@ -520,16 +531,16 @@ resourceLocalUid); if (oit != m_resourceLocalUidsPendingFindInLocalStorageForWritingToFileForOpening.end()) { - QNDEBUG(QStringLiteral("ResourceDataInTemporaryFileStorageManager::") - << QStringLiteral("onFoundResourceData (for resource file opening): ") + QNDEBUG("ResourceDataInTemporaryFileStorageManager::" + << "onFoundResourceData (for resource file opening): " << resource); m_resourceLocalUidsPendingFindInLocalStorageForWritingToFileForOpening.erase(oit); if (Q_UNLIKELY(m_pCurrentNote.isNull())) { - QNWARNING(QStringLiteral("Received resource data from the local storage " - "(for resource file opening) but no note is " - "set to ResourceDataInTemporaryFileStorageManager")); + QNWARNING("Received resource data from the local storage " + "(for resource file opening) but no note is " + "set to ResourceDataInTemporaryFileStorageManager"); return; } @@ -542,18 +553,21 @@ WriteResourceDataCallback callback = OpenResourcePreparationProgressFunctor(resourceLocalUid, *this); - bool isImageResource = (resource.hasMime() && - resource.mime().startsWith(QStringLiteral("image"))); + bool isImageResource = + (resource.hasMime() && + resource.mime().startsWith(QStringLiteral("image"))); ResourceType::type resourceType = (isImageResource ? ResourceType::Image : ResourceType::NonImage); ErrorString errorDescription; - bool res = writeResourceDataToTemporaryFile(noteLocalUid, resourceLocalUid, - resource.dataBody(), dataHash, - resourceType, errorDescription, - CheckResourceFileActualityOption::Off, - callback); + bool res = writeResourceDataToTemporaryFile( + noteLocalUid, resourceLocalUid, + resource.dataBody(), dataHash, + resourceType, errorDescription, + CheckResourceFileActualityOption::Off, + callback); + if (!res) { Q_EMIT failedToOpenResource(resourceLocalUid, noteLocalUid, errorDescription); @@ -563,8 +577,9 @@ QString fileStoragePath = (isImageResource ? m_imageResourceFileStorageLocation : m_nonImageResourceFileStorageLocation); - fileStoragePath += QStringLiteral("/") + noteLocalUid + QStringLiteral("/") + - resourceLocalUid + QStringLiteral(".dat"); + fileStoragePath += QStringLiteral("/") + noteLocalUid + + QStringLiteral("/") + resourceLocalUid + + QStringLiteral(".dat"); watchResourceFileForChanges(resourceLocalUid, fileStoragePath); QDesktopServices::openUrl(QUrl::fromLocalFile(fileStoragePath)); Q_EMIT openedResource(resourceLocalUid, noteLocalUid); @@ -577,17 +592,17 @@ auto fit = m_resourceLocalUidsPendingFindInLocalStorage.find(resourceLocalUid); if (fit != m_resourceLocalUidsPendingFindInLocalStorage.end()) { - QNDEBUG(QStringLiteral("ResourceDataInTemporaryFileStorageManager::") - << QStringLiteral("onFailedToFindResourceData: resource local uid = ") - << resourceLocalUid << QStringLiteral(", error description = ") + QNDEBUG("ResourceDataInTemporaryFileStorageManager::" + << "onFailedToFindResourceData: resource local uid = " + << resourceLocalUid << ", error description = " << errorDescription); m_resourceLocalUidsPendingFindInLocalStorage.erase(fit); if (Q_UNLIKELY(m_pCurrentNote.isNull())) { - QNWARNING(QStringLiteral("Received failure to locate resource data ") - << QStringLiteral("within the local storage but no note ") - << QStringLiteral("is set to ResourceDataInTemporaryFileStorageManager")); + QNWARNING("Received failure to locate resource data " + << "within the local storage but no note " + << "is set to ResourceDataInTemporaryFileStorageManager"); return; } @@ -600,10 +615,9 @@ Q_EMIT noteResourcesReady(noteLocalUid); } else { - QNDEBUG(QStringLiteral("Still pending ") + QNDEBUG("Still pending " << m_resourceLocalUidsPendingFindInLocalStorage.size() - << QStringLiteral(" resources data to be found within " - "the local storage")); + << " resources data to be found within the local storage"); } return; @@ -613,26 +627,26 @@ resourceLocalUid); if (oit != m_resourceLocalUidsPendingFindInLocalStorageForWritingToFileForOpening.end()) { - QNDEBUG(QStringLiteral("ResourceDataInTemporaryFileStorageManager::") - << QStringLiteral("onFailedToFindResourceData (for resource file ") - << QStringLiteral("opening): resource local uid = ") - << resourceLocalUid << QStringLiteral(", error description = ") + QNDEBUG("ResourceDataInTemporaryFileStorageManager::" + << "onFailedToFindResourceData (for resource file " + << "opening): resource local uid = " + << resourceLocalUid << ", error description = " << errorDescription); m_resourceLocalUidsPendingFindInLocalStorage.erase(oit); if (Q_UNLIKELY(m_pCurrentNote.isNull())) { - QNWARNING(QStringLiteral("Received failure to locate resource data " - "within the local storage (for resource file " - "opening) but no note is set to " - "ResourceDataInTemporaryFileStorageManager")); + QNWARNING("Received failure to locate resource data within the " + "local storage (for resource file opening) but no note " + "is set to ResourceDataInTemporaryFileStorageManager"); return; } QString noteLocalUid = m_pCurrentNote->localUid(); - Q_EMIT failedToOpenResource(resourceLocalUid, noteLocalUid, errorDescription); + Q_EMIT failedToOpenResource(resourceLocalUid, noteLocalUid, + errorDescription); return; } } @@ -676,50 +690,50 @@ const QString & noteLocalUid, const QString & resourceLocalUid, const QString & fileStoragePath, const QByteArray & dataHash) const { - QNDEBUG(QStringLiteral("ResourceDataInTemporaryFileStorageManager::") - << QStringLiteral("checkIfResourceFileExistsAndIsActual: note local uid = ") - << noteLocalUid << QStringLiteral(", resource local uid = ") - << resourceLocalUid << QStringLiteral(", data hash = ") << dataHash.toHex()); + QNDEBUG("ResourceDataInTemporaryFileStorageManager::" + << "checkIfResourceFileExistsAndIsActual: note local uid = " + << noteLocalUid << ", resource local uid = " + << resourceLocalUid << ", data hash = " << dataHash.toHex()); if (Q_UNLIKELY(fileStoragePath.isEmpty())) { - QNWARNING(QStringLiteral("Resource file storage location is empty")); + QNWARNING("Resource file storage location is empty"); return false; } QFileInfo resourceFileInfo(fileStoragePath); if (!resourceFileInfo.exists()) { - QNTRACE(QStringLiteral("Resource file for note local uid ") << noteLocalUid - << QStringLiteral(" and resource local uid ") << resourceLocalUid - << QStringLiteral(" does not exist")); + QNTRACE("Resource file for note local uid " << noteLocalUid + << " and resource local uid " << resourceLocalUid + << " does not exist"); return false; } - QFileInfo resourceHashFileInfo(resourceFileInfo.absolutePath() + QStringLiteral("/") + - resourceFileInfo.baseName() + QStringLiteral(".hash")); + QFileInfo resourceHashFileInfo(resourceFileInfo.absolutePath() + + QStringLiteral("/") + + resourceFileInfo.baseName() + + QStringLiteral(".hash")); if (!resourceHashFileInfo.exists()) { - QNTRACE(QStringLiteral("Resource hash file for note local uid ") - << noteLocalUid << QStringLiteral(" and resource local uid ") - << resourceLocalUid << QStringLiteral(" does not exist")); + QNTRACE("Resource hash file for note local uid " + << noteLocalUid << " and resource local uid " + << resourceLocalUid << " does not exist"); return false; } QFile resourceHashFile(resourceHashFileInfo.absoluteFilePath()); bool open = resourceHashFile.open(QIODevice::ReadOnly); if (!open) { - QNWARNING(QStringLiteral("Can't open resource hash file for reading")); + QNWARNING("Can't open resource hash file for reading"); return false; } QByteArray storedHash = resourceHashFile.readAll(); if (storedHash != dataHash) { - QNTRACE(QStringLiteral("Resource must be stale, the stored hash ") - << storedHash.toHex() - << QStringLiteral(" does not match the actual hash ") - << dataHash.toHex()); + QNTRACE("Resource must be stale, the stored hash " << storedHash.toHex() + << " does not match the actual hash " << dataHash.toHex()); return false; } - QNDEBUG(QStringLiteral("Resource file exists and is actual")); + QNDEBUG("Resource file exists and is actual"); return true; } @@ -727,10 +741,10 @@ const QString & resourceLocalUid, const QByteArray & dataHash, const QString & storageFolderPath, int & errorCode, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("ResourceDataInTemporaryFileStorageManager::") - << QStringLiteral("updateResourceHashHelperFile: resource local uid = ") - << resourceLocalUid << QStringLiteral(", data hash = ") - << dataHash.toHex() << QStringLiteral(", storage folder path = ") + QNDEBUG("ResourceDataInTemporaryFileStorageManager::" + << "updateResourceHashHelperFile: resource local uid = " + << resourceLocalUid << ", data hash = " + << dataHash.toHex() << ", storage folder path = " << storageFolderPath); QFile file(storageFolderPath + QStringLiteral("/") + resourceLocalUid + @@ -761,38 +775,38 @@ void ResourceDataInTemporaryFileStorageManager::watchResourceFileForChanges( const QString & resourceLocalUid, const QString & fileStoragePath) { - QNDEBUG(QStringLiteral("ResourceDataInTemporaryFileStorageManager::") - << QStringLiteral("watchResourceFileForChanges: resource local uid = ") - << resourceLocalUid << QStringLiteral(", file storage path = ") + QNDEBUG("ResourceDataInTemporaryFileStorageManager::" + << "watchResourceFileForChanges: resource local uid = " + << resourceLocalUid << ", file storage path = " << fileStoragePath); m_fileSystemWatcher.addPath(fileStoragePath); - QNINFO(QStringLiteral("Start watching for resource file ") << fileStoragePath); + QNINFO("Start watching for resource file " << fileStoragePath); } void ResourceDataInTemporaryFileStorageManager::stopWatchingResourceFile( const QString & filePath) { - QNDEBUG(QStringLiteral("ResourceDataInTemporaryFileStorageManager::") - << QStringLiteral("stopWatchingResourceFile: ") << filePath); + QNDEBUG("ResourceDataInTemporaryFileStorageManager::" + << "stopWatchingResourceFile: " << filePath); auto it = m_resourceLocalUidByFilePath.find(filePath); if (it == m_resourceLocalUidByFilePath.end()) { - QNTRACE(QStringLiteral("File is not being watched, nothing to do")); + QNTRACE("File is not being watched, nothing to do"); return; } m_fileSystemWatcher.removePath(filePath); - QNTRACE(QStringLiteral("Stopped watching for file")); + QNTRACE("Stopped watching for file"); } void ResourceDataInTemporaryFileStorageManager::removeStaleResourceFilesFromCurrentNote() { - QNDEBUG(QStringLiteral("ResourceDataInTemporaryFileStorageManager::" - "removeStaleResourceFilesFromCurrentNote")); + QNDEBUG("ResourceDataInTemporaryFileStorageManager::" + "removeStaleResourceFilesFromCurrentNote"); if (m_pCurrentNote.isNull()) { - QNDEBUG(QStringLiteral("No current note, nothing to do")); + QNDEBUG("No current note, nothing to do"); return; } @@ -810,9 +824,9 @@ { fileInfoList = imageResourceFilesFolder.entryInfoList(QDir::Files); numFiles = fileInfoList.size(); - QNTRACE(QStringLiteral("Found ") << numFiles - << QStringLiteral(" files wihin the image resource files folder ") - << QStringLiteral("for note with local uid ") << m_pCurrentNote->localUid()); + QNTRACE("Found " << numFiles + << " files wihin the image resource files folder " + << "for note with local uid " << m_pCurrentNote->localUid()); } QDir genericResourceImagesFolder(m_nonImageResourceFileStorageLocation + @@ -822,17 +836,15 @@ QFileInfoList genericResourceImageFileInfos = genericResourceImagesFolder.entryInfoList(QDir::Files); int numGenericResourceImageFileInfos = genericResourceImageFileInfos.size(); - QNTRACE(QStringLiteral("Found ") << numGenericResourceImageFileInfos - << QStringLiteral(" files within the generic resource files ") - << QStringLiteral("folder for note with local uid ") - << m_pCurrentNote->localUid()); + QNTRACE("Found " << numGenericResourceImageFileInfos + << " files within the generic resource files " + << "folder for note with local uid " << m_pCurrentNote->localUid()); fileInfoList.append(genericResourceImageFileInfos); numFiles = fileInfoList.size(); } - QNTRACE(QStringLiteral("Total ") << numFiles - << QStringLiteral(" to check for staleness")); + QNTRACE("Total " << numFiles << " to check for staleness"); for(int i = 0; i < numFiles; ++i) { @@ -840,7 +852,7 @@ QString filePath = fileInfo.absoluteFilePath(); if (fileInfo.isSymLink()) { - QNTRACE(QStringLiteral("Removing symlink file without any checks")); + QNTRACE("Removing symlink file without any checks"); stopWatchingResourceFile(filePath); Q_UNUSED(removeFile(filePath)) continue; @@ -848,22 +860,22 @@ QString fullSuffix = fileInfo.completeSuffix(); if (fullSuffix == QStringLiteral("hash")) { - QNTRACE(QStringLiteral("Skipping .hash helper file ") << filePath); + QNTRACE("Skipping .hash helper file " << filePath); continue; } QString baseName = fileInfo.baseName(); - QNTRACE(QStringLiteral("Checking file with base name ") << baseName); + QNTRACE("Checking file with base name " << baseName); int resourceIndex = -1; for(int j = 0; j < numResources; ++j) { - QNTRACE(QStringLiteral("checking against resource with local uid ") + QNTRACE("checking against resource with local uid " << resources[j].localUid()); if (baseName.startsWith(resources[j].localUid())) { - QNTRACE(QStringLiteral("File ") << fileInfo.fileName() - << QStringLiteral(" appears to correspond to resource ") + QNTRACE("File " << fileInfo.fileName() + << " appears to correspond to resource " << resources[j].localUid()); resourceIndex = j; break; @@ -875,26 +887,24 @@ const Resource & resource = resources[resourceIndex]; if (resource.hasDataHash()) { - bool actual = checkIfResourceFileExistsAndIsActual(noteLocalUid, - resource.localUid(), - filePath, - resource.dataHash()); + bool actual = checkIfResourceFileExistsAndIsActual( + noteLocalUid, resource.localUid(), + filePath, resource.dataHash()); if (actual) { - QNTRACE(QStringLiteral("The resource file ") << filePath - << QStringLiteral(" is still actual, will keep it")); + QNTRACE("The resource file " << filePath + << " is still actual, will keep it"); continue; } } else { - QNTRACE(QStringLiteral("Resource at index ") << resourceIndex - << QStringLiteral(" doesn't have the data hash, will " - "remove its resource file just in case")); + QNTRACE("Resource at index " << resourceIndex + << " doesn't have the data hash, will " + << "remove its resource file just in case"); } } - QNTRACE(QStringLiteral("Found stale resource file ") << filePath - << QStringLiteral(", removing it")); + QNTRACE("Found stale resource file " << filePath << ", removing it"); stopWatchingResourceFile(filePath); Q_UNUSED(removeFile(filePath)) @@ -909,11 +919,11 @@ ResourceDataInTemporaryFileStorageManager::partialUpdateResourceFilesForCurrentNote( const QList<Resource> & previousResources, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("ResourceDataInTemporaryFileStorageManager::" - "partialUpdateResourceFilesForCurrentNote")); + QNDEBUG("ResourceDataInTemporaryFileStorageManager::" + "partialUpdateResourceFilesForCurrentNote"); if (Q_UNLIKELY(m_pCurrentNote.isNull())) { - QNDEBUG(QStringLiteral("No current note, nothing to do")); + QNDEBUG("No current note, nothing to do"); return ResultType::Ready; } @@ -926,8 +936,7 @@ { const Resource & resource = *it; const QString resourceLocalUid = resource.localUid(); - QNTRACE(QStringLiteral("Examining resource with local uid ") - << resourceLocalUid); + QNTRACE("Examining resource with local uid " << resourceLocalUid); const Resource * pPreviousResource = Q_NULLPTR; for(auto pit = previousResources.constBegin(), @@ -942,16 +951,15 @@ if (!pPreviousResource) { - QNTRACE(QStringLiteral("No previous resource, considering ") - << QStringLiteral("the resource new: local uid = ") - << resourceLocalUid); + QNTRACE("No previous resource, considering " + << "the resource new: local uid = " << resourceLocalUid); if (!resource.hasMime() || !resource.mime().startsWith(QStringLiteral("image"))) { - QNTRACE(QStringLiteral("Resource has no mime type or mime type " - "is not an image one, won't add " - "the resource to the list of new ones")); + QNTRACE("Resource has no mime type or mime type " + "is not an image one, won't add " + "the resource to the list of new ones"); } else { newAndUpdatedResources << resource; @@ -960,19 +968,19 @@ continue; } - QNTRACE(QStringLiteral("Previous resource's data size = ") + QNTRACE("Previous resource's data size = " << (pPreviousResource->hasDataSize() ? pPreviousResource->dataSize() : 0) - << QStringLiteral(", updated resource's data size = ") + << ", updated resource's data size = " << (resource.hasDataSize() ? resource.dataSize() : 0) - << QStringLiteral("; previous resource's data hash = ") + << "; previous resource's data hash = " << (pPreviousResource->hasDataHash() ? pPreviousResource->dataHash().toHex() : QByteArray()) - << QStringLiteral(", updated resource's data hash = ") + << ", updated resource's data hash = " << (resource.hasDataHash() ? resource.dataHash().toHex() : QByteArray())); @@ -989,17 +997,16 @@ if (dataHashIsDifferent || dataSizeIsDifferent) { - QNTRACE(QStringLiteral("Different or missing data hash or size, ") - << QStringLiteral("considering the resource updated: local uid = ") + QNTRACE("Different or missing data hash or size, " + << "considering the resource updated: local uid = " << resourceLocalUid); if (!resource.hasMime() || !resource.mime().startsWith(QStringLiteral("image"))) { - QNTRACE(QStringLiteral("Resource has no mime type or mime type " - "is not an image one, will remove " - "the resource instead of adding it to " - "the list of updated resources")); + QNTRACE("Resource has no mime type or mime type is not an " + "image one, will remove the resource instead of adding " + "it to the list of updated resources"); removedAndStaleResourceLocalUids << resourceLocalUid; } else { @@ -1029,10 +1036,9 @@ if (!pResource) { - QNTRACE(QStringLiteral("Found no resource with local uid ") - << resourceLocalUid - << QStringLiteral(" within the list of new/updated resources, " - "considering it stale")); + QNTRACE("Found no resource with local uid " << resourceLocalUid + << " within the list of new/updated resources, " + << "considering it stale"); removedAndStaleResourceLocalUids << resourceLocalUid; } } @@ -1107,14 +1113,14 @@ void ResourceDataInTemporaryFileStorageManager::emitPartialUpdateResourceFilesForCurrentNoteProgress( const double progress) { - QNDEBUG(QStringLiteral("ResourceDataInTemporaryFileStorageManager::") - << QStringLiteral("emitPartialUpdateResourceFilesForCurrentNoteProgress: ") - << QStringLiteral("progress = ") << progress); + QNDEBUG("ResourceDataInTemporaryFileStorageManager::" + << "emitPartialUpdateResourceFilesForCurrentNoteProgress: " + << "progress = " << progress); if (Q_UNLIKELY(m_pCurrentNote.isNull())) { - QNWARNING(QStringLiteral("Detected attempt to emit partial update resource ") - << QStringLiteral("files for current note progress but no current ") - << QStringLiteral("note is set; progress = ") << progress); + QNWARNING("Detected attempt to emit partial update resource " + << "files for current note progress but no current " + << "note is set; progress = " << progress); return; } @@ -1125,16 +1131,16 @@ ResourceDataInTemporaryFileStorageManager::putResourcesDataToTemporaryFiles( const QList<Resource> & resources, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("ResourceDataInTemporaryFileStorageManager::") - << QStringLiteral("putResourcesDataToTemporaryFiles: ") - << resources.size() << QStringLiteral(" resources")); + QNDEBUG("ResourceDataInTemporaryFileStorageManager::" + << "putResourcesDataToTemporaryFiles: " + << resources.size() << " resources"); if (Q_UNLIKELY(m_pCurrentNote.isNull())) { - errorDescription.setBase(QT_TR_NOOP("Can't put resources data into " - "temporary files: internal error, " - "no current note is set to " - "ResourceDataInTemporaryFileStorageManager")); + errorDescription.setBase( + QT_TR_NOOP("Can't put resources data into temporary files: internal " + "error, no current note is set to " + "ResourceDataInTemporaryFileStorageManager")); QNWARNING(errorDescription); return ResultType::Error; } @@ -1142,7 +1148,8 @@ size_t numResourcesPendingDataFromLocalStorage = 0; const int numNewAndUpdatedResources = resources.size(); int newOrUpdatedResourceIndex = 0; - for(auto it = resources.constBegin(), end = resources.constEnd(); it != end; ++it) + for(auto it = resources.constBegin(), + end = resources.constEnd(); it != end; ++it) { const Resource & resource = *it; if (!resource.hasDataBody()) @@ -1162,17 +1169,20 @@ PartialUpdateResourceFilesForCurrentNoteProgressFunctor( newOrUpdatedResourceIndex, numNewAndUpdatedResources, *this); - bool res = writeResourceDataToTemporaryFile(m_pCurrentNote->localUid(), - resource.localUid(), - resource.dataBody(), dataHash, - ResourceType::Image, - errorDescription, - CheckResourceFileActualityOption::On, - callback); + bool res = writeResourceDataToTemporaryFile( + m_pCurrentNote->localUid(), + resource.localUid(), + resource.dataBody(), dataHash, + ResourceType::Image, + errorDescription, + CheckResourceFileActualityOption::On, + callback); + if (!res) { - Q_EMIT failedToPutResourceDataIntoTemporaryFile(resource.localUid(), - m_pCurrentNote->localUid(), - errorDescription); + Q_EMIT failedToPutResourceDataIntoTemporaryFile( + resource.localUid(), + m_pCurrentNote->localUid(), + errorDescription); } ++newOrUpdatedResourceIndex; @@ -1188,14 +1198,14 @@ void ResourceDataInTemporaryFileStorageManager::emitOpenResourcePreparationProgress( const double progress, const QString & resourceLocalUid) { - QNDEBUG(QStringLiteral("ResourceDataInTemporaryFileStorageManager::") - << QStringLiteral("emitOpenResourcePreparationProgress: resource local uid = ") - << resourceLocalUid << QStringLiteral(", progress = ") << progress); + QNDEBUG("ResourceDataInTemporaryFileStorageManager::" + << "emitOpenResourcePreparationProgress: resource local uid = " + << resourceLocalUid << ", progress = " << progress); if (Q_UNLIKELY(m_pCurrentNote.isNull())) { - QNWARNING(QStringLiteral("Detected attempt to emit open resource preparation ") - << QStringLiteral("progress but no current note is set; resource local uid = ") - << resourceLocalUid << QStringLiteral(", progress = ") << progress); + QNWARNING("Detected attempt to emit open resource preparation " + << "progress but no current note is set; resource local uid = " + << resourceLocalUid << ", progress = " << progress); return; } @@ -1206,8 +1216,8 @@ void ResourceDataInTemporaryFileStorageManager::requestResourceDataFromLocalStorage( const Resource & resource) { - QNDEBUG(QStringLiteral("ResourceDataInTemporaryFileStorageManager::") - << QStringLiteral("requestResourceDataFromLocalStorage: resource local uid = ") + QNDEBUG("ResourceDataInTemporaryFileStorageManager::" + << "requestResourceDataFromLocalStorage: resource local uid = " << resource.localUid()); Q_EMIT findResourceData(resource.localUid()); } @@ -1219,10 +1229,9 @@ const CheckResourceFileActualityOption::type checkActualityOption, WriteResourceDataCallback callback) { - QNDEBUG(QStringLiteral("ResourceDataInTemporaryFileStorageManager::") - << QStringLiteral("writeResourceDataToTemporaryFile: note local uid = ") - << noteLocalUid << QStringLiteral(", resource local uid = ") - << resourceLocalUid); + QNDEBUG("ResourceDataInTemporaryFileStorageManager::" + << "writeResourceDataToTemporaryFile: note local uid = " + << noteLocalUid << ", resource local uid = " << resourceLocalUid); if (Q_UNLIKELY(noteLocalUid.isEmpty())) { errorDescription.setBase(QT_TR_NOOP("Detected attempt to write resource " @@ -1234,17 +1243,17 @@ if (Q_UNLIKELY(resourceLocalUid.isEmpty())) { errorDescription.setBase(QT_TR_NOOP("Detected attempt to write data for " - "empty resource local uid to local file")); - QNWARNING(errorDescription << QStringLiteral(", note local uid = ") - << noteLocalUid); + "empty resource local uid to local " + "file")); + QNWARNING(errorDescription << ", note local uid = " << noteLocalUid); return false; } if (Q_UNLIKELY(data.isEmpty())) { errorDescription.setBase(QT_TR_NOOP("Detected attempt to write empty " "resource data to local file")); - QNWARNING(errorDescription << QStringLiteral(", note local uid = ") - << noteLocalUid << QStringLiteral(", resource local uid = ") + QNWARNING(errorDescription << ", note local uid = " + << noteLocalUid << ", resource local uid = " << resourceLocalUid); return false; } @@ -1264,8 +1273,8 @@ { errorDescription.setBase(QT_TR_NOOP("Can't create folder to write " "the resource into")); - QNWARNING(errorDescription << QStringLiteral(", note local uid = ") - << noteLocalUid << QStringLiteral(", resource local uid = ") + QNWARNING(errorDescription << ", note local uid = " + << noteLocalUid << ", resource local uid = " << resourceLocalUid); return false; } @@ -1273,16 +1282,16 @@ if (checkActualityOption == CheckResourceFileActualityOption::On) { - bool actual = checkIfResourceFileExistsAndIsActual(noteLocalUid, - resourceLocalUid, - fileStoragePath, - (dataHash.isEmpty() - ? calculateHash(data) - : dataHash)); + bool actual = checkIfResourceFileExistsAndIsActual( + noteLocalUid, + resourceLocalUid, + fileStoragePath, + (dataHash.isEmpty() ? calculateHash(data) : dataHash)); + if (actual) { - QNTRACE(QStringLiteral("Skipping writing the resource to file as it " - "is not necessary, the file already exists " - "and is actual")); + QNTRACE("Skipping writing the resource to file as it " + "is not necessary, the file already exists " + "and is actual"); return true; } } @@ -1294,9 +1303,9 @@ errorDescription.setBase(QT_TR_NOOP("Can't open resource file for writing")); errorDescription.details() = file.errorString(); int errorCode = file.error(); - QNWARNING(errorDescription << QStringLiteral(", error code = ") - << errorCode << QStringLiteral(", note local uid = ") - << noteLocalUid << QStringLiteral(", resource local uid = ") + QNWARNING(errorDescription << ", error code = " + << errorCode << ", note local uid = " + << noteLocalUid << ", resource local uid = " << resourceLocalUid); return false; } @@ -1309,9 +1318,9 @@ errorDescription.setBase(QT_TR_NOOP("Can't write data to resource file")); errorDescription.details() = file.errorString(); int errorCode = file.error(); - QNWARNING(errorDescription << QStringLiteral(", error code = ") - << errorCode << QStringLiteral(", note local uid = ") - << noteLocalUid << QStringLiteral(", resource local uid = ") + QNWARNING(errorDescription << ", error code = " + << errorCode << ", note local uid = " + << noteLocalUid << ", resource local uid = " << resourceLocalUid); return false; } @@ -1328,9 +1337,9 @@ errorDescription.setBase(QT_TR_NOOP("Can't write data to resource file")); errorDescription.details() = file.errorString(); int errorCode = file.error(); - QNWARNING(errorDescription << QStringLiteral(", error code = ") - << errorCode << QStringLiteral(", note local uid = ") - << noteLocalUid << QStringLiteral(", resource local uid = ") + QNWARNING(errorDescription << ", error code = " + << errorCode << ", note local uid = " + << noteLocalUid << ", resource local uid = " << resourceLocalUid); return false; } @@ -1358,14 +1367,14 @@ fileStoragePathInfo.absolutePath(), errorCode, errorDescription); if (Q_UNLIKELY(!res)) { - QNWARNING(errorDescription << QStringLiteral(", error code = ") << errorCode - << QStringLiteral(", resource local uid = ") << resourceLocalUid); + QNWARNING(errorDescription << ", error code = " << errorCode + << ", resource local uid = " << resourceLocalUid); return false; } - QNDEBUG(QStringLiteral("Successfully wrote resource data to file: ") - << QStringLiteral("resource local uid = ") << resourceLocalUid - << QStringLiteral(", file path = ") << fileStoragePath); + QNDEBUG("Successfully wrote resource data to file: " + << "resource local uid = " << resourceLocalUid + << ", file path = " << fileStoragePath); return true; } diff -Nru libquentier-0.5.0/src/note_editor/ResourceDataInTemporaryFileStorageManager.h libquentier-0.5.0/src/note_editor/ResourceDataInTemporaryFileStorageManager.h --- libquentier-0.5.0/src/note_editor/ResourceDataInTemporaryFileStorageManager.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/ResourceDataInTemporaryFileStorageManager.h 2019-07-11 10:46:53.000000000 +0000 @@ -22,6 +22,7 @@ #include <quentier/utility/Macros.h> #include <quentier/utility/FileSystemWatcher.h> #include <quentier/types/ErrorString.h> + #include <QObject> #include <QUuid> #include <QStringList> diff -Nru libquentier-0.5.0/src/note_editor/ResourceInfo.cpp libquentier-0.5.0/src/note_editor/ResourceInfo.cpp --- libquentier-0.5.0/src/note_editor/ResourceInfo.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/ResourceInfo.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -17,6 +17,7 @@ */ #include "ResourceInfo.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { @@ -27,12 +28,12 @@ const QString & resourceLocalFilePath, const QSize & resourceImageSize) { - QNDEBUG(QStringLiteral("ResourceInfo::cacheResourceInfo: resource hash = ") + QNDEBUG("ResourceInfo::cacheResourceInfo: resource hash = " << resourceHash.toHex() - << QStringLiteral(", resource display name = ") << resourceDisplayName - << QStringLiteral(", resource display size = ") << resourceDisplaySize - << QStringLiteral(", resource local file path = ") << resourceLocalFilePath - << QStringLiteral(", resource image size = ") << resourceImageSize); + << ", resource display name = " << resourceDisplayName + << ", resource display size = " << resourceDisplaySize + << ", resource local file path = " << resourceLocalFilePath + << ", resource image size = " << resourceImageSize); Info & info = m_resourceInfoHash[resourceHash]; info.m_resourceDisplayName = resourceDisplayName; @@ -53,12 +54,12 @@ QString & resourceLocalFilePath, QSize & resourceImageSize) const { - QNDEBUG(QStringLiteral("ResourceInfo::findResourceInfo: resource hash = ") + QNDEBUG("ResourceInfo::findResourceInfo: resource hash = " << resourceHash.toHex()); auto it = m_resourceInfoHash.find(resourceHash); if (it == m_resourceInfoHash.end()) { - QNTRACE(QStringLiteral("Resource info was not found")); + QNTRACE("Resource info was not found"); return false; } @@ -68,21 +69,21 @@ resourceLocalFilePath = info.m_resourceLocalFilePath; resourceImageSize = info.m_resourceImageSize; - QNTRACE(QStringLiteral("Found resource info: name = ") << resourceDisplayName - << QStringLiteral(", display size = ") << resourceDisplaySize - << QStringLiteral(", local file path = ") << resourceLocalFilePath - << QStringLiteral(", image size = ") << resourceImageSize); + QNTRACE("Found resource info: name = " << resourceDisplayName + << ", display size = " << resourceDisplaySize + << ", local file path = " << resourceLocalFilePath + << ", image size = " << resourceImageSize); return true; } bool ResourceInfo::removeResourceInfo(const QByteArray & resourceHash) { - QNDEBUG(QStringLiteral("ResourceInfo::removeResourceInfo: resource hash = ") + QNDEBUG("ResourceInfo::removeResourceInfo: resource hash = " << resourceHash.toHex()); auto it = m_resourceInfoHash.find(resourceHash); if (it == m_resourceInfoHash.end()) { - QNTRACE(QStringLiteral("Resource info was not found hence not removed")); + QNTRACE("Resource info was not found hence not removed"); return false; } @@ -92,7 +93,7 @@ void ResourceInfo::clear() { - QNDEBUG(QStringLiteral("ResourceInfo::clear")); + QNDEBUG("ResourceInfo::clear"); m_resourceInfoHash.clear(); } diff -Nru libquentier-0.5.0/src/note_editor/SpellChecker.cpp libquentier-0.5.0/src/note_editor/SpellChecker.cpp --- libquentier-0.5.0/src/note_editor/SpellChecker.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/SpellChecker.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -19,13 +19,15 @@ #include <quentier/note_editor/SpellChecker.h> #include <quentier/utility/FileIOProcessorAsync.h> #include <quentier/types/Account.h> + #include "SpellChecker_p.h" namespace quentier { -SpellChecker::SpellChecker(FileIOProcessorAsync * pFileIOProcessorAsync, - const Account & account, QObject * parent, - const QString & userDictionaryPath) : +SpellChecker::SpellChecker( + FileIOProcessorAsync * pFileIOProcessorAsync, + const Account & account, QObject * parent, + const QString & userDictionaryPath) : QObject(parent), d_ptr(new SpellCheckerPrivate(pFileIOProcessorAsync, account, this, userDictionaryPath)) diff -Nru libquentier-0.5.0/src/note_editor/SpellCheckerDictionariesFinder.cpp libquentier-0.5.0/src/note_editor/SpellCheckerDictionariesFinder.cpp --- libquentier-0.5.0/src/note_editor/SpellCheckerDictionariesFinder.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/SpellCheckerDictionariesFinder.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -17,15 +17,18 @@ */ #include "SpellCheckerDictionariesFinder.h" + #include <quentier/logging/QuentierLogger.h> + #include <QStringList> #include <QFileInfo> #include <QDirIterator> namespace quentier { -#define WRAP(x) \ - << QStringLiteral(x).toUpper() +#define WRAP(x) \ + << QStringLiteral(x).toUpper() \ +// WRAP SpellCheckerDictionariesFinder::SpellCheckerDictionariesFinder( const QSharedPointer<QAtomicInt> & pStopFlag, QObject * parent) : @@ -41,24 +44,26 @@ void SpellCheckerDictionariesFinder::run() { - QNDEBUG(QStringLiteral("SpellCheckerDictionariesFinder::run")); + QNDEBUG("SpellCheckerDictionariesFinder::run"); m_files.clear(); QStringList fileFilters; fileFilters << QStringLiteral("*.dic") << QStringLiteral("*.aff"); #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) -#define CHECK_AND_STOP() \ - if (!m_pStopFlag.isNull() && (m_pStopFlag->load() != 0)) { \ - QNDEBUG(QStringLiteral("Aborting the operation as stop flag is non-zero")); \ - return; \ - } +#define CHECK_AND_STOP() \ + if (!m_pStopFlag.isNull() && (m_pStopFlag->load() != 0)) { \ + QNDEBUG("Aborting the operation as stop flag is non-zero"); \ + return; \ + } \ +// CHECK_AND_STOP #else -#define CHECK_AND_STOP() \ - if (!m_pStopFlag.isNull() && (int(*m_pStopFlag) != 0)) { \ - QNDEBUG(QStringLiteral("Aborting the operation as stop flag is non-zero")); \ - return; \ - } +#define CHECK_AND_STOP() \ + if (!m_pStopFlag.isNull() && (int(*m_pStopFlag) != 0)) { \ + QNDEBUG("Aborting the operation as stop flag is non-zero"); \ + return; \ + } \ +// CHECK_AND_STOP #endif QFileInfoList rootDirs = QDir::drives(); @@ -70,7 +75,7 @@ const QFileInfo & rootDirInfo = rootDirs[i]; if (Q_UNLIKELY(!rootDirInfo.isDir())) { - QNTRACE(QStringLiteral("Skipping non-dir ") << rootDirInfo.absoluteDir()); + QNTRACE("Skipping non-dir " << rootDirInfo.absoluteDir()); continue; } @@ -81,11 +86,11 @@ CHECK_AND_STOP() QString nextDirName = it.next(); - QNTRACE(QStringLiteral("Next dir name = ") << nextDirName); + QNTRACE("Next dir name = " << nextDirName); QFileInfo fileInfo = it.fileInfo(); if (!fileInfo.isReadable()) { - QNTRACE(QStringLiteral("Skipping non-readable file ") + QNTRACE("Skipping non-readable file " << fileInfo.absoluteFilePath()); continue; } @@ -96,30 +101,27 @@ isDicFile = true; } else if (fileNameSuffix != QStringLiteral("aff")) { - QNTRACE(QStringLiteral("Skipping file not actually matching ") - << QStringLiteral("the filter: ") << fileInfo.absoluteFilePath()); + QNTRACE("Skipping file not actually matching the filter: " + << fileInfo.absoluteFilePath()); continue; } QString dictionaryName = fileInfo.baseName(); if (!m_localeList.contains(dictionaryName.toUpper())) { - QNTRACE(QStringLiteral("Skipping dictionary which doesn't appear ") - << QStringLiteral("to correspond to any locale: ") - << dictionaryName); + QNTRACE("Skipping dictionary which doesn't appear to correspond " + "to any locale: " << dictionaryName); continue; } QPair<QString, QString> & pair = m_files[dictionaryName]; if (isDicFile) { - QNTRACE(QStringLiteral("Adding dic file ") - << fileInfo.absoluteFilePath()); + QNTRACE("Adding dic file " << fileInfo.absoluteFilePath()); pair.first = fileInfo.absoluteFilePath(); } else { - QNTRACE(QStringLiteral("Adding aff file ") - << fileInfo.absoluteFilePath()); + QNTRACE("Adding aff file " << fileInfo.absoluteFilePath()); pair.second = fileInfo.absoluteFilePath(); } } @@ -133,9 +135,9 @@ const QPair<QString, QString> & pair = it.value(); if (pair.first.isEmpty() || pair.second.isEmpty()) { - QNTRACE(QStringLiteral("Skipping the incomplete pair of dic/aff files: ") - << QStringLiteral("dic file path = ") << pair.first - << QStringLiteral("; aff file path = ") << pair.second); + QNTRACE("Skipping the incomplete pair of dic/aff files: " + << "dic file path = " << pair.first + << "; aff file path = " << pair.second); it = m_files.erase(it); continue; } @@ -143,8 +145,7 @@ ++it; } - QNDEBUG(QStringLiteral("Found ") << m_files.size() - << QStringLiteral(" valid dictionaries")); + QNDEBUG("Found " << m_files.size() << " valid dictionaries"); Q_EMIT foundDictionaries(m_files); } diff -Nru libquentier-0.5.0/src/note_editor/SpellCheckerDictionariesFinder.h libquentier-0.5.0/src/note_editor/SpellCheckerDictionariesFinder.h --- libquentier-0.5.0/src/note_editor/SpellCheckerDictionariesFinder.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/SpellCheckerDictionariesFinder.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,6 +20,7 @@ #define LIB_QUENTIER_NOTE_EDITOR_SPELL_CHECKER_DICTIONARIES_FINDER_H #include <quentier/utility/Macros.h> + #include <QObject> #include <QRunnable> #include <QHash> diff -Nru libquentier-0.5.0/src/note_editor/SpellChecker_p.cpp libquentier-0.5.0/src/note_editor/SpellChecker_p.cpp --- libquentier-0.5.0/src/note_editor/SpellChecker_p.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/SpellChecker_p.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -17,37 +17,53 @@ */ #include "SpellChecker_p.h" + #include <quentier/utility/FileIOProcessorAsync.h> #include <quentier/utility/ApplicationSettings.h> #include <quentier/utility/StandardPaths.h> #include <quentier/logging/QuentierLogger.h> -#include <hunspell/hunspell.hxx> + #include <QFileInfo> #include <QDir> #include <QDirIterator> #include <QBuffer> #include <QThreadPool> #include <QLocale> + +#include <hunspell/hunspell.hxx> + #include <algorithm> -#define SPELL_CHECKER_FOUND_DICTIONARIES_GROUP \ - QStringLiteral("SpellCheckerFoundDictionaries") -#define SPELL_CHECKER_FOUND_DICTIONARIES_DIC_FILE_ITEM \ - QStringLiteral("DicFile") -#define SPELL_CHECKER_FOUND_DICTIONARIES_AFF_FILE_ITEM \ - QStringLiteral("AffFile") -#define SPELL_CHECKER_FOUND_DICTIONARIES_LANGUAGE_KEY \ - QStringLiteral("LanguageKey") -#define SPELL_CHECKER_FOUND_DICTIONARIES_ARRAY \ - QStringLiteral("Dictionaries") -#define SPELL_CHECKER_ENABLED_SYSTEM_DICTIONARIES_KEY \ - QStringLiteral("EnabledSystemDictionaries") +#define SPELL_CHECKER_FOUND_DICTIONARIES_GROUP \ + QStringLiteral("SpellCheckerFoundDictionaries") \ +// SPELL_CHECKER_FOUND_DICTIONARIES_GROUP + +#define SPELL_CHECKER_FOUND_DICTIONARIES_DIC_FILE_ITEM \ + QStringLiteral("DicFile") \ +// SPELL_CHECKER_FOUND_DICTIONARIES_DIC_FILE_ITEM + +#define SPELL_CHECKER_FOUND_DICTIONARIES_AFF_FILE_ITEM \ + QStringLiteral("AffFile") \ +// SPELL_CHECKER_FOUND_DICTIONARIES_AFF_FILE_ITEM + +#define SPELL_CHECKER_FOUND_DICTIONARIES_LANGUAGE_KEY \ + QStringLiteral("LanguageKey") \ +// SPELL_CHECKER_FOUND_DICTIONARIES_LANGUAGE_KEY + +#define SPELL_CHECKER_FOUND_DICTIONARIES_ARRAY \ + QStringLiteral("Dictionaries") \ +// SPELL_CHECKER_FOUND_DICTIONARIES_ARRAY + +#define SPELL_CHECKER_ENABLED_SYSTEM_DICTIONARIES_KEY \ + QStringLiteral("EnabledSystemDictionaries") \ +// SPELL_CHECKER_ENABLED_SYSTEM_DICTIONARIES_KEY namespace quentier { -SpellCheckerPrivate::SpellCheckerPrivate(FileIOProcessorAsync * pFileIOProcessorAsync, - const Account & account, QObject * parent, - const QString & userDictionaryPath) : +SpellCheckerPrivate::SpellCheckerPrivate( + FileIOProcessorAsync * pFileIOProcessorAsync, + const Account & account, QObject * parent, + const QString & userDictionaryPath) : QObject(parent), m_pFileIOProcessorAsync(pFileIOProcessorAsync), m_currentAccount(account), @@ -71,9 +87,10 @@ Q_UNUSED(m_pDictionariesFinderStopFlag->ref()) } -QVector<QPair<QString,bool> > SpellCheckerPrivate::listAvailableDictionaries() const +QVector<QPair<QString,bool> > +SpellCheckerPrivate::listAvailableDictionaries() const { - QNDEBUG(QStringLiteral("SpellCheckerPrivate::listAvailableDictionaries")); + QNDEBUG("SpellCheckerPrivate::listAvailableDictionaries"); QVector<QPair<QString,bool> > result; result.reserve(m_systemDictionaries.size()); @@ -92,7 +109,7 @@ void SpellCheckerPrivate::setAccount(const Account & account) { - QNDEBUG(QStringLiteral("SpellCheckerPrivate::setAccount: ") << account); + QNDEBUG("SpellCheckerPrivate::setAccount: " << account); m_currentAccount = account; restoreSystemDictionatiesEnabledDisabledSettings(); @@ -100,13 +117,12 @@ void SpellCheckerPrivate::enableDictionary(const QString & language) { - QNDEBUG(QStringLiteral("SpellCheckerPrivate::enableDictionary: language = ") - << language); + QNDEBUG("SpellCheckerPrivate::enableDictionary: language = " << language); auto it = m_systemDictionaries.find(language); if (it == m_systemDictionaries.end()) { - QNINFO(QStringLiteral("Can't enable dictionary: no dictionary was " - "found for language ") << language); + QNINFO("Can't enable dictionary: no dictionary was found for language " + << language); return; } @@ -116,13 +132,12 @@ void SpellCheckerPrivate::disableDictionary(const QString & language) { - QNDEBUG(QStringLiteral("SpellCheckerPrivate::disableDictionary: language = ") - << language); + QNDEBUG("SpellCheckerPrivate::disableDictionary: language = " << language); auto it = m_systemDictionaries.find(language); if (it == m_systemDictionaries.end()) { - QNINFO(QStringLiteral("Can't disable dictionary: no dictionary was " - "found for language ") << language); + QNINFO("Can't disable dictionary: no dictionary was found for language " + << language); return; } @@ -132,7 +147,7 @@ bool SpellCheckerPrivate::checkSpell(const QString & word) const { - QNDEBUG(QStringLiteral("SpellCheckerPrivate::checkSpell: ") << word); + QNDEBUG("SpellCheckerPrivate::checkSpell: " << word); if (m_userDictionary.contains(word, Qt::CaseInsensitive)) { return true; @@ -147,23 +162,20 @@ const Dictionary & dictionary = it.value(); if (dictionary.isEmpty() || !dictionary.m_enabled) { - QNTRACE(QStringLiteral("Skipping dictionary ") - << dictionary.m_dictionaryPath); + QNTRACE("Skipping dictionary " << dictionary.m_dictionaryPath); continue; } bool res = dictionary.m_hunspellWrapper.spell(wordData); if (res) { - QNTRACE(QStringLiteral("Found word ") << word - << QStringLiteral(" in dictionary ") + QNTRACE("Found word " << word << " in dictionary " << dictionary.m_dictionaryPath); return true; } res = dictionary.m_hunspellWrapper.spell(lowerWordData); if (res) { - QNTRACE(QStringLiteral("Found word ") << lowerWordData - << QStringLiteral(" in dictionary ") + QNTRACE("Found word " << lowerWordData << " in dictionary " << dictionary.m_dictionaryPath); return true; } @@ -175,7 +187,7 @@ QStringList SpellCheckerPrivate::spellCorrectionSuggestions( const QString & misSpelledWord) const { - QNDEBUG(QStringLiteral("SpellCheckerPrivate::spellCorrectionSuggestions: ") + QNDEBUG("SpellCheckerPrivate::spellCorrectionSuggestions: " << misSpelledWord); QByteArray wordData = misSpelledWord.toUtf8(); @@ -198,7 +210,7 @@ void SpellCheckerPrivate::addToUserWordlist(const QString & word) { - QNDEBUG(QStringLiteral("SpellCheckerPrivate::addToUserWordlist: ") << word); + QNDEBUG("SpellCheckerPrivate::addToUserWordlist: " << word); ignoreWord(word); @@ -208,8 +220,7 @@ void SpellCheckerPrivate::removeFromUserWordList(const QString & word) { - QNDEBUG(QStringLiteral("SpellCheckerPrivate::removeFromUserWordList: ") - << word); + QNDEBUG("SpellCheckerPrivate::removeFromUserWordList: " << word); removeWord(word); @@ -239,13 +250,13 @@ m_updateUserDictionaryFileRequestId = QUuid::createUuid(); Q_EMIT writeFile(m_userDictionaryPath, dataToWrite, m_updateUserDictionaryFileRequestId, /* append = */ false); - QNTRACE(QStringLiteral("Sent the request to update the user dictionary: ") + QNTRACE("Sent the request to update the user dictionary: " << m_updateUserDictionaryFileRequestId); } void SpellCheckerPrivate::ignoreWord(const QString & word) { - QNDEBUG(QStringLiteral("SpellCheckerPrivate::ignoreWord: ") << word); + QNDEBUG("SpellCheckerPrivate::ignoreWord: " << word); QByteArray wordData = word.toUtf8(); @@ -264,7 +275,7 @@ void SpellCheckerPrivate::removeWord(const QString & word) { - QNDEBUG(QStringLiteral("SpellCheckerPrivate::removeWord: ") << word); + QNDEBUG("SpellCheckerPrivate::removeWord: " << word); QByteArray wordData = word.toUtf8(); @@ -289,21 +300,21 @@ void SpellCheckerPrivate::onDictionariesFound( SpellCheckerDictionariesFinder::DicAndAffFilesByDictionaryName files) { - QNDEBUG(QStringLiteral("SpellCheckerPrivate::onDictionariesFound")); + QNDEBUG("SpellCheckerPrivate::onDictionariesFound"); for(auto it = files.constBegin(), end = files.constEnd(); it != end; ++it) { const QPair<QString, QString> & pair = it.value(); - QNTRACE(QStringLiteral("Raw dictionary file path = ") << pair.first - << QStringLiteral(", raw affix file path = ") << pair.second); + QNTRACE("Raw dictionary file path = " << pair.first + << ", raw affix file path = " << pair.second); Dictionary & dictionary = m_systemDictionaries[it.key()]; dictionary.m_hunspellWrapper.initialize(pair.second, pair.first); dictionary.m_dictionaryPath = pair.first; dictionary.m_enabled = true; - QNTRACE(QStringLiteral("Added dictionary for language ") << it.key() - << QStringLiteral("; dictionary file ") << pair.first - << QStringLiteral(", affix file ") << pair.second); + QNTRACE("Added dictionary for language " << it.key() + << "; dictionary file " << pair.first + << ", affix file " << pair.second); } restoreSystemDictionatiesEnabledDisabledSettings(); @@ -333,7 +344,7 @@ void SpellCheckerPrivate::checkAndScanSystemDictionaries() { - QNDEBUG(QStringLiteral("SpellCheckerPrivate::checkAndScanSystemDictionaries")); + QNDEBUG("SpellCheckerPrivate::checkAndScanSystemDictionaries"); ApplicationSettings appSettings; appSettings.beginGroup(SPELL_CHECKER_FOUND_DICTIONARIES_GROUP); @@ -350,7 +361,7 @@ QString languageKey = appSettings.value(SPELL_CHECKER_FOUND_DICTIONARIES_LANGUAGE_KEY).toString(); if (languageKey.isEmpty()) { - QNTRACE(QStringLiteral("No language key, skipping")); + QNTRACE("No language key, skipping"); continue; } @@ -358,7 +369,7 @@ appSettings.value(SPELL_CHECKER_FOUND_DICTIONARIES_DIC_FILE_ITEM).toString(); QFileInfo dicFileInfo(dicFile); if (!dicFileInfo.exists() || !dicFileInfo.isReadable()) { - QNTRACE(QStringLiteral("Skipping non-existing or unreadable dic file: ") + QNTRACE("Skipping non-existing or unreadable dic file: " << dicFileInfo.absoluteFilePath()); continue; } @@ -367,7 +378,7 @@ appSettings.value(SPELL_CHECKER_FOUND_DICTIONARIES_AFF_FILE_ITEM).toString(); QFileInfo affFileInfo(affFile); if (!affFileInfo.exists() || !affFileInfo.isReadable()) { - QNTRACE(QStringLiteral("Skipping non-existing or unreadable aff file: ") + QNTRACE("Skipping non-existing or unreadable aff file: " << affFileInfo.absoluteFilePath()); continue; } @@ -379,8 +390,8 @@ appSettings.endGroup(); if (existingDictionaries.isEmpty()) { - QNINFO(QStringLiteral("No previously cached dic/aff files seem to actually " - "exist anymore, re-scanning the system for dictionaries")); + QNINFO("No previously cached dic/aff files seem to actually " + "exist anymore, re-scanning the system for dictionaries"); scanSystemDictionaries(); return; } @@ -390,7 +401,7 @@ void SpellCheckerPrivate::scanSystemDictionaries() { - QNDEBUG(QStringLiteral("SpellCheckerPrivate::scanSystemDictionaries")); + QNDEBUG("SpellCheckerPrivate::scanSystemDictionaries"); // First try to look for the paths to dictionaries at the environment variables; // probably that is the only way to get path to system wide dictionaries on Windows @@ -427,19 +438,18 @@ } else { - QNTRACE(QStringLiteral("Number of found paths to dictionaries doesn't ") - << QStringLiteral("correspond to the number of found dictionary ") - << QStringLiteral("names as deduced from libquentier's own ") - << QStringLiteral("environment variables:\n LIBQUENTIERDICTNAMES: ") - << ownDictionaryNames << QStringLiteral("; \n LIBQUENTIERDICTPATHS: ") + QNTRACE("Number of found paths to dictionaries doesn't " + << "correspond to the number of found dictionary " + << "names as deduced from libquentier's own " + << "environment variables:\n LIBQUENTIERDICTNAMES: " + << ownDictionaryNames << "; \n LIBQUENTIERDICTPATHS: " << ownDictionaryPaths); } } else { - QNTRACE(QStringLiteral("Can't find LIBQUENTIERDICTNAMES and/or " - "LIBQUENTIERDICTPATHS within the environment " - "variables")); + QNTRACE("Can't find LIBQUENTIERDICTNAMES and/or LIBQUENTIERDICTPATHS " + "within the environment variables"); } // Also see if there's something set in the environment variables for @@ -473,8 +483,8 @@ } else { - QNTRACE(QStringLiteral("Can't find DICTIONARY and/or DICPATH within " - "the environment variables")); + QNTRACE("Can't find DICTIONARY and/or DICPATH within " + "the environment variables"); } #ifndef Q_OS_WIN @@ -497,12 +507,11 @@ for(auto it = standardPaths.begin(), end = standardPaths.end(); it != end; ++it) { const QString & standardPath = *it; - QNTRACE(QStringLiteral("Inspecting standard path ") << standardPath); + QNTRACE("Inspecting standard path " << standardPath); QDir dir(standardPath); if (!dir.exists()) { - QNTRACE(QStringLiteral("Skipping dir ") << standardPath - << QStringLiteral(" which doesn't exist")); + QNTRACE("Skipping dir " << standardPath << " which doesn't exist"); continue; } @@ -514,7 +523,7 @@ { const QFileInfo & fileInfo = *infoIt; QString fileName = fileInfo.fileName(); - QNTRACE(QStringLiteral("Inspecting file name ") << fileName); + QNTRACE("Inspecting file name " << fileName); if (fileName.endsWith(QStringLiteral(".dic")) || fileName.endsWith(QStringLiteral(".aff"))) @@ -529,9 +538,8 @@ if (!m_systemDictionaries.isEmpty()) { - QNDEBUG(QStringLiteral("Found some dictionaries at the expected locations, " - "won't search for dictionaries just everywhere " - "at the system")); + QNDEBUG("Found some dictionaries at the expected locations, won't " + "search for dictionaries just everywhere at the system"); restoreSystemDictionatiesEnabledDisabledSettings(); ApplicationSettings settings; @@ -571,9 +579,9 @@ return; } - QNDEBUG(QStringLiteral("Can't find hunspell dictionaries in any of the expected " - "standard locations, will see if there are some " - "previously found dictionaries which are still valid")); + QNDEBUG("Can't find hunspell dictionaries in any of the expected " + "standard locations, will see if there are some " + "previously found dictionaries which are still valid"); SpellCheckerDictionariesFinder::DicAndAffFilesByDictionaryName dicAndAffFiles; ApplicationSettings settings; @@ -584,7 +592,8 @@ { settings.beginGroup(SPELL_CHECKER_FOUND_DICTIONARIES_GROUP); - int numDicFiles = settings.beginReadArray(SPELL_CHECKER_FOUND_DICTIONARIES_ARRAY); + int numDicFiles = + settings.beginReadArray(SPELL_CHECKER_FOUND_DICTIONARIES_ARRAY); dicAndAffFiles.reserve(numDicFiles); for(int i = 0; i < numDicFiles; ++i) { @@ -616,16 +625,14 @@ } if (!dicAndAffFiles.isEmpty()) { - QNDEBUG(QStringLiteral("Found some previously found dictionary files, " - "will use them instead of running a new search " - "across the system")); + QNDEBUG("Found some previously found dictionary files, will use them " + "instead of running a new search across the system"); onDictionariesFound(dicAndAffFiles); return; } - QNDEBUG(QStringLiteral("Still can't find any valid hunspell dictionaries, " - "trying the full recursive search across the entire " - "system, just to find something")); + QNDEBUG("Still can't find any valid hunspell dictionaries, trying the full " + "recursive search across the entire system, just to find something"); SpellCheckerDictionariesFinder * pFinder = new SpellCheckerDictionariesFinder(m_pDictionariesFinderStopFlag); @@ -639,55 +646,57 @@ Qt::QueuedConnection); } -void SpellCheckerPrivate::addSystemDictionary(const QString & path, - const QString & name) +void SpellCheckerPrivate::addSystemDictionary( + const QString & path, const QString & name) { - QNDEBUG(QStringLiteral("SpellCheckerPrivate::addSystemDictionary: path = ") - << path << QStringLiteral(", name = ") << name); + QNDEBUG("SpellCheckerPrivate::addSystemDictionary: path = " + << path << ", name = " << name); - QFileInfo dictionaryFileInfo(path + QStringLiteral("/") + name + QStringLiteral(".dic")); + QFileInfo dictionaryFileInfo(path + QStringLiteral("/") + name + + QStringLiteral(".dic")); if (!dictionaryFileInfo.exists()) { - QNTRACE(QStringLiteral("Dictionary file ") << dictionaryFileInfo.absoluteFilePath() - << QStringLiteral(" doesn't exist")); + QNTRACE("Dictionary file " << dictionaryFileInfo.absoluteFilePath() + << " doesn't exist"); return; } if (!dictionaryFileInfo.isReadable()) { - QNTRACE(QStringLiteral("Dictionary file ") << dictionaryFileInfo.absoluteFilePath() - << QStringLiteral(" is not readable")); + QNTRACE("Dictionary file " << dictionaryFileInfo.absoluteFilePath() + << " is not readable"); return; } - QFileInfo affixFileInfo(path + QStringLiteral("/") + name + QStringLiteral(".aff")); + QFileInfo affixFileInfo(path + QStringLiteral("/") + name + + QStringLiteral(".aff")); if (!affixFileInfo.exists()) { - QNTRACE(QStringLiteral("Affix file ") << affixFileInfo.absoluteFilePath() - << QStringLiteral(" does not exist")); + QNTRACE("Affix file " << affixFileInfo.absoluteFilePath() + << " does not exist"); return; } if (!affixFileInfo.isReadable()) { - QNTRACE(QStringLiteral("Affix file ") << affixFileInfo.absoluteFilePath() - << QStringLiteral(" is not readable")); + QNTRACE("Affix file " << affixFileInfo.absoluteFilePath() + << " is not readable"); return; } QString dictionaryFilePath = dictionaryFileInfo.absoluteFilePath(); QString affixFilePath = affixFileInfo.absoluteFilePath(); - QNTRACE(QStringLiteral("Raw dictionary file path = ") << dictionaryFilePath - << QStringLiteral(", raw affix file path = ") << affixFilePath); + QNTRACE("Raw dictionary file path = " << dictionaryFilePath + << ", raw affix file path = " << affixFilePath); Dictionary & dictionary = m_systemDictionaries[name]; dictionary.m_hunspellWrapper.initialize(affixFilePath, dictionaryFilePath); dictionary.m_dictionaryPath = dictionaryFilePath; dictionary.m_enabled = true; - QNTRACE(QStringLiteral("Added dictionary for language ") << name - << QStringLiteral("; dictionary file ") << dictionaryFilePath - << QStringLiteral(", affix file ") << affixFilePath); + QNTRACE("Added dictionary for language " << name + << "; dictionary file " << dictionaryFilePath + << ", affix file " << affixFilePath); } void SpellCheckerPrivate::initializeUserDictionary(const QString & userDictionaryPath) { - QNDEBUG(QStringLiteral("SpellCheckerPrivate::initializeUserDictionary: ") + QNDEBUG("SpellCheckerPrivate::initializeUserDictionary: " << (userDictionaryPath.isEmpty() ? QStringLiteral("<empty>") : userDictionaryPath)); @@ -698,14 +707,12 @@ { bool res = checkUserDictionaryPath(userDictionaryPath); if (!res) { - QNINFO(QStringLiteral("Can't accept the proposed user dictionary path, " - "will use the fallback chain of possible user " - "dictionary paths instead")); + QNINFO("Can't accept the proposed user dictionary path, will use the " + "fallback chain of possible user dictionary paths instead"); } else { m_userDictionaryPath = userDictionaryPath; - QNDEBUG(QStringLiteral("Set user dictionary path to ") - << userDictionaryPath); + QNDEBUG("Set user dictionary path to " << userDictionaryPath); foundValidPath = true; } } @@ -720,17 +727,17 @@ if (!userDictionaryPathFromSettings.isEmpty()) { - QNTRACE(QStringLiteral("Inspecting the user dictionary path found " - "in the application settings")); + QNTRACE("Inspecting the user dictionary path found " + "in the application settings"); bool res = checkUserDictionaryPath(userDictionaryPathFromSettings); if (!res) { - QNINFO(QStringLiteral("Can't accept the user dictionary path " - "from the application settings: ") + QNINFO("Can't accept the user dictionary path " + << "from the application settings: " << userDictionaryPathFromSettings); } else { m_userDictionaryPath = userDictionaryPathFromSettings; - QNDEBUG(QStringLiteral("Set user dictionary path to ") + QNDEBUG("Set user dictionary path to " << userDictionaryPathFromSettings); foundValidPath = true; } @@ -739,21 +746,19 @@ if (!foundValidPath) { - QNTRACE(QStringLiteral("Haven't found valid user dictionary file path " - "within the app settings, fallback to " - "the default path")); + QNTRACE("Haven't found valid user dictionary file path within the app " + "settings, fallback to the default path"); QString fallbackUserDictionaryPath = applicationPersistentStoragePath() + QStringLiteral("/spellcheck/user_dictionary.txt"); bool res = checkUserDictionaryPath(fallbackUserDictionaryPath); if (!res) { - QNINFO(QStringLiteral("Can't accept even the fallback default path")); + QNINFO("Can't accept even the fallback default path"); } else { m_userDictionaryPath = fallbackUserDictionaryPath; - QNDEBUG(QStringLiteral("Set user dictionary path to ") - << fallbackUserDictionaryPath); + QNDEBUG("Set user dictionary path to " << fallbackUserDictionaryPath); foundValidPath = true; } } @@ -762,7 +767,8 @@ { ApplicationSettings settings; settings.beginGroup(QStringLiteral("SpellCheck")); - settings.setValue(QStringLiteral("UserDictionaryPath"), m_userDictionaryPath); + settings.setValue(QStringLiteral("UserDictionaryPath"), + m_userDictionaryPath); settings.endGroup(); QObject::connect(this, @@ -779,24 +785,25 @@ m_readUserDictionaryRequestId = QUuid::createUuid(); Q_EMIT readFile(m_userDictionaryPath, m_readUserDictionaryRequestId); - QNTRACE(QStringLiteral("Sent the request to read the user dictionary file: id = ") + QNTRACE("Sent the request to read the user dictionary file: id = " << m_readUserDictionaryRequestId); } else { - QNINFO(QStringLiteral("Please specify the valid path for the user dictionary " - "under UserDictionaryPath entry in SpellCheck section " - "of application settings")); + QNINFO("Please specify the valid path for the user dictionary " + "under UserDictionaryPath entry in SpellCheck section " + "of application settings"); } } -bool SpellCheckerPrivate::checkUserDictionaryPath(const QString & userDictionaryPath) const +bool SpellCheckerPrivate::checkUserDictionaryPath( + const QString & userDictionaryPath) const { QFileInfo info(userDictionaryPath); if (info.exists()) { if (!info.isFile()) { - QNTRACE(QStringLiteral("User dictionary path candidate is not a file")); + QNTRACE("User dictionary path candidate is not a file"); return false; } @@ -805,16 +812,12 @@ QFile file(userDictionaryPath); bool res = file.setPermissions(QFile::WriteUser | QFile::ReadUser); if (!res) { - QNTRACE(QStringLiteral("User dictionary path candidate is a file ") - << QStringLiteral("with insufficient permissions and ") - << QStringLiteral("attempt to fix that has failed: readable =") - << (info.isReadable() - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", writable = ") - << (info.isWritable() - ? QStringLiteral("true") - : QStringLiteral("false"))); + QNTRACE("User dictionary path candidate is a file " + << "with insufficient permissions and " + << "attempt to fix that has failed: readable =" + << (info.isReadable() ? "true" : "false") + << ", writable = " + << (info.isWritable() ? "true" : "false")); return false; } } @@ -827,8 +830,8 @@ { bool res = dir.mkpath(dir.absolutePath()); if (!res) { - QNWARNING(QStringLiteral("Can't create not yet existing user " - "dictionary path candidate folder")); + QNWARNING("Can't create not yet existing user " + "dictionary path candidate folder"); return false; } } @@ -838,10 +841,10 @@ void SpellCheckerPrivate::checkUserDictionaryDataPendingWriting() { - QNDEBUG(QStringLiteral("SpellCheckerPrivate::checkUserDictionaryDataPendingWriting")); + QNDEBUG("SpellCheckerPrivate::checkUserDictionaryDataPendingWriting"); if (m_userDictionaryPartPendingWriting.isEmpty()) { - QNTRACE(QStringLiteral("Nothing is pending writing")); + QNTRACE("Nothing is pending writing"); return; } @@ -872,8 +875,8 @@ Q_EMIT writeFile(m_userDictionaryPath, dataToWrite, m_appendUserDictionaryPartToFileRequestId, /* append = */ true); - QNTRACE(QStringLiteral("Sent the request to append the data pending ") - << QStringLiteral("writing to user dictionary, id = ") + QNTRACE("Sent the request to append the data pending " + << "writing to user dictionary, id = " << m_appendUserDictionaryPartToFileRequestId); } @@ -882,7 +885,7 @@ void SpellCheckerPrivate::persistEnabledSystemDictionaries() { - QNDEBUG(QStringLiteral("SpellCheckerPrivate::persistEnabledSystemDictionaries")); + QNDEBUG("SpellCheckerPrivate::persistEnabledSystemDictionaries"); QStringList enabledSystemDictionaries; enabledSystemDictionaries.reserve(m_systemDictionaries.size()); @@ -895,7 +898,7 @@ } } - QNTRACE(QStringLiteral("Enabled system dictionaties: ") + QNTRACE("Enabled system dictionaties: " << enabledSystemDictionaries.join(QStringLiteral(", "))); ApplicationSettings appSettings(m_currentAccount); @@ -905,8 +908,8 @@ void SpellCheckerPrivate::restoreSystemDictionatiesEnabledDisabledSettings() { - QNDEBUG(QStringLiteral("SpellCheckerPrivate::" - "restoreSystemDictionatiesEnabledDisabledSettings")); + QNDEBUG("SpellCheckerPrivate::" + "restoreSystemDictionatiesEnabledDisabledSettings"); ApplicationSettings appSettings(m_currentAccount); bool containsEnabledSystemDictionaries = @@ -921,13 +924,11 @@ if (enabledSystemDictionaries.contains(name)) { it.value().m_enabled = true; - QNTRACE(QStringLiteral("Enabled ") << name - << QStringLiteral(" dictionary")); + QNTRACE("Enabled " << name << " dictionary"); } else { it.value().m_enabled = false; - QNTRACE(QStringLiteral("Disabled ") << name - << QStringLiteral(" dictionary")); + QNTRACE("Disabled " << name << " dictionary"); } } @@ -935,13 +936,13 @@ return; } - QNDEBUG(QStringLiteral("Found no previously persisted settings for enabled " - "system dictionaries, will enable the dictionary " - "corresponding to the system locale")); + QNDEBUG("Found no previously persisted settings for enabled system " + "dictionaries, will enable the dictionary corresponding to " + "the system locale"); QLocale systemLocale = QLocale::system(); QString systemLocaleName = systemLocale.name(); - QNDEBUG(QStringLiteral("System locale name: ") << systemLocaleName); + QNDEBUG("System locale name: " << systemLocaleName); auto systemLocaleDictIt = m_systemDictionaries.find(systemLocaleName); if (systemLocaleDictIt != m_systemDictionaries.end()) @@ -954,8 +955,7 @@ } else { - QNINFO(QStringLiteral("Found no dictionary corresponding to " - "the system locale!")); + QNINFO("Found no dictionary corresponding to the system locale!"); // Ok, will enable all existing system dictionaries for(auto it = m_systemDictionaries.begin(), @@ -970,10 +970,9 @@ persistEnabledSystemDictionaries(); } -void SpellCheckerPrivate::onReadFileRequestProcessed(bool success, - ErrorString errorDescription, - QByteArray data, - QUuid requestId) +void SpellCheckerPrivate::onReadFileRequestProcessed( + bool success, ErrorString errorDescription, + QByteArray data, QUuid requestId) { Q_UNUSED(errorDescription) @@ -981,9 +980,8 @@ return; } - QNDEBUG(QStringLiteral("SpellCheckerPrivate::onReadFileRequestProcessed: success = ") - << (success ? QStringLiteral("true") : QStringLiteral("false")) - << QStringLiteral(", request id = ") << requestId); + QNDEBUG("SpellCheckerPrivate::onReadFileRequestProcessed: success = " + << (success ? "true" : "false") << ", request id = " << requestId); m_readUserDictionaryRequestId = QUuid(); @@ -1022,12 +1020,12 @@ } else { - QNWARNING(QStringLiteral("Can't open the data buffer for reading")); + QNWARNING("Can't open the data buffer for reading"); } } else { - QNWARNING(QStringLiteral("Can't read the data from user's dictionary")); + QNWARNING("Can't read the data from user's dictionary"); } m_userDictionaryReady = true; @@ -1036,9 +1034,8 @@ } } -void SpellCheckerPrivate::onWriteFileRequestProcessed(bool success, - ErrorString errorDescription, - QUuid requestId) +void SpellCheckerPrivate::onWriteFileRequestProcessed( + bool success, ErrorString errorDescription, QUuid requestId) { if (requestId == m_appendUserDictionaryPartToFileRequestId) { onAppendUserDictionaryPartDone(success, errorDescription); @@ -1068,34 +1065,34 @@ } } -void SpellCheckerPrivate::onAppendUserDictionaryPartDone(bool success, - ErrorString errorDescription) +void SpellCheckerPrivate::onAppendUserDictionaryPartDone( + bool success, ErrorString errorDescription) { - QNDEBUG(QStringLiteral("SpellCheckerPrivate::onAppendUserDictionaryPartDone: success = ") - << (success ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("SpellCheckerPrivate::onAppendUserDictionaryPartDone: success = " + << (success ? "true" : "false")); Q_UNUSED(errorDescription) m_appendUserDictionaryPartToFileRequestId = QUuid(); if (Q_UNLIKELY(!success)) { - QNWARNING(QStringLiteral("Can't append word to the user dictionary file")); + QNWARNING("Can't append word to the user dictionary file"); return; } checkUserDictionaryDataPendingWriting(); } -void SpellCheckerPrivate::onUpdateUserDictionaryDone(bool success, - ErrorString errorDescription) +void SpellCheckerPrivate::onUpdateUserDictionaryDone( + bool success, ErrorString errorDescription) { - QNDEBUG(QStringLiteral("SpellCheckerPrivate::onUpdateUserDictionaryDone: success = ") - << (success ? QStringLiteral("true") : QStringLiteral("false")) - << QStringLiteral(", error description = ") << errorDescription); + QNDEBUG("SpellCheckerPrivate::onUpdateUserDictionaryDone: success = " + << (success ? "true" : "false") + << ", error description = " << errorDescription); m_updateUserDictionaryFileRequestId = QUuid(); if (Q_UNLIKELY(!success)) { - QNWARNING(QStringLiteral("Can't update the user dictionary file")); + QNWARNING("Can't update the user dictionary file"); return; } } diff -Nru libquentier-0.5.0/src/note_editor/SpellChecker_p.h libquentier-0.5.0/src/note_editor/SpellChecker_p.h --- libquentier-0.5.0/src/note_editor/SpellChecker_p.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/SpellChecker_p.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,9 +20,11 @@ #define LIB_QUENTIER_NOTE_EDITOR_SPELL_CHECKER_P_H #include "SpellCheckerDictionariesFinder.h" + #include <quentier/utility/Macros.h> #include <quentier/types/ErrorString.h> #include <quentier/types/Account.h> + #include <QObject> #include <QStringList> #include <QVector> @@ -87,8 +89,11 @@ void checkUserDictionaryDataPendingWriting(); - void onAppendUserDictionaryPartDone(bool success, ErrorString errorDescription); - void onUpdateUserDictionaryDone(bool success, ErrorString errorDescription); + void onAppendUserDictionaryPartDone( + bool success, ErrorString errorDescription); + + void onUpdateUserDictionaryDone( + bool success, ErrorString errorDescription); void persistEnabledSystemDictionaries(); void restoreSystemDictionatiesEnabledDisabledSettings(); diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/AddHyperlinkUndoCommand.cpp libquentier-0.5.0/src/note_editor/undo_stack/AddHyperlinkUndoCommand.cpp --- libquentier-0.5.0/src/note_editor/undo_stack/AddHyperlinkUndoCommand.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/AddHyperlinkUndoCommand.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,36 +18,42 @@ #include "AddHyperlinkUndoCommand.h" #include "../NoteEditor_p.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { -#define GET_PAGE() \ - NoteEditorPage * page = \ - qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ - if (Q_UNLIKELY(!page)) { \ - ErrorString error(QT_TRANSLATE_NOOP("AddHyperlinkUndoCommand", \ - "Can't undo/redo adding the hyperlink "\ - "to the selected text: no note editor "\ - "page")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } - -AddHyperlinkUndoCommand::AddHyperlinkUndoCommand(NoteEditorPrivate & noteEditor, - const Callback & callback, - QUndoCommand * parent) : +#define GET_PAGE() \ + NoteEditorPage * page = \ + qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ + if (Q_UNLIKELY(!page)) \ + { \ + ErrorString error( \ + QT_TRANSLATE_NOOP("AddHyperlinkUndoCommand", \ + "Can't undo/redo adding the hyperlink " \ + "to the selected text: no note editor " \ + "page")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// GET_PAGE + +AddHyperlinkUndoCommand::AddHyperlinkUndoCommand( + NoteEditorPrivate & noteEditor, + const Callback & callback, + QUndoCommand * parent) : INoteEditorUndoCommand(noteEditor, parent), m_callback(callback) { setText(tr("Add hyperlink")); } -AddHyperlinkUndoCommand::AddHyperlinkUndoCommand(NoteEditorPrivate & noteEditor, - const Callback & callback, - const QString & text, - QUndoCommand * parent) : +AddHyperlinkUndoCommand::AddHyperlinkUndoCommand( + NoteEditorPrivate & noteEditor, + const Callback & callback, + const QString & text, + QUndoCommand * parent) : INoteEditorUndoCommand(noteEditor, text, parent), m_callback(callback) {} @@ -57,18 +63,20 @@ void AddHyperlinkUndoCommand::redoImpl() { - QNDEBUG(QStringLiteral("AddHyperlinkUndoCommand::redoImpl")); + QNDEBUG("AddHyperlinkUndoCommand::redoImpl"); GET_PAGE() - page->executeJavaScript(QStringLiteral("hyperlinkManager.redo();"), m_callback); + page->executeJavaScript(QStringLiteral("hyperlinkManager.redo();"), + m_callback); } void AddHyperlinkUndoCommand::undoImpl() { - QNDEBUG(QStringLiteral("AddHyperlinkUndoCommand::undoImpl")); + QNDEBUG("AddHyperlinkUndoCommand::undoImpl"); GET_PAGE() - page->executeJavaScript(QStringLiteral("hyperlinkManager.undo();"), m_callback); + page->executeJavaScript(QStringLiteral("hyperlinkManager.undo();"), + m_callback); } } // namespace quentier diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/AddHyperlinkUndoCommand.h libquentier-0.5.0/src/note_editor/undo_stack/AddHyperlinkUndoCommand.h --- libquentier-0.5.0/src/note_editor/undo_stack/AddHyperlinkUndoCommand.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/AddHyperlinkUndoCommand.h 2019-07-11 10:46:53.000000000 +0000 @@ -29,10 +29,16 @@ Q_OBJECT typedef NoteEditorPage::Callback Callback; public: - AddHyperlinkUndoCommand(NoteEditorPrivate & noteEditor, const Callback & callback, - QUndoCommand * parent = Q_NULLPTR); - AddHyperlinkUndoCommand(NoteEditorPrivate & noteEditor, const Callback & callback, - const QString & text, QUndoCommand * parent = Q_NULLPTR); + AddHyperlinkUndoCommand( + NoteEditorPrivate & noteEditor, + const Callback & callback, + QUndoCommand * parent = Q_NULLPTR); + + AddHyperlinkUndoCommand( + NoteEditorPrivate & noteEditor, + const Callback & callback, + const QString & text, QUndoCommand * parent = Q_NULLPTR); + virtual ~AddHyperlinkUndoCommand(); virtual void redoImpl() Q_DECL_OVERRIDE; diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/AddResourceUndoCommand.cpp libquentier-0.5.0/src/note_editor/undo_stack/AddResourceUndoCommand.cpp --- libquentier-0.5.0/src/note_editor/undo_stack/AddResourceUndoCommand.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/AddResourceUndoCommand.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,26 +18,31 @@ #include "AddResourceUndoCommand.h" #include "../NoteEditor_p.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { -#define GET_PAGE() \ - NoteEditorPage * page = \ - qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ - if (Q_UNLIKELY(!page)) { \ - ErrorString error(QT_TRANSLATE_NOOP("AddResourceUndoCommand", \ - "Can't undo/redo adding the attachment: "\ - "no note editor page")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } - -AddResourceUndoCommand::AddResourceUndoCommand(const Resource & resource, - const Callback & callback, - NoteEditorPrivate & noteEditorPrivate, - QUndoCommand * parent) : +#define GET_PAGE() \ + NoteEditorPage * page = \ + qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ + if (Q_UNLIKELY(!page)) \ + { \ + ErrorString error( \ + QT_TRANSLATE_NOOP("AddResourceUndoCommand", \ + "Can't undo/redo adding the attachment: " \ + "no note editor page")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// GET_PAGE + +AddResourceUndoCommand::AddResourceUndoCommand( + const Resource & resource, + const Callback & callback, + NoteEditorPrivate & noteEditorPrivate, + QUndoCommand * parent) : INoteEditorUndoCommand(noteEditorPrivate, parent), m_resource(resource), m_callback(callback) @@ -45,11 +50,12 @@ setText(tr("Add attachment")); } -AddResourceUndoCommand::AddResourceUndoCommand(const Resource & resource, - const Callback & callback, - NoteEditorPrivate & noteEditorPrivate, - const QString & text, - QUndoCommand * parent) : +AddResourceUndoCommand::AddResourceUndoCommand( + const Resource & resource, + const Callback & callback, + NoteEditorPrivate & noteEditorPrivate, + const QString & text, + QUndoCommand * parent) : INoteEditorUndoCommand(noteEditorPrivate, text, parent), m_resource(resource), m_callback(callback) @@ -60,22 +66,24 @@ void AddResourceUndoCommand::undoImpl() { - QNDEBUG(QStringLiteral("AddResourceUndoCommand::undoImpl")); + QNDEBUG("AddResourceUndoCommand::undoImpl"); m_noteEditorPrivate.removeResourceFromNote(m_resource); GET_PAGE() - page->executeJavaScript(QStringLiteral("resourceManager.undo();"), m_callback); + page->executeJavaScript(QStringLiteral("resourceManager.undo();"), + m_callback); } void AddResourceUndoCommand::redoImpl() { - QNDEBUG(QStringLiteral("AddResourceUndoCommand::redoImpl")); + QNDEBUG("AddResourceUndoCommand::redoImpl"); m_noteEditorPrivate.addResourceToNote(m_resource); GET_PAGE() - page->executeJavaScript(QStringLiteral("resourceManager.redo();"), m_callback); + page->executeJavaScript(QStringLiteral("resourceManager.redo();"), + m_callback); } } // namespace quentier diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/AddResourceUndoCommand.h libquentier-0.5.0/src/note_editor/undo_stack/AddResourceUndoCommand.h --- libquentier-0.5.0/src/note_editor/undo_stack/AddResourceUndoCommand.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/AddResourceUndoCommand.h 2019-07-11 10:46:53.000000000 +0000 @@ -31,12 +31,16 @@ Q_OBJECT typedef NoteEditorPage::Callback Callback; public: - AddResourceUndoCommand(const Resource & resource, const Callback & callback, - NoteEditorPrivate & noteEditorPrivate, - QUndoCommand * parent = Q_NULLPTR); - AddResourceUndoCommand(const Resource & resource, const Callback & callback, - NoteEditorPrivate & noteEditorPrivate, - const QString & text, QUndoCommand * parent = Q_NULLPTR); + AddResourceUndoCommand( + const Resource & resource, const Callback & callback, + NoteEditorPrivate & noteEditorPrivate, + QUndoCommand * parent = Q_NULLPTR); + + AddResourceUndoCommand( + const Resource & resource, const Callback & callback, + NoteEditorPrivate & noteEditorPrivate, + const QString & text, QUndoCommand * parent = Q_NULLPTR); + virtual ~AddResourceUndoCommand(); virtual void undoImpl() Q_DECL_OVERRIDE; diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/DecryptUndoCommand.cpp libquentier-0.5.0/src/note_editor/undo_stack/DecryptUndoCommand.cpp --- libquentier-0.5.0/src/note_editor/undo_stack/DecryptUndoCommand.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/DecryptUndoCommand.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,21 +18,25 @@ #include "DecryptUndoCommand.h" #include "../NoteEditor_p.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { -#define GET_PAGE() \ - NoteEditorPage * page = \ - qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ - if (Q_UNLIKELY(!page)) { \ - ErrorString error(QT_TRANSLATE_NOOP("DecryptUndoCommand", \ - "Can't undo/redo the encrypted text "\ - "decryption: no note editor page")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } +#define GET_PAGE() \ + NoteEditorPage * page = \ + qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ + if (Q_UNLIKELY(!page)) \ + { \ + ErrorString error( \ + QT_TRANSLATE_NOOP("DecryptUndoCommand", \ + "Can't undo/redo the encrypted text " \ + "decryption: no note editor page")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// GET_PAGE DecryptUndoCommand::DecryptUndoCommand( const EncryptDecryptUndoCommandInfo & info, @@ -63,7 +67,7 @@ void DecryptUndoCommand::redoImpl() { - QNDEBUG(QStringLiteral("DecryptUndoCommand::redoImpl")); + QNDEBUG("DecryptUndoCommand::redoImpl"); GET_PAGE() @@ -80,7 +84,7 @@ void DecryptUndoCommand::undoImpl() { - QNDEBUG(QStringLiteral("DecryptUndoCommand::undoImpl")); + QNDEBUG("DecryptUndoCommand::undoImpl"); GET_PAGE() diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/DecryptUndoCommand.h libquentier-0.5.0/src/note_editor/undo_stack/DecryptUndoCommand.h --- libquentier-0.5.0/src/note_editor/undo_stack/DecryptUndoCommand.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/DecryptUndoCommand.h 2019-07-11 10:46:53.000000000 +0000 @@ -32,15 +32,21 @@ Q_OBJECT typedef NoteEditorPage::Callback Callback; public: - DecryptUndoCommand(const EncryptDecryptUndoCommandInfo & info, - const QSharedPointer<DecryptedTextManager> & decryptedTextManager, - NoteEditorPrivate & noteEditorPrivate, - const Callback & callback, QUndoCommand * parent = Q_NULLPTR); - DecryptUndoCommand(const EncryptDecryptUndoCommandInfo & info, - const QSharedPointer<DecryptedTextManager> & decryptedTextManager, - NoteEditorPrivate & noteEditorPrivate, - const Callback & callback, const QString & text, - QUndoCommand * parent = Q_NULLPTR); + DecryptUndoCommand( + const EncryptDecryptUndoCommandInfo & info, + const QSharedPointer<DecryptedTextManager> & decryptedTextManager, + NoteEditorPrivate & noteEditorPrivate, + const Callback & callback, + QUndoCommand * parent = Q_NULLPTR); + + DecryptUndoCommand( + const EncryptDecryptUndoCommandInfo & info, + const QSharedPointer<DecryptedTextManager> & decryptedTextManager, + NoteEditorPrivate & noteEditorPrivate, + const Callback & callback, + const QString & text, + QUndoCommand * parent = Q_NULLPTR); + virtual ~DecryptUndoCommand(); virtual void redoImpl() Q_DECL_OVERRIDE; diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/EditHyperlinkUndoCommand.cpp libquentier-0.5.0/src/note_editor/undo_stack/EditHyperlinkUndoCommand.cpp --- libquentier-0.5.0/src/note_editor/undo_stack/EditHyperlinkUndoCommand.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/EditHyperlinkUndoCommand.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,35 +18,40 @@ #include "EditHyperlinkUndoCommand.h" #include "../NoteEditor_p.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { -#define GET_PAGE() \ - NoteEditorPage * page = \ - qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ - if (Q_UNLIKELY(!page)) { \ - ErrorString error(QT_TRANSLATE_NOOP("EditHyperlinkUndoCommand", \ - "Can't undo/redo hyperlink edit: "\ - "no note editor page")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } - -EditHyperlinkUndoCommand::EditHyperlinkUndoCommand(NoteEditorPrivate & noteEditorPrivate, - const Callback & callback, - QUndoCommand * parent) : +#define GET_PAGE() \ + NoteEditorPage * page = \ + qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ + if (Q_UNLIKELY(!page)) \ + { \ + ErrorString error(QT_TRANSLATE_NOOP("EditHyperlinkUndoCommand", \ + "Can't undo/redo hyperlink edit: " \ + "no note editor page")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// GET_PAGE + +EditHyperlinkUndoCommand::EditHyperlinkUndoCommand( + NoteEditorPrivate & noteEditorPrivate, + const Callback & callback, + QUndoCommand * parent) : INoteEditorUndoCommand(noteEditorPrivate, parent), m_callback(callback) { setText(tr("Edit hyperlink")); } -EditHyperlinkUndoCommand::EditHyperlinkUndoCommand(NoteEditorPrivate & noteEditorPrivate, - const Callback & callback, - const QString & text, - QUndoCommand * parent) : +EditHyperlinkUndoCommand::EditHyperlinkUndoCommand( + NoteEditorPrivate & noteEditorPrivate, + const Callback & callback, + const QString & text, + QUndoCommand * parent) : INoteEditorUndoCommand(noteEditorPrivate, text, parent), m_callback(callback) {} @@ -56,7 +61,7 @@ void EditHyperlinkUndoCommand::redoImpl() { - QNDEBUG(QStringLiteral("EditHyperlinkUndoCommand::redoImpl")); + QNDEBUG("EditHyperlinkUndoCommand::redoImpl"); GET_PAGE() page->executeJavaScript(QStringLiteral("hyperlinkManager.redo();"), @@ -65,7 +70,7 @@ void EditHyperlinkUndoCommand::undoImpl() { - QNDEBUG(QStringLiteral("EditHyperlinkUndoCommand::undoImpl")); + QNDEBUG("EditHyperlinkUndoCommand::undoImpl"); GET_PAGE() page->executeJavaScript(QStringLiteral("hyperlinkManager.undo();"), diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/EditHyperlinkUndoCommand.h libquentier-0.5.0/src/note_editor/undo_stack/EditHyperlinkUndoCommand.h --- libquentier-0.5.0/src/note_editor/undo_stack/EditHyperlinkUndoCommand.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/EditHyperlinkUndoCommand.h 2019-07-11 10:46:53.000000000 +0000 @@ -29,11 +29,17 @@ Q_OBJECT typedef NoteEditorPage::Callback Callback; public: - EditHyperlinkUndoCommand(NoteEditorPrivate & noteEditorPrivate, - const Callback & callback, QUndoCommand * parent = Q_NULLPTR); - EditHyperlinkUndoCommand(NoteEditorPrivate & noteEditorPrivate, - const Callback & callback, const QString & text, - QUndoCommand * parent = Q_NULLPTR); + EditHyperlinkUndoCommand( + NoteEditorPrivate & noteEditorPrivate, + const Callback & callback, + QUndoCommand * parent = Q_NULLPTR); + + EditHyperlinkUndoCommand( + NoteEditorPrivate & noteEditorPrivate, + const Callback & callback, + const QString & text, + QUndoCommand * parent = Q_NULLPTR); + virtual ~EditHyperlinkUndoCommand(); virtual void redoImpl() Q_DECL_OVERRIDE; diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/EncryptDecryptUndoCommandInfo.h libquentier-0.5.0/src/note_editor/undo_stack/EncryptDecryptUndoCommandInfo.h --- libquentier-0.5.0/src/note_editor/undo_stack/EncryptDecryptUndoCommandInfo.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/EncryptDecryptUndoCommandInfo.h 2019-07-11 10:46:53.000000000 +0000 @@ -1,3 +1,21 @@ +/* + * Copyright 2016-2019 Dmitry Ivanov + * + * This file is part of libquentier + * + * libquentier is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * libquentier 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with libquentier. If not, see <http://www.gnu.org/licenses/>. + */ + #ifndef LIB_QUENTIER_NOTE_EDITOR_UNDO_STACK_ENCRYPT_DECRYPT_UNDO_COMMAND_INFO_H #define LIB_QUENTIER_NOTE_EDITOR_UNDO_STACK_ENCRYPT_DECRYPT_UNDO_COMMAND_INFO_H diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/EncryptUndoCommand.cpp libquentier-0.5.0/src/note_editor/undo_stack/EncryptUndoCommand.cpp --- libquentier-0.5.0/src/note_editor/undo_stack/EncryptUndoCommand.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/EncryptUndoCommand.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,35 +18,41 @@ #include "EncryptUndoCommand.h" #include "../NoteEditor_p.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { -#define GET_PAGE() \ - NoteEditorPage * page = \ - qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ - if (Q_UNLIKELY(!page)) { \ - ErrorString error(QT_TRANSLATE_NOOP("EncryptUndoCommand", \ - "Can't undo/redo the text encryption: "\ - "can't get note editor page")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } - -EncryptUndoCommand::EncryptUndoCommand(NoteEditorPrivate & noteEditorPrivate, - const Callback & callback, - QUndoCommand * parent) : +#define GET_PAGE() \ + NoteEditorPage * page = \ + qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ + if (Q_UNLIKELY(!page)) \ + { \ + ErrorString error( \ + QT_TRANSLATE_NOOP("EncryptUndoCommand", \ + "Can't undo/redo the text encryption: " \ + "can't get note editor page")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// GET_PAGE + +EncryptUndoCommand::EncryptUndoCommand( + NoteEditorPrivate & noteEditorPrivate, + const Callback & callback, + QUndoCommand * parent) : INoteEditorUndoCommand(noteEditorPrivate, parent), m_callback(callback) { setText(tr("Encrypt selected text")); } -EncryptUndoCommand:: EncryptUndoCommand(NoteEditorPrivate & noteEditorPrivate, - const Callback & callback, - const QString & text, - QUndoCommand * parent) : +EncryptUndoCommand:: EncryptUndoCommand( + NoteEditorPrivate & noteEditorPrivate, + const Callback & callback, + const QString & text, + QUndoCommand * parent) : INoteEditorUndoCommand(noteEditorPrivate, text, parent), m_callback(callback) {} @@ -56,7 +62,7 @@ void EncryptUndoCommand::redoImpl() { - QNDEBUG(QStringLiteral("EncryptUndoCommand::redoImpl")); + QNDEBUG("EncryptUndoCommand::redoImpl"); GET_PAGE() page->executeJavaScript(QStringLiteral("encryptDecryptManager.redo();"), @@ -65,7 +71,7 @@ void EncryptUndoCommand::undoImpl() { - QNDEBUG(QStringLiteral("EncryptUndoCommand::undoImpl")); + QNDEBUG("EncryptUndoCommand::undoImpl"); GET_PAGE() page->executeJavaScript(QStringLiteral("encryptDecryptManager.undo();"), diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/EncryptUndoCommand.h libquentier-0.5.0/src/note_editor/undo_stack/EncryptUndoCommand.h --- libquentier-0.5.0/src/note_editor/undo_stack/EncryptUndoCommand.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/EncryptUndoCommand.h 2019-07-11 10:46:53.000000000 +0000 @@ -29,10 +29,17 @@ Q_OBJECT typedef NoteEditorPage::Callback Callback; public: - EncryptUndoCommand(NoteEditorPrivate & noteEditorPrivate, const Callback & callback, - QUndoCommand * parent = Q_NULLPTR); - EncryptUndoCommand(NoteEditorPrivate & noteEditorPrivate, const Callback & callback, - const QString & text, QUndoCommand * parent = Q_NULLPTR); + EncryptUndoCommand( + NoteEditorPrivate & noteEditorPrivate, + const Callback & callback, + QUndoCommand * parent = Q_NULLPTR); + + EncryptUndoCommand( + NoteEditorPrivate & noteEditorPrivate, + const Callback & callback, + const QString & text, + QUndoCommand * parent = Q_NULLPTR); + virtual ~EncryptUndoCommand(); virtual void redoImpl() Q_DECL_OVERRIDE; diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/HideDecryptedTextUndoCommand.cpp libquentier-0.5.0/src/note_editor/undo_stack/HideDecryptedTextUndoCommand.cpp --- libquentier-0.5.0/src/note_editor/undo_stack/HideDecryptedTextUndoCommand.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/HideDecryptedTextUndoCommand.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,21 +18,25 @@ #include "HideDecryptedTextUndoCommand.h" #include "../NoteEditor_p.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { -#define GET_PAGE() \ - NoteEditorPage * page = \ - qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ - if (Q_UNLIKELY(!page)) { \ - ErrorString error(QT_TRANSLATE_NOOP("HideDecryptedTextUndoCommand", \ - "Can't undo/redo the decrypted text "\ - "hiding: can't get note editor page")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } +#define GET_PAGE() \ + NoteEditorPage * page = \ + qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ + if (Q_UNLIKELY(!page)) \ + { \ + ErrorString error( \ + QT_TRANSLATE_NOOP("HideDecryptedTextUndoCommand", \ + "Can't undo/redo the decrypted text " \ + "hiding: can't get note editor page")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// GET_PAGE HideDecryptedTextUndoCommand::HideDecryptedTextUndoCommand( NoteEditorPrivate & noteEditorPrivate, @@ -55,7 +59,7 @@ void HideDecryptedTextUndoCommand::redoImpl() { - QNDEBUG(QStringLiteral("HideDecryptedTextUndoCommand::redoImpl")); + QNDEBUG("HideDecryptedTextUndoCommand::redoImpl"); GET_PAGE() page->executeJavaScript(QStringLiteral("encryptDecryptManager.redo();"), @@ -64,7 +68,7 @@ void HideDecryptedTextUndoCommand::undoImpl() { - QNDEBUG(QStringLiteral("HideDecryptedTextUndoCommand::undoImpl")); + QNDEBUG("HideDecryptedTextUndoCommand::undoImpl"); GET_PAGE() page->executeJavaScript(QStringLiteral("encryptDecryptManager.undo();"), diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/HideDecryptedTextUndoCommand.h libquentier-0.5.0/src/note_editor/undo_stack/HideDecryptedTextUndoCommand.h --- libquentier-0.5.0/src/note_editor/undo_stack/HideDecryptedTextUndoCommand.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/HideDecryptedTextUndoCommand.h 2019-07-11 10:46:53.000000000 +0000 @@ -29,12 +29,17 @@ Q_OBJECT typedef NoteEditorPage::Callback Callback; public: - HideDecryptedTextUndoCommand(NoteEditorPrivate & noteEditorPrivate, - const Callback & callback, - QUndoCommand * parent = Q_NULLPTR); - HideDecryptedTextUndoCommand(NoteEditorPrivate & noteEditorPrivate, - const Callback & callback, const QString & text, - QUndoCommand * parent = Q_NULLPTR); + HideDecryptedTextUndoCommand( + NoteEditorPrivate & noteEditorPrivate, + const Callback & callback, + QUndoCommand * parent = Q_NULLPTR); + + HideDecryptedTextUndoCommand( + NoteEditorPrivate & noteEditorPrivate, + const Callback & callback, + const QString & text, + QUndoCommand * parent = Q_NULLPTR); + virtual ~HideDecryptedTextUndoCommand(); virtual void redoImpl() Q_DECL_OVERRIDE; diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/ImageResizeUndoCommand.cpp libquentier-0.5.0/src/note_editor/undo_stack/ImageResizeUndoCommand.cpp --- libquentier-0.5.0/src/note_editor/undo_stack/ImageResizeUndoCommand.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/ImageResizeUndoCommand.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,30 +18,34 @@ #include "ImageResizeUndoCommand.h" #include "../NoteEditor_p.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { -#define GET_PAGE() \ - NoteEditorPage * page = \ - qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ - if (Q_UNLIKELY(!page)) { \ - ErrorString error(QT_TRANSLATE_NOOP("ImageResizeUndoCommand", \ - "Can't undo/redo image resizing: "\ - "can't get note editor page")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } - -ImageResizeUndoCommand::ImageResizeUndoCommand(NoteEditorPrivate & noteEditor, - QUndoCommand * parent) : +#define GET_PAGE() \ + NoteEditorPage * page = \ + qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ + if (Q_UNLIKELY(!page)) { \ + ErrorString error(QT_TRANSLATE_NOOP("ImageResizeUndoCommand", \ + "Can't undo/redo image resizing: " \ + "can't get note editor page")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// GET_PAGE + +ImageResizeUndoCommand::ImageResizeUndoCommand( + NoteEditorPrivate & noteEditor, + QUndoCommand * parent) : INoteEditorUndoCommand(noteEditor, parent) {} -ImageResizeUndoCommand::ImageResizeUndoCommand(NoteEditorPrivate & noteEditor, - const QString & text, - QUndoCommand * parent) : +ImageResizeUndoCommand::ImageResizeUndoCommand( + NoteEditorPrivate & noteEditor, + const QString & text, + QUndoCommand * parent) : INoteEditorUndoCommand(noteEditor, text, parent) {} @@ -50,7 +54,7 @@ void ImageResizeUndoCommand::redoImpl() { - QNDEBUG(QStringLiteral("ImageResizeUndoCommand::redoImpl")); + QNDEBUG("ImageResizeUndoCommand::redoImpl"); GET_PAGE() page->executeJavaScript(QStringLiteral("resizableImageManager.redo();")); @@ -58,7 +62,7 @@ void ImageResizeUndoCommand::undoImpl() { - QNDEBUG(QStringLiteral("ImageResizeUndoCommand::undoImpl")); + QNDEBUG("ImageResizeUndoCommand::undoImpl"); GET_PAGE() page->executeJavaScript(QStringLiteral("resizableImageManager.undo();")); diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/ImageResizeUndoCommand.h libquentier-0.5.0/src/note_editor/undo_stack/ImageResizeUndoCommand.h --- libquentier-0.5.0/src/note_editor/undo_stack/ImageResizeUndoCommand.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/ImageResizeUndoCommand.h 2019-07-11 10:46:53.000000000 +0000 @@ -27,10 +27,15 @@ { Q_OBJECT public: - ImageResizeUndoCommand(NoteEditorPrivate & noteEditor, - QUndoCommand * parent = Q_NULLPTR); - ImageResizeUndoCommand(NoteEditorPrivate & noteEditor, - const QString & text, QUndoCommand * parent = Q_NULLPTR); + ImageResizeUndoCommand( + NoteEditorPrivate & noteEditor, + QUndoCommand * parent = Q_NULLPTR); + + ImageResizeUndoCommand( + NoteEditorPrivate & noteEditor, + const QString & text, + QUndoCommand * parent = Q_NULLPTR); + virtual ~ImageResizeUndoCommand(); virtual void redoImpl() Q_DECL_OVERRIDE; diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/ImageResourceRotationUndoCommand.cpp libquentier-0.5.0/src/note_editor/undo_stack/ImageResourceRotationUndoCommand.cpp --- libquentier-0.5.0/src/note_editor/undo_stack/ImageResourceRotationUndoCommand.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/ImageResourceRotationUndoCommand.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -17,7 +17,9 @@ */ #include "ImageResourceRotationUndoCommand.h" + #include <quentier/logging/QuentierLogger.h> + #include <limits> namespace quentier { @@ -72,12 +74,12 @@ void ImageResourceRotationUndoCommand::redoImpl() { - QNDEBUG(QStringLiteral("ImageResourceRotationUndoCommand::redoImpl")); + QNDEBUG("ImageResourceRotationUndoCommand::redoImpl"); const Note * pNote = m_noteEditorPrivate.notePtr(); if (Q_UNLIKELY(!pNote)) { - QNDEBUG(QStringLiteral("Can't redo image resource rotation: no note " - "is set to the editor")); + QNDEBUG("Can't redo image resource rotation: no note " + "is set to the editor"); return; } @@ -88,12 +90,12 @@ void ImageResourceRotationUndoCommand::undoImpl() { - QNDEBUG(QStringLiteral("ImageResourceRotationUndoCommand::undoImpl")); + QNDEBUG("ImageResourceRotationUndoCommand::undoImpl"); const Note * pNote = m_noteEditorPrivate.notePtr(); if (Q_UNLIKELY(!pNote)) { - QNDEBUG(QStringLiteral("Can't undo image resource rotation: no note " - "is set to the editor")); + QNDEBUG("Can't undo image resource rotation: no note " + "is set to the editor"); return; } diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/ImageResourceRotationUndoCommand.h libquentier-0.5.0/src/note_editor/undo_stack/ImageResourceRotationUndoCommand.h --- libquentier-0.5.0/src/note_editor/undo_stack/ImageResourceRotationUndoCommand.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/ImageResourceRotationUndoCommand.h 2019-07-11 10:46:53.000000000 +0000 @@ -21,7 +21,9 @@ #include "INoteEditorUndoCommand.h" #include "../NoteEditor_p.h" + #include <quentier/types/Resource.h> + #include <QSize> namespace quentier { diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/INoteEditorUndoCommand.cpp libquentier-0.5.0/src/note_editor/undo_stack/INoteEditorUndoCommand.cpp --- libquentier-0.5.0/src/note_editor/undo_stack/INoteEditorUndoCommand.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/INoteEditorUndoCommand.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -21,15 +21,17 @@ namespace quentier { -INoteEditorUndoCommand::INoteEditorUndoCommand(NoteEditorPrivate & noteEditorPrivate, - QUndoCommand * parent) : +INoteEditorUndoCommand::INoteEditorUndoCommand( + NoteEditorPrivate & noteEditorPrivate, + QUndoCommand * parent) : QuentierUndoCommand(parent), m_noteEditorPrivate(noteEditorPrivate) {} -INoteEditorUndoCommand::INoteEditorUndoCommand(NoteEditorPrivate & noteEditorPrivate, - const QString & text, - QUndoCommand * parent) : +INoteEditorUndoCommand::INoteEditorUndoCommand( + NoteEditorPrivate & noteEditorPrivate, + const QString & text, + QUndoCommand * parent) : QuentierUndoCommand(text, parent), m_noteEditorPrivate(noteEditorPrivate) {} diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/INoteEditorUndoCommand.h libquentier-0.5.0/src/note_editor/undo_stack/INoteEditorUndoCommand.h --- libquentier-0.5.0/src/note_editor/undo_stack/INoteEditorUndoCommand.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/INoteEditorUndoCommand.h 2019-07-11 10:46:53.000000000 +0000 @@ -32,10 +32,14 @@ virtual ~INoteEditorUndoCommand(); protected: - INoteEditorUndoCommand(NoteEditorPrivate & noteEditorPrivate, - QUndoCommand * parent = Q_NULLPTR); - INoteEditorUndoCommand(NoteEditorPrivate & noteEditorPrivate, - const QString & text, QUndoCommand * parent = Q_NULLPTR); + INoteEditorUndoCommand( + NoteEditorPrivate & noteEditorPrivate, + QUndoCommand * parent = Q_NULLPTR); + + INoteEditorUndoCommand( + NoteEditorPrivate & noteEditorPrivate, + const QString & text, + QUndoCommand * parent = Q_NULLPTR); NoteEditorPrivate & m_noteEditorPrivate; }; diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/InsertHtmlUndoCommand.cpp libquentier-0.5.0/src/note_editor/undo_stack/InsertHtmlUndoCommand.cpp --- libquentier-0.5.0/src/note_editor/undo_stack/InsertHtmlUndoCommand.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/InsertHtmlUndoCommand.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,51 +18,65 @@ #include "InsertHtmlUndoCommand.h" #include "../NoteEditor_p.h" + #include <quentier/logging/QuentierLogger.h> #include <quentier/utility/Utility.h> + #include <QCryptographicHash> #include <QMimeDatabase> #include <QMimeType> namespace quentier { -#define GET_PAGE() \ - NoteEditorPage * page = \ - qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ - if (Q_UNLIKELY(!page)) { \ - ErrorString error(QT_TRANSLATE_NOOP("InsertHtmlUndoCommand", \ - "Can't undo/redo the html insertion: "\ - "no note editor page")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } +#define GET_PAGE() \ + NoteEditorPage * page = \ + qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ + if (Q_UNLIKELY(!page)) \ + { \ + ErrorString error( \ + QT_TRANSLATE_NOOP("InsertHtmlUndoCommand", \ + "Can't undo/redo the html insertion: " \ + "no note editor page")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// GET_PAGE InsertHtmlUndoCommand::InsertHtmlUndoCommand( - QList<Resource> addedResources, QStringList resourceFileStoragePaths, - const Callback & callback, NoteEditorPrivate & noteEditor, + QList<Resource> addedResources, + QStringList resourceFileStoragePaths, + const Callback & callback, + NoteEditorPrivate & noteEditor, QHash<QString, QString> & resourceFileStoragePathsByResourceLocalUid, - ResourceInfo & resourceInfo, QUndoCommand * parent) : + ResourceInfo & resourceInfo, + QUndoCommand * parent) : INoteEditorUndoCommand(noteEditor, parent), m_addedResources(addedResources), m_resourceFileStoragePaths(resourceFileStoragePaths), m_callback(callback), - m_resourceFileStoragePathsByResourceLocalUid(resourceFileStoragePathsByResourceLocalUid), + m_resourceFileStoragePathsByResourceLocalUid( + resourceFileStoragePathsByResourceLocalUid), m_resourceInfo(resourceInfo) { setText(tr("Insert HTML")); } InsertHtmlUndoCommand::InsertHtmlUndoCommand( - QList<Resource> addedResources, QStringList resourceFileStoragePaths, - const Callback & callback, NoteEditorPrivate & noteEditor, + QList<Resource> addedResources, + QStringList resourceFileStoragePaths, + const Callback & callback, + NoteEditorPrivate & noteEditor, QHash<QString, QString> & resourceFileStoragePathsByResourceLocalUid, - ResourceInfo & resourceInfo, const QString & text, QUndoCommand * parent) : + ResourceInfo & resourceInfo, + const QString & text, + QUndoCommand * parent) : INoteEditorUndoCommand(noteEditor, text, parent), m_addedResources(addedResources), m_resourceFileStoragePaths(resourceFileStoragePaths), m_callback(callback), - m_resourceFileStoragePathsByResourceLocalUid(resourceFileStoragePathsByResourceLocalUid), + m_resourceFileStoragePathsByResourceLocalUid( + resourceFileStoragePathsByResourceLocalUid), m_resourceInfo(resourceInfo) {} @@ -71,7 +85,7 @@ void InsertHtmlUndoCommand::undoImpl() { - QNDEBUG(QStringLiteral("InsertHtmlUndoCommand::undoImpl")); + QNDEBUG("InsertHtmlUndoCommand::undoImpl"); const QList<Resource> & addedResources = m_addedResources; int numResources = addedResources.size(); @@ -82,12 +96,10 @@ if (Q_UNLIKELY(!pResource->hasDataHash())) { - QNDEBUG(QStringLiteral("One of added resources has no data hash: ") - << *pResource); + QNDEBUG("One of added resources has no data hash: " << *pResource); if (!pResource->hasDataBody()) { - QNDEBUG(QStringLiteral("This resource has no data body as well, " - "just skipping it")); + QNDEBUG("This resource has no data body as well, skipping it"); continue; } @@ -115,7 +127,7 @@ void InsertHtmlUndoCommand::redoImpl() { - QNDEBUG(QStringLiteral("InsertHtmlUndoCommand::redoImpl")); + QNDEBUG("InsertHtmlUndoCommand::redoImpl"); const QList<Resource> & addedResources = m_addedResources; int numResources = addedResources.size(); @@ -133,30 +145,26 @@ if (Q_UNLIKELY(!mimeType.isValid())) { - QNDEBUG(QStringLiteral("Could not deduce the resource data's mime " - "type from the mime type name or resource has " - "no declared mime type")); + QNDEBUG("Could not deduce the resource data's mime type from the " + "mime type name or resource has no declared mime type"); if (pResource->hasDataBody()) { - QNDEBUG(QStringLiteral("Trying to deduce the mime type from " - "the resource's data")); + QNDEBUG("Trying to deduce the mime type from the resource data"); mimeType = mimeDatabase.mimeTypeForData(pResource->dataBody()); } } if (Q_UNLIKELY(!mimeType.isValid())) { - QNDEBUG(QStringLiteral("All attempts to deduce the correct mime type " - "have failed, fallback to mime type of image/png")); + QNDEBUG("All attempts to deduce the correct mime type " + "have failed, fallback to mime type of image/png"); mimeType = mimeDatabase.mimeTypeForName(QStringLiteral("image/png")); } if (Q_UNLIKELY(!pResource->hasMime())) { - QNDEBUG(QStringLiteral("One of added resources has no mime type: ") - << *pResource); + QNDEBUG("One of added resources has no mime type: " << *pResource); if (!pResource->hasDataBody()) { - QNDEBUG(QStringLiteral("This resource has no data body as well, " - "just skipping it")); + QNDEBUG("This resource has no data body as well, skipping it"); continue; } @@ -169,12 +177,10 @@ if (Q_UNLIKELY(!pResource->hasDataHash())) { - QNDEBUG(QStringLiteral("One of added resources has no data hash: ") - << *pResource); + QNDEBUG("One of added resources has no data hash: " << *pResource); if (!pResource->hasDataBody()) { - QNDEBUG(QStringLiteral("This resource has no data body as well, " - "just skipping it")); + QNDEBUG("This resource has no data body as well, skipping it"); continue; } @@ -188,12 +194,10 @@ if (Q_UNLIKELY(!pResource->hasDataSize())) { - QNDEBUG(QStringLiteral("One of added resources has no data size: ") - << *pResource); + QNDEBUG("One of added resources has no data size: " << *pResource); if (!pResource->hasDataBody()) { - QNDEBUG(QStringLiteral("This resource has no data body as well, " - "just skipping it")); + QNDEBUG("This resource has no data body as well, skipping it"); continue; } @@ -223,12 +227,12 @@ } else { - QNWARNING(QStringLiteral("Can't restore the resource file storage path ") - << QStringLiteral("for one of resources: the number of ") - << QStringLiteral("resource file storage path is less than ") - << QStringLiteral("or equal to the index: paths = ") + QNWARNING("Can't restore the resource file storage path " + << "for one of resources: the number of " + << "resource file storage path is less than " + << "or equal to the index: paths = " << m_resourceFileStoragePaths.join(QStringLiteral(", ")) - << QStringLiteral("; resource: ") << pResource); + << "; resource: " << pResource); } } diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/InsertHtmlUndoCommand.h libquentier-0.5.0/src/note_editor/undo_stack/InsertHtmlUndoCommand.h --- libquentier-0.5.0/src/note_editor/undo_stack/InsertHtmlUndoCommand.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/InsertHtmlUndoCommand.h 2019-07-11 10:46:53.000000000 +0000 @@ -21,8 +21,10 @@ #include "INoteEditorUndoCommand.h" #include "../NoteEditorPage.h" + #include <quentier/utility/Macros.h> #include <quentier/types/Resource.h> + #include <QStringList> #include <QHash> diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/NoteEditorContentEditUndoCommand.cpp libquentier-0.5.0/src/note_editor/undo_stack/NoteEditorContentEditUndoCommand.cpp --- libquentier-0.5.0/src/note_editor/undo_stack/NoteEditorContentEditUndoCommand.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/NoteEditorContentEditUndoCommand.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,6 +18,7 @@ #include "NoteEditorContentEditUndoCommand.h" #include "../NoteEditor_p.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { @@ -46,15 +47,15 @@ void NoteEditorContentEditUndoCommand::redoImpl() { - QNDEBUG(QStringLiteral("NoteEditorContentEditUndoCommand::redoImpl (") - << text() << QStringLiteral(")")); + QNDEBUG("NoteEditorContentEditUndoCommand::redoImpl (" + << text() << ")"); m_noteEditorPrivate.redoPageAction(); } void NoteEditorContentEditUndoCommand::undoImpl() { - QNDEBUG(QStringLiteral("NoteEditorContentEditUndoCommand::undoImpl (") - << text() << QStringLiteral(")")); + QNDEBUG("NoteEditorContentEditUndoCommand::undoImpl (" + << text() << ")"); m_noteEditorPrivate.undoPageAction(); m_noteEditorPrivate.setNoteResources(m_resources); } diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/NoteEditorContentEditUndoCommand.h libquentier-0.5.0/src/note_editor/undo_stack/NoteEditorContentEditUndoCommand.h --- libquentier-0.5.0/src/note_editor/undo_stack/NoteEditorContentEditUndoCommand.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/NoteEditorContentEditUndoCommand.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,7 +20,9 @@ #define LIB_QUENTIER_NOTE_EDITOR_UNDO_STACK_NOTE_EDITOR_CONTENT_EDIT_UNDO_COMMAND_H #include "INoteEditorUndoCommand.h" + #include <quentier/types/Resource.h> + #include <QList> namespace quentier { @@ -29,12 +31,16 @@ { Q_OBJECT public: - NoteEditorContentEditUndoCommand(NoteEditorPrivate & noteEditorPrivate, - const QList<Resource> & resources, - QUndoCommand * parent = Q_NULLPTR); - NoteEditorContentEditUndoCommand(NoteEditorPrivate & noteEditorPrivate, - const QList<Resource> & resources, - const QString & text, QUndoCommand * parent = Q_NULLPTR); + NoteEditorContentEditUndoCommand( + NoteEditorPrivate & noteEditorPrivate, + const QList<Resource> & resources, + QUndoCommand * parent = Q_NULLPTR); + + NoteEditorContentEditUndoCommand( + NoteEditorPrivate & noteEditorPrivate, + const QList<Resource> & resources, + const QString & text, QUndoCommand * parent = Q_NULLPTR); + virtual ~NoteEditorContentEditUndoCommand(); virtual void redoImpl() Q_DECL_OVERRIDE; diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/RemoveHyperlinkUndoCommand.cpp libquentier-0.5.0/src/note_editor/undo_stack/RemoveHyperlinkUndoCommand.cpp --- libquentier-0.5.0/src/note_editor/undo_stack/RemoveHyperlinkUndoCommand.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/RemoveHyperlinkUndoCommand.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,35 +18,41 @@ #include "RemoveHyperlinkUndoCommand.h" #include "../NoteEditor_p.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { -#define GET_PAGE() \ - NoteEditorPage * page = \ - qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ - if (Q_UNLIKELY(!page)) { \ - ErrorString error(QT_TRANSLATE_NOOP("RemoveHyperlinkUndoCommand", \ - "Can't undo/redo hyperlink removal: "\ - "no note editor's page")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } - -RemoveHyperlinkUndoCommand::RemoveHyperlinkUndoCommand(NoteEditorPrivate & noteEditor, - const Callback & callback, - QUndoCommand * parent) : +#define GET_PAGE() \ + NoteEditorPage * page = \ + qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ + if (Q_UNLIKELY(!page)) \ + { \ + ErrorString error( \ + QT_TRANSLATE_NOOP("RemoveHyperlinkUndoCommand", \ + "Can't undo/redo hyperlink removal: " \ + "no note editor's page")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// GET_PAGE + +RemoveHyperlinkUndoCommand::RemoveHyperlinkUndoCommand( + NoteEditorPrivate & noteEditor, + const Callback & callback, + QUndoCommand * parent) : INoteEditorUndoCommand(noteEditor, parent), m_callback(callback) { setText(tr("Remove hyperlink")); } -RemoveHyperlinkUndoCommand::RemoveHyperlinkUndoCommand(NoteEditorPrivate & noteEditor, - const Callback & callback, - const QString & text, - QUndoCommand * parent) : +RemoveHyperlinkUndoCommand::RemoveHyperlinkUndoCommand( + NoteEditorPrivate & noteEditor, + const Callback & callback, + const QString & text, + QUndoCommand * parent) : INoteEditorUndoCommand(noteEditor, text, parent), m_callback(callback) {} @@ -56,7 +62,7 @@ void RemoveHyperlinkUndoCommand::redoImpl() { - QNDEBUG(QStringLiteral("RemoveHyperlinkUndoCommand::redoImpl")); + QNDEBUG("RemoveHyperlinkUndoCommand::redoImpl"); GET_PAGE() page->executeJavaScript(QStringLiteral("hyperlinkManager.redo();"), @@ -65,7 +71,7 @@ void RemoveHyperlinkUndoCommand::undoImpl() { - QNDEBUG(QStringLiteral("RemoveHyperlinkUndoCommand::undoImpl")); + QNDEBUG("RemoveHyperlinkUndoCommand::undoImpl"); GET_PAGE() page->executeJavaScript(QStringLiteral("hyperlinkManager.undo();"), diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/RemoveHyperlinkUndoCommand.h libquentier-0.5.0/src/note_editor/undo_stack/RemoveHyperlinkUndoCommand.h --- libquentier-0.5.0/src/note_editor/undo_stack/RemoveHyperlinkUndoCommand.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/RemoveHyperlinkUndoCommand.h 2019-07-11 10:46:53.000000000 +0000 @@ -29,12 +29,17 @@ Q_OBJECT typedef NoteEditorPage::Callback Callback; public: - RemoveHyperlinkUndoCommand(NoteEditorPrivate & noteEditor, - const Callback & callback, - QUndoCommand * parent = Q_NULLPTR); - RemoveHyperlinkUndoCommand(NoteEditorPrivate & noteEditor, - const Callback & callback, const QString & text, - QUndoCommand * parent = Q_NULLPTR); + RemoveHyperlinkUndoCommand( + NoteEditorPrivate & noteEditor, + const Callback & callback, + QUndoCommand * parent = Q_NULLPTR); + + RemoveHyperlinkUndoCommand( + NoteEditorPrivate & noteEditor, + const Callback & callback, + const QString & text, + QUndoCommand * parent = Q_NULLPTR); + virtual ~RemoveHyperlinkUndoCommand(); virtual void redoImpl() Q_DECL_OVERRIDE; diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/RemoveResourceUndoCommand.cpp libquentier-0.5.0/src/note_editor/undo_stack/RemoveResourceUndoCommand.cpp --- libquentier-0.5.0/src/note_editor/undo_stack/RemoveResourceUndoCommand.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/RemoveResourceUndoCommand.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,21 +18,25 @@ #include "RemoveResourceUndoCommand.h" #include "../NoteEditor_p.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { -#define GET_PAGE() \ - NoteEditorPage * page = \ - qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ - if (Q_UNLIKELY(!page)) { \ - ErrorString error(QT_TRANSLATE_NOOP("RemoveResourceUndoCommand", \ - "Can't undo/redo remove attachment: "\ - "can't get note editor page")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } +#define GET_PAGE() \ + NoteEditorPage * page = \ + qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ + if (Q_UNLIKELY(!page)) \ + { \ + ErrorString error( \ + QT_TRANSLATE_NOOP("RemoveResourceUndoCommand", \ + "Can't undo/redo remove attachment: " \ + "can't get note editor page")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// GET_PAGE RemoveResourceUndoCommand::RemoveResourceUndoCommand( const Resource & resource, const Callback & callback, @@ -45,8 +49,10 @@ } RemoveResourceUndoCommand::RemoveResourceUndoCommand( - const Resource & resource, const Callback & callback, - NoteEditorPrivate & noteEditorPrivate, const QString & text, + const Resource & resource, + const Callback & callback, + NoteEditorPrivate & noteEditorPrivate, + const QString & text, QUndoCommand * parent) : INoteEditorUndoCommand(noteEditorPrivate, text, parent), m_resource(resource), @@ -58,7 +64,7 @@ void RemoveResourceUndoCommand::undoImpl() { - QNDEBUG(QStringLiteral("RemoveResourceUndoCommand::undoImpl")); + QNDEBUG("RemoveResourceUndoCommand::undoImpl"); m_noteEditorPrivate.addResourceToNote(m_resource); @@ -70,7 +76,7 @@ void RemoveResourceUndoCommand::redoImpl() { - QNDEBUG(QStringLiteral("RemoveResourceUndoCommand::redoImpl")); + QNDEBUG("RemoveResourceUndoCommand::redoImpl"); m_noteEditorPrivate.removeResourceFromNote(m_resource); diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/RemoveResourceUndoCommand.h libquentier-0.5.0/src/note_editor/undo_stack/RemoveResourceUndoCommand.h --- libquentier-0.5.0/src/note_editor/undo_stack/RemoveResourceUndoCommand.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/RemoveResourceUndoCommand.h 2019-07-11 10:46:53.000000000 +0000 @@ -21,6 +21,7 @@ #include "INoteEditorUndoCommand.h" #include "../NoteEditorPage.h" + #include <quentier/utility/Macros.h> #include <quentier/types/Resource.h> @@ -31,12 +32,19 @@ Q_OBJECT typedef NoteEditorPage::Callback Callback; public: - RemoveResourceUndoCommand(const Resource & resource, const Callback & callback, - NoteEditorPrivate & noteEditorPrivate, - QUndoCommand * parent = Q_NULLPTR); - RemoveResourceUndoCommand(const Resource & resource, const Callback & callback, - NoteEditorPrivate & noteEditorPrivate, - const QString & text, QUndoCommand * parent = Q_NULLPTR); + RemoveResourceUndoCommand( + const Resource & resource, + const Callback & callback, + NoteEditorPrivate & noteEditorPrivate, + QUndoCommand * parent = Q_NULLPTR); + + RemoveResourceUndoCommand( + const Resource & resource, + const Callback & callback, + NoteEditorPrivate & noteEditorPrivate, + const QString & text, + QUndoCommand * parent = Q_NULLPTR); + virtual ~RemoveResourceUndoCommand(); virtual void undoImpl() Q_DECL_OVERRIDE; diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/RenameResourceUndoCommand.cpp libquentier-0.5.0/src/note_editor/undo_stack/RenameResourceUndoCommand.cpp --- libquentier-0.5.0/src/note_editor/undo_stack/RenameResourceUndoCommand.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/RenameResourceUndoCommand.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -24,7 +24,8 @@ namespace quentier { RenameResourceUndoCommand::RenameResourceUndoCommand( - const Resource & resource, const QString & previousResourceName, + const Resource & resource, + const QString & previousResourceName, NoteEditorPrivate & noteEditor, GenericResourceImageManager * pGenericResourceImageManager, QHash<QByteArray, QString> & genericResourceImageFilePathsByResourceHash, @@ -46,7 +47,8 @@ NoteEditorPrivate & noteEditor, GenericResourceImageManager * pGenericResourceImageManager, QHash<QByteArray, QString> & genericResourceImageFilePathsByResourceHash, - const QString & text, QUndoCommand * parent) : + const QString & text, + QUndoCommand * parent) : INoteEditorUndoCommand(noteEditor, text, parent), m_resource(resource), m_previousResourceName(previousResourceName), diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/RenameResourceUndoCommand.h libquentier-0.5.0/src/note_editor/undo_stack/RenameResourceUndoCommand.h --- libquentier-0.5.0/src/note_editor/undo_stack/RenameResourceUndoCommand.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/RenameResourceUndoCommand.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,7 +20,9 @@ #define LIB_QUENTIER_NOTE_EDITOR_UNDO_STACK_RENAME_RESOURCE_UNDO_COMMAND_H #include "INoteEditorUndoCommand.h" + #include <quentier/types/Resource.h> + #include <QHash> namespace quentier { @@ -32,14 +34,16 @@ Q_OBJECT public: RenameResourceUndoCommand( - const Resource & resource, const QString & previousResourceName, + const Resource & resource, + const QString & previousResourceName, NoteEditorPrivate & noteEditor, GenericResourceImageManager * pGenericResourceImageManager, QHash<QByteArray, QString> & genericResourceImageFilePathsByResourceHash, QUndoCommand * parent = Q_NULLPTR); RenameResourceUndoCommand( - const Resource & resource, const QString & previousResourceName, + const Resource & resource, + const QString & previousResourceName, NoteEditorPrivate & noteEditor, GenericResourceImageManager * pGenericResourceImageManager, QHash<QByteArray, QString> & genericResourceImageFilePathsByResourceHash, diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/ReplaceAllUndoCommand.cpp libquentier-0.5.0/src/note_editor/undo_stack/ReplaceAllUndoCommand.cpp --- libquentier-0.5.0/src/note_editor/undo_stack/ReplaceAllUndoCommand.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/ReplaceAllUndoCommand.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,27 +18,32 @@ #include "ReplaceAllUndoCommand.h" #include "../NoteEditor_p.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { -#define GET_PAGE() \ - NoteEditorPage * page = \ - qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ - if (Q_UNLIKELY(!page)) { \ - ErrorString error(QT_TRANSLATE_NOOP("ReplaceAllUndoCommand", \ - "Can't undo/redo text replacement: "\ - "can't get note editor page")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } - -ReplaceAllUndoCommand::ReplaceAllUndoCommand(const QString & textToReplace, - const bool matchCase, - NoteEditorPrivate & noteEditorPrivate, - Callback callback, - QUndoCommand * parent) : +#define GET_PAGE() \ + NoteEditorPage * page = \ + qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ + if (Q_UNLIKELY(!page)) \ + { \ + ErrorString error( \ + QT_TRANSLATE_NOOP("ReplaceAllUndoCommand", \ + "Can't undo/redo text replacement: " \ + "can't get note editor page")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// GET_PAGE + +ReplaceAllUndoCommand::ReplaceAllUndoCommand( + const QString & textToReplace, + const bool matchCase, + NoteEditorPrivate & noteEditorPrivate, + Callback callback, + QUndoCommand * parent) : INoteEditorUndoCommand(noteEditorPrivate, parent), m_textToReplace(textToReplace), m_matchCase(matchCase), @@ -47,12 +52,13 @@ setText(tr("Replace all")); } -ReplaceAllUndoCommand::ReplaceAllUndoCommand(const QString & textToReplace, - const bool matchCase, - NoteEditorPrivate & noteEditorPrivate, - const QString & text, - Callback callback, - QUndoCommand * parent) : +ReplaceAllUndoCommand::ReplaceAllUndoCommand( + const QString & textToReplace, + const bool matchCase, + NoteEditorPrivate & noteEditorPrivate, + const QString & text, + Callback callback, + QUndoCommand * parent) : INoteEditorUndoCommand(noteEditorPrivate, text, parent), m_textToReplace(textToReplace), m_matchCase(matchCase), @@ -64,7 +70,7 @@ void ReplaceAllUndoCommand::redoImpl() { - QNDEBUG(QStringLiteral("ReplaceAllUndoCommand::redoImpl")); + QNDEBUG("ReplaceAllUndoCommand::redoImpl"); GET_PAGE() @@ -79,7 +85,7 @@ void ReplaceAllUndoCommand::undoImpl() { - QNDEBUG(QStringLiteral("ReplaceAllUndoCommand::undoImpl")); + QNDEBUG("ReplaceAllUndoCommand::undoImpl"); GET_PAGE() diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/ReplaceAllUndoCommand.h libquentier-0.5.0/src/note_editor/undo_stack/ReplaceAllUndoCommand.h --- libquentier-0.5.0/src/note_editor/undo_stack/ReplaceAllUndoCommand.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/ReplaceAllUndoCommand.h 2019-07-11 10:46:53.000000000 +0000 @@ -29,13 +29,21 @@ Q_OBJECT typedef NoteEditorPage::Callback Callback; public: - ReplaceAllUndoCommand(const QString & textToReplace, const bool matchCase, - NoteEditorPrivate & noteEditorPrivate, - Callback callback, QUndoCommand * parent = Q_NULLPTR); - ReplaceAllUndoCommand(const QString & textToReplace, const bool matchCase, - NoteEditorPrivate & noteEditorPrivate, - const QString & text, Callback callback, - QUndoCommand * parent = Q_NULLPTR); + ReplaceAllUndoCommand( + const QString & textToReplace, + const bool matchCase, + NoteEditorPrivate & noteEditorPrivate, + Callback callback, + QUndoCommand * parent = Q_NULLPTR); + + ReplaceAllUndoCommand( + const QString & textToReplace, + const bool matchCase, + NoteEditorPrivate & noteEditorPrivate, + const QString & text, + Callback callback, + QUndoCommand * parent = Q_NULLPTR); + virtual ~ReplaceAllUndoCommand(); virtual void redoImpl() Q_DECL_OVERRIDE; diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/ReplaceUndoCommand.cpp libquentier-0.5.0/src/note_editor/undo_stack/ReplaceUndoCommand.cpp --- libquentier-0.5.0/src/note_editor/undo_stack/ReplaceUndoCommand.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/ReplaceUndoCommand.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,28 +18,32 @@ #include "ReplaceUndoCommand.h" #include "../NoteEditor_p.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { -#define GET_PAGE() \ - NoteEditorPage * page = \ - qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ - if (Q_UNLIKELY(!page)) { \ - ErrorString error(QT_TRANSLATE_NOOP("ReplaceUndoCommand", \ - "Can't undo/redo text replacement: "\ - "can't get note editor page")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } - - -ReplaceUndoCommand::ReplaceUndoCommand(const QString & textToReplace, - const bool matchCase, - NoteEditorPrivate & noteEditorPrivate, - Callback callback, - QUndoCommand * parent) : +#define GET_PAGE() \ + NoteEditorPage * page = \ + qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ + if (Q_UNLIKELY(!page)) \ + { \ + ErrorString error( \ + QT_TRANSLATE_NOOP("ReplaceUndoCommand", \ + "Can't undo/redo text replacement: " \ + "can't get note editor page")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// GET_PAGE + +ReplaceUndoCommand::ReplaceUndoCommand( + const QString & textToReplace, + const bool matchCase, + NoteEditorPrivate & noteEditorPrivate, + Callback callback, + QUndoCommand * parent) : INoteEditorUndoCommand(noteEditorPrivate, parent), m_textToReplace(textToReplace), m_matchCase(matchCase), @@ -48,12 +52,13 @@ setText(tr("Replace text")); } -ReplaceUndoCommand::ReplaceUndoCommand(const QString & textToReplace, - const bool matchCase, - NoteEditorPrivate & noteEditorPrivate, - const QString & text, - Callback callback, - QUndoCommand * parent) : +ReplaceUndoCommand::ReplaceUndoCommand( + const QString & textToReplace, + const bool matchCase, + NoteEditorPrivate & noteEditorPrivate, + const QString & text, + Callback callback, + QUndoCommand * parent) : INoteEditorUndoCommand(noteEditorPrivate, text, parent), m_textToReplace(textToReplace), m_matchCase(matchCase), @@ -65,7 +70,7 @@ void ReplaceUndoCommand::redoImpl() { - QNDEBUG(QStringLiteral("ReplaceUndoCommand::redoImpl")); + QNDEBUG("ReplaceUndoCommand::redoImpl"); GET_PAGE() @@ -80,7 +85,7 @@ void ReplaceUndoCommand::undoImpl() { - QNDEBUG(QStringLiteral("ReplaceUndoCommand::undoImpl")); + QNDEBUG("ReplaceUndoCommand::undoImpl"); GET_PAGE() diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/ReplaceUndoCommand.h libquentier-0.5.0/src/note_editor/undo_stack/ReplaceUndoCommand.h --- libquentier-0.5.0/src/note_editor/undo_stack/ReplaceUndoCommand.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/ReplaceUndoCommand.h 2019-07-11 10:46:53.000000000 +0000 @@ -29,13 +29,21 @@ Q_OBJECT typedef NoteEditorPage::Callback Callback; public: - ReplaceUndoCommand(const QString & textToReplace, const bool matchCase, - NoteEditorPrivate & noteEditorPrivate, - Callback callback, QUndoCommand * parent = Q_NULLPTR); - ReplaceUndoCommand(const QString & textToReplace, const bool matchCase, - NoteEditorPrivate & noteEditorPrivate, - const QString & text, Callback callback, - QUndoCommand * parent = Q_NULLPTR); + ReplaceUndoCommand( + const QString & textToReplace, + const bool matchCase, + NoteEditorPrivate & noteEditorPrivate, + Callback callback, + QUndoCommand * parent = Q_NULLPTR); + + ReplaceUndoCommand( + const QString & textToReplace, + const bool matchCase, + NoteEditorPrivate & noteEditorPrivate, + const QString & text, + Callback callback, + QUndoCommand * parent = Q_NULLPTR); + virtual ~ReplaceUndoCommand(); virtual void redoImpl() Q_DECL_OVERRIDE; diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/SourceCodeFormatUndoCommand.cpp libquentier-0.5.0/src/note_editor/undo_stack/SourceCodeFormatUndoCommand.cpp --- libquentier-0.5.0/src/note_editor/undo_stack/SourceCodeFormatUndoCommand.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/SourceCodeFormatUndoCommand.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,21 +18,25 @@ #include "SourceCodeFormatUndoCommand.h" #include "../NoteEditor_p.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { -#define GET_PAGE() \ - NoteEditorPage * page = \ - qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ - if (Q_UNLIKELY(!page)) { \ - ErrorString error(QT_TRANSLATE_NOOP("SourceCodeFormatUndoCommand", \ - "Can't undo/redo source code "\ - "formatting: no note editor page")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } +#define GET_PAGE() \ + NoteEditorPage * page = \ + qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ + if (Q_UNLIKELY(!page)) \ + { \ + ErrorString error( \ + QT_TRANSLATE_NOOP("SourceCodeFormatUndoCommand", \ + "Can't undo/redo source code " \ + "formatting: no note editor page")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// GET_PAGE SourceCodeFormatUndoCommand::SourceCodeFormatUndoCommand( NoteEditorPrivate & noteEditor, @@ -58,7 +62,7 @@ void SourceCodeFormatUndoCommand::redoImpl() { - QNDEBUG(QStringLiteral("SourceCodeFormatUndoCommand::redoImpl")); + QNDEBUG("SourceCodeFormatUndoCommand::redoImpl"); GET_PAGE() page->executeJavaScript(QStringLiteral("sourceCodeFormatter.redo();"), @@ -67,7 +71,7 @@ void SourceCodeFormatUndoCommand::undoImpl() { - QNDEBUG(QStringLiteral("SourceCodeFormatUndoCommand::undoImpl")); + QNDEBUG("SourceCodeFormatUndoCommand::undoImpl"); GET_PAGE() page->executeJavaScript(QStringLiteral("sourceCodeFormatter.undo();"), diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/SourceCodeFormatUndoCommand.h libquentier-0.5.0/src/note_editor/undo_stack/SourceCodeFormatUndoCommand.h --- libquentier-0.5.0/src/note_editor/undo_stack/SourceCodeFormatUndoCommand.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/SourceCodeFormatUndoCommand.h 2019-07-11 10:46:53.000000000 +0000 @@ -29,13 +29,17 @@ Q_OBJECT typedef NoteEditorPage::Callback Callback; public: - SourceCodeFormatUndoCommand(NoteEditorPrivate & noteEditor, - const Callback & callback, - QUndoCommand * parent = Q_NULLPTR); - SourceCodeFormatUndoCommand(NoteEditorPrivate & noteEditor, - const Callback & callback, - const QString & text, - QUndoCommand * parent = Q_NULLPTR); + SourceCodeFormatUndoCommand( + NoteEditorPrivate & noteEditor, + const Callback & callback, + QUndoCommand * parent = Q_NULLPTR); + + SourceCodeFormatUndoCommand( + NoteEditorPrivate & noteEditor, + const Callback & callback, + const QString & text, + QUndoCommand * parent = Q_NULLPTR); + virtual ~SourceCodeFormatUndoCommand(); virtual void redoImpl() Q_DECL_OVERRIDE; diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/SpellCheckAddToUserWordListUndoCommand.cpp libquentier-0.5.0/src/note_editor/undo_stack/SpellCheckAddToUserWordListUndoCommand.cpp --- libquentier-0.5.0/src/note_editor/undo_stack/SpellCheckAddToUserWordListUndoCommand.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/SpellCheckAddToUserWordListUndoCommand.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,6 +18,7 @@ #include "SpellCheckAddToUserWordListUndoCommand.h" #include "../NoteEditor_p.h" + #include <quentier/note_editor/SpellChecker.h> #include <quentier/logging/QuentierLogger.h> @@ -47,10 +48,10 @@ void SpellCheckAddToUserWordListUndoCommand::redoImpl() { - QNDEBUG(QStringLiteral("SpellCheckAddToUserWordListUndoCommand::redoImpl")); + QNDEBUG("SpellCheckAddToUserWordListUndoCommand::redoImpl"); if (Q_UNLIKELY(m_pSpellChecker.isNull())) { - QNTRACE(QStringLiteral("No spell checker")); + QNTRACE("No spell checker"); return; } @@ -64,10 +65,10 @@ void SpellCheckAddToUserWordListUndoCommand::undoImpl() { - QNDEBUG(QStringLiteral("SpellCheckAddToUserWordListUndoCommand::undoImpl")); + QNDEBUG("SpellCheckAddToUserWordListUndoCommand::undoImpl"); if (Q_UNLIKELY(m_pSpellChecker.isNull())) { - QNTRACE(QStringLiteral("No spell checker")); + QNTRACE("No spell checker"); return; } diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/SpellCheckAddToUserWordListUndoCommand.h libquentier-0.5.0/src/note_editor/undo_stack/SpellCheckAddToUserWordListUndoCommand.h --- libquentier-0.5.0/src/note_editor/undo_stack/SpellCheckAddToUserWordListUndoCommand.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/SpellCheckAddToUserWordListUndoCommand.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,6 +20,7 @@ #define LIB_QUENTIER_NOTE_EDITOR_UNDO_STACK_SPELL_CHECK_ADD_TO_USER_WORDLIST_UNDO_COMMAND_H #include "INoteEditorUndoCommand.h" + #include <QPointer> namespace quentier { @@ -30,15 +31,19 @@ { Q_OBJECT public: - SpellCheckAddToUserWordListUndoCommand(NoteEditorPrivate & noteEditor, - const QString & word, - SpellChecker * pSpellChecker, - QUndoCommand * parent = Q_NULLPTR); - SpellCheckAddToUserWordListUndoCommand(NoteEditorPrivate & noteEditor, - const QString & word, - SpellChecker * pSpellChecker, - const QString & text, - QUndoCommand * parent = Q_NULLPTR); + SpellCheckAddToUserWordListUndoCommand( + NoteEditorPrivate & noteEditor, + const QString & word, + SpellChecker * pSpellChecker, + QUndoCommand * parent = Q_NULLPTR); + + SpellCheckAddToUserWordListUndoCommand( + NoteEditorPrivate & noteEditor, + const QString & word, + SpellChecker * pSpellChecker, + const QString & text, + QUndoCommand * parent = Q_NULLPTR); + virtual ~SpellCheckAddToUserWordListUndoCommand(); virtual void redoImpl() Q_DECL_OVERRIDE; diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/SpellCheckIgnoreWordUndoCommand.cpp libquentier-0.5.0/src/note_editor/undo_stack/SpellCheckIgnoreWordUndoCommand.cpp --- libquentier-0.5.0/src/note_editor/undo_stack/SpellCheckIgnoreWordUndoCommand.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/SpellCheckIgnoreWordUndoCommand.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,14 +18,17 @@ #include "SpellCheckIgnoreWordUndoCommand.h" #include "../NoteEditor_p.h" + #include <quentier/note_editor/SpellChecker.h> #include <quentier/logging/QuentierLogger.h> namespace quentier { SpellCheckIgnoreWordUndoCommand::SpellCheckIgnoreWordUndoCommand( - NoteEditorPrivate & noteEditor, const QString & ignoredWord, - SpellChecker * pSpellChecker, QUndoCommand * parent) : + NoteEditorPrivate & noteEditor, + const QString & ignoredWord, + SpellChecker * pSpellChecker, + QUndoCommand * parent) : INoteEditorUndoCommand(noteEditor, parent), m_pSpellChecker(pSpellChecker), m_ignoredWord(ignoredWord) @@ -34,8 +37,10 @@ } SpellCheckIgnoreWordUndoCommand::SpellCheckIgnoreWordUndoCommand( - NoteEditorPrivate & noteEditor, const QString & ignoredWord, - SpellChecker * pSpellChecker, const QString & text, + NoteEditorPrivate & noteEditor, + const QString & ignoredWord, + SpellChecker * pSpellChecker, + const QString & text, QUndoCommand * parent) : INoteEditorUndoCommand(noteEditor, text, parent), m_pSpellChecker(pSpellChecker), @@ -47,10 +52,10 @@ void SpellCheckIgnoreWordUndoCommand::redoImpl() { - QNDEBUG(QStringLiteral("SpellCheckIgnoreWordUndoCommand::redoImpl")); + QNDEBUG("SpellCheckIgnoreWordUndoCommand::redoImpl"); if (Q_UNLIKELY(m_pSpellChecker.isNull())) { - QNTRACE(QStringLiteral("No spell checker")); + QNTRACE("No spell checker"); return; } @@ -64,10 +69,10 @@ void SpellCheckIgnoreWordUndoCommand::undoImpl() { - QNDEBUG(QStringLiteral("SpellCheckIgnoreWordUndoCommand::undoImpl")); + QNDEBUG("SpellCheckIgnoreWordUndoCommand::undoImpl"); if (Q_UNLIKELY(m_pSpellChecker.isNull())) { - QNTRACE(QStringLiteral("No spell checker")); + QNTRACE("No spell checker"); return; } diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/SpellCheckIgnoreWordUndoCommand.h libquentier-0.5.0/src/note_editor/undo_stack/SpellCheckIgnoreWordUndoCommand.h --- libquentier-0.5.0/src/note_editor/undo_stack/SpellCheckIgnoreWordUndoCommand.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/SpellCheckIgnoreWordUndoCommand.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,6 +20,7 @@ #define LIB_QUENTIER_NOTE_EDITOR_UNDO_STACK_SPELL_CHECK_IGNORE_WORD_UNDO_COMMAND_H #include "INoteEditorUndoCommand.h" + #include <QPointer> namespace quentier { @@ -30,15 +31,19 @@ { Q_OBJECT public: - SpellCheckIgnoreWordUndoCommand(NoteEditorPrivate & noteEditor, - const QString & ignoredWord, - SpellChecker * pSpellChecker, - QUndoCommand * parent = Q_NULLPTR); - SpellCheckIgnoreWordUndoCommand(NoteEditorPrivate & noteEditor, - const QString & ignoredWord, - SpellChecker * pSpellChecker, - const QString & text, - QUndoCommand * parent = Q_NULLPTR); + SpellCheckIgnoreWordUndoCommand( + NoteEditorPrivate & noteEditor, + const QString & ignoredWord, + SpellChecker * pSpellChecker, + QUndoCommand * parent = Q_NULLPTR); + + SpellCheckIgnoreWordUndoCommand( + NoteEditorPrivate & noteEditor, + const QString & ignoredWord, + SpellChecker * pSpellChecker, + const QString & text, + QUndoCommand * parent = Q_NULLPTR); + virtual ~SpellCheckIgnoreWordUndoCommand(); virtual void redoImpl() Q_DECL_OVERRIDE; diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/SpellCorrectionUndoCommand.cpp libquentier-0.5.0/src/note_editor/undo_stack/SpellCorrectionUndoCommand.cpp --- libquentier-0.5.0/src/note_editor/undo_stack/SpellCorrectionUndoCommand.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/SpellCorrectionUndoCommand.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,35 +18,41 @@ #include "SpellCorrectionUndoCommand.h" #include "../NoteEditor_p.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { -#define GET_PAGE() \ - NoteEditorPage * page = \ - qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ - if (Q_UNLIKELY(!page)) { \ - ErrorString error(QT_TRANSLATE_NOOP("SpellCorrectionUndoCommand", \ - "Can't undo/redo spelling correction: "\ - "can't get note editor's page")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } - -SpellCorrectionUndoCommand::SpellCorrectionUndoCommand(NoteEditorPrivate & noteEditor, - const Callback & callback, - QUndoCommand * parent) : +#define GET_PAGE() \ + NoteEditorPage * page = \ + qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ + if (Q_UNLIKELY(!page)) \ + { \ + ErrorString error( \ + QT_TRANSLATE_NOOP("SpellCorrectionUndoCommand", \ + "Can't undo/redo spelling correction: " \ + "can't get note editor's page")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// GET_PAGE + +SpellCorrectionUndoCommand::SpellCorrectionUndoCommand( + NoteEditorPrivate & noteEditor, + const Callback & callback, + QUndoCommand * parent) : INoteEditorUndoCommand(noteEditor, parent), m_callback(callback) { setText(tr("Spelling correction")); } -SpellCorrectionUndoCommand::SpellCorrectionUndoCommand(NoteEditorPrivate & noteEditor, - const Callback & callback, - const QString & text, - QUndoCommand * parent) : +SpellCorrectionUndoCommand::SpellCorrectionUndoCommand( + NoteEditorPrivate & noteEditor, + const Callback & callback, + const QString & text, + QUndoCommand * parent) : INoteEditorUndoCommand(noteEditor, text, parent), m_callback(callback) {} diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/SpellCorrectionUndoCommand.h libquentier-0.5.0/src/note_editor/undo_stack/SpellCorrectionUndoCommand.h --- libquentier-0.5.0/src/note_editor/undo_stack/SpellCorrectionUndoCommand.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/SpellCorrectionUndoCommand.h 2019-07-11 10:46:53.000000000 +0000 @@ -29,13 +29,17 @@ Q_OBJECT typedef NoteEditorPage::Callback Callback; public: - SpellCorrectionUndoCommand(NoteEditorPrivate & noteEditor, - const Callback & callback, - QUndoCommand * parent = Q_NULLPTR); - SpellCorrectionUndoCommand(NoteEditorPrivate & noteEditor, - const Callback & callback, - const QString & text, - QUndoCommand * parent = Q_NULLPTR); + SpellCorrectionUndoCommand( + NoteEditorPrivate & noteEditor, + const Callback & callback, + QUndoCommand * parent = Q_NULLPTR); + + SpellCorrectionUndoCommand( + NoteEditorPrivate & noteEditor, + const Callback & callback, + const QString & text, + QUndoCommand * parent = Q_NULLPTR); + virtual ~SpellCorrectionUndoCommand(); virtual void redoImpl() Q_DECL_OVERRIDE; diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/TableActionUndoCommand.cpp libquentier-0.5.0/src/note_editor/undo_stack/TableActionUndoCommand.cpp --- libquentier-0.5.0/src/note_editor/undo_stack/TableActionUndoCommand.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/TableActionUndoCommand.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,35 +18,40 @@ #include "TableActionUndoCommand.h" #include "../NoteEditor_p.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { -#define GET_PAGE() \ - NoteEditorPage * page = \ - qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ - if (Q_UNLIKELY(!page)) { \ - ErrorString error(QT_TRANSLATE_NOOP("TableActionUndoCommand", \ - "Can't table action: can't get "\ - "note editor page")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } - -TableActionUndoCommand::TableActionUndoCommand(NoteEditorPrivate & noteEditorPrivate, - Callback callback, - QUndoCommand * parent) : +#define GET_PAGE() \ + NoteEditorPage * page = \ + qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ + if (Q_UNLIKELY(!page)) \ + { \ + ErrorString error(QT_TRANSLATE_NOOP("TableActionUndoCommand", \ + "Can't table action: can't get " \ + "note editor page")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// GET_PAGE + +TableActionUndoCommand::TableActionUndoCommand( + NoteEditorPrivate & noteEditorPrivate, + Callback callback, + QUndoCommand * parent) : INoteEditorUndoCommand(noteEditorPrivate, parent), m_callback(callback) { setText(tr("Table action")); } -TableActionUndoCommand::TableActionUndoCommand(NoteEditorPrivate & noteEditorPrivate, - const QString & text, - Callback callback, - QUndoCommand * parent) : +TableActionUndoCommand::TableActionUndoCommand( + NoteEditorPrivate & noteEditorPrivate, + const QString & text, + Callback callback, + QUndoCommand * parent) : INoteEditorUndoCommand(noteEditorPrivate, text, parent), m_callback(callback) {} @@ -56,7 +61,7 @@ void TableActionUndoCommand::redoImpl() { - QNDEBUG(QStringLiteral("TableActionUndoCommand::redoImpl")); + QNDEBUG("TableActionUndoCommand::redoImpl"); GET_PAGE() @@ -66,7 +71,7 @@ void TableActionUndoCommand::undoImpl() { - QNDEBUG(QStringLiteral("TableActionUndoCommand::undoImpl")); + QNDEBUG("TableActionUndoCommand::undoImpl"); GET_PAGE() diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/TableActionUndoCommand.h libquentier-0.5.0/src/note_editor/undo_stack/TableActionUndoCommand.h --- libquentier-0.5.0/src/note_editor/undo_stack/TableActionUndoCommand.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/TableActionUndoCommand.h 2019-07-11 10:46:53.000000000 +0000 @@ -29,11 +29,17 @@ Q_OBJECT typedef NoteEditorPage::Callback Callback; public: - TableActionUndoCommand(NoteEditorPrivate & noteEditorPrivate, - Callback callback, QUndoCommand * parent = Q_NULLPTR); - TableActionUndoCommand(NoteEditorPrivate & noteEditorPrivate, - const QString & text, Callback callback, - QUndoCommand * parent = Q_NULLPTR); + TableActionUndoCommand( + NoteEditorPrivate & noteEditorPrivate, + Callback callback, + QUndoCommand * parent = Q_NULLPTR); + + TableActionUndoCommand( + NoteEditorPrivate & noteEditorPrivate, + const QString & text, + Callback callback, + QUndoCommand * parent = Q_NULLPTR); + virtual ~TableActionUndoCommand(); virtual void redoImpl() Q_DECL_OVERRIDE; diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/ToDoCheckboxAutomaticInsertionUndoCommand.cpp libquentier-0.5.0/src/note_editor/undo_stack/ToDoCheckboxAutomaticInsertionUndoCommand.cpp --- libquentier-0.5.0/src/note_editor/undo_stack/ToDoCheckboxAutomaticInsertionUndoCommand.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/ToDoCheckboxAutomaticInsertionUndoCommand.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,21 +18,25 @@ #include "ToDoCheckboxAutomaticInsertionUndoCommand.h" #include "../NoteEditor_p.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { -#define GET_PAGE() \ - NoteEditorPage * page = \ - qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ - if (Q_UNLIKELY(!page)) { \ - ErrorString error(QT_TRANSLATE_NOOP("ToDoCheckboxAutomaticInsertionUndoCommand", \ - "Can't undo/redo the automatic insertion " \ - "of a TODO checkbox: no note editor page")); \ - QNWARNING(error); \ - Q_EMIT notifyError(error); \ - return; \ - } +#define GET_PAGE() \ + NoteEditorPage * page = \ + qobject_cast<NoteEditorPage*>(m_noteEditorPrivate.page()); \ + if (Q_UNLIKELY(!page)) \ + { \ + ErrorString error( \ + QT_TRANSLATE_NOOP("ToDoCheckboxAutomaticInsertionUndoCommand", \ + "Can't undo/redo the automatic insertion " \ + "of a TODO checkbox: no note editor page")); \ + QNWARNING(error); \ + Q_EMIT notifyError(error); \ + return; \ + } \ +// GET_PAGE ToDoCheckboxAutomaticInsertionUndoCommand::ToDoCheckboxAutomaticInsertionUndoCommand( NoteEditorPrivate & noteEditor, @@ -58,7 +62,7 @@ void ToDoCheckboxAutomaticInsertionUndoCommand::redoImpl() { - QNDEBUG(QStringLiteral("ToDoCheckboxAutomaticInsertionUndoCommand::redoImpl")); + QNDEBUG("ToDoCheckboxAutomaticInsertionUndoCommand::redoImpl"); GET_PAGE() page->executeJavaScript(QStringLiteral("toDoCheckboxAutomaticInserter.redo()"), @@ -67,7 +71,7 @@ void ToDoCheckboxAutomaticInsertionUndoCommand::undoImpl() { - QNDEBUG(QStringLiteral("ToDoCheckboxAutomaticInsertionUndoCommand::undoImpl")); + QNDEBUG("ToDoCheckboxAutomaticInsertionUndoCommand::undoImpl"); GET_PAGE() page->executeJavaScript(QStringLiteral("toDoCheckboxAutomaticInserter.undo()"), diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/ToDoCheckboxAutomaticInsertionUndoCommand.h libquentier-0.5.0/src/note_editor/undo_stack/ToDoCheckboxAutomaticInsertionUndoCommand.h --- libquentier-0.5.0/src/note_editor/undo_stack/ToDoCheckboxAutomaticInsertionUndoCommand.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/ToDoCheckboxAutomaticInsertionUndoCommand.h 2019-07-11 10:46:53.000000000 +0000 @@ -29,13 +29,17 @@ Q_OBJECT typedef NoteEditorPage::Callback Callback; public: - ToDoCheckboxAutomaticInsertionUndoCommand(NoteEditorPrivate & noteEditor, - const Callback & callback, - QUndoCommand * parent = Q_NULLPTR); - ToDoCheckboxAutomaticInsertionUndoCommand(NoteEditorPrivate & noteEditor, - const Callback & callback, - const QString & text, - QUndoCommand * parent = Q_NULLPTR); + ToDoCheckboxAutomaticInsertionUndoCommand( + NoteEditorPrivate & noteEditor, + const Callback & callback, + QUndoCommand * parent = Q_NULLPTR); + + ToDoCheckboxAutomaticInsertionUndoCommand( + NoteEditorPrivate & noteEditor, + const Callback & callback, + const QString & text, + QUndoCommand * parent = Q_NULLPTR); + virtual ~ToDoCheckboxAutomaticInsertionUndoCommand(); virtual void redoImpl() Q_DECL_OVERRIDE; diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/ToDoCheckboxUndoCommand.cpp libquentier-0.5.0/src/note_editor/undo_stack/ToDoCheckboxUndoCommand.cpp --- libquentier-0.5.0/src/note_editor/undo_stack/ToDoCheckboxUndoCommand.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/ToDoCheckboxUndoCommand.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,23 +18,26 @@ #include "ToDoCheckboxUndoCommand.h" #include "../NoteEditor_p.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { -ToDoCheckboxUndoCommand::ToDoCheckboxUndoCommand(const quint64 enToDoCheckboxId, - NoteEditorPrivate & noteEditorPrivate, - QUndoCommand * parent) : +ToDoCheckboxUndoCommand::ToDoCheckboxUndoCommand( + const quint64 enToDoCheckboxId, + NoteEditorPrivate & noteEditorPrivate, + QUndoCommand * parent) : INoteEditorUndoCommand(noteEditorPrivate, parent), m_enToDoCheckboxId(enToDoCheckboxId) { setText(tr("Change ToDo state")); } -ToDoCheckboxUndoCommand::ToDoCheckboxUndoCommand(const quint64 enToDoCheckboxId, - NoteEditorPrivate & noteEditorPrivate, - const QString & text, - QUndoCommand * parent) : +ToDoCheckboxUndoCommand::ToDoCheckboxUndoCommand( + const quint64 enToDoCheckboxId, + NoteEditorPrivate & noteEditorPrivate, + const QString & text, + QUndoCommand * parent) : INoteEditorUndoCommand(noteEditorPrivate, text, parent), m_enToDoCheckboxId(enToDoCheckboxId) {} @@ -44,13 +47,13 @@ void ToDoCheckboxUndoCommand::redoImpl() { - QNDEBUG(QStringLiteral("ToDoCheckboxUndoCommand::redoImpl")); + QNDEBUG("ToDoCheckboxUndoCommand::redoImpl"); m_noteEditorPrivate.flipEnToDoCheckboxState(m_enToDoCheckboxId); } void ToDoCheckboxUndoCommand::undoImpl() { - QNDEBUG(QStringLiteral("ToDoCheckboxUndoCommand::undoImpl")); + QNDEBUG("ToDoCheckboxUndoCommand::undoImpl"); m_noteEditorPrivate.flipEnToDoCheckboxState(m_enToDoCheckboxId); } diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/ToDoCheckboxUndoCommand.h libquentier-0.5.0/src/note_editor/undo_stack/ToDoCheckboxUndoCommand.h --- libquentier-0.5.0/src/note_editor/undo_stack/ToDoCheckboxUndoCommand.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/ToDoCheckboxUndoCommand.h 2019-07-11 10:46:53.000000000 +0000 @@ -27,13 +27,17 @@ { Q_OBJECT public: - ToDoCheckboxUndoCommand(const quint64 enToDoCheckboxId, - NoteEditorPrivate & noteEditorPrivate, - QUndoCommand * parent = Q_NULLPTR); - ToDoCheckboxUndoCommand(const quint64 enToDoCheckboxId, - NoteEditorPrivate & noteEditorPrivate, - const QString & text, - QUndoCommand * parent = Q_NULLPTR); + ToDoCheckboxUndoCommand( + const quint64 enToDoCheckboxId, + NoteEditorPrivate & noteEditorPrivate, + QUndoCommand * parent = Q_NULLPTR); + + ToDoCheckboxUndoCommand( + const quint64 enToDoCheckboxId, + NoteEditorPrivate & noteEditorPrivate, + const QString & text, + QUndoCommand * parent = Q_NULLPTR); + virtual ~ToDoCheckboxUndoCommand(); virtual void redoImpl() Q_DECL_OVERRIDE; diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/UpdateResourceUndoCommand.cpp libquentier-0.5.0/src/note_editor/undo_stack/UpdateResourceUndoCommand.cpp --- libquentier-0.5.0/src/note_editor/undo_stack/UpdateResourceUndoCommand.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/UpdateResourceUndoCommand.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,13 +18,16 @@ #include "UpdateResourceUndoCommand.h" #include "../NoteEditor_p.h" + #include <quentier/logging/QuentierLogger.h> namespace quentier { UpdateResourceUndoCommand::UpdateResourceUndoCommand( - const Resource & resourceBefore, const Resource & resourceAfter, - NoteEditorPrivate & noteEditorPrivate, QUndoCommand * parent) : + const Resource & resourceBefore, + const Resource & resourceAfter, + NoteEditorPrivate & noteEditorPrivate, + QUndoCommand * parent) : INoteEditorUndoCommand(noteEditorPrivate, parent), m_resourceBefore(resourceBefore), m_resourceAfter(resourceAfter) @@ -33,8 +36,10 @@ } UpdateResourceUndoCommand::UpdateResourceUndoCommand( - const Resource & resourceBefore, const Resource & resourceAfter, - NoteEditorPrivate & noteEditorPrivate, const QString & text, + const Resource & resourceBefore, + const Resource & resourceAfter, + NoteEditorPrivate & noteEditorPrivate, + const QString & text, QUndoCommand * parent) : INoteEditorUndoCommand(noteEditorPrivate, text, parent), m_resourceBefore(resourceBefore), @@ -48,7 +53,7 @@ void UpdateResourceUndoCommand::undoImpl() { - QNDEBUG(QStringLiteral("UpdateResourceUndoCommand::undoImpl")); + QNDEBUG("UpdateResourceUndoCommand::undoImpl"); m_noteEditorPrivate.replaceResourceInNote(m_resourceBefore); m_noteEditorPrivate.updateFromNote(); @@ -56,7 +61,7 @@ void UpdateResourceUndoCommand::redoImpl() { - QNDEBUG(QStringLiteral("UpdateResourceUndoCommand::redoImpl")); + QNDEBUG("UpdateResourceUndoCommand::redoImpl"); m_noteEditorPrivate.replaceResourceInNote(m_resourceAfter); m_noteEditorPrivate.updateFromNote(); diff -Nru libquentier-0.5.0/src/note_editor/undo_stack/UpdateResourceUndoCommand.h libquentier-0.5.0/src/note_editor/undo_stack/UpdateResourceUndoCommand.h --- libquentier-0.5.0/src/note_editor/undo_stack/UpdateResourceUndoCommand.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/undo_stack/UpdateResourceUndoCommand.h 2019-07-11 10:46:53.000000000 +0000 @@ -20,6 +20,7 @@ #define LIB_QUENTIER_NOTE_EDITOR_UNDO_STACK_UPDATE_RESOURCE_UNDO_COMMAND_H #include "INoteEditorUndoCommand.h" + #include <quentier/types/Resource.h> namespace quentier { @@ -28,15 +29,19 @@ { Q_OBJECT public: - UpdateResourceUndoCommand(const Resource & resourceBefore, - const Resource & resourceAfter, - NoteEditorPrivate & noteEditorPrivate, - QUndoCommand * parent = Q_NULLPTR); - UpdateResourceUndoCommand(const Resource & resourceBefore, - const Resource & resourceAfter, - NoteEditorPrivate & noteEditorPrivate, - const QString & text, - QUndoCommand * parent = Q_NULLPTR); + UpdateResourceUndoCommand( + const Resource & resourceBefore, + const Resource & resourceAfter, + NoteEditorPrivate & noteEditorPrivate, + QUndoCommand * parent = Q_NULLPTR); + + UpdateResourceUndoCommand( + const Resource & resourceBefore, + const Resource & resourceAfter, + NoteEditorPrivate & noteEditorPrivate, + const QString & text, + QUndoCommand * parent = Q_NULLPTR); + virtual ~UpdateResourceUndoCommand(); virtual void undoImpl() Q_DECL_OVERRIDE; diff -Nru libquentier-0.5.0/src/note_editor/WebSocketClientWrapper.cpp libquentier-0.5.0/src/note_editor/WebSocketClientWrapper.cpp --- libquentier-0.5.0/src/note_editor/WebSocketClientWrapper.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/WebSocketClientWrapper.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -18,6 +18,7 @@ #include "WebSocketClientWrapper.h" #include "WebSocketTransport.h" + #include <QtWebSockets/QWebSocketServer> WebSocketClientWrapper::WebSocketClientWrapper(QWebSocketServer * server, diff -Nru libquentier-0.5.0/src/note_editor/WebSocketTransport.cpp libquentier-0.5.0/src/note_editor/WebSocketTransport.cpp --- libquentier-0.5.0/src/note_editor/WebSocketTransport.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/note_editor/WebSocketTransport.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -17,7 +17,9 @@ */ #include "WebSocketTransport.h" + #include <quentier/logging/QuentierLogger.h> + #include <QtWebSockets/QWebSocket> #include <QJsonDocument> #include <QJsonObject> @@ -50,15 +52,15 @@ bool WebSocketTransport::parseMessage(QByteArray messageData, QJsonObject & object) { - QNTRACE(QStringLiteral("WebSocketTransport::parseMessage: ") << messageData); + QNTRACE("WebSocketTransport::parseMessage: " << messageData); QJsonParseError error; QJsonDocument document = QJsonDocument::fromJson(messageData, &error); if (!error.error) { if (!document.isObject()) { - QNWARNING(QStringLiteral("Failed to parse JSON message that is not ") - << QStringLiteral("an object: ") << messageData); + QNWARNING("Failed to parse JSON message that is not an object: " + << messageData); return false; } @@ -67,14 +69,13 @@ } if (error.error != QJsonParseError::GarbageAtEnd) { - QNWARNING(QStringLiteral("Failed to parse text message as JSON object: ") - << messageData << QStringLiteral("; error is: ") - << error.errorString()); + QNWARNING("Failed to parse text message as JSON object: " + << messageData << "; error is: " << error.errorString()); return false; } - QNTRACE(QStringLiteral("Detected \"garbage at the end\" JSON parsing error, ") - << QStringLiteral("trying to workaround; message data: ") << messageData); + QNTRACE("Detected \"garbage at the end\" JSON parsing error, " + << "trying to workaround; message data: " << messageData); /** * NOTE: for some reason which I can't fully comprehend yet the first part @@ -86,8 +87,8 @@ */ int lastOpeningCurvyBraceIndex = messageData.lastIndexOf('{'); if (lastOpeningCurvyBraceIndex <= 0) { - QNWARNING(QStringLiteral("Failed to workaround \"Garbage at the end\" ") - << QStringLiteral("error, message data: ") << messageData); + QNWARNING("Failed to workaround \"Garbage at the end\" " + << "error, message data: " << messageData); return false; } diff -Nru libquentier-0.5.0/src/synchronization/AuthenticationManager_p.cpp libquentier-0.5.0/src/synchronization/AuthenticationManager_p.cpp --- libquentier-0.5.0/src/synchronization/AuthenticationManager_p.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/AuthenticationManager_p.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -52,7 +52,7 @@ void AuthenticationManagerPrivate::onAuthenticationRequest() { - QNDEBUG(QStringLiteral("AuthenticationManagerPrivate::onAuthenticationRequest")); + QNDEBUG("AuthenticationManagerPrivate::onAuthenticationRequest"); QWidget * pParentWidget = qobject_cast<QWidget*>(parent()); QScopedPointer<qevercloud::EvernoteOAuthDialog> pDialog( diff -Nru libquentier-0.5.0/src/synchronization/ExceptionHandlingHelpers.h libquentier-0.5.0/src/synchronization/ExceptionHandlingHelpers.h --- libquentier-0.5.0/src/synchronization/ExceptionHandlingHelpers.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/ExceptionHandlingHelpers.h 2019-07-11 10:46:53.000000000 +0000 @@ -24,117 +24,139 @@ // 1) "Implementation" macros containing the bulk of exception handling code -#define CATCH_THRIFT_EXCEPTION_IMPL(...) \ - catch(const qevercloud::ThriftException & thriftException) \ - { \ - errorDescription.setBase(QT_TRANSLATE_NOOP("synchronization", \ - "Thrift exception")); \ - errorDescription.details() = QStringLiteral("type = "); \ +#define CATCH_THRIFT_EXCEPTION_IMPL(...) \ + catch(const qevercloud::ThriftException & thriftException) \ + { \ + errorDescription.setBase(QT_TRANSLATE_NOOP("synchronization", \ + "Thrift exception")); \ + errorDescription.details() = QStringLiteral("type = "); \ errorDescription.details() += QString::number(thriftException.type()); \ - errorDescription.details() += QStringLiteral(": "); \ - errorDescription.details() += QString::fromUtf8(thriftException.what()); \ - QNWARNING(errorDescription); \ - __VA_ARGS__ ; \ - } - -#define CATCH_EVERNOTE_EXCEPTION_IMPL(...) \ - catch(const qevercloud::EvernoteException & evernoteException) \ - { \ - errorDescription.setBase(QT_TRANSLATE_NOOP("synchronization", \ - "QEverCloud Evernote exception")); \ - if (!evernoteException.exceptionData().isNull()) { \ - errorDescription.details() = \ - evernoteException.exceptionData()->errorMessage; \ - } \ - QNWARNING(errorDescription); \ - __VA_ARGS__ ; \ - } - -#define CATCH_EVER_CLOUD_EXCEPTION_IMPL(...) \ - catch(const qevercloud::EverCloudException & everCloudException) \ - { \ - errorDescription.setBase(QT_TRANSLATE_NOOP("synchronization", \ - "QEverCloud exception")); \ - errorDescription.details() = \ - QString::fromUtf8(everCloudException.what()); \ - QNWARNING(errorDescription); \ - __VA_ARGS__ ; \ - } - -#define CATCH_STD_EXCEPTION_IMPL(...) \ - catch(const std::exception & e) \ - { \ - errorDescription.setBase(QT_TRANSLATE_NOOP("synchronization", \ - "std::exception")); \ - errorDescription.details() = QString::fromUtf8(e.what()); \ - QNWARNING(errorDescription); \ - __VA_ARGS__ ; \ - } - -#define CATCH_GENERIC_EXCEPTIONS_IMPL(...) \ - CATCH_THRIFT_EXCEPTION_IMPL( __VA_ARGS__ ) \ - CATCH_EVERNOTE_EXCEPTION_IMPL( __VA_ARGS__ ) \ - CATCH_EVER_CLOUD_EXCEPTION_IMPL( __VA_ARGS__ ) \ - CATCH_STD_EXCEPTION_IMPL( __VA_ARGS__ ) + errorDescription.details() += QStringLiteral(": "); \ + errorDescription.details() += \ + QString::fromUtf8(thriftException.what()); \ + QNWARNING(errorDescription); \ + __VA_ARGS__ ; \ + } \ +// CATCH_THRIFT_EXCEPTION_IMPL + +#define CATCH_EVERNOTE_EXCEPTION_IMPL(...) \ + catch(const qevercloud::EvernoteException & evernoteException) \ + { \ + errorDescription.setBase( \ + QT_TRANSLATE_NOOP("synchronization", \ + "QEverCloud Evernote exception")); \ + if (!evernoteException.exceptionData().isNull()) { \ + errorDescription.details() = \ + evernoteException.exceptionData()->errorMessage; \ + } \ + QNWARNING(errorDescription); \ + __VA_ARGS__ ; \ + } \ +// CATCH_EVERNOTE_EXCEPTION_IMPL + +#define CATCH_EVER_CLOUD_EXCEPTION_IMPL(...) \ + catch(const qevercloud::EverCloudException & everCloudException) \ + { \ + errorDescription.setBase(QT_TRANSLATE_NOOP("synchronization", \ + "QEverCloud exception")); \ + errorDescription.details() = \ + QString::fromUtf8(everCloudException.what()); \ + QNWARNING(errorDescription); \ + __VA_ARGS__ ; \ + } \ +// CATCH_EVER_CLOUD_EXCEPTION_IMPL + +#define CATCH_STD_EXCEPTION_IMPL(...) \ + catch(const std::exception & e) \ + { \ + errorDescription.setBase(QT_TRANSLATE_NOOP("synchronization", \ + "std::exception")); \ + errorDescription.details() = QString::fromUtf8(e.what()); \ + QNWARNING(errorDescription); \ + __VA_ARGS__ ; \ + } \ +// CATCH_STD_EXCEPTION_IMPL + +#define CATCH_GENERIC_EXCEPTIONS_IMPL(...) \ + CATCH_THRIFT_EXCEPTION_IMPL( __VA_ARGS__ ) \ + CATCH_EVERNOTE_EXCEPTION_IMPL( __VA_ARGS__ ) \ + CATCH_EVER_CLOUD_EXCEPTION_IMPL( __VA_ARGS__ ) \ + CATCH_STD_EXCEPTION_IMPL( __VA_ARGS__ ) \ +// CATCH_GENERIC_EXCEPTIONS_IMPL // 2) Macros returning false in the end of exception handling -#define CATCH_THRIFT_EXCEPTION_RET_FALSE() \ - CATCH_THRIFT_EXCEPTION_IMPL(return false) - -#define CATCH_EVERNOTE_EXCEPTION_RET_FALSE() \ - CATCH_EVERNOTE_EXCEPTION_IMPL(return false) - -#define CATCH_EVER_CLOUD_EXCEPTION_RET_FALSE() \ - CATCH_EVER_CLOUD_EXCEPTION_IMPL(return false) - -#define CATCH_STD_EXCEPTION_RET_FALSE() \ - CATCH_STD_EXCEPTION_IMPL(return false) - -#define CATCH_GENERIC_EXCEPTIONS_RET_FALSE() \ - CATCH_THRIFT_EXCEPTION_RET_FALSE() \ - CATCH_EVERNOTE_EXCEPTION_RET_FALSE() \ - CATCH_EVER_CLOUD_EXCEPTION_RET_FALSE() \ - CATCH_STD_EXCEPTION_RET_FALSE() +#define CATCH_THRIFT_EXCEPTION_RET_FALSE() \ + CATCH_THRIFT_EXCEPTION_IMPL(return false) \ +// CATCH_THRIFT_EXCEPTION_RET_FALSE + +#define CATCH_EVERNOTE_EXCEPTION_RET_FALSE() \ + CATCH_EVERNOTE_EXCEPTION_IMPL(return false) \ +// CATCH_EVERNOTE_EXCEPTION_RET_FALSE + +#define CATCH_EVER_CLOUD_EXCEPTION_RET_FALSE() \ + CATCH_EVER_CLOUD_EXCEPTION_IMPL(return false) \ +// CATCH_EVER_CLOUD_EXCEPTION_RET_FALSE + +#define CATCH_STD_EXCEPTION_RET_FALSE() \ + CATCH_STD_EXCEPTION_IMPL(return false) \ +// CATCH_STD_EXCEPTION_RET_FALSE + +#define CATCH_GENERIC_EXCEPTIONS_RET_FALSE() \ + CATCH_THRIFT_EXCEPTION_RET_FALSE() \ + CATCH_EVERNOTE_EXCEPTION_RET_FALSE() \ + CATCH_EVER_CLOUD_EXCEPTION_RET_FALSE() \ + CATCH_STD_EXCEPTION_RET_FALSE() \ +// CATCH_GENERIC_EXCEPTIONS_RET_FALSE // 3) Macros returning no value -#define CATCH_THRIFT_EXCEPTION_RET() \ - CATCH_THRIFT_EXCEPTION_IMPL(return) - -#define CATCH_EVERNOTE_EXCEPTION_RET() \ - CATCH_EVERNOTE_EXCEPTION_IMPL(return) - -#define CATCH_EVER_CLOUD_EXCEPTION_RET() \ - CATCH_EVER_CLOUD_EXCEPTION_IMPL(return) - -#define CATCH_STD_EXCEPTION_RET() \ - CATCH_STD_EXCEPTION_IMPL(return) - -#define CATCH_GENERIC_EXCEPTIONS_RET() \ - CATCH_THRIFT_EXCEPTION_RET() \ - CATCH_EVERNOTE_EXCEPTION_RET() \ - CATCH_EVER_CLOUD_EXCEPTION_RET() \ - CATCH_STD_EXCEPTION_RET() +#define CATCH_THRIFT_EXCEPTION_RET() \ + CATCH_THRIFT_EXCEPTION_IMPL(return) \ +// CATCH_THRIFT_EXCEPTION_RET + +#define CATCH_EVERNOTE_EXCEPTION_RET() \ + CATCH_EVERNOTE_EXCEPTION_IMPL(return) \ +// CATCH_EVERNOTE_EXCEPTION_RET + +#define CATCH_EVER_CLOUD_EXCEPTION_RET() \ + CATCH_EVER_CLOUD_EXCEPTION_IMPL(return) \ +// CATCH_EVER_CLOUD_EXCEPTION_RET + +#define CATCH_STD_EXCEPTION_RET() \ + CATCH_STD_EXCEPTION_IMPL(return) \ +// CATCH_STD_EXCEPTION_RET + +#define CATCH_GENERIC_EXCEPTIONS_RET() \ + CATCH_THRIFT_EXCEPTION_RET() \ + CATCH_EVERNOTE_EXCEPTION_RET() \ + CATCH_EVER_CLOUD_EXCEPTION_RET() \ + CATCH_STD_EXCEPTION_RET() \ +// CATCH_GENERIC_EXCEPTIONS_RET // 4) Macros not returning anything -#define CATCH_THRIFT_EXCEPTION_NO_RET() \ - CATCH_THRIFT_EXCEPTION_IMPL() - -#define CATCH_EVERNOTE_EXCEPTION_NO_RET() \ - CATCH_EVERNOTE_EXCEPTION_IMPL() - -#define CATCH_EVER_CLOUD_EXCEPTION_NO_RET() \ - CATCH_EVER_CLOUD_EXCEPTION_IMPL() - -#define CATCH_STD_EXCEPTION_NO_RET() \ - CATCH_STD_EXCEPTION_IMPL() - -#define CATCH_GENERIC_EXCEPTIONS_NO_RET() \ - CATCH_THRIFT_EXCEPTION_NO_RET() \ - CATCH_EVERNOTE_EXCEPTION_NO_RET() \ - CATCH_EVER_CLOUD_EXCEPTION_NO_RET() \ - CATCH_STD_EXCEPTION_NO_RET() +#define CATCH_THRIFT_EXCEPTION_NO_RET() \ + CATCH_THRIFT_EXCEPTION_IMPL() \ +// CATCH_THRIFT_EXCEPTION_NO_RET + +#define CATCH_EVERNOTE_EXCEPTION_NO_RET() \ + CATCH_EVERNOTE_EXCEPTION_IMPL() \ +// CATCH_EVERNOTE_EXCEPTION_NO_RET + +#define CATCH_EVER_CLOUD_EXCEPTION_NO_RET() \ + CATCH_EVER_CLOUD_EXCEPTION_IMPL() \ +// CATCH_EVER_CLOUD_EXCEPTION_NO_RET + +#define CATCH_STD_EXCEPTION_NO_RET() \ + CATCH_STD_EXCEPTION_IMPL() \ +// CATCH_STD_EXCEPTION_NO_RET + +#define CATCH_GENERIC_EXCEPTIONS_NO_RET() \ + CATCH_THRIFT_EXCEPTION_NO_RET() \ + CATCH_EVERNOTE_EXCEPTION_NO_RET() \ + CATCH_EVER_CLOUD_EXCEPTION_NO_RET() \ + CATCH_STD_EXCEPTION_NO_RET() \ +// CATCH_GENERIC_EXCEPTIONS_NO_RET #endif // LIB_QUENTIER_SYNCHRONIZATION_EXCEPTION_HANDLING_HELPERS_H diff -Nru libquentier-0.5.0/src/synchronization/FullSyncStaleDataItemsExpunger.cpp libquentier-0.5.0/src/synchronization/FullSyncStaleDataItemsExpunger.cpp --- libquentier-0.5.0/src/synchronization/FullSyncStaleDataItemsExpunger.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/FullSyncStaleDataItemsExpunger.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -23,23 +23,27 @@ #include <quentier/logging/QuentierLogger.h> #include <QStringList> -#define __FELOG_BASE(message, level) \ - if (m_linkedNotebookGuid.isEmpty()) { \ - __QNLOG_BASE(message, level); \ - } \ - else { \ - __QNLOG_BASE(QStringLiteral("[linked notebook ") << m_linkedNotebookGuid \ - << QStringLiteral("]: ") << message, level); \ - } - -#define FETRACE(message) \ - __FELOG_BASE(message, Trace) - -#define FEDEBUG(message) \ - __FELOG_BASE(message, Debug) - -#define FEWARNING(message) \ - __FELOG_BASE(message, Warn) +#define __FELOG_BASE(message, level) \ + if (m_linkedNotebookGuid.isEmpty()) { \ + __QNLOG_BASE(message, level); \ + } \ + else { \ + __QNLOG_BASE("[linked notebook " << m_linkedNotebookGuid \ + << "]: " << message, level); \ + } \ +// __FELOG_BASE + +#define FETRACE(message) \ + __FELOG_BASE(message, Trace) \ +// FETRACE + +#define FEDEBUG(message) \ + __FELOG_BASE(message, Debug) \ +// FEDEBUG + +#define FEWARNING(message) \ + __FELOG_BASE(message, Warn) \ +// FEWARNING namespace quentier { @@ -77,10 +81,10 @@ void FullSyncStaleDataItemsExpunger::start() { - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::start")); + FEDEBUG("FullSyncStaleDataItemsExpunger::start"); if (m_inProgress) { - FEDEBUG(QStringLiteral("Already started")); + FEDEBUG("Already started"); return; } @@ -88,7 +92,7 @@ checkAndRequestCachesFilling(); if (pendingCachesFilling()) { - FEDEBUG(QStringLiteral("Pending caches filling")); + FEDEBUG("Pending caches filling"); return; } @@ -97,10 +101,10 @@ void FullSyncStaleDataItemsExpunger::onNotebookCacheFilled() { - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::onNotebookCacheFilled")); + FEDEBUG("FullSyncStaleDataItemsExpunger::onNotebookCacheFilled"); if (Q_UNLIKELY(!m_inProgress)) { - FEDEBUG(QStringLiteral("Not in progress at the moment")); + FEDEBUG("Not in progress at the moment"); return; } @@ -113,10 +117,10 @@ void FullSyncStaleDataItemsExpunger::onTagCacheFilled() { - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::onTagCacheFilled")); + FEDEBUG("FullSyncStaleDataItemsExpunger::onTagCacheFilled"); if (Q_UNLIKELY(!m_inProgress)) { - FEDEBUG(QStringLiteral("Not in progress at the moment")); + FEDEBUG("Not in progress at the moment"); return; } @@ -129,10 +133,10 @@ void FullSyncStaleDataItemsExpunger::onSavedSearchCacheFilled() { - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::onSavedSearchCacheFilled")); + FEDEBUG("FullSyncStaleDataItemsExpunger::onSavedSearchCacheFilled"); if (Q_UNLIKELY(!m_inProgress)) { - FEDEBUG(QStringLiteral("Not in progress at the moment")); + FEDEBUG("Not in progress at the moment"); return; } @@ -145,10 +149,10 @@ void FullSyncStaleDataItemsExpunger::onNoteCacheFilled() { - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::onNoteCacheFilled")); + FEDEBUG("FullSyncStaleDataItemsExpunger::onNoteCacheFilled"); if (Q_UNLIKELY(!m_inProgress)) { - FEDEBUG(QStringLiteral("Not in progress at the moment")); + FEDEBUG("Not in progress at the moment"); return; } @@ -159,35 +163,33 @@ } } -void FullSyncStaleDataItemsExpunger::onExpungeNotebookComplete(Notebook notebook, - QUuid requestId) +void FullSyncStaleDataItemsExpunger::onExpungeNotebookComplete( + Notebook notebook, QUuid requestId) { auto it = m_expungeNotebookRequestIds.find(requestId); if (it == m_expungeNotebookRequestIds.end()) { return; } - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::onExpungeNotebookComplete: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", notebook: ") << notebook); + FEDEBUG("FullSyncStaleDataItemsExpunger::onExpungeNotebookComplete: " + << "request id = " << requestId << ", notebook: " << notebook); Q_UNUSED(m_expungeNotebookRequestIds.erase(it)) checkRequestsCompletionAndSendResult(); } -void FullSyncStaleDataItemsExpunger::onExpungeNotebookFailed(Notebook notebook, - ErrorString errorDescription, - QUuid requestId) +void FullSyncStaleDataItemsExpunger::onExpungeNotebookFailed( + Notebook notebook, ErrorString errorDescription, QUuid requestId) { auto it = m_expungeNotebookRequestIds.find(requestId); if (it == m_expungeNotebookRequestIds.end()) { return; } - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::onExpungeNotebookFailed: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", error description = ") << errorDescription - << QStringLiteral(", notebook: ") << notebook); + FEDEBUG("FullSyncStaleDataItemsExpunger::onExpungeNotebookFailed: " + << "request id = " << requestId + << ", error description = " << errorDescription + << ", notebook: " << notebook); Q_EMIT failure(errorDescription); } @@ -200,128 +202,120 @@ return; } - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::onExpungeTagComplete: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", tag: ") << tag - << QStringLiteral("\nExpunged child tag local uids: ") + FEDEBUG("FullSyncStaleDataItemsExpunger::onExpungeTagComplete: " + << "request id = " << requestId << ", tag: " << tag + << "\nExpunged child tag local uids: " << expungedChildTagLocalUids.join(QStringLiteral(", "))); Q_UNUSED(m_expungeTagRequestIds.erase(it)) checkRequestsCompletionAndSendResult(); } -void FullSyncStaleDataItemsExpunger::onExpungeTagFailed(Tag tag, - ErrorString errorDescription, - QUuid requestId) +void FullSyncStaleDataItemsExpunger::onExpungeTagFailed( + Tag tag, ErrorString errorDescription, QUuid requestId) { auto it = m_expungeTagRequestIds.find(requestId); if (it == m_expungeTagRequestIds.end()) { return; } - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::onExpungeTagFailed: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", error description = ") << errorDescription - << QStringLiteral(", tag: ") << tag); + FEDEBUG("FullSyncStaleDataItemsExpunger::onExpungeTagFailed: " + << "request id = " << requestId + << ", error description = " << errorDescription + << ", tag: " << tag); Q_EMIT failure(errorDescription); } -void FullSyncStaleDataItemsExpunger::onExpungeSavedSearchComplete(SavedSearch search, - QUuid requestId) +void FullSyncStaleDataItemsExpunger::onExpungeSavedSearchComplete( + SavedSearch search, QUuid requestId) { auto it = m_expungeSavedSearchRequestIds.find(requestId); if (it == m_expungeSavedSearchRequestIds.end()) { return; } - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::onExpungeSavedSearchComplete: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", saved search: ") << search); + FEDEBUG("FullSyncStaleDataItemsExpunger::onExpungeSavedSearchComplete: " + << "request id = " << requestId << ", saved search: " << search); Q_UNUSED(m_expungeSavedSearchRequestIds.erase(it)) checkRequestsCompletionAndSendResult(); } -void FullSyncStaleDataItemsExpunger::onExpungeSavedSearchFailed(SavedSearch search, - ErrorString errorDescription, - QUuid requestId) +void FullSyncStaleDataItemsExpunger::onExpungeSavedSearchFailed( + SavedSearch search, ErrorString errorDescription, QUuid requestId) { auto it = m_expungeSavedSearchRequestIds.find(requestId); if (it == m_expungeSavedSearchRequestIds.end()) { return; } - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::onExpungeSavedSearchFailed: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", error description = ") << errorDescription - << QStringLiteral(", search: ") << search); + FEDEBUG("FullSyncStaleDataItemsExpunger::onExpungeSavedSearchFailed: " + << "request id = " << requestId + << ", error description = " << errorDescription + << ", search: " << search); Q_EMIT failure(errorDescription); } -void FullSyncStaleDataItemsExpunger::onExpungeNoteComplete(Note note, - QUuid requestId) +void FullSyncStaleDataItemsExpunger::onExpungeNoteComplete( + Note note, QUuid requestId) { auto it = m_expungeNoteRequestIds.find(requestId); if (it == m_expungeNoteRequestIds.end()) { return; } - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::onExpungeNoteComplete: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", note: ") << note); + FEDEBUG("FullSyncStaleDataItemsExpunger::onExpungeNoteComplete: " + << "request id = " << requestId << ", note: " << note); Q_UNUSED(m_expungeNoteRequestIds.erase(it)) checkRequestsCompletionAndSendResult(); } -void FullSyncStaleDataItemsExpunger::onExpungeNoteFailed(Note note, - ErrorString errorDescription, - QUuid requestId) +void FullSyncStaleDataItemsExpunger::onExpungeNoteFailed( + Note note, ErrorString errorDescription, QUuid requestId) { auto it = m_expungeNoteRequestIds.find(requestId); if (it == m_expungeNoteRequestIds.end()) { return; } - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::onExpungeNoteFailed: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", error description = ") << errorDescription - << QStringLiteral(", note: ") << note); + FEDEBUG("FullSyncStaleDataItemsExpunger::onExpungeNoteFailed: " + << "request id = " << requestId + << ", error description = " << errorDescription + << ", note: " << note); Q_EMIT failure(errorDescription); } -void FullSyncStaleDataItemsExpunger::onUpdateNotebookComplete(Notebook notebook, - QUuid requestId) +void FullSyncStaleDataItemsExpunger::onUpdateNotebookComplete( + Notebook notebook, QUuid requestId) { auto it = m_updateNotebookRequestId.find(requestId); if (it == m_updateNotebookRequestId.end()) { return; } - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::onUpdateNotebookComplete: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", notebook: ") << notebook); + FEDEBUG("FullSyncStaleDataItemsExpunger::onUpdateNotebookComplete: " + << "request id = " << requestId << ", notebook: " << notebook); Q_UNUSED(m_updateNotebookRequestId.erase(it)) checkRequestsCompletionAndSendResult(); } -void FullSyncStaleDataItemsExpunger::onUpdateNotebookFailed(Notebook notebook, - ErrorString errorDescription, - QUuid requestId) +void FullSyncStaleDataItemsExpunger::onUpdateNotebookFailed( + Notebook notebook, ErrorString errorDescription, QUuid requestId) { auto it = m_updateNotebookRequestId.find(requestId); if (it == m_updateNotebookRequestId.end()) { return; } - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::onUpdateNotebookFailed: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", error description = ") << errorDescription - << QStringLiteral(", notebook: ") << notebook); + FEDEBUG("FullSyncStaleDataItemsExpunger::onUpdateNotebookFailed: " + << "request id = " << requestId + << ", error description = " << errorDescription + << ", notebook: " << notebook); Q_EMIT failure(errorDescription); } @@ -333,61 +327,57 @@ return; } - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::onUpdateTagComplete: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", tag: ") << tag); + FEDEBUG("FullSyncStaleDataItemsExpunger::onUpdateTagComplete: " + << "request id = " << requestId << ", tag: " << tag); Q_UNUSED(m_updateTagRequestIds.erase(it)) checkTagUpdatesCompletionAndSendExpungeTagRequests(); checkRequestsCompletionAndSendResult(); } -void FullSyncStaleDataItemsExpunger::onUpdateTagFailed(Tag tag, - ErrorString errorDescription, - QUuid requestId) +void FullSyncStaleDataItemsExpunger::onUpdateTagFailed( + Tag tag, ErrorString errorDescription, QUuid requestId) { auto it = m_updateTagRequestIds.find(requestId); if (it == m_updateTagRequestIds.end()) { return; } - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::onUpdateTagFailed: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", error description = ") << errorDescription - << QStringLiteral(", tag: ") << tag); + FEDEBUG("FullSyncStaleDataItemsExpunger::onUpdateTagFailed: " + << "request id = " << requestId + << ", error description = " << errorDescription + << ", tag: " << tag); Q_EMIT failure(errorDescription); } -void FullSyncStaleDataItemsExpunger::onUpdateSavedSearchComplete(SavedSearch search, - QUuid requestId) +void FullSyncStaleDataItemsExpunger::onUpdateSavedSearchComplete( + SavedSearch search, QUuid requestId) { auto it = m_updateSavedSearchRequestIds.find(requestId); if (it == m_updateSavedSearchRequestIds.end()) { return; } - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::onUpdateSavedSearchComplete: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", saved search: ") << search); + FEDEBUG("FullSyncStaleDataItemsExpunger::onUpdateSavedSearchComplete: " + << "request id = " << requestId << ", saved search: " << search); Q_UNUSED(m_updateSavedSearchRequestIds.erase(it)) checkRequestsCompletionAndSendResult(); } -void FullSyncStaleDataItemsExpunger::onUpdateSavedSearchFailed(SavedSearch search, - ErrorString errorDescription, - QUuid requestId) +void FullSyncStaleDataItemsExpunger::onUpdateSavedSearchFailed( + SavedSearch search, ErrorString errorDescription, QUuid requestId) { auto it = m_updateSavedSearchRequestIds.find(requestId); if (it == m_updateSavedSearchRequestIds.end()) { return; } - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::onUpdateSavedSearchFailed: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", error description = ") << errorDescription - << QStringLiteral(", saved search: ") << search); + FEDEBUG("FullSyncStaleDataItemsExpunger::onUpdateSavedSearchFailed: " + << "request id = " << requestId + << ", error description = " << errorDescription + << ", saved search: " << search); Q_EMIT failure(errorDescription); } @@ -400,21 +390,21 @@ return; } - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::onUpdateNoteComplete: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", update resource metadata = ") + FEDEBUG("FullSyncStaleDataItemsExpunger::onUpdateNoteComplete: " + << "request id = " << requestId + << ", update resource metadata = " << ((options & LocalStorageManager::UpdateNoteOption::UpdateResourceMetadata) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", update resource binary data = ") + ? "true" + : "false") + << ", update resource binary data = " << ((options & LocalStorageManager::UpdateNoteOption::UpdateResourceBinaryData) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", update tags = ") + ? "true" + : "false") + << ", update tags = " << ((options & LocalStorageManager::UpdateNoteOption::UpdateTags) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", note: ") << note); + ? "true" + : "false") + << ", note: " << note); Q_UNUSED(m_updateNoteRequestIds.erase(it)) checkRequestsCompletionAndSendResult(); @@ -429,32 +419,32 @@ return; } - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::onUpdateNoteFailed: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", update resource metadata = ") + FEDEBUG("FullSyncStaleDataItemsExpunger::onUpdateNoteFailed: " + << "request id = " << requestId + << ", update resource metadata = " << ((options & LocalStorageManager::UpdateNoteOption::UpdateResourceMetadata) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", update resource binary data = ") + ? "true" + : "false") + << ", update resource binary data = " << ((options & LocalStorageManager::UpdateNoteOption::UpdateResourceBinaryData) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", update tags = ") + ? "true" + : "false") + << ", update tags = " << ((options & LocalStorageManager::UpdateNoteOption::UpdateTags) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", error description = ") << errorDescription - << QStringLiteral(", note: ") << note); + ? "true" + : "false") + << ", error description = " << errorDescription + << ", note: " << note); Q_EMIT failure(errorDescription); } void FullSyncStaleDataItemsExpunger::connectToLocalStorage() { - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::connectToLocalStorage")); + FEDEBUG("FullSyncStaleDataItemsExpunger::connectToLocalStorage"); if (m_connectedToLocalStorage) { - FEDEBUG(QStringLiteral("Already connected to the local storage")); + FEDEBUG("Already connected to the local storage"); return; } @@ -633,10 +623,10 @@ void FullSyncStaleDataItemsExpunger::disconnectFromLocalStorage() { - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::disconnectFromLocalStorage")); + FEDEBUG("FullSyncStaleDataItemsExpunger::disconnectFromLocalStorage"); if (!m_connectedToLocalStorage) { - FEDEBUG(QStringLiteral("Not connected to local storage at the moment")); + FEDEBUG("Not connected to local storage at the moment"); return; } @@ -795,8 +785,7 @@ void FullSyncStaleDataItemsExpunger::checkAndRequestCachesFilling() { - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::" - "checkAndRequestCachesFilling")); + FEDEBUG("FullSyncStaleDataItemsExpunger::checkAndRequestCachesFilling"); if (Q_UNLIKELY(m_pNotebookSyncCache.isNull())) { m_pNotebookSyncCache = @@ -817,7 +806,7 @@ } else { - FEDEBUG(QStringLiteral("The notebook sync cache is already filled")); + FEDEBUG("The notebook sync cache is already filled"); } if (Q_UNLIKELY(m_pTagSyncCache.isNull())) { @@ -839,7 +828,7 @@ } else { - FEDEBUG(QStringLiteral("The tag sync cache is already filled")); + FEDEBUG("The tag sync cache is already filled"); } // NOTE: saved searches are not a part of linked notebook content so there's @@ -866,7 +855,7 @@ } else { - FEDEBUG(QStringLiteral("The saved search sync cache is already filled")); + FEDEBUG("The saved search sync cache is already filled"); } } @@ -882,42 +871,41 @@ } else { - FEDEBUG(QStringLiteral("The note sync cache is already filled")); + FEDEBUG("The note sync cache is already filled"); } } bool FullSyncStaleDataItemsExpunger::pendingCachesFilling() const { - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::pendingCachesFilling")); + FEDEBUG("FullSyncStaleDataItemsExpunger::pendingCachesFilling"); if (m_pendingNotebookSyncCache) { - FEDEBUG(QStringLiteral("Still pending notebook sync cache")); + FEDEBUG("Still pending notebook sync cache"); return true; } if (m_pendingTagSyncCache) { - FEDEBUG(QStringLiteral("Still pending tag sync cache")); + FEDEBUG("Still pending tag sync cache"); return true; } if (m_pendingSavedSearchSyncCache) { - FEDEBUG(QStringLiteral("Still pending saved search sync cache")); + FEDEBUG("Still pending saved search sync cache"); return true; } if (m_pendingNoteSyncCache) { - FEDEBUG(QStringLiteral("Still pending note sync cache")); + FEDEBUG("Still pending note sync cache"); return true; } - FEDEBUG(QStringLiteral("Found no pending sync caches")); + FEDEBUG("Found no pending sync caches"); return false; } void FullSyncStaleDataItemsExpunger::analyzeDataAndSendRequestsOrResult() { - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::" - "analyzeDataAndSendRequestsOrResult")); + FEDEBUG("FullSyncStaleDataItemsExpunger::analyzeDataAndSendRequestsOrResult"); QSet<QString> notebookGuidsToExpunge; QSet<QString> savedSearchGuidsToExpunge; @@ -943,31 +931,30 @@ if (m_syncedGuids.m_syncedNotebookGuids.find(guid) != m_syncedGuids.m_syncedNotebookGuids.end()) { - FETRACE(QStringLiteral("Found notebook guid ") << guid - << QStringLiteral(" within the synced ones")); + FETRACE("Found notebook guid " << guid + << " within the synced ones"); continue; } auto dirtyNotebookIt = dirtyNotebooksByGuidHash.find(guid); if (dirtyNotebookIt == dirtyNotebooksByGuidHash.end()) { - FETRACE(QStringLiteral("Notebook guid ") << guid - << QStringLiteral(" doesn't appear within the list of " - "dirty notebooks")); + FETRACE("Notebook guid " << guid + << " doesn't appear within the list of " + << "dirty notebooks"); Q_UNUSED(notebookGuidsToExpunge.insert(guid)) } else { - FETRACE(QStringLiteral("Notebook guid ") << guid - << QStringLiteral(" appears within the list of " - "dirty notebooks")); + FETRACE("Notebook guid " << guid + << " appears within the list of dirty notebooks"); dirtyNotebooksToUpdate << dirtyNotebookIt.value(); } } } else { - FEWARNING(QStringLiteral("Notebook sync cache is expired")); + FEWARNING("Notebook sync cache is expired"); } if (!m_pTagSyncCache.isNull()) @@ -984,30 +971,29 @@ if (m_syncedGuids.m_syncedTagGuids.find(guid) != m_syncedGuids.m_syncedTagGuids.end()) { - FETRACE(QStringLiteral("Found tag guid ") << guid - << QStringLiteral(" within the synced ones")); + FETRACE("Found tag guid " << guid + << " within the synced ones"); continue; } auto dirtyTagIt = dirtyTagsByGuidHash.find(guid); if (dirtyTagIt == dirtyTagsByGuidHash.end()) { - FETRACE(QStringLiteral("Tag guid ") << guid - << QStringLiteral(" doesn't appear within the list of " - "dirty tags")); + FETRACE("Tag guid " << guid + << " doesn't appear within the list of dirty tags"); Q_UNUSED(m_tagGuidsToExpunge.insert(guid)) } else { - FETRACE(QStringLiteral("Tag guid ") << guid - << QStringLiteral(" appears within the list of dirty tags")); + FETRACE("Tag guid " << guid + << " appears within the list of dirty tags"); dirtyTagsToUpdate << dirtyTagIt.value(); } } } else { - FEWARNING(QStringLiteral("Tag sync cache is expired")); + FEWARNING("Tag sync cache is expired"); } // Need to check if dirty tags to update have parent guids corresponding @@ -1027,8 +1013,8 @@ continue; } - FETRACE(QStringLiteral("Clearing parent guid from dirty tag because " - "the parent tag is going to be expunged: ") << tag); + FETRACE("Clearing parent guid from dirty tag because " + << "the parent tag is going to be expunged: " << tag); tag.setParentGuid(QString()); tag.setParentLocalUid(QString()); @@ -1048,31 +1034,29 @@ if (m_syncedGuids.m_syncedSavedSearchGuids.find(guid) != m_syncedGuids.m_syncedSavedSearchGuids.end()) { - FETRACE(QStringLiteral("Found saved search guid ") << guid - << QStringLiteral(" within the synced ones")); + FETRACE("Found saved search guid " << guid + << " within the synced ones"); continue; } auto dirtySavedSearchIt = dirtySavedSearchesByGuid.find(guid); if (dirtySavedSearchIt == dirtySavedSearchesByGuid.end()) { - FETRACE(QStringLiteral("Saved search guid ") << guid - << QStringLiteral(" doesn't appear within the list of " - "dirty searches")); + FETRACE("Saved search guid " << guid + << " doesn't appear within the list of dirty searches"); Q_UNUSED(savedSearchGuidsToExpunge.insert(guid)) } else { - FETRACE(QStringLiteral("Saved search guid ") << guid - << QStringLiteral(" appears within the list of dirty " - "saved searches")); + FETRACE("Saved search guid " << guid + << " appears within the list of dirty saved searches"); dirtySavedSearchesToUpdate << dirtySavedSearchIt.value(); } } } else if (m_linkedNotebookGuid.isEmpty()) { - FEWARNING(QStringLiteral("Saved search sync cache is expired")); + FEWARNING("Saved search sync cache is expired"); } const NoteSyncCache::NoteGuidToLocalUidBimap & noteGuidToLocalUidBimap = @@ -1085,17 +1069,15 @@ if (m_syncedGuids.m_syncedNoteGuids.find(guid) != m_syncedGuids.m_syncedNoteGuids.end()) { - FETRACE(QStringLiteral("Found note guid ") << guid - << QStringLiteral(" within the synced ones")); + FETRACE("Found note guid " << guid << " within the synced ones"); continue; } auto dirtyNoteIt = dirtyNotesByGuid.find(guid); if (dirtyNoteIt == dirtyNotesByGuid.end()) { - FETRACE(QStringLiteral("Note guid ") << guid - << QStringLiteral(" doesn't appear within the list of " - "dirty notes")); + FETRACE("Note guid " << guid + << " doesn't appear within the list of dirty notes"); Q_UNUSED(noteGuidsToExpunge.insert(guid)) } else @@ -1105,9 +1087,9 @@ auto notebookGuidIt = notebookGuidByNoteGuid.find(guid); if (Q_UNLIKELY(notebookGuidIt == notebookGuidByNoteGuid.end())) { - FEWARNING(QStringLiteral("Failed to find cached notebook guid ") - << QStringLiteral("for note guid ") << guid - << QStringLiteral(", won't do anything with this note")); + FEWARNING("Failed to find cached notebook guid " + << "for note guid " << guid + << ", won't do anything with this note"); continue; } @@ -1119,8 +1101,7 @@ if (m_syncedGuids.m_syncedNotebookGuids.find(notebookGuid) != m_syncedGuids.m_syncedNotebookGuids.end()) { - FEDEBUG(QStringLiteral("Found notebook for a dirty note: " - "it is synced")); + FEDEBUG("Found notebook for a dirty note: it is synced"); foundActualNotebook = true; } else @@ -1130,15 +1111,15 @@ auto dirtyNotebookIt = dirtyNotebooksByGuidHash.find(notebookGuid); if (dirtyNotebookIt != dirtyNotebooksByGuidHash.end()) { - FEDEBUG(QStringLiteral("Found notebook for a dirty note: " - "it is also marked dirty")); + FEDEBUG("Found notebook for a dirty note: " + "it is also marked dirty"); foundActualNotebook = true; } } } else { - FEWARNING(QStringLiteral("Notebook sync cache is expired")); + FEWARNING("Notebook sync cache is expired"); } if (foundActualNotebook) @@ -1146,17 +1127,16 @@ // This means the notebook for the note won't be expunged and // hence we should include the note into the list of those that // need to be updated - FETRACE(QStringLiteral("Note guid ") << guid - << QStringLiteral(" appears within the list of " - "dirty notes")); + FETRACE("Note guid " << guid + << " appears within the list of dirty notes"); dirtyNotesToUpdate << dirtyNoteIt.value(); continue; } - FEDEBUG(QStringLiteral("Found no notebook for the note which should " - "survive the purge; that means the note would " - "be expunged automatically so there's no need " - "to do anything with it; note guid = ") << guid); + FEDEBUG("Found no notebook for the note which should " + "survive the purge; that means the note would " + "be expunged automatically so there's no need " + "to do anything with it; note guid = " << guid); } } @@ -1169,11 +1149,11 @@ dirtySavedSearchesToUpdate.isEmpty() && dirtyNotesToUpdate.isEmpty()) { - FEDEBUG(QStringLiteral("Nothing is required to be updated or expunged")); + FEDEBUG("Nothing is required to be updated or expunged"); m_inProgress = false; - FEDEBUG(QStringLiteral("Emitting the finished signal")); + FEDEBUG("Emitting the finished signal"); Q_EMIT finished(); return; @@ -1191,9 +1171,9 @@ QUuid requestId = QUuid::createUuid(); Q_UNUSED(m_expungeNotebookRequestIds.insert(requestId)) - FETRACE(QStringLiteral("Emitting the request to expunge notebook: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", notebook guid = ") << guid); + FETRACE("Emitting the request to expunge notebook: " + << "request id = " << requestId + << ", notebook guid = " << guid); Q_EMIT expungeNotebook(dummyNotebook, requestId); } @@ -1211,9 +1191,9 @@ QUuid requestId = QUuid::createUuid(); Q_UNUSED(m_expungeSavedSearchRequestIds.insert(requestId)) - FETRACE(QStringLiteral("Emitting the request to expunge saved search: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", saved search guid = ") << guid); + FETRACE("Emitting the request to expunge saved search: " + << "request id = " << requestId + << ", saved search guid = " << guid); Q_EMIT expungeSavedSearch(dummySearch, requestId); } @@ -1227,8 +1207,8 @@ QUuid requestId = QUuid::createUuid(); Q_UNUSED(m_expungeNoteRequestIds.insert(requestId)) - FETRACE(QStringLiteral("Emitting the request to expunge note: request id = ") - << requestId << QStringLiteral(", note guid = ") << guid); + FETRACE("Emitting the request to expunge note: request id = " + << requestId << ", note guid = " << guid); Q_EMIT expungeNote(dummyNote, requestId); } @@ -1241,8 +1221,8 @@ QUuid requestId = QUuid::createUuid(); Q_UNUSED(m_updateNotebookRequestId.insert(requestId)) - FETRACE(QStringLiteral("Emitting the request to update notebook: request id = ") - << requestId << QStringLiteral(", notebook: ") << notebook); + FETRACE("Emitting the request to update notebook: request id = " + << requestId << ", notebook: " << notebook); Q_EMIT updateNotebook(notebook, requestId); } @@ -1255,8 +1235,8 @@ QUuid requestId = QUuid::createUuid(); Q_UNUSED(m_updateTagRequestIds.insert(requestId)) - FETRACE(QStringLiteral("Emitting the request to update tag: request id = ") - << requestId << QStringLiteral(", tag: ") << tag); + FETRACE("Emitting the request to update tag: request id = " + << requestId << ", tag: " << tag); Q_EMIT updateTag(tag, requestId); } @@ -1271,9 +1251,9 @@ QUuid requestId = QUuid::createUuid(); Q_UNUSED(m_updateSavedSearchRequestIds.insert(requestId)) - FETRACE(QStringLiteral("Emitting the request to update saved search: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", saved search: ") << search); + FETRACE("Emitting the request to update saved search: " + << "request id = " << requestId + << ", saved search: " << search); Q_EMIT updateSavedSearch(search, requestId); } @@ -1292,93 +1272,92 @@ QUuid requestId = QUuid::createUuid(); Q_UNUSED(m_updateNoteRequestIds.insert(requestId)) - FETRACE(QStringLiteral("Emitting the request to update note: request id = ") - << requestId << QStringLiteral(", note: ") << note); + FETRACE("Emitting the request to update note: request id = " + << requestId << ", note: " << note); Q_EMIT updateNote(note, LocalStorageManager::UpdateNoteOptions(0), requestId); } } void FullSyncStaleDataItemsExpunger::checkRequestsCompletionAndSendResult() { - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::" - "checkRequestsCompletionAndSendResult")); + FEDEBUG("FullSyncStaleDataItemsExpunger::checkRequestsCompletionAndSendResult"); if (!m_expungeNotebookRequestIds.isEmpty()) { - FEDEBUG(QStringLiteral("Still pending ") << m_expungeNotebookRequestIds.size() - << QStringLiteral(" expunge notebook requests")); + FEDEBUG("Still pending " << m_expungeNotebookRequestIds.size() + << " expunge notebook requests"); return; } if (!m_expungeTagRequestIds.isEmpty()) { - FEDEBUG(QStringLiteral("Still pending ") << m_expungeTagRequestIds.size() - << QStringLiteral(" expunge tag requests")); + FEDEBUG("Still pending " << m_expungeTagRequestIds.size() + << " expunge tag requests"); return; } if (!m_expungeNoteRequestIds.isEmpty()) { - FEDEBUG(QStringLiteral("Still pending ") << m_expungeNoteRequestIds.size() - << QStringLiteral(" expunge note requests")); + FEDEBUG("Still pending " << m_expungeNoteRequestIds.size() + << " expunge note requests"); return; } if (!m_expungeSavedSearchRequestIds.isEmpty()) { - FEDEBUG(QStringLiteral("Still pending ") << m_expungeSavedSearchRequestIds.size() - << QStringLiteral(" expunge saved search requests")); + FEDEBUG("Still pending " << m_expungeSavedSearchRequestIds.size() + << " expunge saved search requests"); return; } if (!m_updateNotebookRequestId.isEmpty()) { - FEDEBUG(QStringLiteral("Still pending ") << m_updateNotebookRequestId.size() - << QStringLiteral(" update notebook requests")); + FEDEBUG("Still pending " << m_updateNotebookRequestId.size() + << " update notebook requests"); return; } if (!m_updateTagRequestIds.isEmpty()) { - FEDEBUG(QStringLiteral("Still pending ") << m_updateTagRequestIds.size() - << QStringLiteral(" update tag requests")); + FEDEBUG("Still pending " << m_updateTagRequestIds.size() + << " update tag requests"); return; } if (!m_updateNoteRequestIds.isEmpty()) { - FEDEBUG(QStringLiteral("Still pending ") << m_updateNoteRequestIds.size() - << QStringLiteral(" update note requests")); + FEDEBUG("Still pending " << m_updateNoteRequestIds.size() + << " update note requests"); return; } if (!m_updateSavedSearchRequestIds.isEmpty()) { - FEDEBUG(QStringLiteral("Still pending ") << m_updateSavedSearchRequestIds.size() - << QStringLiteral(" update saved search requests")); + FEDEBUG("Still pending " << m_updateSavedSearchRequestIds.size() + << " update saved search requests"); return; } disconnectFromLocalStorage(); m_inProgress = false; - FEDEBUG(QStringLiteral("Emitting the finished signal")); + FEDEBUG("Emitting the finished signal"); Q_EMIT finished(); } void FullSyncStaleDataItemsExpunger::checkTagUpdatesCompletionAndSendExpungeTagRequests() { - FEDEBUG(QStringLiteral("FullSyncStaleDataItemsExpunger::" - "checkTagUpdatesCompletionAndSendExpungeTagRequests")); + FEDEBUG("FullSyncStaleDataItemsExpunger::" + "checkTagUpdatesCompletionAndSendExpungeTagRequests"); if (!m_updateTagRequestIds.isEmpty()) { - FEDEBUG(QStringLiteral("Still pending ") << m_updateTagRequestIds.size() - << QStringLiteral(" tag update requests")); + FEDEBUG("Still pending " << m_updateTagRequestIds.size() + << " tag update requests"); return; } if (m_tagGuidsToExpunge.isEmpty()) { - FEDEBUG(QStringLiteral("Detected no pending tag update requests but " - "there are no tags meant to be expunged - " - "either there are no such ones or because expunge " - "requests have already been sent")); + FEDEBUG("Detected no pending tag update requests but " + "there are no tags meant to be expunged - " + "either there are no such ones or because expunge " + "requests have already been sent"); return; } - FEDEBUG(QStringLiteral("Detected no pending tag update requests, " - "expunging the tags meant to be expunged")); + FEDEBUG("Detected no pending tag update requests, " + "expunging the tags meant to be expunged"); for(auto it = m_tagGuidsToExpunge.constBegin(), end = m_tagGuidsToExpunge.constEnd(); it != end; ++it) @@ -1390,8 +1369,8 @@ QUuid requestId = QUuid::createUuid(); Q_UNUSED(m_expungeTagRequestIds.insert(requestId)) - FETRACE(QStringLiteral("Emitting the request to expunge tag: request id = ") - << requestId << QStringLiteral(", tag guid = ") << guid); + FETRACE("Emitting the request to expunge tag: request id = " + << requestId << ", tag guid = " << guid); Q_EMIT expungeTag(dummyTag, requestId); } diff -Nru libquentier-0.5.0/src/synchronization/InkNoteImageDownloader.cpp libquentier-0.5.0/src/synchronization/InkNoteImageDownloader.cpp --- libquentier-0.5.0/src/synchronization/InkNoteImageDownloader.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/InkNoteImageDownloader.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -55,15 +55,16 @@ void InkNoteImageDownloader::run() { - QNDEBUG(QStringLiteral("InkNoteImageDownloader::run: host = ") << m_host - << QStringLiteral(", resource guid = ") << m_resourceGuid - << QStringLiteral(", note guid = ") << m_noteGuid - << QStringLiteral(", storage folder path = ") << m_storageFolderPath); - -#define SET_ERROR(error) \ - ErrorString errorDescription(error); \ - Q_EMIT finished(false, m_resourceGuid, m_noteGuid, errorDescription); \ - return + QNDEBUG("InkNoteImageDownloader::run: host = " << m_host + << ", resource guid = " << m_resourceGuid + << ", note guid = " << m_noteGuid + << ", storage folder path = " << m_storageFolderPath); + +#define SET_ERROR(error) \ + ErrorString errorDescription(error); \ + Q_EMIT finished(false, m_resourceGuid, m_noteGuid, errorDescription); \ + return \ +// SET_ERROR if (Q_UNLIKELY(m_host.isEmpty())) { SET_ERROR(QT_TR_NOOP("host is empty")); @@ -92,8 +93,8 @@ catch(const qevercloud::EverCloudException & everCloudException) { ErrorString errorDescription(QT_TR_NOOP("Caught EverCloudException on " - "attempt to download the ink note " - "image data")); + "attempt to download the ink " + "note image data")); auto exceptionData = everCloudException.exceptionData(); if (!exceptionData.isNull()) { errorDescription.details() = exceptionData->errorMessage; @@ -104,17 +105,18 @@ } catch(const std::exception & stdException) { - ErrorString errorDescription(QT_TR_NOOP("Caught std::exception on attempt " - "to download the ink note image " - "data")); + ErrorString errorDescription(QT_TR_NOOP("Caught std::exception on " + "attempt to download the ink " + "note image data")); errorDescription.details() = QString::fromUtf8(stdException.what()); Q_EMIT finished(false, m_resourceGuid, m_noteGuid, errorDescription); return; } catch(...) { - ErrorString errorDescription(QT_TR_NOOP("Caught unknown exception on attempt " - "to download the ink note image data")); + ErrorString errorDescription(QT_TR_NOOP("Caught unknown exception on " + "attempt to download the ink " + "note image data")); Q_EMIT finished(false, m_resourceGuid, m_noteGuid, errorDescription); return; } @@ -129,19 +131,22 @@ QDir dir(m_storageFolderPath); bool res = dir.mkpath(m_storageFolderPath); if (Q_UNLIKELY(!res)) { - SET_ERROR(QT_TR_NOOP("can't create a folder to store the ink note images in")); + SET_ERROR(QT_TR_NOOP("can't create a folder to store the ink note " + "images in")); } } else if (Q_UNLIKELY(!folderPathInfo.isDir())) { - SET_ERROR(QT_TR_NOOP("can't create a folder to store the ink note images in: " - "a file with similar name and path already exists")); + SET_ERROR(QT_TR_NOOP("can't create a folder to store the ink note " + "images in: a file with similar name and path " + "already exists")); } else if (Q_UNLIKELY(!folderPathInfo.isWritable())) { - SET_ERROR(QT_TR_NOOP("the folder for ink note images storage is not writable")); + SET_ERROR(QT_TR_NOOP("the folder for ink note images storage is not " + "writable")); } - QString filePath = m_storageFolderPath + QStringLiteral("/") + m_resourceGuid + - QStringLiteral(".png"); + QString filePath = m_storageFolderPath + QStringLiteral("/") + + m_resourceGuid + QStringLiteral(".png"); QFile file(filePath); if (Q_UNLIKELY(!file.open(QIODevice::WriteOnly))) { SET_ERROR(QT_TR_NOOP("can't open the ink note image file for writing")); diff -Nru libquentier-0.5.0/src/synchronization/INoteStore.cpp libquentier-0.5.0/src/synchronization/INoteStore.cpp --- libquentier-0.5.0/src/synchronization/INoteStore.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/INoteStore.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -20,8 +20,9 @@ namespace quentier { -INoteStore::INoteStore(const QSharedPointer<qevercloud::NoteStore> & pQecNoteStore, - QObject * parent) : +INoteStore::INoteStore( + const QSharedPointer<qevercloud::NoteStore> & pQecNoteStore, + QObject * parent) : QObject(parent), m_pQecNoteStore(pQecNoteStore) {} diff -Nru libquentier-0.5.0/src/synchronization/IUserStore.cpp libquentier-0.5.0/src/synchronization/IUserStore.cpp --- libquentier-0.5.0/src/synchronization/IUserStore.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/IUserStore.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -21,7 +21,8 @@ namespace quentier { -IUserStore::IUserStore(const QSharedPointer<qevercloud::UserStore> & pQecUserStore) : +IUserStore::IUserStore( + const QSharedPointer<qevercloud::UserStore> & pQecUserStore) : m_pQecUserStore(pQecUserStore) {} diff -Nru libquentier-0.5.0/src/synchronization/NotebookSyncCache.cpp libquentier-0.5.0/src/synchronization/NotebookSyncCache.cpp --- libquentier-0.5.0/src/synchronization/NotebookSyncCache.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/NotebookSyncCache.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -19,29 +19,33 @@ #include "NotebookSyncCache.h" #include <quentier/logging/QuentierLogger.h> -#define __NCLOG_BASE(message, level) \ - if (m_linkedNotebookGuid.isEmpty()) { \ - __QNLOG_BASE(message, level); \ - } \ - else { \ - __QNLOG_BASE(QStringLiteral("[linked notebook ") << m_linkedNotebookGuid \ - << QStringLiteral("]: ") << message, level); \ - } - -#define NCTRACE(message) \ - __NCLOG_BASE(message, Trace) - -#define NCDEBUG(message) \ - __NCLOG_BASE(message, Debug) - -#define NCWARNING(message) \ - __NCLOG_BASE(message, Warn) +#define __NCLOG_BASE(message, level) \ + if (m_linkedNotebookGuid.isEmpty()) { \ + __QNLOG_BASE(message, level); \ + } \ + else { \ + __QNLOG_BASE("[linked notebook " << m_linkedNotebookGuid << "]: " \ + << message, level); \ + } \ +// __NCLOG_BASE + +#define NCTRACE(message) \ + __NCLOG_BASE(message, Trace) \ +// NCTRACE + +#define NCDEBUG(message) \ + __NCLOG_BASE(message, Debug) \ +// NCDEBUG + +#define NCWARNING(message) \ + __NCLOG_BASE(message, Warn) \ +// NCWARNING namespace quentier { -NotebookSyncCache::NotebookSyncCache(LocalStorageManagerAsync & localStorageManagerAsync, - const QString & linkedNotebookGuid, - QObject * parent) : +NotebookSyncCache::NotebookSyncCache( + LocalStorageManagerAsync & localStorageManagerAsync, + const QString & linkedNotebookGuid, QObject * parent) : QObject(parent), m_localStorageManagerAsync(localStorageManagerAsync), m_connectedToLocalStorage(false), @@ -57,7 +61,7 @@ void NotebookSyncCache::clear() { - NCDEBUG(QStringLiteral("NotebookSyncCache::clear")); + NCDEBUG("NotebookSyncCache::clear"); disconnectFromLocalStorage(); @@ -85,11 +89,11 @@ void NotebookSyncCache::fill() { - NCDEBUG(QStringLiteral("NotebookSyncCache::fill")); + NCDEBUG("NotebookSyncCache::fill"); if (m_connectedToLocalStorage) { - NCDEBUG(QStringLiteral("Already connected to the local storage, " - "no need to do anything")); + NCDEBUG("Already connected to the local storage, " + "no need to do anything"); return; } @@ -109,13 +113,11 @@ return; } - NCDEBUG(QStringLiteral("NotebookSyncCache::onListNotebooksComplete: flag = ") - << flag << QStringLiteral(", limit = ") << limit - << QStringLiteral(", offset = ") << offset - << QStringLiteral(", order = ") << order - << QStringLiteral(", order direction = ") << orderDirection - << QStringLiteral(", linked notebook guid = ") << linkedNotebookGuid - << QStringLiteral(", request id = ") << requestId); + NCDEBUG("NotebookSyncCache::onListNotebooksComplete: flag = " + << flag << ", limit = " << limit << ", offset = " << offset + << ", order = " << order << ", order direction = " << orderDirection + << ", linked notebook guid = " << linkedNotebookGuid + << ", request id = " << requestId); for(auto it = foundNotebooks.constBegin(), end = foundNotebooks.constEnd(); it != end; ++it) @@ -126,8 +128,8 @@ m_listNotebooksRequestId = QUuid(); if (foundNotebooks.size() == static_cast<int>(limit)) { - NCTRACE(QStringLiteral("The number of found notebooks matches the limit, " - "requesting more notebooks from the local storage")); + NCTRACE("The number of found notebooks matches the limit, " + "requesting more notebooks from the local storage"); m_offset += limit; requestNotebooksList(); return; @@ -148,17 +150,15 @@ return; } - NCDEBUG(QStringLiteral("NotebookSyncCache::onListNotebooksFailed: flag = ") - << flag << QStringLiteral(", limit = ") << limit - << QStringLiteral(", offset = ") << offset - << QStringLiteral(", order = ") << order - << QStringLiteral(", order direction = ") << orderDirection - << QStringLiteral(", linked notebook guid = ") << linkedNotebookGuid - << QStringLiteral(", error description = ") << errorDescription - << QStringLiteral(", request id = ") << requestId); + NCDEBUG("NotebookSyncCache::onListNotebooksFailed: flag = " + << flag << ", limit = " << limit << ", offset = " << offset + << ", order = " << order << ", order direction = " << orderDirection + << ", linked notebook guid = " << linkedNotebookGuid + << ", error description = " << errorDescription + << ", request id = " << requestId); - NCWARNING(QStringLiteral("Failed to cache the notebook information required ") - << QStringLiteral("for the sync: ") << errorDescription); + NCWARNING("Failed to cache the notebook information required " + << "for the sync: " << errorDescription); m_notebookNameByLocalUid.clear(); m_notebookNameByGuid.clear(); @@ -169,37 +169,40 @@ Q_EMIT failure(errorDescription); } -void NotebookSyncCache::onAddNotebookComplete(Notebook notebook, QUuid requestId) +void NotebookSyncCache::onAddNotebookComplete( + Notebook notebook, QUuid requestId) { - NCDEBUG(QStringLiteral("NotebookSyncCache::onAddNotebookComplete: request id = ") - << requestId << QStringLiteral(", notebook: ") << notebook); + NCDEBUG("NotebookSyncCache::onAddNotebookComplete: request id = " + << requestId << ", notebook: " << notebook); processNotebook(notebook); } -void NotebookSyncCache::onUpdateNotebookComplete(Notebook notebook, QUuid requestId) +void NotebookSyncCache::onUpdateNotebookComplete( + Notebook notebook, QUuid requestId) { - NCDEBUG(QStringLiteral("NotebookSyncCache::onUpdateNotebookComplete: request id = ") - << requestId << QStringLiteral(", notebook: ") << notebook); + NCDEBUG("NotebookSyncCache::onUpdateNotebookComplete: request id = " + << requestId << ", notebook: " << notebook); removeNotebook(notebook.localUid()); processNotebook(notebook); } -void NotebookSyncCache::onExpungeNotebookComplete(Notebook notebook, QUuid requestId) +void NotebookSyncCache::onExpungeNotebookComplete( + Notebook notebook, QUuid requestId) { - NCDEBUG(QStringLiteral("NotebookSyncCache::onExpungeNotebookComplete: request id = ") - << requestId << QStringLiteral(", notebook: ") << notebook); + NCDEBUG("NotebookSyncCache::onExpungeNotebookComplete: request id = " + << requestId << ", notebook: " << notebook); removeNotebook(notebook.localUid()); } void NotebookSyncCache::connectToLocalStorage() { - NCDEBUG(QStringLiteral("NotebookSyncCache::connectToLocalStorage")); + NCDEBUG("NotebookSyncCache::connectToLocalStorage"); if (m_connectedToLocalStorage) { - NCDEBUG(QStringLiteral("Already connected to the local storage")); + NCDEBUG("Already connected to the local storage"); return; } @@ -278,10 +281,10 @@ void NotebookSyncCache::disconnectFromLocalStorage() { - NCDEBUG(QStringLiteral("NotebookSyncCache::disconnectFromLocalStorage")); + NCDEBUG("NotebookSyncCache::disconnectFromLocalStorage"); if (!m_connectedToLocalStorage) { - NCDEBUG(QStringLiteral("Not connected to local storage at the moment")); + NCDEBUG("Not connected to local storage at the moment"); return; } @@ -354,12 +357,12 @@ void NotebookSyncCache::requestNotebooksList() { - NCDEBUG(QStringLiteral("NotebookSyncCache::requestNotebooksList")); + NCDEBUG("NotebookSyncCache::requestNotebooksList"); m_listNotebooksRequestId = QUuid::createUuid(); - NCTRACE(QStringLiteral("Emitting the request to list notebooks: request id = ") - << m_listNotebooksRequestId << QStringLiteral(", offset = ") << m_offset); + NCTRACE("Emitting the request to list notebooks: request id = " + << m_listNotebooksRequestId << ", offset = " << m_offset); Q_EMIT listNotebooks(LocalStorageManager::ListAll, m_limit, m_offset, LocalStorageManager::ListNotebooksOrder::NoOrder, @@ -370,13 +373,12 @@ void NotebookSyncCache::removeNotebook(const QString & notebookLocalUid) { - NCDEBUG(QStringLiteral("NotebookSyncCache::removeNotebook: local uid = ") + NCDEBUG("NotebookSyncCache::removeNotebook: local uid = " << notebookLocalUid); auto localUidIt = m_notebookNameByLocalUid.find(notebookLocalUid); if (Q_UNLIKELY(localUidIt == m_notebookNameByLocalUid.end())) { - NCDEBUG(QStringLiteral("The notebook name was not found in the cache " - "by local uid")); + NCDEBUG("The notebook name was not found in the cache by local uid"); return; } @@ -385,8 +387,7 @@ auto guidIt = m_notebookGuidByName.find(name); if (Q_UNLIKELY(guidIt == m_notebookGuidByName.end())) { - NCDEBUG(QStringLiteral("The notebook guid was not found in the cache " - "by name")); + NCDEBUG("The notebook guid was not found in the cache by name"); return; } @@ -400,8 +401,7 @@ auto nameIt = m_notebookNameByGuid.find(guid); if (Q_UNLIKELY(nameIt == m_notebookNameByGuid.end())) { - NCDEBUG(QStringLiteral("The notebook name was not found in the cache " - "by guid")); + NCDEBUG("The notebook name was not found in the cache by guid"); return; } @@ -410,7 +410,7 @@ void NotebookSyncCache::processNotebook(const Notebook & notebook) { - NCDEBUG(QStringLiteral("NotebookSyncCache::processNotebook: ") << notebook); + NCDEBUG("NotebookSyncCache::processNotebook: " << notebook); if (notebook.hasGuid()) { @@ -428,7 +428,7 @@ } if (!notebook.hasName()) { - NCDEBUG(QStringLiteral("Skipping the notebook without a name")); + NCDEBUG("Skipping the notebook without a name"); return; } diff -Nru libquentier-0.5.0/src/synchronization/NotebookSyncConflictResolver.cpp libquentier-0.5.0/src/synchronization/NotebookSyncConflictResolver.cpp --- libquentier-0.5.0/src/synchronization/NotebookSyncConflictResolver.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/NotebookSyncConflictResolver.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -46,10 +46,10 @@ void NotebookSyncConflictResolver::start() { - QNDEBUG(QStringLiteral("NotebookSyncConflictResolver::start")); + QNDEBUG("NotebookSyncConflictResolver::start"); if (Q_UNLIKELY(m_started)) { - QNDEBUG(QStringLiteral("Already started")); + QNDEBUG("Already started"); return; } @@ -59,7 +59,7 @@ ErrorString error(QT_TR_NOOP("Can't resolve the conflict between remote " "and local notebooks: the remote notebook " "has no guid set")); - QNWARNING(error << QStringLiteral(": ") << m_remoteNotebook); + QNWARNING(error << ": " << m_remoteNotebook); Q_EMIT failure(m_remoteNotebook, error); return; } @@ -68,7 +68,7 @@ ErrorString error(QT_TR_NOOP("Can't resolve the conflict between remote " "and local notebooks: the remote notebook " "has no name set")); - QNWARNING(error << QStringLiteral(": ") << m_remoteNotebook); + QNWARNING(error << ": " << m_remoteNotebook); Q_EMIT failure(m_remoteNotebook, error); return; } @@ -77,7 +77,7 @@ ErrorString error(QT_TR_NOOP("Can't resolve the conflict between remote " "and local notebooks: the local conflicting " "notebook has neither guid nor name set")); - QNWARNING(error << QStringLiteral(": ") << m_localConflict); + QNWARNING(error << ": " << m_localConflict); Q_EMIT failure(m_remoteNotebook, error); return; } @@ -95,71 +95,67 @@ } } -void NotebookSyncConflictResolver::onAddNotebookComplete(Notebook notebook, - QUuid requestId) +void NotebookSyncConflictResolver::onAddNotebookComplete( + Notebook notebook, QUuid requestId) { if (requestId != m_addNotebookRequestId) { return; } - QNDEBUG(QStringLiteral("NotebookSyncConflictResolver::onAddNotebookComplete: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", notebook: ") << notebook); + QNDEBUG("NotebookSyncConflictResolver::onAddNotebookComplete: " + << "request id = " << requestId << ", notebook: " << notebook); if (m_state == State::PendingRemoteNotebookAdoptionInLocalStorage) { - QNDEBUG(QStringLiteral("Successfully added the remote notebook " - "to the local storage")); + QNDEBUG("Successfully added the remote notebook " + "to the local storage"); Q_EMIT finished(m_remoteNotebook); } else { ErrorString error(QT_TR_NOOP("Internal error: wrong state on receiving " - "the confirmation about the notebook addition " - "from the local storage")); - QNWARNING(error << QStringLiteral(", notebook: ") << notebook); + "the confirmation about the notebook " + "addition from the local storage")); + QNWARNING(error << ", notebook: " << notebook); Q_EMIT failure(m_remoteNotebook, error); } } -void NotebookSyncConflictResolver::onAddNotebookFailed(Notebook notebook, - ErrorString errorDescription, - QUuid requestId) +void NotebookSyncConflictResolver::onAddNotebookFailed( + Notebook notebook, ErrorString errorDescription, QUuid requestId) { if (requestId != m_addNotebookRequestId) { return; } - QNDEBUG(QStringLiteral("NotebookSyncConflictResolver::onAddNotebookFailed: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", error description = ") << errorDescription - << QStringLiteral("; notebook: ") << notebook); + QNDEBUG("NotebookSyncConflictResolver::onAddNotebookFailed: " + << "request id = " << requestId + << ", error description = " << errorDescription + << "; notebook: " << notebook); Q_EMIT failure(m_remoteNotebook, errorDescription); } -void NotebookSyncConflictResolver::onUpdateNotebookComplete(Notebook notebook, - QUuid requestId) +void NotebookSyncConflictResolver::onUpdateNotebookComplete( + Notebook notebook, QUuid requestId) { if (requestId != m_updateNotebookRequestId) { return; } - QNDEBUG(QStringLiteral("NotebookSyncConflictResolver::onUpdateNotebookComplete: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", notebook: ") << notebook); + QNDEBUG("NotebookSyncConflictResolver::onUpdateNotebookComplete: " + << "request id = " << requestId << ", notebook: " << notebook); if (m_state == State::OverrideLocalChangesWithRemoteChanges) { - QNDEBUG(QStringLiteral("Successfully overridden the local changes with " - "remote changes")); + QNDEBUG("Successfully overridden the local changes with remote changes"); Q_EMIT finished(m_remoteNotebook); return; } else if (m_state == State::PendingConflictingNotebookRenaming) { - QNDEBUG(QStringLiteral("Successfully renamed the local notebook conflicting " - "by name with the remote notebook")); + QNDEBUG("Successfully renamed the local notebook conflicting " + "by name with the remote notebook"); // Now need to find the duplicate of the remote notebook by guid: // 1) if one exists, update it from the remote changes - notwithstanding @@ -183,9 +179,8 @@ auto it = nameByGuidHash.find(m_remoteNotebook.guid.ref()); if (it == nameByGuidHash.end()) { - QNDEBUG(QStringLiteral("Found no duplicate of the remote notebook " - "by guid, adding new notebook to the local " - "storage")); + QNDEBUG("Found no duplicate of the remote notebook by guid, adding " + "new notebook to the local storage"); Notebook notebook(m_remoteNotebook); notebook.setLinkedNotebookGuid(m_remoteNotebookLinkedNotebookGuid); @@ -193,17 +188,15 @@ notebook.setLocal(false); m_addNotebookRequestId = QUuid::createUuid(); - QNTRACE(QStringLiteral("Emitting the request to add notebook: ") - << QStringLiteral("request id = ") - << m_addNotebookRequestId << QStringLiteral(", notebook: ") + QNTRACE("Emitting the request to add notebook: request id = " + << m_addNotebookRequestId << ", notebook: " << notebook); Q_EMIT addNotebook(notebook, m_addNotebookRequestId); } else { - QNDEBUG(QStringLiteral("The duplicate by guid exists in the local " - "storage, updating it with the state " - "of the remote notebook")); + QNDEBUG("The duplicate by guid exists in the local storage, " + "updating it with the state of the remote notebook"); Notebook notebook(m_localConflict); notebook.qevercloudNotebook() = m_remoteNotebook; @@ -212,16 +205,16 @@ notebook.setLocal(false); m_updateNotebookRequestId = QUuid::createUuid(); - QNTRACE(QStringLiteral("Emitting the request to update notebook: ") - << QStringLiteral("request id = ") << m_updateNotebookRequestId - << QStringLiteral(", notebook: ") << notebook); + QNTRACE("Emitting the request to update notebook: " + << "request id = " << m_updateNotebookRequestId + << ", notebook: " << notebook); Q_EMIT updateNotebook(notebook, m_updateNotebookRequestId); } } else if (m_state == State::PendingRemoteNotebookAdoptionInLocalStorage) { - QNDEBUG(QStringLiteral("Successfully finalized the sequence of actions " - "required for resolving the conflict of notebooks")); + QNDEBUG("Successfully finalized the sequence of actions " + "required for resolving the conflict of notebooks"); Q_EMIT finished(m_remoteNotebook); } else @@ -229,37 +222,35 @@ ErrorString error(QT_TR_NOOP("Internal error: wrong state on receiving " "the confirmation about the notebook update " "from the local storage")); - QNWARNING(error << QStringLiteral(", notebook: ") << notebook); + QNWARNING(error << ", notebook: " << notebook); Q_EMIT failure(m_remoteNotebook, error); } } -void NotebookSyncConflictResolver::onUpdateNotebookFailed(Notebook notebook, - ErrorString errorDescription, - QUuid requestId) +void NotebookSyncConflictResolver::onUpdateNotebookFailed( + Notebook notebook, ErrorString errorDescription, QUuid requestId) { if (requestId != m_updateNotebookRequestId) { return; } - QNDEBUG(QStringLiteral("NotebookSyncConflictResolver::onUpdateNotebookFailed: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", error description = ") << errorDescription - << QStringLiteral("; notebook: ") << notebook); + QNDEBUG("NotebookSyncConflictResolver::onUpdateNotebookFailed: " + << "request id = " << requestId + << ", error description = " << errorDescription + << "; notebook: " << notebook); Q_EMIT failure(m_remoteNotebook, errorDescription); } -void NotebookSyncConflictResolver::onFindNotebookComplete(Notebook notebook, - QUuid requestId) +void NotebookSyncConflictResolver::onFindNotebookComplete( + Notebook notebook, QUuid requestId) { if (requestId != m_findNotebookRequestId) { return; } - QNDEBUG(QStringLiteral("NotebookSyncConflictResolver::onFindNotebookComplete: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", notebook: ") << notebook); + QNDEBUG("NotebookSyncConflictResolver::onFindNotebookComplete: " + << "request id = " << requestId << ", notebook: " << notebook); m_findNotebookRequestId = QUuid(); @@ -267,18 +258,17 @@ processNotebooksConflictByName(notebook); } -void NotebookSyncConflictResolver::onFindNotebookFailed(Notebook notebook, - ErrorString errorDescription, - QUuid requestId) +void NotebookSyncConflictResolver::onFindNotebookFailed( + Notebook notebook, ErrorString errorDescription, QUuid requestId) { if (requestId != m_findNotebookRequestId) { return; } - QNDEBUG(QStringLiteral("NotebookSyncConflictResolver::onFindNotebookFailed: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", error description = ") << errorDescription - << QStringLiteral(", notebook: ") << notebook); + QNDEBUG("NotebookSyncConflictResolver::onFindNotebookFailed: " + << "request id = " << requestId + << ", error description = " << errorDescription + << ", notebook: " << notebook); m_findNotebookRequestId = QUuid(); @@ -289,10 +279,10 @@ void NotebookSyncConflictResolver::onCacheFilled() { - QNDEBUG(QStringLiteral("NotebookSyncConflictResolver::onCacheFilled")); + QNDEBUG("NotebookSyncConflictResolver::onCacheFilled"); if (!m_pendingCacheFilling) { - QNDEBUG(QStringLiteral("Not pending the cache filling")); + QNDEBUG("Not pending the cache filling"); return; } @@ -305,19 +295,19 @@ else { ErrorString error(QT_TR_NOOP("Internal error: wrong state on receiving " - "the notebook info cache filling notification")); - QNWARNING(error << QStringLiteral(", state = ") << m_state); + "the notebook info cache filling " + "notification")); + QNWARNING(error << ", state = " << m_state); Q_EMIT failure(m_remoteNotebook, error); } } void NotebookSyncConflictResolver::onCacheFailed(ErrorString errorDescription) { - QNDEBUG(QStringLiteral("NotebookSyncConflictResolver::onCacheFailed: ") - << errorDescription); + QNDEBUG("NotebookSyncConflictResolver::onCacheFailed: " << errorDescription); if (!m_pendingCacheFilling) { - QNDEBUG(QStringLiteral("Not pending the cache filling")); + QNDEBUG("Not pending the cache filling"); return; } @@ -327,7 +317,7 @@ void NotebookSyncConflictResolver::connectToLocalStorage() { - QNDEBUG(QStringLiteral("NotebookSyncConflictResolver::connectToLocalStorage")); + QNDEBUG("NotebookSyncConflictResolver::connectToLocalStorage"); // Connect local signals to local storage manager async's slots QObject::connect(this, @@ -399,7 +389,7 @@ void NotebookSyncConflictResolver::processNotebooksConflictByGuid() { - QNDEBUG(QStringLiteral("NotebookSyncConflictResolver::processNotebooksConflictByGuid")); + QNDEBUG("NotebookSyncConflictResolver::processNotebooksConflictByGuid"); // Need to understand whether there's a duplicate by name in the local storage // for the new state of the remote notebook @@ -410,11 +400,11 @@ auto it = guidByNameHash.find(m_remoteNotebook.name.ref().toLower()); if (it == guidByNameHash.end()) { - QNDEBUG(QStringLiteral("As deduced by the existing notebook info cache, " - "there is no local notebook with the same name " - "as the name from the new state of the remote " - "notebook, can safely override the local changes " - "with the remote changes: ") << m_remoteNotebook); + QNDEBUG("As deduced by the existing notebook info cache, " + "there is no local notebook with the same name " + "as the name from the new state of the remote " + "notebook, can safely override the local changes " + "with the remote changes: " << m_remoteNotebook); overrideLocalChangesWithRemoteChanges(); return; } @@ -426,28 +416,28 @@ dummyNotebook.unsetLocalUid(); dummyNotebook.setName(m_remoteNotebook.name.ref()); m_findNotebookRequestId = QUuid::createUuid(); - QNTRACE(QStringLiteral("Emitting the request to find notebook by name: request id = ") - << m_findNotebookRequestId << QStringLiteral(", notebook: ") << dummyNotebook); + QNTRACE("Emitting the request to find notebook by name: request id = " + << m_findNotebookRequestId << ", notebook: " << dummyNotebook); Q_EMIT findNotebook(dummyNotebook, m_findNotebookRequestId); } void NotebookSyncConflictResolver::processNotebooksConflictByName( const Notebook & localConflict) { - QNDEBUG(QStringLiteral("NotebookSyncConflictResolver::processNotebooksConflictByName: ") - << QStringLiteral("local conflict = ") << localConflict); + QNDEBUG("NotebookSyncConflictResolver::processNotebooksConflictByName: " + << "local conflict = " << localConflict); if (localConflict.hasGuid() && (localConflict.guid() == m_remoteNotebook.guid.ref())) { - QNDEBUG(QStringLiteral("The conflicting notebooks match by name and guid => " - "the changes from the remote notebook should just " - "override the local changes")); + QNDEBUG("The conflicting notebooks match by name and guid => " + "the changes from the remote notebook should just " + "override the local changes"); overrideLocalChangesWithRemoteChanges(); return; } - QNDEBUG(QStringLiteral("The conflicting notebooks match by name but not by guid")); + QNDEBUG("The conflicting notebooks match by name but not by guid"); QString localConflictLinkedNotebookGuid; if (localConflict.hasLinkedNotebookGuid()) { @@ -456,11 +446,11 @@ if (localConflictLinkedNotebookGuid != m_remoteNotebookLinkedNotebookGuid) { - QNDEBUG(QStringLiteral("The notebooks conflicting by name don't have " - "matching linked notebook guids => they are either " - "from user's own account and a linked notebook or " - "from two different linked notebooks => can just " - "add the remote linked notebook to the local storage")); + QNDEBUG("The notebooks conflicting by name don't have " + "matching linked notebook guids => they are either " + "from user's own account and a linked notebook or " + "from two different linked notebooks => can just " + "add the remote linked notebook to the local storage"); m_state = State::PendingRemoteNotebookAdoptionInLocalStorage; @@ -470,8 +460,8 @@ notebook.setLocal(false); m_addNotebookRequestId = QUuid::createUuid(); - QNTRACE(QStringLiteral("Emitting the request to add notebook: request id = ") - << m_addNotebookRequestId << QStringLiteral(", notebook: ") << notebook); + QNTRACE("Emitting the request to add notebook: request id = " + << m_addNotebookRequestId << ", notebook: " << notebook); Q_EMIT addNotebook(notebook, m_addNotebookRequestId); return; } @@ -481,16 +471,15 @@ // so won't implement it here; who knows, maybe some day Evernote would // actually allow to map two notebooks to a single linked notebook - QNDEBUG(QStringLiteral("Both conflicting notebooks are from user's own account " - "or from the same linked notebook => should rename " - "the local conflicting notebook to \"free\" the name " - "it occupies")); + QNDEBUG("Both conflicting notebooks are from user's own account or from " + "the same linked notebook => should rename the local conflicting " + "notebook to \"free\" the name it occupies"); m_state = State::PendingConflictingNotebookRenaming; if (!m_cache.isFilled()) { - QNDEBUG(QStringLiteral("The cache of notebook info has not been filled yet")); + QNDEBUG("The cache of notebook info has not been filled yet"); QObject::connect(&m_cache, QNSIGNAL(NotebookSyncCache,filled), @@ -508,19 +497,19 @@ m_pendingCacheFilling = true; m_notebookToBeRenamed = localConflict; - QNTRACE(QStringLiteral("Emitting the request to fill the notebooks cache")); + QNTRACE("Emitting the request to fill the notebooks cache"); Q_EMIT fillNotebooksCache(); return; } - QNDEBUG(QStringLiteral("The cache of notebook info has already been filled")); + QNDEBUG("The cache of notebook info has already been filled"); renameConflictingLocalNotebook(localConflict); } void NotebookSyncConflictResolver::overrideLocalChangesWithRemoteChanges() { - QNDEBUG(QStringLiteral("NotebookSyncConflictResolver::" - "overrideLocalChangesWithRemoteChanges")); + QNDEBUG("NotebookSyncConflictResolver::" + "overrideLocalChangesWithRemoteChanges"); m_state = State::OverrideLocalChangesWithRemoteChanges; @@ -541,16 +530,16 @@ } m_updateNotebookRequestId = QUuid::createUuid(); - QNTRACE(QStringLiteral("Emitting the request to update notebook: request id = ") - << m_updateNotebookRequestId << QStringLiteral(", notebook: ") << notebook); + QNTRACE("Emitting the request to update notebook: request id = " + << m_updateNotebookRequestId << ", notebook: " << notebook); Q_EMIT updateNotebook(notebook, m_updateNotebookRequestId); } void NotebookSyncConflictResolver::renameConflictingLocalNotebook( const Notebook & localConflict) { - QNDEBUG(QStringLiteral("NotebookSyncConflictResolver::") - << QStringLiteral("renameConflictingLocalNotebook: local conflict = ") + QNDEBUG("NotebookSyncConflictResolver::" + << "renameConflictingLocalNotebook: local conflict = " << localConflict); QString name = (localConflict.hasName() @@ -579,8 +568,8 @@ notebook.setDirty(true); m_updateNotebookRequestId = QUuid::createUuid(); - QNTRACE(QStringLiteral("Emitting the request to update notebook: request id = ") - << m_updateNotebookRequestId << QStringLiteral(", notebook: ") << notebook); + QNTRACE("Emitting the request to update notebook: request id = " + << m_updateNotebookRequestId << ", notebook: " << notebook); Q_EMIT updateNotebook(notebook, m_updateNotebookRequestId); } diff -Nru libquentier-0.5.0/src/synchronization/NoteStore.cpp libquentier-0.5.0/src/synchronization/NoteStore.cpp --- libquentier-0.5.0/src/synchronization/NoteStore.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/NoteStore.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -28,18 +28,21 @@ namespace quentier { -#define SET_EDAM_USER_EXCEPTION_ERROR(userException) \ - errorDescription.setBase(QT_TRANSLATE_NOOP("NoteStore", \ +#define SET_EDAM_USER_EXCEPTION_ERROR(userException) \ + errorDescription.setBase(QT_TRANSLATE_NOOP("NoteStore", \ "caught EDAM user exception")); \ - errorDescription.details() = QStringLiteral("error code"); \ - errorDescription.details() += ToString(userException.errorCode); \ - if (!userException.exceptionData().isNull()) { \ - errorDescription.details() += QStringLiteral(": "); \ - errorDescription.details() += userException.exceptionData()->errorMessage; \ - } - -NoteStore::NoteStore(const QSharedPointer<qevercloud::NoteStore> & pQecNoteStore, - QObject * parent) : + errorDescription.details() = QStringLiteral("error code"); \ + errorDescription.details() += ToString(userException.errorCode); \ + if (!userException.exceptionData().isNull()) { \ + errorDescription.details() += QStringLiteral(": "); \ + errorDescription.details() += \ + userException.exceptionData()->errorMessage; \ + } \ +// SET_EDAM_USER_EXCEPTION_ERROR + +NoteStore::NoteStore( + const QSharedPointer<qevercloud::NoteStore> & pQecNoteStore, + QObject * parent) : INoteStore(pQecNoteStore, parent), m_noteGuidByAsyncResultPtr(), m_resourceGuidByAsyncResultPtr() @@ -54,12 +57,13 @@ INoteStore * NoteStore::create() const { - return new NoteStore(QSharedPointer<qevercloud::NoteStore>(new qevercloud::NoteStore)); + return new NoteStore( + QSharedPointer<qevercloud::NoteStore>(new qevercloud::NoteStore)); } void NoteStore::stop() { - QNDEBUG(QStringLiteral("NoteStore::stop")); + QNDEBUG("NoteStore::stop"); for(auto it = m_noteGuidByAsyncResultPtr.begin(), end = m_noteGuidByAsyncResultPtr.end(); it != end; ++it) @@ -168,7 +172,7 @@ qevercloud::Note noteMetadata = m_pQecNoteStore->createNote(note.qevercloudNote(), linkedNotebookAuthToken); - QNDEBUG(QStringLiteral("Note metadata returned from createNote method: ") + QNDEBUG("Note metadata returned from createNote method: " << noteMetadata); if (noteMetadata.guid.isSet()) { @@ -207,7 +211,7 @@ qevercloud::Note noteMetadata = m_pQecNoteStore->updateNote(note.qevercloudNote(), linkedNotebookAuthToken); - QNDEBUG(QStringLiteral("Note metadata returned from updateNote method: ") + QNDEBUG("Note metadata returned from updateNote method: " << noteMetadata); if (noteMetadata.guid.isSet()) { @@ -331,7 +335,8 @@ { try { - qint32 usn = m_pQecNoteStore->updateSearch(savedSearch.qevercloudSavedSearch()); + qint32 usn = + m_pQecNoteStore->updateSearch(savedSearch.qevercloudSavedSearch()); savedSearch.setUpdateSequenceNumber(usn); return 0; } @@ -385,9 +390,9 @@ ErrorString & errorDescription, qint32 & rateLimitSeconds) { - QNDEBUG(QStringLiteral("NoteStore::getSyncChunk: after USN = ") << afterUSN - << QStringLiteral(", max entries = ") << maxEntries - << QStringLiteral(", sync chunk filter = ") << filter); + QNDEBUG("NoteStore::getSyncChunk: after USN = " << afterUSN + << ", max entries = " << maxEntries + << ", sync chunk filter = " << filter); try { @@ -455,11 +460,10 @@ const bool fullSyncOnly, qevercloud::SyncChunk & syncChunk, ErrorString & errorDescription, qint32 & rateLimitSeconds) { - QNDEBUG(QStringLiteral("NoteStore::getLinkedNotebookSyncChunk: linked notebook: ") - << linkedNotebook << QStringLiteral("\nAfter USN = ") << afterUSN - << QStringLiteral(", max entries = ") << maxEntries - << QStringLiteral(", full sync only = ") - << (fullSyncOnly ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("NoteStore::getLinkedNotebookSyncChunk: linked notebook: " + << linkedNotebook << "\nAfter USN = " << afterUSN + << ", max entries = " << maxEntries << ", full sync only = " + << (fullSyncOnly ? "true" : "false")); try { @@ -525,22 +529,22 @@ Note & note, ErrorString & errorDescription, qint32 & rateLimitSeconds) { - QNDEBUG(QStringLiteral("NoteStore::getNote: with content = ") + QNDEBUG("NoteStore::getNote: with content = " << (withContent - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with resources data = ") + ? "true" + : "false") + << ", with resources data = " << (withResourcesData - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with resources recognition = ") + ? "true" + : "false") + << ", with resources recognition = " << (withResourcesRecognition - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with resources alternate data = ") + ? "true" + : "false") + << ", with resources alternate data = " << (withResourceAlternateData - ? QStringLiteral("true") - : QStringLiteral("false"))); + ? "true" + : "false")); if (!note.hasGuid()) { errorDescription.setBase(QT_TR_NOOP("can't get note: note's guid is empty")); @@ -589,39 +593,39 @@ const QString & authToken, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("NoteStore::getNoteAsync: with content = ") + QNDEBUG("NoteStore::getNoteAsync: with content = " << (withContent - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with resource data = ") + ? "true" + : "false") + << ", with resource data = " << (withResourceData - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with resource recognition = ") + ? "true" + : "false") + << ", with resource recognition = " << (withResourcesRecognition - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with resource alternate data = ") + ? "true" + : "false") + << ", with resource alternate data = " << (withResourceAlternateData - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with shared notes = ") + ? "true" + : "false") + << ", with shared notes = " << (withSharedNotes - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with note app data values = ") + ? "true" + : "false") + << ", with note app data values = " << (withNoteAppDataValues - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with resource app data values = ") + ? "true" + : "false") + << ", with resource app data values = " << (withResourceAppDataValues - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with note limits = ") + ? "true" + : "false") + << ", with note limits = " << (withNoteLimits - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", note guid = ") << noteGuid); + ? "true" + : "false") + << ", note guid = " << noteGuid); if (Q_UNLIKELY(noteGuid.isEmpty())) { errorDescription.setBase(QT_TR_NOOP("Detected the attempt to get full " @@ -638,7 +642,7 @@ noteResultSpec.includeNoteAppDataValues = withNoteAppDataValues; noteResultSpec.includeResourceAppDataValues = withResourceAppDataValues; noteResultSpec.includeAccountLimits = withNoteLimits; - QNTRACE(QStringLiteral("Note result spec: ") << noteResultSpec); + QNTRACE("Note result spec: " << noteResultSpec); qevercloud::AsyncResult * pAsyncResult = m_pQecNoteStore->getNoteWithResultSpecAsync(noteGuid, noteResultSpec, @@ -671,23 +675,23 @@ ErrorString & errorDescription, qint32 & rateLimitSeconds) { - QNDEBUG(QStringLiteral("NoteStore::getResource: with data body = ") + QNDEBUG("NoteStore::getResource: with data body = " << (withDataBody - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with recognition data body = ") + ? "true" + : "false") + << ", with recognition data body = " << (withRecognitionDataBody - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with alternate data body = ") + ? "true" + : "false") + << ", with alternate data body = " << (withAlternateDataBody - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with attributes = ") + ? "true" + : "false") + << ", with attributes = " << (withAttributes - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", resource guid = ") + ? "true" + : "false") + << ", resource guid = " << (resource.hasGuid() ? resource.guid() : QStringLiteral("<not set>"))); @@ -737,23 +741,23 @@ const QString & authToken, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("NoteStore::getResourceAsync: with data body = ") + QNDEBUG("NoteStore::getResourceAsync: with data body = " << (withDataBody - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with recognition data body = ") + ? "true" + : "false") + << ", with recognition data body = " << (withRecognitionDataBody - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with alternate data body = ") + ? "true" + : "false") + << ", with alternate data body = " << (withAlternateDataBody - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with attributes = ") + ? "true" + : "false") + << ", with attributes = " << (withAttributes - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", resource guid = ") << resourceGuid); + ? "true" + : "false") + << ", resource guid = " << resourceGuid); if (Q_UNLIKELY(resourceGuid.isEmpty())) { errorDescription.setBase(QT_TR_NOOP("Detected the attempt to get full " @@ -866,7 +870,7 @@ void NoteStore::onGetNoteAsyncFinished( QVariant result, QSharedPointer<EverCloudExceptionData> exceptionData) { - QNDEBUG(QStringLiteral("NoteStore::onGetNoteAsyncFinished")); + QNDEBUG("NoteStore::onGetNoteAsyncFinished"); QString noteGuid; @@ -880,15 +884,14 @@ Q_UNUSED(m_noteGuidByAsyncResultPtr.erase(it)) } else { - QNDEBUG(QStringLiteral("Couldn't find the note guid by async result ptr")); + QNDEBUG("Couldn't find the note guid by async result ptr"); return; } } else { - QNDEBUG(QStringLiteral("Couldn't get non-NULL pointer to AsyncResult, " - "hence can't get the note guid to which the result " - "corresponds")); + QNDEBUG("Couldn't get non-NULL pointer to AsyncResult, hence can't " + "get the note guid to which the result corresponds"); return; } @@ -901,7 +904,7 @@ if (!exceptionData.isNull()) { - QNDEBUG(QStringLiteral("Error: ") << exceptionData->errorMessage); + QNDEBUG("Error: " << exceptionData->errorMessage); try { @@ -936,7 +939,7 @@ void NoteStore::onGetResourceAsyncFinished( QVariant result, QSharedPointer<EverCloudExceptionData> exceptionData) { - QNDEBUG(QStringLiteral("NoteStore::onGetResourceAsyncFinished")); + QNDEBUG("NoteStore::onGetResourceAsyncFinished"); QString resourceGuid; @@ -950,16 +953,14 @@ Q_UNUSED(m_resourceGuidByAsyncResultPtr.erase(it)) } else { - QNDEBUG(QStringLiteral("Couldn't find the resource guid by async " - "result ptr")); + QNDEBUG("Couldn't find the resource guid by async result ptr"); return; } } else { - QNDEBUG(QStringLiteral("Couldn't get non-NULL pointer to AsyncResult, " - "hence can't get the resource guid " - "to which the result corresponds")); + QNDEBUG("Couldn't get non-NULL pointer to AsyncResult, hence can't get " + "the resource guid to which the result corresponds"); return; } @@ -972,7 +973,7 @@ if (!exceptionData.isNull()) { - QNDEBUG(QStringLiteral("Error: ") << exceptionData->errorMessage); + QNDEBUG("Error: " << exceptionData->errorMessage); try { @@ -1214,8 +1215,7 @@ errorDescription.appendBase(QT_TR_NOOP("invalid length of saved " "search's query")); errorDescription.details() = QString::number(search.query().length()); - QNWARNING(errorDescription << QStringLiteral(", query: ") - << search.query()); + QNWARNING(errorDescription << ", query: " << search.query()); } else { @@ -1698,7 +1698,7 @@ errorDescription.appendBase(QT_TR_NOOP("invalid length for note's " "ENML content")); errorDescription.details() = QString::number(note.content().length()); - QNWARNING(errorDescription << QStringLiteral(", note's content: ") + QNWARNING(errorDescription << ", note's content: " << note.content()); } else @@ -1706,35 +1706,36 @@ errorDescription.appendBase(QT_TR_NOOP("note has no content")); } } - else if (userException.parameter.ref().startsWith(QStringLiteral("NoteAttributes."))) + else if (userException.parameter.ref().startsWith( + QStringLiteral("NoteAttributes."))) { if (note.hasNoteAttributes()) { errorDescription.appendBase(QT_TR_NOOP("invalid note attributes")); - QNWARNING(errorDescription << QStringLiteral(": ") - << note.noteAttributes()); + QNWARNING(errorDescription << ": " << note.noteAttributes()); } else { errorDescription.appendBase(QT_TR_NOOP("note has no attributes")); } } - else if (userException.parameter.ref().startsWith(QStringLiteral("ResourceAttributes."))) + else if (userException.parameter.ref().startsWith( + QStringLiteral("ResourceAttributes."))) { errorDescription.appendBase(QT_TR_NOOP("invalid resource attributes " "for some of note's resources")); - QNWARNING(errorDescription << QStringLiteral(", note: ") << note); + QNWARNING(errorDescription << ", note: " << note); } else if (userException.parameter.ref() == QStringLiteral("Resource.mime")) { errorDescription.appendBase(QT_TR_NOOP("invalid mime type for some " "of note's resources")); - QNWARNING(errorDescription << QStringLiteral(", note: ") << note); + QNWARNING(errorDescription << ", note: " << note); } else if (userException.parameter.ref() == QStringLiteral("Tag.name")) { errorDescription.appendBase(QT_TR_NOOP("Note.tagNames was provided " "and one of the specified tags " "had invalid length or pattern")); - QNWARNING(errorDescription << QStringLiteral(", note: ") << note); + QNWARNING(errorDescription << ", note: " << note); } else { errorDescription.appendBase(QT_TR_NOOP("unexpected parameter")); @@ -1801,7 +1802,7 @@ if (userException.parameter.ref() == QStringLiteral("Resource.data")) { errorDescription.appendBase(QT_TR_NOOP("data body for some of note's " "resources is missing")); - QNWARNING(errorDescription << QStringLiteral(", note: ") << note); + QNWARNING(errorDescription << ", note: " << note); } else { errorDescription.appendBase(QT_TR_NOOP("unexpected parameter")); @@ -1823,7 +1824,7 @@ errorDescription.appendBase(QT_TR_NOOP("note's content doesn't validate " "against DTD")); - QNWARNING(errorDescription << QStringLiteral(", note: ") << note); + QNWARNING(errorDescription << ", note: " << note); return userException.errorCode; } else if (userException.errorCode == qevercloud::EDAMErrorCode::LIMIT_REACHED) @@ -1866,26 +1867,29 @@ { errorDescription.appendBase(QT_TR_NOOP("too many tags on note")); } - else if (userException.parameter.ref() == QStringLiteral("Resource.data.size")) + else if (userException.parameter.ref() == + QStringLiteral("Resource.data.size")) { errorDescription.appendBase(QT_TR_NOOP("one of note's resource's data " "is too large")); } - else if (userException.parameter.ref().startsWith(QStringLiteral("NoteAttribute."))) + else if (userException.parameter.ref().startsWith( + QStringLiteral("NoteAttribute."))) { errorDescription.appendBase(QT_TR_NOOP("note attributes string is " "too large")); if (note.hasNoteAttributes()) { - QNWARNING(errorDescription << QStringLiteral(", note attributes: ") + QNWARNING(errorDescription << ", note attributes: " << note.noteAttributes()); } } - else if (userException.parameter.ref().startsWith(QStringLiteral("ResourceAttribute."))) + else if (userException.parameter.ref().startsWith( + QStringLiteral("ResourceAttribute."))) { errorDescription.appendBase(QT_TR_NOOP("one of note's resources has " "too large resource attributes " "string")); - QNWARNING(errorDescription << QStringLiteral(", note: ") << note); + QNWARNING(errorDescription << ", note: " << note); } else if (userException.parameter.ref() == QStringLiteral("Tag")) { @@ -1893,7 +1897,7 @@ "and the required new tags " "would exceed the maximum " "number per account")); - QNWARNING(errorDescription << QStringLiteral(", note: ") << note); + QNWARNING(errorDescription << ", note: " << note); } else { @@ -1930,7 +1934,7 @@ errorDescription.appendBase(QT_TR_NOOP("note's notebook is not " "owned by user")); if (note.hasNotebookGuid()) { - QNWARNING(errorDescription << QStringLiteral(", notebook guid: ") + QNWARNING(errorDescription << ", notebook guid: " << note.notebookGuid()); } } diff -Nru libquentier-0.5.0/src/synchronization/NoteSyncCache.cpp libquentier-0.5.0/src/synchronization/NoteSyncCache.cpp --- libquentier-0.5.0/src/synchronization/NoteSyncCache.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/NoteSyncCache.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -19,28 +19,33 @@ #include "NoteSyncCache.h" #include <quentier/logging/QuentierLogger.h> -#define __NSLOG_BASE(message, level) \ - if (m_linkedNotebookGuid.isEmpty()) { \ - __QNLOG_BASE(message, level); \ - } \ - else { \ - __QNLOG_BASE(QStringLiteral("[linked notebook ") << m_linkedNotebookGuid \ - << QStringLiteral("]: ") << message, level); \ - } - -#define NSTRACE(message) \ - __NSLOG_BASE(message, Trace) - -#define NSDEBUG(message) \ - __NSLOG_BASE(message, Debug) - -#define NSWARNING(message) \ - __NSLOG_BASE(message, Warn) +#define __NSLOG_BASE(message, level) \ + if (m_linkedNotebookGuid.isEmpty()) { \ + __QNLOG_BASE(message, level); \ + } \ + else { \ + __QNLOG_BASE("[linked notebook " << m_linkedNotebookGuid \ + << "]: " << message, level); \ + } \ +// __NSLOG_BASE + +#define NSTRACE(message) \ + __NSLOG_BASE(message, Trace) \ +// NSTRACE + +#define NSDEBUG(message) \ + __NSLOG_BASE(message, Debug) \ +// NSDEBUG + +#define NSWARNING(message) \ + __NSLOG_BASE(message, Warn) \ +// NSWARNING namespace quentier { -NoteSyncCache::NoteSyncCache(LocalStorageManagerAsync & localStorageManagerAsync, - const QString & linkedNotebookGuid, QObject * parent) : +NoteSyncCache::NoteSyncCache( + LocalStorageManagerAsync & localStorageManagerAsync, + const QString & linkedNotebookGuid, QObject * parent) : QObject(parent), m_localStorageManagerAsync(localStorageManagerAsync), m_connectedToLocalStorage(false), @@ -55,7 +60,7 @@ void NoteSyncCache::clear() { - NSDEBUG(QStringLiteral("NoteSyncCache::clear")); + NSDEBUG("NoteSyncCache::clear"); disconnectFromLocalStorage(); @@ -81,11 +86,11 @@ void NoteSyncCache::fill() { - NSDEBUG(QStringLiteral("NoteSyncCache::fill")); + NSDEBUG("NoteSyncCache::fill"); if (m_connectedToLocalStorage) { - NSDEBUG(QStringLiteral("Already connected to the local storage, no need " - "to do anything")); + NSDEBUG("Already connected to the local storage, no need " + "to do anything"); return; } @@ -93,34 +98,32 @@ requestNotesList(); } -void NoteSyncCache::onListNotesComplete(LocalStorageManager::ListObjectsOptions flag, - LocalStorageManager::GetNoteOptions options, - size_t limit, size_t offset, - LocalStorageManager::ListNotesOrder::type order, - LocalStorageManager::OrderDirection::type orderDirection, - QString linkedNotebookGuid, - QList<Note> foundNotes, - QUuid requestId) +void NoteSyncCache::onListNotesComplete( + LocalStorageManager::ListObjectsOptions flag, + LocalStorageManager::GetNoteOptions options, + size_t limit, size_t offset, + LocalStorageManager::ListNotesOrder::type order, + LocalStorageManager::OrderDirection::type orderDirection, + QString linkedNotebookGuid, QList<Note> foundNotes, QUuid requestId) { if (requestId != m_listNotesRequestId) { return; } - NSDEBUG(QStringLiteral("NoteSyncCache::onListNotesComplete: flag = ") << flag - << QStringLiteral(", with resource metadata = ") + NSDEBUG("NoteSyncCache::onListNotesComplete: flag = " << flag + << ", with resource metadata = " << ((options & LocalStorageManager::GetNoteOption::WithResourceMetadata) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with resource binary data = ") + ? "true" + : "false") + << ", with resource binary data = " << ((options & LocalStorageManager::GetNoteOption::WithResourceBinaryData) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", limit = ") << limit << QStringLiteral(", offset = ") - << offset << QStringLiteral(", order = ") << order - << QStringLiteral(", order direction = ") << orderDirection - << QStringLiteral(", linked notebook guid = ") << linkedNotebookGuid - << QStringLiteral(", num found notes = ") << foundNotes.size() - << QStringLiteral(", request id = ") << requestId); + ? "true" + : "false") + << ", limit = " << limit << ", offset = " << offset << ", order = " + << order << ", order direction = " << orderDirection + << ", linked notebook guid = " << linkedNotebookGuid + << ", num found notes = " << foundNotes.size() + << ", request id = " << requestId); for(auto it = foundNotes.constBegin(), end = foundNotes.constEnd(); it != end; ++it) @@ -131,8 +134,8 @@ m_listNotesRequestId = QUuid(); if (foundNotes.size() == static_cast<int>(limit)) { - NSTRACE(QStringLiteral("The number of found notes matches the limit, " - "requesting more notes from the local storage")); + NSTRACE("The number of found notes matches the limit, " + "requesting more notes from the local storage"); m_offset += limit; requestNotesList(); return; @@ -141,36 +144,35 @@ Q_EMIT filled(); } -void NoteSyncCache::onListNotesFailed(LocalStorageManager::ListObjectsOptions flag, - LocalStorageManager::GetNoteOptions options, - size_t limit, size_t offset, - LocalStorageManager::ListNotesOrder::type order, - LocalStorageManager::OrderDirection::type orderDirection, - QString linkedNotebookGuid, - ErrorString errorDescription, - QUuid requestId) +void NoteSyncCache::onListNotesFailed( + LocalStorageManager::ListObjectsOptions flag, + LocalStorageManager::GetNoteOptions options, + size_t limit, size_t offset, + LocalStorageManager::ListNotesOrder::type order, + LocalStorageManager::OrderDirection::type orderDirection, + QString linkedNotebookGuid, ErrorString errorDescription, + QUuid requestId) { if (requestId != m_listNotesRequestId) { return; } - NSDEBUG(QStringLiteral("NoteSyncCache::onListNotesFailed: flag = ") << flag - << QStringLiteral(", with resource metadata = ") + NSDEBUG("NoteSyncCache::onListNotesFailed: flag = " << flag + << ", with resource metadata = " << ((options & LocalStorageManager::GetNoteOption::WithResourceMetadata) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with resource binary data = ") + ? "true" + : "false") + << ", with resource binary data = " << ((options & LocalStorageManager::GetNoteOption::WithResourceBinaryData) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", limit = ") << limit << QStringLiteral(", offset = ") - << offset << QStringLiteral(", order = ") << order - << QStringLiteral(", order direction = ") << orderDirection - << QStringLiteral(", linked notebook guid = ") - << linkedNotebookGuid << QStringLiteral(", error description = ") - << errorDescription << QStringLiteral(", request id = ") << requestId); + ? "true" + : "false") + << ", limit = " << limit << ", offset = " << offset << ", order = " + << order << ", order direction = " << orderDirection + << ", linked notebook guid = " << linkedNotebookGuid + << ", error description = " << errorDescription + << ", request id = " << requestId); - NSWARNING(QStringLiteral("Failed to cache the note information required for the sync: ") + NSWARNING("Failed to cache the note information required for the sync: " << errorDescription); m_noteGuidToLocalUidBimap.clear(); @@ -183,8 +185,8 @@ void NoteSyncCache::onAddNoteComplete(Note note, QUuid requestId) { - NSDEBUG(QStringLiteral("NoteSyncCache::onAddNoteComplete: request id = ") << requestId - << QStringLiteral(", note: ") << note); + NSDEBUG("NoteSyncCache::onAddNoteComplete: request id = " << requestId + << ", note: " << note); processNote(note); } @@ -192,38 +194,38 @@ void NoteSyncCache::onUpdateNoteComplete( Note note, LocalStorageManager::UpdateNoteOptions options, QUuid requestId) { - NSDEBUG(QStringLiteral("NoteSyncCache::onUpdateNoteComplete: request id = ") - << requestId << QStringLiteral(", update resource metadata = ") + NSDEBUG("NoteSyncCache::onUpdateNoteComplete: request id = " + << requestId << ", update resource metadata = " << ((options & LocalStorageManager::UpdateNoteOption::UpdateResourceMetadata) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", update resource binary data = ") + ? "true" + : "false") + << ", update resource binary data = " << ((options & LocalStorageManager::UpdateNoteOption::UpdateResourceBinaryData) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", update tags = ") + ? "true" + : "false") + << ", update tags = " << ((options & LocalStorageManager::UpdateNoteOption::UpdateTags) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", note: ") << note); + ? "true" + : "false") + << ", note: " << note); processNote(note); } void NoteSyncCache::onExpungeNoteComplete(Note note, QUuid requestId) { - NSDEBUG(QStringLiteral("NoteSyncCache::onExpungeNoteComplete: request id = ") - << requestId << QStringLiteral(", note: ") << note); + NSDEBUG("NoteSyncCache::onExpungeNoteComplete: request id = " + << requestId << ", note: " << note); removeNote(note.localUid()); } void NoteSyncCache::connectToLocalStorage() { - NSDEBUG(QStringLiteral("NoteSyncCache::connectToLocalStorage")); + NSDEBUG("NoteSyncCache::connectToLocalStorage"); if (m_connectedToLocalStorage) { - NSDEBUG(QStringLiteral("Already connected to the local storage")); + NSDEBUG("Already connected to the local storage"); return; } @@ -296,10 +298,10 @@ void NoteSyncCache::disconnectFromLocalStorage() { - NSDEBUG(QStringLiteral("NoteSyncCache::disconnectFromLocalStorage")); + NSDEBUG("NoteSyncCache::disconnectFromLocalStorage"); if (!m_connectedToLocalStorage) { - NSDEBUG(QStringLiteral("Not connected to local storage at the moment")); + NSDEBUG("Not connected to local storage at the moment"); return; } @@ -370,30 +372,30 @@ void NoteSyncCache::requestNotesList() { - NSDEBUG(QStringLiteral("NoteSyncCache::requestNotesList")); + NSDEBUG("NoteSyncCache::requestNotesList"); m_listNotesRequestId = QUuid::createUuid(); - NSTRACE(QStringLiteral("Emitting the request to list notes: request id = ") - << m_listNotesRequestId << QStringLiteral(", offset = ") << m_offset); + NSTRACE("Emitting the request to list notes: request id = " + << m_listNotesRequestId << ", offset = " << m_offset); LocalStorageManager::GetNoteOptions options( LocalStorageManager::GetNoteOption::WithResourceMetadata); Q_EMIT listNotes(LocalStorageManager::ListAll, options, m_limit, m_offset, LocalStorageManager::ListNotesOrder::NoOrder, LocalStorageManager::OrderDirection::Ascending, (m_linkedNotebookGuid.isEmpty() - ? QStringLiteral("") + ? QLatin1String("") : m_linkedNotebookGuid), m_listNotesRequestId); } void NoteSyncCache::removeNote(const QString & noteLocalUid) { - NSDEBUG(QStringLiteral("NoteSyncCache::removeNote: ") << noteLocalUid); + NSDEBUG("NoteSyncCache::removeNote: " << noteLocalUid); auto localUidIt = m_noteGuidToLocalUidBimap.right.find(noteLocalUid); if (localUidIt == m_noteGuidToLocalUidBimap.right.end()) { - NSDEBUG(QStringLiteral("Found no cached note to remove")); + NSDEBUG("Found no cached note to remove"); return; } @@ -413,7 +415,7 @@ void NoteSyncCache::processNote(const Note & note) { - NSDEBUG(QStringLiteral("NoteSyncCache::processNote: ") << note); + NSDEBUG("NoteSyncCache::processNote: " << note); if (note.hasGuid()) { diff -Nru libquentier-0.5.0/src/synchronization/NoteSyncConflictResolver.cpp libquentier-0.5.0/src/synchronization/NoteSyncConflictResolver.cpp --- libquentier-0.5.0/src/synchronization/NoteSyncConflictResolver.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/NoteSyncConflictResolver.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -26,10 +26,9 @@ namespace quentier { -NoteSyncConflictResolver::NoteSyncConflictResolver(IManager & manager, - const qevercloud::Note & remoteNote, - const Note & localConflict, - QObject * parent) : +NoteSyncConflictResolver::NoteSyncConflictResolver( + IManager & manager, const qevercloud::Note & remoteNote, + const Note & localConflict, QObject * parent) : QObject(parent), m_manager(manager), m_remoteNote(remoteNote), @@ -50,15 +49,14 @@ void NoteSyncConflictResolver::start() { - QNDEBUG(QStringLiteral("NoteSyncConflictResolver::start: remote note guid = ") + QNDEBUG("NoteSyncConflictResolver::start: remote note guid = " << (m_remoteNote.guid.isSet() ? m_remoteNote.guid.ref() : QStringLiteral("<not set>")) - << QStringLiteral(", local conflict local uid = ") - << m_localConflict.localUid()); + << ", local conflict local uid = " << m_localConflict.localUid()); if (m_started) { - QNDEBUG(QStringLiteral("Already started")); + QNDEBUG("Already started"); return; } @@ -68,18 +66,18 @@ processNotesConflictByGuid(); } -void NoteSyncConflictResolver::onAuthDataUpdated(QString authToken, QString shardId, - qevercloud::Timestamp expirationTime) +void NoteSyncConflictResolver::onAuthDataUpdated( + QString authToken, QString shardId, qevercloud::Timestamp expirationTime) { - QNDEBUG(QStringLiteral("NoteSyncConflictResolver::onAuthDataUpdated")); + QNDEBUG("NoteSyncConflictResolver::onAuthDataUpdated"); Q_UNUSED(authToken) Q_UNUSED(shardId) Q_UNUSED(expirationTime) if (Q_UNLIKELY(!m_pendingAuthDataUpdate)) { - QNWARNING(QStringLiteral("NoteSyncConflictResolver: received unexpected " - "auth data update, ignoring it")); + QNWARNING("NoteSyncConflictResolver: received unexpected " + "auth data update, ignoring it"); return; } @@ -91,14 +89,14 @@ QHash<QString,QPair<QString,QString> > authTokensAndShardIdsByLinkedNotebookGuid, QHash<QString,qevercloud::Timestamp> authTokenExpirationTimesByLinkedNotebookGuid) { - QNDEBUG(QStringLiteral("NoteSyncConflictResolver::onLinkedNotebooksAuthDataUpdated")); + QNDEBUG("NoteSyncConflictResolver::onLinkedNotebooksAuthDataUpdated"); Q_UNUSED(authTokensAndShardIdsByLinkedNotebookGuid) Q_UNUSED(authTokenExpirationTimesByLinkedNotebookGuid) if (Q_UNLIKELY(!m_pendingLinkedNotebookAuthDataUpdate)) { - QNWARNING(QStringLiteral("NoteSyncConflictResolver: received unexpected " - "linked notebook auth data update, ignoring it")); + QNWARNING("NoteSyncConflictResolver: received unexpected " + "linked notebook auth data update, ignoring it"); return; } @@ -112,16 +110,16 @@ return; } - QNDEBUG(QStringLiteral("NoteSyncConflictResolver::onAddNoteComplete: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", note: ") << note); + QNDEBUG("NoteSyncConflictResolver::onAddNoteComplete: " + << "request id = " << requestId + << ", note: " << note); m_addNoteRequestId = QUuid(); if (m_pendingRemoteNoteAdditionToLocalStorage) { - QNDEBUG(QStringLiteral("Successfully added remote note as a new note " - "to the local storage")); + QNDEBUG("Successfully added remote note as a new note " + "to the local storage"); m_pendingRemoteNoteAdditionToLocalStorage = false; Q_EMIT finished(m_remoteNote); } @@ -132,7 +130,7 @@ "unidentified note addition acknowledge " "event within the local storage")); APPEND_NOTE_DETAILS(error, m_remoteNoteAsLocalNote) - QNWARNING(error << QStringLiteral(": ") << m_remoteNote); + QNWARNING(error << ": " << m_remoteNote); Q_EMIT failure(m_remoteNote, error); } } @@ -145,9 +143,9 @@ return; } - QNDEBUG(QStringLiteral("NoteSyncConflictResolver::onAddNoteFailed: request id = ") - << requestId << QStringLiteral(", error description = ") - << errorDescription << QStringLiteral("; note: ") << note); + QNDEBUG("NoteSyncConflictResolver::onAddNoteFailed: request id = " + << requestId << ", error description = " + << errorDescription << "; note: " << note); m_addNoteRequestId = QUuid(); Q_EMIT failure(m_remoteNote, errorDescription); @@ -160,56 +158,55 @@ return; } - QNDEBUG(QStringLiteral("NoteSyncConflictResolver::onUpdateNoteComplete: note = ") - << note << QStringLiteral("\nRequest id = ") << requestId - << QStringLiteral(", update resource metadata = ") + QNDEBUG("NoteSyncConflictResolver::onUpdateNoteComplete: note = " + << note << "\nRequest id = " << requestId + << ", update resource metadata = " << ((options & LocalStorageManager::UpdateNoteOption::UpdateResourceMetadata) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", update resource binary data = ") + ? "true" + : "false") + << ", update resource binary data = " << ((options & LocalStorageManager::UpdateNoteOption::UpdateResourceBinaryData) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", update tags = ") + ? "true" + : "false") + << ", update tags = " << ((options & LocalStorageManager::UpdateNoteOption::UpdateTags) - ? QStringLiteral("true") - : QStringLiteral("false"))); + ? "true" + : "false")); m_updateNoteRequestId = QUuid(); if (m_pendingLocalConflictUpdateInLocalStorage) { - QNDEBUG(QStringLiteral("Local conflicting note was successfully updated " - "in the local storage")); + QNDEBUG("Local conflicting note was successfully updated " + "in the local storage"); m_pendingLocalConflictUpdateInLocalStorage = false; if (m_pendingFullRemoteNoteDataDownload) { - QNDEBUG(QStringLiteral("Still waiting for full remote note's " - "data downloading")); + QNDEBUG("Still waiting for full remote note's data downloading"); return; } if (m_retryNoteDownloadingTimerId != 0) { - QNDEBUG(QStringLiteral("Retry full remote note data timer is active, " - "hence the remote note data has not been " - "fully downloaded yet")); + QNDEBUG("Retry full remote note data timer is active, " + "hence the remote note data has not been " + "fully downloaded yet"); return; } if (m_pendingAuthDataUpdate) { - QNDEBUG(QStringLiteral("Remote note was not downloaded properly yet, " - "pending auth token for full remote note " - "data downloading")); + QNDEBUG("Remote note was not downloaded properly yet, " + "pending auth token for full remote note " + "data downloading"); return; } if (m_manager.syncingLinkedNotebooksContent() && m_pendingLinkedNotebookAuthDataUpdate) { - QNDEBUG(QStringLiteral("Remote note was not downloaded properly yet, " - "pending linked notebook auth token for full " - "remote note data downloading")); + QNDEBUG("Remote note was not downloaded properly yet, " + "pending linked notebook auth token for full " + "remote note data downloading"); return; } @@ -217,8 +214,8 @@ } else if (m_pendingRemoteNoteUpdateInLocalStorage) { - QNDEBUG(QStringLiteral("Remote note was successfully updated " - "in the local storage")); + QNDEBUG("Remote note was successfully updated " + "in the local storage"); m_pendingRemoteNoteUpdateInLocalStorage = false; Q_EMIT finished(m_remoteNote); } @@ -229,7 +226,7 @@ "unidentified note update acknowledge from " "the local storage")); APPEND_NOTE_DETAILS(error, m_remoteNoteAsLocalNote) - QNWARNING(error << QStringLiteral(": ") << m_remoteNote); + QNWARNING(error << ": " << m_remoteNote); Q_EMIT failure(m_remoteNote, error); } } @@ -242,21 +239,21 @@ return; } - QNWARNING(QStringLiteral("NoteSyncConflictResolver::onUpdateNoteFailed: note = ") - << note << QStringLiteral("\nRequest id = ") << requestId - << QStringLiteral(", update resource metadata = ") + QNWARNING("NoteSyncConflictResolver::onUpdateNoteFailed: note = " + << note << "\nRequest id = " << requestId + << ", update resource metadata = " << ((options & LocalStorageManager::UpdateNoteOption::UpdateResourceMetadata) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", update resource binary data = ") + ? "true" + : "false") + << ", update resource binary data = " << ((options & LocalStorageManager::UpdateNoteOption::UpdateResourceBinaryData) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", update tags = ") + ? "true" + : "false") + << ", update tags = " << ((options & LocalStorageManager::UpdateNoteOption::UpdateTags) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral("; error description = ") << errorDescription); + ? "true" + : "false") + << "; error description = " << errorDescription); m_updateNoteRequestId = QUuid(); @@ -268,7 +265,7 @@ error.appendBase(errorDescription.base()); error.appendBase(errorDescription.additionalBases()); APPEND_NOTE_DETAILS(error, m_remoteNoteAsLocalNote) - QNWARNING(error << QStringLiteral(": ") << m_remoteNote); + QNWARNING(error << ": " << m_remoteNote); Q_EMIT failure(m_remoteNote, error); } else if (m_pendingRemoteNoteUpdateInLocalStorage) @@ -279,7 +276,7 @@ error.appendBase(errorDescription.base()); error.appendBase(errorDescription.additionalBases()); APPEND_NOTE_DETAILS(error, m_remoteNoteAsLocalNote) - QNWARNING(error << QStringLiteral(": ") << m_remoteNote); + QNWARNING(error << ": " << m_remoteNote); Q_EMIT failure(m_remoteNote, error); } else @@ -291,7 +288,7 @@ error.appendBase(errorDescription.base()); error.appendBase(errorDescription.additionalBases()); APPEND_NOTE_DETAILS(error, m_remoteNoteAsLocalNote) - QNWARNING(error << QStringLiteral(": ") << m_remoteNote); + QNWARNING(error << ": " << m_remoteNote); Q_EMIT failure(m_remoteNote, error); } } @@ -306,11 +303,11 @@ return; } - QNDEBUG(QStringLiteral("NoteSyncConflictResolver::onGetNoteAsyncFinished: ") - << QStringLiteral("error code = ") << errorCode - << QStringLiteral(", note = ") << qecNote - << QStringLiteral("\nRate limit seconds = ") << rateLimitSeconds - << QStringLiteral(", error description = ") << errorDescription); + QNDEBUG("NoteSyncConflictResolver::onGetNoteAsyncFinished: " + << "error code = " << errorCode + << ", note = " << qecNote + << "\nRate limit seconds = " << rateLimitSeconds + << ", error description = " << errorDescription); m_pendingFullRemoteNoteDataDownload = false; @@ -339,10 +336,10 @@ return; } - QNDEBUG(QStringLiteral("Started timer to retry downloading full note data: ") - << QStringLiteral("timer id = ") << timerId - << QStringLiteral(", need to wait for ") << rateLimitSeconds - << QStringLiteral(" seconds")); + QNDEBUG("Started timer to retry downloading full note data: " + << "timer id = " << timerId + << ", need to wait for " << rateLimitSeconds + << " seconds"); m_retryNoteDownloadingTimerId = timerId; Q_EMIT rateLimitExceeded(rateLimitSeconds); return; @@ -378,17 +375,17 @@ LocalStorageManager::UpdateNoteOption::UpdateResourceMetadata | LocalStorageManager::UpdateNoteOption::UpdateResourceBinaryData | LocalStorageManager::UpdateNoteOption::UpdateTags); - QNDEBUG(QStringLiteral("Emitting the request to update the local conflict " - "overridden by the remote note within the local " - "storage: request id = ") << m_updateNoteRequestId - << QStringLiteral(", note: ") << m_remoteNoteAsLocalNote); + QNDEBUG("Emitting the request to update the local conflict " + << "overridden by the remote note within the local " + << "storage: request id = " << m_updateNoteRequestId + << ", note: " << m_remoteNoteAsLocalNote); Q_EMIT updateNote(m_localConflict, options, m_updateNoteRequestId); } else { if (m_pendingLocalConflictUpdateInLocalStorage) { - QNDEBUG(QStringLiteral("Still pending the update of local conflicting " - "note in the local storage")); + QNDEBUG("Still pending the update of local conflicting " + "note in the local storage"); return; } @@ -398,7 +395,7 @@ void NoteSyncConflictResolver::connectToLocalStorage() { - QNDEBUG(QStringLiteral("NoteSyncConflictResolver::connectToLocalStorage")); + QNDEBUG("NoteSyncConflictResolver::connectToLocalStorage"); LocalStorageManagerAsync & localStorageManagerAsync = m_manager.localStorageManagerAsync(); @@ -444,13 +441,13 @@ void NoteSyncConflictResolver::processNotesConflictByGuid() { - QNDEBUG(QStringLiteral("NoteSyncConflictResolver::processNotesConflictByGuid")); + QNDEBUG("NoteSyncConflictResolver::processNotesConflictByGuid"); if (Q_UNLIKELY(!m_remoteNote.guid.isSet())) { ErrorString error(QT_TR_NOOP("Can't resolve the conflict between remote " "and local notes: the remote note has no guid set")); APPEND_NOTE_DETAILS(error, Note(m_remoteNote)) - QNWARNING(error << QStringLiteral(": ") << m_remoteNote); + QNWARNING(error << ": " << m_remoteNote); Q_EMIT failure(m_remoteNote, error); return; } @@ -460,7 +457,7 @@ "and local notes: the remote note has no " "update sequence number set")); APPEND_NOTE_DETAILS(error, Note(m_remoteNote)) - QNWARNING(error << QStringLiteral(": ") << m_remoteNote); + QNWARNING(error << ": " << m_remoteNote); Q_EMIT failure(m_remoteNote, error); return; } @@ -470,7 +467,7 @@ "and local notes: the local note has " "no guid set")); APPEND_NOTE_DETAILS(error, m_localConflict) - QNWARNING(error << QStringLiteral(": ") << m_localConflict); + QNWARNING(error << ": " << m_localConflict); Q_EMIT failure(m_remoteNote, error); return; } @@ -479,7 +476,7 @@ ErrorString error(QT_TR_NOOP("Note sync conflict resolution was applied " "to notes which do not conflict by guid")); APPEND_NOTE_DETAILS(error, m_localConflict) - QNWARNING(error << QStringLiteral(": ") << m_localConflict); + QNWARNING(error << ": " << m_localConflict); Q_EMIT failure(m_remoteNote, error); return; } @@ -487,9 +484,9 @@ if (m_localConflict.hasUpdateSequenceNumber() && (m_localConflict.updateSequenceNumber() >= m_remoteNote.updateSequenceNum.ref())) { - QNDEBUG(QStringLiteral("The local note has update sequence number equal ") - << QStringLiteral("to or greater than the remote note's one ") - << QStringLiteral("=> local note should override the remote one")); + QNDEBUG("The local note has update sequence number equal " + << "to or greater than the remote note's one " + << "=> local note should override the remote one"); Q_EMIT finished(m_remoteNote); return; } @@ -501,14 +498,14 @@ } if (!m_localConflict.isDirty()) { - QNDEBUG(QStringLiteral("The local conflicting note is not dirty and thus " - "should be overridden with the remote note")); + QNDEBUG("The local conflicting note is not dirty and thus " + "should be overridden with the remote note"); m_shouldOverrideLocalNoteWithRemoteNote = true; return; } - QNDEBUG(QStringLiteral("The local conflicting note has been marked as dirty " - "one, need to clear Evernote-assigned fields from it")); + QNDEBUG("The local conflicting note has been marked as dirty " + "one, need to clear Evernote-assigned fields from it"); m_localConflict.setGuid(QString()); m_localConflict.setUpdateSequenceNumber(-1); @@ -555,18 +552,18 @@ m_updateNoteRequestId = QUuid::createUuid(); LocalStorageManager::UpdateNoteOptions options( LocalStorageManager::UpdateNoteOption::UpdateResourceMetadata); - QNDEBUG(QStringLiteral("Emitting the request to update the local conflicting ") - << QStringLiteral("note (after clearing Evernote assigned fields from it): ") - << QStringLiteral("request id = ") << m_updateNoteRequestId - << QStringLiteral(", note to update: ") << m_localConflict); + QNDEBUG("Emitting the request to update the local conflicting " + << "note (after clearing Evernote assigned fields from it): " + << "request id = " << m_updateNoteRequestId + << ", note to update: " << m_localConflict); Q_EMIT updateNote(m_localConflict, options, m_updateNoteRequestId); } void NoteSyncConflictResolver::overrideLocalNoteWithRemoteChanges() { - QNDEBUG(QStringLiteral("NoteSyncConflictResolver::overrideLocalNoteWithRemoteChanges")); - QNTRACE(QStringLiteral("Local conflict: ") << m_localConflict - << QStringLiteral("\nRemote note: ") << m_remoteNoteAsLocalNote); + QNDEBUG("NoteSyncConflictResolver::overrideLocalNoteWithRemoteChanges"); + QNTRACE("Local conflict: " << m_localConflict + << "\nRemote note: " << m_remoteNoteAsLocalNote); Note localNote(m_localConflict); @@ -629,8 +626,8 @@ { const Resource & updatedResource = *uit; if (Q_UNLIKELY(!updatedResource.hasGuid())) { - QNWARNING(QStringLiteral("Skipping resource from remote note ") - << QStringLiteral("without guid: ") << updatedResource); + QNWARNING("Skipping resource from remote note " + << "without guid: " << updatedResource); continue; } @@ -660,22 +657,22 @@ } localNote.setResources(amendedResources); - QNTRACE(QStringLiteral("Local note after overriding: ") << localNote); + QNTRACE("Local note after overriding: " << localNote); m_localConflict = localNote; } void NoteSyncConflictResolver::addRemoteNoteToLocalStorageAsNewNote() { - QNDEBUG(QStringLiteral("NoteSyncConflictResolver::" - "addRemoteNoteToLocalStorageAsNewNote")); + QNDEBUG("NoteSyncConflictResolver::" + "addRemoteNoteToLocalStorageAsNewNote"); m_pendingRemoteNoteAdditionToLocalStorage = true; m_addNoteRequestId = QUuid::createUuid(); - QNDEBUG(QStringLiteral("Emitting the request to add note to the local storage: ") - << QStringLiteral("request id = ") << m_addNoteRequestId - << QStringLiteral(", note: ") << m_remoteNoteAsLocalNote); + QNDEBUG("Emitting the request to add note to the local storage: " + << "request id = " << m_addNoteRequestId + << ", note: " << m_remoteNoteAsLocalNote); Q_EMIT addNote(m_remoteNoteAsLocalNote, m_addNoteRequestId); } @@ -697,7 +694,7 @@ error.appendBase(errorDescription.base()); error.appendBase(errorDescription.additionalBases()); APPEND_NOTE_DETAILS(error, m_remoteNoteAsLocalNote); - QNWARNING(error << QStringLiteral(": ") << m_remoteNoteAsLocalNote); + QNWARNING(error << ": " << m_remoteNoteAsLocalNote); Q_EMIT failure(m_remoteNote, error); return false; } @@ -727,14 +724,14 @@ if (!res) { APPEND_NOTE_DETAILS(errorDescription, m_remoteNoteAsLocalNote) - QNWARNING(errorDescription << QStringLiteral(", note: ") + QNWARNING(errorDescription << ", note: " << m_remoteNoteAsLocalNote); Q_EMIT failure(m_remoteNote, errorDescription); return false; } m_pendingFullRemoteNoteDataDownload = true; - QNDEBUG(QStringLiteral("Pending full remote note data downloading")); + QNDEBUG("Pending full remote note data downloading"); return true; } @@ -750,11 +747,11 @@ int timerId = pEvent->timerId(); killTimer(timerId); - QNDEBUG(QStringLiteral("Killed timer with id ") << timerId); + QNDEBUG("Killed timer with id " << timerId); if (timerId == m_retryNoteDownloadingTimerId) { - QNDEBUG(QStringLiteral("NoteSyncConflictResolver::timerEvent: retrying " - "the download of full remote note data")); + QNDEBUG("NoteSyncConflictResolver::timerEvent: retrying " + "the download of full remote note data"); Q_UNUSED(downloadFullRemoteNoteData()); } } diff -Nru libquentier-0.5.0/src/synchronization/NoteThumbnailDownloader.cpp libquentier-0.5.0/src/synchronization/NoteThumbnailDownloader.cpp --- libquentier-0.5.0/src/synchronization/NoteThumbnailDownloader.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/NoteThumbnailDownloader.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -50,18 +50,16 @@ void NoteThumbnailDownloader::start() { - QNDEBUG(QStringLiteral("NoteThumbnailDownloader::start: host = ") << m_host - << QStringLiteral(", note guid = ") << m_noteGuid - << QStringLiteral(", is public = ") - << (m_noteFromPublicLinkedNotebook - ? QStringLiteral("true") - : QStringLiteral("false"))); - -#define SET_ERROR(error) \ - ErrorString errorDescription(error); \ - QNDEBUG(errorDescription); \ - Q_EMIT finished(false, m_noteGuid, QByteArray(), errorDescription); \ - return + QNDEBUG("NoteThumbnailDownloader::start: host = " << m_host + << ", note guid = " << m_noteGuid << ", is public = " + << (m_noteFromPublicLinkedNotebook ? "true" : "false")); + +#define SET_ERROR(error) \ + ErrorString errorDescription(error); \ + QNDEBUG(errorDescription); \ + Q_EMIT finished(false, m_noteGuid, QByteArray(), errorDescription); \ + return \ +// SET_ERROR if (Q_UNLIKELY(m_host.isEmpty())) { SET_ERROR(QT_TR_NOOP("host is empty")); @@ -108,7 +106,7 @@ void NoteThumbnailDownloader::onDownloadFinished( QVariant result, QSharedPointer<EverCloudExceptionData> error) { - QNDEBUG(QStringLiteral("NoteThumbnailDownloader::onDownloadFinished")); + QNDEBUG("NoteThumbnailDownloader::onDownloadFinished"); delete m_pThumbnail; m_pThumbnail = Q_NULLPTR; diff -Nru libquentier-0.5.0/src/synchronization/RemoteToLocalSynchronizationManager.cpp libquentier-0.5.0/src/synchronization/RemoteToLocalSynchronizationManager.cpp --- libquentier-0.5.0/src/synchronization/RemoteToLocalSynchronizationManager.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/RemoteToLocalSynchronizationManager.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -40,17 +40,43 @@ #define ACCOUNT_LIMITS_KEY_GROUP QStringLiteral("AccountLimits/") #define ACCOUNT_LIMITS_LAST_SYNC_TIME_KEY QStringLiteral("last_sync_time") #define ACCOUNT_LIMITS_SERVICE_LEVEL_KEY QStringLiteral("service_level") -#define ACCOUNT_LIMITS_USER_MAIL_LIMIT_DAILY_KEY QStringLiteral("user_mail_limit_daily") + +#define ACCOUNT_LIMITS_USER_MAIL_LIMIT_DAILY_KEY \ + QStringLiteral("user_mail_limit_daily") \ +// ACCOUNT_LIMITS_USER_MAIL_LIMIT_DAILY_KEY + #define ACCOUNT_LIMITS_NOTE_SIZE_MAX_KEY QStringLiteral("note_size_max") #define ACCOUNT_LIMITS_RESOURCE_SIZE_MAX_KEY QStringLiteral("resource_size_max") -#define ACCOUNT_LIMITS_USER_LINKED_NOTEBOOK_MAX_KEY QStringLiteral("user_linked_notebook_max") + +#define ACCOUNT_LIMITS_USER_LINKED_NOTEBOOK_MAX_KEY \ + QStringLiteral("user_linked_notebook_max") \ +// ACCOUNT_LIMITS_USER_LINKED_NOTEBOOK_MAX_KEY + #define ACCOUNT_LIMITS_UPLOAD_LIMIT_KEY QStringLiteral("upload_limit") -#define ACCOUNT_LIMITS_USER_NOTE_COUNT_MAX_KEY QStringLiteral("user_note_count_max") -#define ACCOUNT_LIMITS_USER_NOTEBOOK_COUNT_MAX_KEY QStringLiteral("user_notebook_count_max") -#define ACCOUNT_LIMITS_USER_TAG_COUNT_MAX_KEY QStringLiteral("user_tag_count_max") -#define ACCOUNT_LIMITS_NOTE_TAG_COUNT_MAX_KEY QStringLiteral("note_tag_count_max") -#define ACCOUNT_LIMITS_USER_SAVED_SEARCH_COUNT_MAX_KEY QStringLiteral("user_saved_search_count_max") -#define ACCOUNT_LIMITS_NOTE_RESOURCE_COUNT_MAX_KEY QStringLiteral("note_resource_count_max") + +#define ACCOUNT_LIMITS_USER_NOTE_COUNT_MAX_KEY \ + QStringLiteral("user_note_count_max") \ +// ACCOUNT_LIMITS_USER_NOTE_COUNT_MAX_KEY + +#define ACCOUNT_LIMITS_USER_NOTEBOOK_COUNT_MAX_KEY \ + QStringLiteral("user_notebook_count_max") \ +// ACCOUNT_LIMITS_USER_NOTEBOOK_COUNT_MAX_KEY + +#define ACCOUNT_LIMITS_USER_TAG_COUNT_MAX_KEY \ + QStringLiteral("user_tag_count_max") \ +// ACCOUNT_LIMITS_USER_TAG_COUNT_MAX_KEY + +#define ACCOUNT_LIMITS_NOTE_TAG_COUNT_MAX_KEY \ + QStringLiteral("note_tag_count_max") \ +// ACCOUNT_LIMITS_NOTE_TAG_COUNT_MAX_KEY + +#define ACCOUNT_LIMITS_USER_SAVED_SEARCH_COUNT_MAX_KEY \ + QStringLiteral("user_saved_search_count_max") \ +// ACCOUNT_LIMITS_USER_SAVED_SEARCH_COUNT_MAX_KEY + +#define ACCOUNT_LIMITS_NOTE_RESOURCE_COUNT_MAX_KEY \ + QStringLiteral("note_resource_count_max") \ +// ACCOUNT_LIMITS_NOTE_RESOURCE_COUNT_MAX_KEY #define SYNC_SETTINGS_KEY_GROUP QStringLiteral("SynchronizationSettings") #define SHOULD_DOWNLOAD_NOTE_THUMBNAILS QStringLiteral("DownloadNoteThumbnails") @@ -59,38 +85,45 @@ #define THIRTY_DAYS_IN_MSEC (2592000000) -#define SET_ITEM_TYPE_TO_ERROR() \ - errorDescription.details() = QStringLiteral("item type = "); \ - errorDescription.details() += typeName - -#define SET_CANT_FIND_BY_NAME_ERROR() \ - ErrorString errorDescription(QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", \ - "Found a data item with empty "\ - "name in the local storage")); \ - SET_ITEM_TYPE_TO_ERROR(); \ - QNWARNING(errorDescription << QStringLiteral(": ") << element) - -#define SET_CANT_FIND_BY_GUID_ERROR() \ - ErrorString errorDescription(QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", \ - "Found a data item with empty guid")); \ - SET_ITEM_TYPE_TO_ERROR(); \ - QNWARNING(errorDescription << QStringLiteral(": ") << element) - -#define SET_EMPTY_PENDING_LIST_ERROR() \ - ErrorString errorDescription(QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", \ - "Detected attempt to find a "\ - "data item within the list " \ - "of remote items waiting for "\ - "processing but that list is empty")); \ - QNWARNING(errorDescription << QStringLiteral(": ") << element) - -#define SET_CANT_FIND_IN_PENDING_LIST_ERROR() \ - ErrorString errorDescription(QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", \ - "can't find the data item within "\ - "the list of remote elements waiting "\ - "for processing")); \ - SET_ITEM_TYPE_TO_ERROR(); \ - QNWARNING(errorDescription << QStringLiteral(": ") << element) +#define SET_ITEM_TYPE_TO_ERROR() \ + errorDescription.details() = QStringLiteral("item type = "); \ + errorDescription.details() += typeName \ +// SET_ITEM_TYPE_TO_ERROR + +#define SET_CANT_FIND_BY_NAME_ERROR() \ + ErrorString errorDescription( \ + QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", \ + "Found a data item with empty " \ + "name in the local storage")); \ + SET_ITEM_TYPE_TO_ERROR(); \ + QNWARNING(errorDescription << ": " << element) \ +// SET_CANT_FIND_BY_NAME_ERROR + +#define SET_CANT_FIND_BY_GUID_ERROR() \ + ErrorString errorDescription( \ + QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", \ + "Found a data item with empty guid")); \ + SET_ITEM_TYPE_TO_ERROR(); \ + QNWARNING(errorDescription << ": " << element) \ +// SET_CANT_FIND_BY_GUID_ERROR + +#define SET_EMPTY_PENDING_LIST_ERROR() \ + ErrorString errorDescription( \ + QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", \ + "Detected attempt to find a data item within " \ + "the list of remote items waiting for " \ + "processing but that list is empty")); \ + QNWARNING(errorDescription << ": " << element) \ +// SET_EMPTY_PENDING_LIST_ERROR + +#define SET_CANT_FIND_IN_PENDING_LIST_ERROR() \ + ErrorString errorDescription( \ + QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", \ + "can't find the data item within the list of remote "\ + "elements waiting for processing")); \ + SET_ITEM_TYPE_TO_ERROR(); \ + QNWARNING(errorDescription << ": " << element) \ +// SET_CANT_FIND_IN_PENDING_LIST_ERROR namespace quentier { @@ -100,17 +133,19 @@ NoteSyncConflictResolverManager(RemoteToLocalSynchronizationManager & manager); virtual LocalStorageManagerAsync & localStorageManagerAsync() Q_DECL_OVERRIDE; - virtual INoteStore * noteStoreForNote(const Note & note, QString & authToken, - ErrorString & errorDescription) Q_DECL_OVERRIDE; + + virtual INoteStore * noteStoreForNote( + const Note & note, QString & authToken, + ErrorString & errorDescription) Q_DECL_OVERRIDE; + virtual bool syncingLinkedNotebooksContent() const Q_DECL_OVERRIDE; private: RemoteToLocalSynchronizationManager & m_manager; }; -RemoteToLocalSynchronizationManager::RemoteToLocalSynchronizationManager(IManager & manager, - const QString & host, - QObject * parent) : +RemoteToLocalSynchronizationManager::RemoteToLocalSynchronizationManager( + IManager & manager, const QString & host, QObject * parent) : QObject(parent), m_manager(manager), m_connectedToLocalStorage(false), @@ -143,7 +178,7 @@ m_updateTagRequestIds(), m_expungeTagRequestIds(), m_pendingTagsSyncStart(false), - m_tagSyncCache(m_manager.localStorageManagerAsync(), QStringLiteral("")), + m_tagSyncCache(m_manager.localStorageManagerAsync(), QLatin1String("")), m_tagSyncCachesByLinkedNotebookGuids(), m_linkedNotebookGuidsPendingTagSyncCachesFill(), m_linkedNotebookGuidsByTagGuids(), @@ -194,7 +229,7 @@ m_updateNotebookRequestIds(), m_expungeNotebookRequestIds(), m_pendingNotebooksSyncStart(false), - m_notebookSyncCache(m_manager.localStorageManagerAsync(), QStringLiteral("")), + m_notebookSyncCache(m_manager.localStorageManagerAsync(), QLatin1String("")), m_notebookSyncCachesByLinkedNotebookGuids(), m_linkedNotebookGuidsByNotebookGuids(), m_linkedNotebookGuidsByResourceGuids(), @@ -252,14 +287,16 @@ QNSIGNAL(INoteStore,getNoteAsyncFinished, qint32,qevercloud::Note,qint32,ErrorString), this, - QNSLOT(RemoteToLocalSynchronizationManager,onGetNoteAsyncFinished, + QNSLOT(RemoteToLocalSynchronizationManager, + onGetNoteAsyncFinished, qint32,qevercloud::Note,qint32,ErrorString), Qt::ConnectionType(Qt::UniqueConnection | Qt::QueuedConnection)); QObject::connect(&(m_manager.noteStore()), QNSIGNAL(INoteStore,getResourceAsyncFinished, qint32,qevercloud::Resource,qint32,ErrorString), this, - QNSLOT(RemoteToLocalSynchronizationManager,onGetResourceAsyncFinished, + QNSLOT(RemoteToLocalSynchronizationManager, + onGetResourceAsyncFinished, qint32,qevercloud::Resource,qint32,ErrorString), Qt::ConnectionType(Qt::UniqueConnection | Qt::QueuedConnection)); } @@ -274,12 +311,11 @@ void RemoteToLocalSynchronizationManager::setAccount(const Account & account) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::setAccount: ") + QNDEBUG("RemoteToLocalSynchronizationManager::setAccount: " << account.name()); if (m_user.hasId() && (m_user.id() != account.id())) { - QNDEBUG(QStringLiteral("Switching to a different user, " - "clearing the current state")); + QNDEBUG("Switching to a different user, clearing the current state"); clearAll(); } @@ -366,22 +402,20 @@ return account; } -bool RemoteToLocalSynchronizationManager::syncUser(const qevercloud::UserID userId, - ErrorString & errorDescription, - const bool writeUserDataToLocalStorage) -{ - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::syncUser: user id = ") - << userId << QStringLiteral(", write user data to local storage = ") - << (writeUserDataToLocalStorage - ? QStringLiteral("true") - : QStringLiteral("false"))); +bool RemoteToLocalSynchronizationManager::syncUser( + const qevercloud::UserID userId, ErrorString & errorDescription, + const bool writeUserDataToLocalStorage) +{ + QNDEBUG("RemoteToLocalSynchronizationManager::syncUser: user id = " + << userId << ", write user data to local storage = " + << (writeUserDataToLocalStorage ? "true" : "false")); m_user = User(); m_user.setId(userId); // Checking the protocol version first if (!checkProtocolVersion(errorDescription)) { - QNDEBUG(QStringLiteral("Protocol version check failed: ") << errorDescription); + QNDEBUG("Protocol version check failed: " << errorDescription); return false; } @@ -389,18 +423,20 @@ // Retrieving the latest user info then, to figure out the service level // and stuff like that - if (!syncUserImpl(waitIfRateLimitReached, errorDescription, writeUserDataToLocalStorage)) { - QNDEBUG(QStringLiteral("Syncing the user has failed: ") << errorDescription); + if (!syncUserImpl(waitIfRateLimitReached, errorDescription, + writeUserDataToLocalStorage)) + { + QNDEBUG("Syncing the user has failed: " << errorDescription); return false; } if (!checkAndSyncAccountLimits(waitIfRateLimitReached, errorDescription)) { - QNDEBUG(QStringLiteral("Syncing the user's account limits has failed: ") + QNDEBUG("Syncing the user's account limits has failed: " << errorDescription); return false; } - QNTRACE(QStringLiteral("Synchronized user data: ") << m_user); + QNTRACE("Synchronized user data: " << m_user); return true; } @@ -444,7 +480,7 @@ void RemoteToLocalSynchronizationManager::start(qint32 afterUsn) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::start: afterUsn = ") + QNDEBUG("RemoteToLocalSynchronizationManager::start: afterUsn = " << afterUsn); m_lastUsnOnStart = afterUsn; @@ -510,9 +546,9 @@ if (!res) { - QNTRACE(QStringLiteral("The service has no updates for user's own " - "account, need to check for updates from " - "linked notebooks")); + QNTRACE("The service has no updates for user's own " + "account, need to check for updates from " + "linked notebooks"); m_fullNoteContentsDownloaded = true; Q_EMIT synchronizedContentFromUsersOwnAccount(m_lastUpdateCount, @@ -526,8 +562,7 @@ } if (!res) { - QNTRACE(QStringLiteral("The service has no updates for any " - "of linked notebooks")); + QNTRACE("The service has no updates for any of linked notebooks"); finalize(); } @@ -547,10 +582,10 @@ void RemoteToLocalSynchronizationManager::stop() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::stop")); + QNDEBUG("RemoteToLocalSynchronizationManager::stop"); if (!m_active) { - QNDEBUG(QStringLiteral("Already stopped")); + QNDEBUG("Already stopped"); return; } @@ -563,16 +598,15 @@ template <> void RemoteToLocalSynchronizationManager::emitAddRequest<Tag>(const Tag & tag) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::emitAddRequest<Tag>: ") + QNDEBUG("RemoteToLocalSynchronizationManager::emitAddRequest<Tag>: " << tag); registerTagPendingAddOrUpdate(tag); QUuid addTagRequestId = QUuid::createUuid(); Q_UNUSED(m_addTagRequestIds.insert(addTagRequestId)); - QNTRACE(QStringLiteral("Emitting the request to add tag to local storage: " - "request id = ") << addTagRequestId - << QStringLiteral(", tag: ") << tag); + QNTRACE("Emitting the request to add tag to local storage: request id = " + << addTagRequestId << ", tag: " << tag); Q_EMIT addTag(tag, addTagRequestId); } @@ -580,16 +614,16 @@ void RemoteToLocalSynchronizationManager::emitAddRequest<SavedSearch>( const SavedSearch & search) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::emitAddRequest") - << QStringLiteral("<SavedSearch>: ") << search); + QNDEBUG("RemoteToLocalSynchronizationManager::emitAddRequest" + << "<SavedSearch>: " << search); registerSavedSearchPendingAddOrUpdate(search); QUuid addSavedSearchRequestId = QUuid::createUuid(); Q_UNUSED(m_addSavedSearchRequestIds.insert(addSavedSearchRequestId)); - QNTRACE(QStringLiteral("Emitting the request to add saved search to local storage: " - "request id = ") << addSavedSearchRequestId - << QStringLiteral(", saved search: ") << search); + QNTRACE("Emitting the request to add saved search to local storage: " + << "request id = " << addSavedSearchRequestId + << ", saved search: " << search); Q_EMIT addSavedSearch(search, addSavedSearchRequestId); } @@ -597,16 +631,16 @@ void RemoteToLocalSynchronizationManager::emitAddRequest<LinkedNotebook>( const LinkedNotebook & linkedNotebook) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::emitAddRequest") - << QStringLiteral("<LinkedNotebook>: ") << linkedNotebook); + QNDEBUG("RemoteToLocalSynchronizationManager::emitAddRequest" + << "<LinkedNotebook>: " << linkedNotebook); registerLinkedNotebookPendingAddOrUpdate(linkedNotebook); QUuid addLinkedNotebookRequestId = QUuid::createUuid(); Q_UNUSED(m_addLinkedNotebookRequestIds.insert(addLinkedNotebookRequestId)); - QNTRACE(QStringLiteral("Emitting the request to add linked notebook to local " - "storage: request id = ") << addLinkedNotebookRequestId - << QStringLiteral(", linked notebook: ") << linkedNotebook); + QNTRACE("Emitting the request to add linked notebook to local " + << "storage: request id = " << addLinkedNotebookRequestId + << ", linked notebook: " << linkedNotebook); Q_EMIT addLinkedNotebook(linkedNotebook, addLinkedNotebookRequestId); } @@ -614,97 +648,95 @@ void RemoteToLocalSynchronizationManager::emitAddRequest<Notebook>( const Notebook & notebook) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::emitAddRequest") - << QStringLiteral("<Notebook>: ") << notebook); + QNDEBUG("RemoteToLocalSynchronizationManager::emitAddRequest" + << "<Notebook>: " << notebook); registerNotebookPendingAddOrUpdate(notebook); QUuid addNotebookRequestId = QUuid::createUuid(); Q_UNUSED(m_addNotebookRequestIds.insert(addNotebookRequestId)); - QNTRACE(QStringLiteral("Emitting the request to add notebook to local storage: " - "request id = ") << addNotebookRequestId - << QStringLiteral(", notebook: ") << notebook); + QNTRACE("Emitting the request to add notebook to local storage: " + << "request id = " << addNotebookRequestId + << ", notebook: " << notebook); Q_EMIT addNotebook(notebook, addNotebookRequestId); } template <> void RemoteToLocalSynchronizationManager::emitAddRequest<Note>(const Note & note) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::emitAddRequest<Note>: ") + QNDEBUG("RemoteToLocalSynchronizationManager::emitAddRequest<Note>: " << note); registerNotePendingAddOrUpdate(note); QUuid addNoteRequestId = QUuid::createUuid(); Q_UNUSED(m_addNoteRequestIds.insert(addNoteRequestId)); - QNTRACE(QStringLiteral("Emitting the request to add note to local storage: " - "request id = ") << addNoteRequestId - << QStringLiteral(", note: ") << note); + QNTRACE("Emitting the request to add note to local storage: " + << "request id = " << addNoteRequestId << ", note: " << note); Q_EMIT addNote(note, addNoteRequestId); } -void RemoteToLocalSynchronizationManager::onFindUserCompleted(User user, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onFindUserCompleted( + User user, QUuid requestId) { if (requestId != m_findUserRequestId) { return; } - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::onFindUserCompleted: ") - << QStringLiteral("user = ") << user - << QStringLiteral("\nRequest id = ") << requestId); + QNDEBUG("RemoteToLocalSynchronizationManager::onFindUserCompleted: " + << "user = " << user << "\nRequest id = " << requestId); m_user = user; m_findUserRequestId = QUuid(); // Updating the user info as user was found in the local storage m_addOrUpdateUserRequestId = QUuid::createUuid(); - QNTRACE(QStringLiteral("Emitting the request to update user in the local storage " - "database: request id = ") << m_addOrUpdateUserRequestId - << QStringLiteral(", user = ") << m_user); + QNTRACE("Emitting the request to update user in the local storage " + << "database: request id = " << m_addOrUpdateUserRequestId + << ", user = " << m_user); Q_EMIT updateUser(m_user, m_addOrUpdateUserRequestId); } -void RemoteToLocalSynchronizationManager::onFindUserFailed(User user, - ErrorString errorDescription, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onFindUserFailed( + User user, ErrorString errorDescription, QUuid requestId) { if (requestId != m_findUserRequestId) { return; } - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::onFindUserFailed: ") - << QStringLiteral("user = ") << user - << QStringLiteral("\nError description = ") << errorDescription - << QStringLiteral(", request id = ") << requestId); + QNDEBUG("RemoteToLocalSynchronizationManager::onFindUserFailed: " + << "user = " << user + << "\nError description = " << errorDescription + << ", request id = " << requestId); m_findUserRequestId = QUuid(); // Adding the user info as user was not found in the local storage m_addOrUpdateUserRequestId = QUuid::createUuid(); - QNTRACE(QStringLiteral("Emitting the request to add user to the local storage " - "database: request id = ") << m_addOrUpdateUserRequestId - << QStringLiteral(", user = ") << m_user); + QNTRACE("Emitting the request to add user to the local storage " + << "database: request id = " << m_addOrUpdateUserRequestId + << ", user = " << m_user); Q_EMIT addUser(m_user, m_addOrUpdateUserRequestId); } -void RemoteToLocalSynchronizationManager::onFindNotebookCompleted(Notebook notebook, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onFindNotebookCompleted( + Notebook notebook, QUuid requestId) { - QNTRACE(QStringLiteral("RemoteToLocalSynchronizationManager::onFindNotebookCompleted: " - "request id = ") << requestId - << QStringLiteral(", notebook: ") << notebook); + QNTRACE("RemoteToLocalSynchronizationManager::onFindNotebookCompleted: " + << "request id = " << requestId << ", notebook: " << notebook); bool foundByGuid = onFoundDuplicateByGuid(notebook, requestId, QStringLiteral("Notebook"), - m_notebooks, m_notebooksPendingAddOrUpdate, + m_notebooks, + m_notebooksPendingAddOrUpdate, m_findNotebookByGuidRequestIds); if (foundByGuid) { return; } bool foundByName = onFoundDuplicateByName(notebook, requestId, - QStringLiteral("Notebook"), m_notebooks, + QStringLiteral("Notebook"), + m_notebooks, m_notebooksPendingAddOrUpdate, m_findNotebookByNameRequestIds); if (foundByName) { @@ -714,7 +746,7 @@ auto rit = m_notesWithFindRequestIdsPerFindNotebookRequestId.find(requestId); if (rit != m_notesWithFindRequestIdsPerFindNotebookRequestId.end()) { - QNDEBUG(QStringLiteral("Found notebook needed for note synchronization")); + QNDEBUG("Found notebook needed for note synchronization"); const QPair<Note,QUuid> & noteWithFindRequestId = rit.value(); const Note & note = noteWithFindRequestId.first; @@ -744,8 +776,8 @@ auto iit = m_inkNoteResourceDataPerFindNotebookRequestId.find(requestId); if (iit != m_inkNoteResourceDataPerFindNotebookRequestId.end()) { - QNDEBUG(QStringLiteral("Found notebook for ink note image downloading " - "for note resource")); + QNDEBUG("Found notebook for ink note image downloading " + "for note resource"); InkNoteResourceData resourceData = iit.value(); Q_UNUSED(m_inkNoteResourceDataPerFindNotebookRequestId.erase(iit)) @@ -764,10 +796,11 @@ return; } - auto iit_note = m_notesPendingInkNoteImagesDownloadByFindNotebookRequestId.find(requestId); + auto iit_note = + m_notesPendingInkNoteImagesDownloadByFindNotebookRequestId.find(requestId); if (iit_note != m_notesPendingInkNoteImagesDownloadByFindNotebookRequestId.end()) { - QNDEBUG(QStringLiteral("Found notebook for ink note images downloading for note")); + QNDEBUG("Found notebook for ink note images downloading for note"); Note note = iit_note.value(); Q_UNUSED(m_notesPendingInkNoteImagesDownloadByFindNotebookRequestId.erase(iit_note)) @@ -775,9 +808,9 @@ bool res = setupInkNoteImageDownloadingForNote(note, notebook); if (Q_UNLIKELY(!res)) { - QNDEBUG(QStringLiteral("Wasn't able to set up the ink note image " - "downloading for note: ") << note - << QStringLiteral("\nNotebook: ") << notebook); + QNDEBUG("Wasn't able to set up the ink note image " + << "downloading for note: " << note + << "\nNotebook: " << notebook); // NOTE: treat it as a recoverable failure, just ignore it and // consider the note properly downloaded @@ -790,10 +823,11 @@ return; } - auto thumbnailIt = m_notesPendingThumbnailDownloadByFindNotebookRequestId.find(requestId); + auto thumbnailIt = + m_notesPendingThumbnailDownloadByFindNotebookRequestId.find(requestId); if (thumbnailIt != m_notesPendingThumbnailDownloadByFindNotebookRequestId.end()) { - QNDEBUG(QStringLiteral("Found note for note thumbnail downloading")); + QNDEBUG("Found note for note thumbnail downloading"); Note note = thumbnailIt.value(); Q_UNUSED(m_notesPendingThumbnailDownloadByFindNotebookRequestId.erase(thumbnailIt)) @@ -801,8 +835,8 @@ bool res = setupNoteThumbnailDownloading(note, notebook); if (Q_UNLIKELY(!res)) { - QNDEBUG(QStringLiteral("Wasn't able to set up the thumbnail downloading for note: ") - << note << QStringLiteral("\nNotebook: ") << notebook); + QNDEBUG("Wasn't able to set up the thumbnail downloading for note: " + << note << "\nNotebook: " << notebook); // NOTE: treat it as a recoverable failure, just ignore it and consider // the note properly downloaded @@ -816,24 +850,27 @@ } } -void RemoteToLocalSynchronizationManager::onFindNotebookFailed(Notebook notebook, - ErrorString errorDescription, - QUuid requestId) -{ - QNTRACE(QStringLiteral("RemoteToLocalSynchronizationManager::onFindNotebookFailed: " - "request id = ") << requestId - << QStringLiteral(", error description: ") << errorDescription - << QStringLiteral(", notebook: ") << notebook); +void RemoteToLocalSynchronizationManager::onFindNotebookFailed( + Notebook notebook, ErrorString errorDescription, QUuid requestId) +{ + QNTRACE("RemoteToLocalSynchronizationManager::onFindNotebookFailed: " + << "request id = " << requestId + << ", error description: " << errorDescription + << ", notebook: " << notebook); bool failedToFindByGuid = onNoDuplicateByGuid(notebook, requestId, - errorDescription, QStringLiteral("Notebook"), - m_notebooks, m_findNotebookByGuidRequestIds); + errorDescription, + QStringLiteral("Notebook"), + m_notebooks, + m_findNotebookByGuidRequestIds); if (failedToFindByGuid) { return; } - bool failedToFindByName = onNoDuplicateByName(notebook, requestId, errorDescription, - QStringLiteral("Notebook"), m_notebooks, + bool failedToFindByName = onNoDuplicateByName(notebook, requestId, + errorDescription, + QStringLiteral("Notebook"), + m_notebooks, m_findNotebookByNameRequestIds); if (failedToFindByName) { return; @@ -843,7 +880,7 @@ if (rit != m_notesWithFindRequestIdsPerFindNotebookRequestId.end()) { ErrorString errorDescription(QT_TR_NOOP("Failed to find the notebook for " "one of synchronized notes")); - QNWARNING(errorDescription << QStringLiteral(": ") << notebook); + QNWARNING(errorDescription << ": " << notebook); Q_EMIT failure(errorDescription); return; } @@ -860,8 +897,8 @@ Q_UNUSED(m_resourceGuidsPendingFindNotebookForInkNoteImageDownloadPerNoteGuid.erase(git)) } - QNWARNING(QStringLiteral("Can't find the notebook for the purpose of " - "setting up the ink note image downloading")); + QNWARNING("Can't find the notebook for the purpose of " + "setting up the ink note image downloading"); checkAndIncrementResourceDownloadProgress(resourceData.m_resourceGuid); @@ -889,15 +926,16 @@ Q_UNUSED(m_resourceGuidsPendingInkNoteImageDownloadPerNoteGuid.remove(note.guid())) } - QNWARNING(QStringLiteral("Can't find the notebook for the purpose of " - "setting up the ink note image downloading")); + QNWARNING("Can't find the notebook for the purpose of " + "setting up the ink note image downloading"); /** * NOTE: incrementing note download progress here because we haven't * incremented it on the receipt of full note data before setting up * the ink note image downloading */ - checkAndIncrementNoteDownloadProgress(note.hasGuid() ? note.guid() : QString()); + checkAndIncrementNoteDownloadProgress( + note.hasGuid() ? note.guid() : QString()); /** * NOTE: handle the failure to download the ink note image as @@ -910,7 +948,8 @@ return; } - auto thumbnailIt = m_notesPendingThumbnailDownloadByFindNotebookRequestId.find(requestId); + auto thumbnailIt = + m_notesPendingThumbnailDownloadByFindNotebookRequestId.find(requestId); if (thumbnailIt != m_notesPendingThumbnailDownloadByFindNotebookRequestId.end()) { Note note = thumbnailIt.value(); @@ -918,20 +957,21 @@ if (note.hasGuid()) { - // We might already have this note within those "pending the thumbnail download", - // need to remove it from there + // We might already have this note within those "pending + // the thumbnail download", need to remove it from there auto dit = m_notesPendingThumbnailDownloadByGuid.find(note.guid()); if (dit != m_notesPendingThumbnailDownloadByGuid.end()) { Q_UNUSED(m_notesPendingThumbnailDownloadByGuid.erase(dit)) } } - QNWARNING(QStringLiteral("Can't find the notebook for the purpose of " - "setting up the note thumbnail downloading")); + QNWARNING("Can't find the notebook for the purpose of " + "setting up the note thumbnail downloading"); /** - * NOTE: incrementing note download progress here because we haven't incremented it - * on the receipt of full note data before setting up the thumbnails downloading + * NOTE: incrementing note download progress here because we haven't + * incremented it on the receipt of full note data before setting up + * the thumbnails downloading */ checkAndIncrementNoteDownloadProgress(note.hasGuid() ? note.guid() @@ -957,9 +997,9 @@ auto it = m_findNoteByGuidRequestIds.find(requestId); if (it != m_findNoteByGuidRequestIds.end()) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::onFindNoteCompleted: " - "requestId = ") << requestId); - QNTRACE(QStringLiteral("Note = ") << note); + QNDEBUG("RemoteToLocalSynchronizationManager::onFindNoteCompleted: " + << "requestId = " << requestId); + QNTRACE("Note = " << note); // NOTE: erase is required for proper work of the macro; the request // would be re-inserted below if macro doesn't return from the method @@ -973,14 +1013,14 @@ "doesn't have a notebook guid")); APPEND_NOTE_DETAILS(errorDescription, note) - QNWARNING(errorDescription << QStringLiteral(": ") << note); + QNWARNING(errorDescription << ": " << note); Q_EMIT failure(errorDescription); return; } QUuid findNotebookPerNoteRequestId = QUuid::createUuid(); m_notesWithFindRequestIdsPerFindNotebookRequestId[findNotebookPerNoteRequestId] = - QPair<Note,QUuid>(note, requestId); + QPair<Note,QUuid>(note, requestId); Notebook notebookToFind; notebookToFind.unsetLocalUid(); @@ -1003,7 +1043,7 @@ "for the resource synchronization " "but it doesn't have a guid")); APPEND_NOTE_DETAILS(errorDescription, note) - QNWARNING(errorDescription << QStringLiteral(": ") << note); + QNWARNING(errorDescription << ": " << note); Q_EMIT failure(errorDescription); return; } @@ -1012,11 +1052,12 @@ if (shouldDownloadThumbnailsForNotes()) { - auto noteThumbnailDownloadIt = m_notesPendingThumbnailDownloadByGuid.find(note.guid()); + auto noteThumbnailDownloadIt = + m_notesPendingThumbnailDownloadByGuid.find(note.guid()); if (noteThumbnailDownloadIt == m_notesPendingThumbnailDownloadByGuid.end()) { - QNDEBUG(QStringLiteral("Need to download the thumbnail for " - "the note with added or updated resource")); + QNDEBUG("Need to download the thumbnail for " + "the note with added or updated resource"); // NOTE: don't care whether was capable to start downloading the note thumnail, // if not, this error is simply ignored @@ -1032,11 +1073,11 @@ if (resource.hasMime() && resource.hasWidth() && resource.hasHeight() && (resource.mime() == QStringLiteral("application/vnd.evernote.ink"))) { - QNDEBUG(QStringLiteral("The resource appears to be the one for " - "the ink note, need to download the image for it; " - "but first need to understand whether the note " - "owning the resource is from the current " - "user's account or from some linked notebook")); + QNDEBUG("The resource appears to be the one for " + "the ink note, need to download the image for it; " + "but first need to understand whether the note " + "owning the resource is from the current " + "user's account or from some linked notebook"); if (pNotebook) { @@ -1062,56 +1103,56 @@ } Q_UNUSED(m_resourceGuidsPendingFindNotebookForInkNoteImageDownloadPerNoteGuid.insert( - note.guid(), resource.guid())) + note.guid(), resource.guid())) QUuid findNotebookForInkNoteSetupRequestId = QUuid::createUuid(); m_inkNoteResourceDataPerFindNotebookRequestId[findNotebookForInkNoteSetupRequestId] = resourceData; - QNTRACE(QStringLiteral("Emitting the request to find a notebook " - "for the ink note image download resolution: ") + QNTRACE("Emitting the request to find a notebook " + << "for the ink note image download resolution: " << findNotebookForInkNoteSetupRequestId - << QStringLiteral(", resource guid = ") + << ", resource guid = " << resourceData.m_resourceGuid - << QStringLiteral(", resource height = ") + << ", resource height = " << resourceData.m_resourceHeight - << QStringLiteral(", resource width = ") + << ", resource width = " << resourceData.m_resourceWidth - << QStringLiteral(", note guid = ") << note.guid() - << QStringLiteral(", notebook: ") << dummyNotebook); + << ", note guid = " << note.guid() + << ", notebook: " << dummyNotebook); Q_EMIT findNotebook(dummyNotebook, findNotebookForInkNoteSetupRequestId); } else { - QNWARNING(QStringLiteral("Can't download the ink note image: note " - "has neither notebook local uid nor " - "notebook guid: ") << note); + QNWARNING("Can't download the ink note image: note " + << "has neither notebook local uid nor " + << "notebook guid: " << note); } } auto resourceFoundIt = m_guidsOfResourcesFoundWithinTheLocalStorage.find(resource.guid()); if (resourceFoundIt == m_guidsOfResourcesFoundWithinTheLocalStorage.end()) { - QNDEBUG(QStringLiteral("Duplicate of synchronized resource was not found " - "in the local storage database! Attempting to " - "add it to local storage")); + QNDEBUG("Duplicate of synchronized resource was not found " + "in the local storage database! Attempting to " + "add it to local storage"); registerResourcePendingAddOrUpdate(resource); getFullResourceDataAsyncAndAddToLocalStorage(resource, note); return; } if (!resource.isDirty()) { - QNDEBUG(QStringLiteral("Found duplicate resource in local storage " - "which is not marked dirty => overriding it " - "with the version received from the remote storage")); + QNDEBUG("Found duplicate resource in local storage " + "which is not marked dirty => overriding it " + "with the version received from the remote storage"); registerResourcePendingAddOrUpdate(resource); getFullResourceDataAsyncAndUpdateInLocalStorage(resource, note); return; } - QNDEBUG(QStringLiteral("Found duplicate resource in local storage which " - "is marked dirty => will treat it as a conflict " - "of notes")); + QNDEBUG("Found duplicate resource in local storage which " + "is marked dirty => will treat it as a conflict " + "of notes"); Note conflictingNote = createConflictingNote(note); @@ -1133,9 +1174,8 @@ QSet<QUuid>::iterator it = m_findNoteByGuidRequestIds.find(requestId); if (it != m_findNoteByGuidRequestIds.end()) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::onFindNoteFailed: ") - << QStringLiteral("note = ") << note << QStringLiteral(", requestId = ") - << requestId); + QNDEBUG("RemoteToLocalSynchronizationManager::onFindNoteFailed: " + << "note = " << note << ", requestId = " << requestId); Q_UNUSED(m_findNoteByGuidRequestIds.erase(it)); @@ -1159,9 +1199,8 @@ auto rit = m_resourcesByFindNoteRequestIds.find(requestId); if (rit != m_resourcesByFindNoteRequestIds.end()) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::onFindNoteFailed: ") - << QStringLiteral("note = ") << note << QStringLiteral(", requestId = ") - << requestId); + QNDEBUG("RemoteToLocalSynchronizationManager::onFindNoteFailed: " + << "note = " << note << ", requestId = " << requestId); Q_UNUSED(m_resourcesByFindNoteRequestIds.erase(rit)); @@ -1170,14 +1209,14 @@ "in the local storage")); APPEND_NOTE_DETAILS(errorDescription, note) - QNWARNING(errorDescription << QStringLiteral(", note attempted to be found: ") - << note); + QNWARNING(errorDescription << ", note attempted to be found: " << note); Q_EMIT failure(errorDescription); return; } } -void RemoteToLocalSynchronizationManager::onFindTagCompleted(Tag tag, QUuid requestId) +void RemoteToLocalSynchronizationManager::onFindTagCompleted( + Tag tag, QUuid requestId) { bool foundByGuid = onFoundDuplicateByGuid(tag, requestId, QStringLiteral("Tag"), m_tags, m_tagsPendingAddOrUpdate, @@ -1194,9 +1233,8 @@ } } -void RemoteToLocalSynchronizationManager::onFindTagFailed(Tag tag, - ErrorString errorDescription, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onFindTagFailed( + Tag tag, ErrorString errorDescription, QUuid requestId) { bool failedToFindByGuid = onNoDuplicateByGuid(tag, requestId, errorDescription, QStringLiteral("Tag"), m_tags, @@ -1222,9 +1260,9 @@ QSet<QUuid>::iterator rit = m_findResourceByGuidRequestIds.find(requestId); if (rit != m_findResourceByGuidRequestIds.end()) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::onFindResourceCompleted: " - "resource = ") << resource - << QStringLiteral(", requestId = ") << requestId); + QNDEBUG("RemoteToLocalSynchronizationManager::onFindResourceCompleted: " + << "resource = " << resource + << ", requestId = " << requestId); Q_UNUSED(m_findResourceByGuidRequestIds.erase(rit)) @@ -1245,7 +1283,7 @@ ErrorString errorDescription(QT_TR_NOOP("Found duplicate resource " "in the local storage which " "doesn't have a note guid")); - QNWARNING(errorDescription << QStringLiteral(": ") << resource); + QNWARNING(errorDescription << ": " << resource); Q_EMIT failure(errorDescription); return; } @@ -1259,9 +1297,9 @@ noteToFind.unsetLocalUid(); noteToFind.setGuid(resource.noteGuid()); - QNTRACE(QStringLiteral("Emitting the request to find resource's note by guid: " - "request id = ") << findNotePerResourceRequestId - << QStringLiteral(", note: ") << noteToFind); + QNTRACE("Emitting the request to find resource's note by guid: " + "request id = " << findNotePerResourceRequestId + << ", note: " << noteToFind); LocalStorageManager::GetNoteOptions options( LocalStorageManager::GetNoteOption::WithResourceMetadata | @@ -1280,9 +1318,8 @@ QSet<QUuid>::iterator rit = m_findResourceByGuidRequestIds.find(requestId); if (rit != m_findResourceByGuidRequestIds.end()) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::onFindResourceFailed: " - "resource = ") << resource - << QStringLiteral(", requestId = ") << requestId); + QNDEBUG("RemoteToLocalSynchronizationManager::onFindResourceFailed: " + "resource = " << resource << ", requestId = " << requestId); Q_UNUSED(m_findResourceByGuidRequestIds.erase(rit)) @@ -1302,7 +1339,7 @@ if (!resource.hasNoteGuid()) { errorDescription.setBase(QT_TR_NOOP("Detected resource which doesn't " "have note guid set")); - QNWARNING(errorDescription << QStringLiteral(": ") << resource); + QNWARNING(errorDescription << ": " << resource); Q_EMIT failure(errorDescription); return; } @@ -1314,9 +1351,9 @@ noteToFind.unsetLocalUid(); noteToFind.setGuid(resource.noteGuid()); - QNTRACE(QStringLiteral("Emitting the request to find resource's note by guid: " - "request id = ") << findNotePerResourceRequestId - << QStringLiteral(", note: ") << noteToFind); + QNTRACE("Emitting the request to find resource's note by guid: " + << "request id = " << findNotePerResourceRequestId + << ", note: " << noteToFind); LocalStorageManager::GetNoteOptions options = LocalStorageManager::GetNoteOption::WithResourceMetadata; @@ -1336,16 +1373,17 @@ } void RemoteToLocalSynchronizationManager::onFindLinkedNotebookFailed( - LinkedNotebook linkedNotebook, ErrorString errorDescription, QUuid requestId) + LinkedNotebook linkedNotebook, ErrorString errorDescription, + QUuid requestId) { QSet<QUuid>::iterator rit = m_findLinkedNotebookRequestIds.find(requestId); if (rit == m_findLinkedNotebookRequestIds.end()) { return; } - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::onFindLinkedNotebookFailed: ") - << linkedNotebook << QStringLiteral(", errorDescription = ") - << errorDescription << QStringLiteral(", requestId = ") << requestId); + QNDEBUG("RemoteToLocalSynchronizationManager::onFindLinkedNotebookFailed: " + << linkedNotebook << ", errorDescription = " + << errorDescription << ", requestId = " << requestId); Q_UNUSED(m_findLinkedNotebookRequestIds.erase(rit)); @@ -1362,8 +1400,8 @@ emitAddRequest(linkedNotebook); } -void RemoteToLocalSynchronizationManager::onFindSavedSearchCompleted(SavedSearch savedSearch, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onFindSavedSearchCompleted( + SavedSearch savedSearch, QUuid requestId) { bool foundByGuid = onFoundDuplicateByGuid(savedSearch, requestId, QStringLiteral("SavedSearch"), @@ -1384,9 +1422,8 @@ } } -void RemoteToLocalSynchronizationManager::onFindSavedSearchFailed(SavedSearch savedSearch, - ErrorString errorDescription, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onFindSavedSearchFailed( + SavedSearch savedSearch, ErrorString errorDescription, QUuid requestId) { bool failedToFindByGuid = onNoDuplicateByGuid(savedSearch, requestId, errorDescription, @@ -1415,11 +1452,10 @@ QSet<QUuid>::iterator it = addElementRequestIds.find(requestId); if (it != addElementRequestIds.end()) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("onAddDataElementCompleted<") - << typeName << QStringLiteral(">: ") << typeName - << QStringLiteral(" = ") << element - << QStringLiteral(", requestId = ") << requestId); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "onAddDataElementCompleted<" << typeName << ">: " + << typeName << " = " << element << ", requestId = " + << requestId); Q_UNUSED(addElementRequestIds.erase(it)); performPostAddOrUpdateChecks<ElementType>(element); @@ -1427,31 +1463,29 @@ } } -void RemoteToLocalSynchronizationManager::onAddUserCompleted(User user, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onAddUserCompleted( + User user, QUuid requestId) { if (requestId != m_addOrUpdateUserRequestId) { return; } - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::onAddUserCompleted: ") - << QStringLiteral("user = ") << user << QStringLiteral("\nRequest id = ") - << requestId); + QNDEBUG("RemoteToLocalSynchronizationManager::onAddUserCompleted: " + << "user = " << user << "\nRequest id = " << requestId); m_addOrUpdateUserRequestId = QUuid(); m_onceAddedOrUpdatedUserInLocalStorage = true; } -void RemoteToLocalSynchronizationManager::onAddUserFailed(User user, - ErrorString errorDescription, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onAddUserFailed( + User user, ErrorString errorDescription, QUuid requestId) { if (requestId != m_addOrUpdateUserRequestId) { return; } - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::onAddUserFailed: ") - << user << QStringLiteral("\nRequest id = ") << requestId); + QNDEBUG("RemoteToLocalSynchronizationManager::onAddUserFailed: " + << user << "\nRequest id = " << requestId); ErrorString error(QT_TR_NOOP("Failed to add the user data fetched from " "the remote database to the local storage")); @@ -1463,13 +1497,15 @@ m_addOrUpdateUserRequestId = QUuid(); } -void RemoteToLocalSynchronizationManager::onAddTagCompleted(Tag tag, QUuid requestId) +void RemoteToLocalSynchronizationManager::onAddTagCompleted( + Tag tag, QUuid requestId) { - onAddDataElementCompleted(tag, requestId, QStringLiteral("Tag"), m_addTagRequestIds); + onAddDataElementCompleted(tag, requestId, QStringLiteral("Tag"), + m_addTagRequestIds); } -void RemoteToLocalSynchronizationManager::onAddSavedSearchCompleted(SavedSearch search, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onAddSavedSearchCompleted( + SavedSearch search, QUuid requestId) { onAddDataElementCompleted(search, requestId, QStringLiteral("SavedSearch"), m_addSavedSearchRequestIds); @@ -1484,12 +1520,11 @@ QSet<QUuid>::iterator it = addElementRequestIds.find(requestId); if (it != addElementRequestIds.end()) { - QNWARNING(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("onAddDataElementFailed<") - << typeName << QStringLiteral(">: ") << typeName - << QStringLiteral(" = ") << element - << QStringLiteral("\nError description = ") << errorDescription - << QStringLiteral(", requestId = ") << requestId); + QNWARNING("RemoteToLocalSynchronizationManager::" + << "onAddDataElementFailed<" << typeName << ">: " + << typeName << " = " << element + << "\nError description = " << errorDescription + << ", requestId = " << requestId); Q_UNUSED(addElementRequestIds.erase(it)); @@ -1505,58 +1540,53 @@ } } -void RemoteToLocalSynchronizationManager::onAddTagFailed(Tag tag, - ErrorString errorDescription, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onAddTagFailed( + Tag tag, ErrorString errorDescription, QUuid requestId) { onAddDataElementFailed(tag, requestId, errorDescription, QStringLiteral("Tag"), m_addTagRequestIds); } -void RemoteToLocalSynchronizationManager::onAddSavedSearchFailed(SavedSearch search, - ErrorString errorDescription, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onAddSavedSearchFailed( + SavedSearch search, ErrorString errorDescription, QUuid requestId) { onAddDataElementFailed(search, requestId, errorDescription, - QStringLiteral("SavedSearch"), m_addSavedSearchRequestIds); + QStringLiteral("SavedSearch"), + m_addSavedSearchRequestIds); } -void RemoteToLocalSynchronizationManager::onUpdateUserCompleted(User user, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onUpdateUserCompleted( + User user, QUuid requestId) { if (requestId != m_addOrUpdateUserRequestId) { if (user.hasId() && m_user.hasId() && (user.id() == m_user.id())) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("onUpdateUserCompleted: external update ") - << QStringLiteral("of current user, request id = ") - << requestId); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "onUpdateUserCompleted: external update " + << "of current user, request id = " << requestId); m_user = user; } return; } - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::onUpdateUserCompleted: ") - << QStringLiteral("user = ") << user << QStringLiteral("\nRequest id = ") - << requestId); + QNDEBUG("RemoteToLocalSynchronizationManager::onUpdateUserCompleted: " + << "user = " << user << "\nRequest id = " << requestId); m_addOrUpdateUserRequestId = QUuid(); m_onceAddedOrUpdatedUserInLocalStorage = true; } -void RemoteToLocalSynchronizationManager::onUpdateUserFailed(User user, - ErrorString errorDescription, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onUpdateUserFailed( + User user, ErrorString errorDescription, QUuid requestId) { if (requestId != m_addOrUpdateUserRequestId) { return; } - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::onUpdateUserFailed: ") - << QStringLiteral("user = ") << user - << QStringLiteral("\nError description = ") << errorDescription - << QStringLiteral(", request id = ") << requestId); + QNDEBUG("RemoteToLocalSynchronizationManager::onUpdateUserFailed: " + << "user = " << user << "\nError description = " << errorDescription + << ", request id = " << requestId); ErrorString error(QT_TR_NOOP("Can't update the user data fetched from " "the remote database in the local storage")); @@ -1578,26 +1608,24 @@ return; } - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizartionManager::") - << QStringLiteral("onUpdateDataElementCompleted<") - << typeName << QStringLiteral(">: ") << typeName - << QStringLiteral(" = ") << element - << QStringLiteral(", requestId = ") << requestId); + QNDEBUG("RemoteToLocalSynchronizartionManager::" + << "onUpdateDataElementCompleted<" << typeName << ">: " + << typeName << " = " << element << ", requestId = " << requestId); Q_UNUSED(updateElementRequestIds.erase(rit)); performPostAddOrUpdateChecks<ElementType>(element); checkServerDataMergeCompletion(); } -void RemoteToLocalSynchronizationManager::onUpdateTagCompleted(Tag tag, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onUpdateTagCompleted( + Tag tag, QUuid requestId) { onUpdateDataElementCompleted(tag, requestId, QStringLiteral("Tag"), m_updateTagRequestIds); } -void RemoteToLocalSynchronizationManager::onUpdateSavedSearchCompleted(SavedSearch search, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onUpdateSavedSearchCompleted( + SavedSearch search, QUuid requestId) { onUpdateDataElementCompleted(search, requestId, QStringLiteral("SavedSearch"), m_updateSavedSearchRequestIds); @@ -1614,11 +1642,10 @@ return; } - QNWARNING(QStringLiteral("RemoteToLocalSynchronizationManager::onUpdateDataElementFailed<") - << typeName << QStringLiteral(">: ") << typeName - << QStringLiteral(" = ") << element - << QStringLiteral(", errorDescription = ") << errorDescription - << QStringLiteral(", requestId = ") << requestId); + QNWARNING("RemoteToLocalSynchronizationManager::onUpdateDataElementFailed<" + << typeName << ">: " << typeName << " = " << element + << ", errorDescription = " << errorDescription + << ", requestId = " << requestId); Q_UNUSED(updateElementRequestIds.erase(it)); @@ -1630,12 +1657,11 @@ Q_EMIT failure(error); } -void RemoteToLocalSynchronizationManager::onUpdateTagFailed(Tag tag, - ErrorString errorDescription, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onUpdateTagFailed( + Tag tag, ErrorString errorDescription, QUuid requestId) { - onUpdateDataElementFailed(tag, requestId, errorDescription, QStringLiteral("Tag"), - m_updateTagRequestIds); + onUpdateDataElementFailed(tag, requestId, errorDescription, + QStringLiteral("Tag"), m_updateTagRequestIds); } void RemoteToLocalSynchronizationManager::onExpungeTagCompleted( @@ -1646,9 +1672,8 @@ Q_UNUSED(expungedChildTagLocalUids) } -void RemoteToLocalSynchronizationManager::onExpungeTagFailed(Tag tag, - ErrorString errorDescription, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onExpungeTagFailed( + Tag tag, ErrorString errorDescription, QUuid requestId) { onExpungeDataElementFailed(tag, requestId, errorDescription, QStringLiteral("Tag"), m_expungeTagRequestIds); @@ -1658,8 +1683,8 @@ QUuid requestId) { if (requestId == m_expungeNotelessTagsRequestId) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "onExpungeNotelessTagsFromLinkedNotebooksCompleted")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "onExpungeNotelessTagsFromLinkedNotebooksCompleted"); m_expungeNotelessTagsRequestId = QUuid(); finalize(); return; @@ -1673,8 +1698,8 @@ return; } - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("onExpungeNotelessTagsFromLinkedNotebooksFailed: ") + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "onExpungeNotelessTagsFromLinkedNotebooksFailed: " << errorDescription); m_expungeNotelessTagsRequestId = QUuid(); @@ -1686,25 +1711,23 @@ Q_EMIT failure(error); } -void RemoteToLocalSynchronizationManager::onUpdateSavedSearchFailed(SavedSearch search, - ErrorString errorDescription, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onUpdateSavedSearchFailed( + SavedSearch search, ErrorString errorDescription, QUuid requestId) { onUpdateDataElementFailed(search, requestId, errorDescription, QStringLiteral("SavedSearch"), m_updateSavedSearchRequestIds); } -void RemoteToLocalSynchronizationManager::onExpungeSavedSearchCompleted(SavedSearch search, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onExpungeSavedSearchCompleted( + SavedSearch search, QUuid requestId) { onExpungeDataElementCompleted(search, requestId, QStringLiteral("SavedSearch"), m_expungeSavedSearchRequestIds); } -void RemoteToLocalSynchronizationManager::onExpungeSavedSearchFailed(SavedSearch search, - ErrorString errorDescription, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onExpungeSavedSearchFailed( + SavedSearch search, ErrorString errorDescription, QUuid requestId) { onExpungeDataElementFailed(search, requestId, errorDescription, QStringLiteral("SavedSearch"), @@ -1715,8 +1738,8 @@ void RemoteToLocalSynchronizationManager::performPostAddOrUpdateChecks<Tag>( const Tag & tag) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "performPostAddOrUpdateChecks<Tag>: ") << tag); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "performPostAddOrUpdateChecks<Tag>: " << tag); unregisterTagPendingAddOrUpdate(tag); syncNextTagPendingProcessing(); @@ -1728,8 +1751,8 @@ void RemoteToLocalSynchronizationManager::performPostAddOrUpdateChecks<Notebook>( const Notebook & notebook) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::performPostAddOrUpdateChecks<Notebook>: ") - << notebook); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "performPostAddOrUpdateChecks<Notebook>: " << notebook); unregisterNotebookPendingAddOrUpdate(notebook); checkNotebooksAndTagsSyncCompletionAndLaunchNotesAndResourcesSync(); @@ -1740,9 +1763,8 @@ void RemoteToLocalSynchronizationManager::performPostAddOrUpdateChecks<Note>( const Note & note) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("performPostAddOrUpdateChecks<Note>: ") - << note); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "performPostAddOrUpdateChecks<Note>: " << note); unregisterNotePendingAddOrUpdate(note); checkNotesSyncCompletionAndLaunchResourcesSync(); @@ -1753,9 +1775,8 @@ void RemoteToLocalSynchronizationManager::performPostAddOrUpdateChecks<Resource>( const Resource & resource) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("performPostAddOrUpdateChecks<Resource>: ") - << resource); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "performPostAddOrUpdateChecks<Resource>: " << resource); unregisterResourcePendingAddOrUpdate(resource); checkServerDataMergeCompletion(); @@ -1765,8 +1786,8 @@ void RemoteToLocalSynchronizationManager::performPostAddOrUpdateChecks<SavedSearch>( const SavedSearch & search) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("performPostAddOrUpdateChecks<SavedSearch>: ") + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "performPostAddOrUpdateChecks<SavedSearch>: " << search); unregisterSavedSearchPendingAddOrUpdate(search); @@ -1809,8 +1830,7 @@ return; } - QNTRACE(QStringLiteral("Expunged ") << typeName - << QStringLiteral(" from local storage: ") << element); + QNTRACE("Expunged " << typeName << " from local storage: " << element); Q_UNUSED(expungeElementRequestIds.erase(it)) performPostExpungeChecks<ElementType>(); @@ -1831,12 +1851,11 @@ return; } - QNDEBUG(QStringLiteral("Failed to expunge ") << typeName - << QStringLiteral(" from the local storage; won't panic since most " - "likely the corresponding data element has never " - "existed in the local storage in the first place. " - "Error description: ") - << errorDescription); + QNDEBUG("Failed to expunge " << typeName + << " from the local storage; won't panic since most " + << "likely the corresponding data element has never " + << "existed in the local storage in the first place. " + << "Error description: " << errorDescription); Q_UNUSED(expungeElementRequestIds.erase(it)) performPostExpungeChecks<ElementType>(); @@ -1845,7 +1864,7 @@ void RemoteToLocalSynchronizationManager::expungeTags() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::expungeTags: ") + QNDEBUG("RemoteToLocalSynchronizationManager::expungeTags: " << m_expungedTags.size()); if (m_expungedTags.isEmpty()) { @@ -1863,8 +1882,8 @@ QUuid expungeTagRequestId = QUuid::createUuid(); Q_UNUSED(m_expungeTagRequestIds.insert(expungeTagRequestId)); - QNTRACE(QStringLiteral("Emitting the request to expunge tag: guid = ") - << expungedTagGuid << QStringLiteral(", request id = ") + QNTRACE("Emitting the request to expunge tag: guid = " + << expungedTagGuid << ", request id = " << expungeTagRequestId); Q_EMIT expungeTag(tagToExpunge, expungeTagRequestId); } @@ -1874,7 +1893,7 @@ void RemoteToLocalSynchronizationManager::expungeSavedSearches() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::expungeSavedSearches: ") + QNDEBUG("RemoteToLocalSynchronizationManager::expungeSavedSearches: " << m_expungedSavedSearches.size()); if (m_expungedSavedSearches.isEmpty()) { @@ -1892,8 +1911,8 @@ QUuid expungeSavedSearchRequestId = QUuid::createUuid(); Q_UNUSED(m_expungeSavedSearchRequestIds.insert(expungeSavedSearchRequestId)); - QNTRACE(QStringLiteral("Emitting the request to expunge saved search: guid = ") - << expungedSavedSerchGuid << QStringLiteral(", request id = ") + QNTRACE("Emitting the request to expunge saved search: guid = " + << expungedSavedSerchGuid << ", request id = " << expungeSavedSearchRequestId); Q_EMIT expungeSavedSearch(searchToExpunge, expungeSavedSearchRequestId); } @@ -1903,7 +1922,7 @@ void RemoteToLocalSynchronizationManager::expungeLinkedNotebooks() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::expungeLinkedNotebooks: ") + QNDEBUG("RemoteToLocalSynchronizationManager::expungeLinkedNotebooks: " << m_expungedLinkedNotebooks.size()); if (m_expungedLinkedNotebooks.isEmpty()) { @@ -1920,8 +1939,8 @@ QUuid expungeLinkedNotebookRequestId = QUuid::createUuid(); Q_UNUSED(m_expungeLinkedNotebookRequestIds.insert(expungeLinkedNotebookRequestId)); - QNTRACE(QStringLiteral("Emitting the request to expunge linked notebook: guid = ") - << expungedLinkedNotebookGuid << QStringLiteral(", request id = ") + QNTRACE("Emitting the request to expunge linked notebook: guid = " + << expungedLinkedNotebookGuid << ", request id = " << expungeLinkedNotebookRequestId); Q_EMIT expungeLinkedNotebook(linkedNotebookToExpunge, expungeLinkedNotebookRequestId); @@ -1932,7 +1951,7 @@ void RemoteToLocalSynchronizationManager::expungeNotebooks() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::expungeNotebooks: ") + QNDEBUG("RemoteToLocalSynchronizationManager::expungeNotebooks: " << m_expungedNotebooks.size()); if (m_expungedNotebooks.isEmpty()) { @@ -1950,8 +1969,8 @@ QUuid expungeNotebookRequestId = QUuid::createUuid(); Q_UNUSED(m_expungeNotebookRequestIds.insert(expungeNotebookRequestId)); - QNTRACE(QStringLiteral("Emitting the request to expunge notebook: notebook guid = ") - << expungedNotebookGuid << QStringLiteral(", request id = ") + QNTRACE("Emitting the request to expunge notebook: notebook guid = " + << expungedNotebookGuid << ", request id = " << expungeNotebookRequestId); Q_EMIT expungeNotebook(notebookToExpunge, expungeNotebookRequestId); } @@ -1961,7 +1980,7 @@ void RemoteToLocalSynchronizationManager::expungeNotes() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::expungeNotes: ") + QNDEBUG("RemoteToLocalSynchronizationManager::expungeNotes: " << m_expungedNotes.size()); if (m_expungedNotes.isEmpty()) { @@ -1979,8 +1998,8 @@ QUuid expungeNoteRequestId = QUuid::createUuid(); Q_UNUSED(m_expungeNoteRequestIds.insert(expungeNoteRequestId)); - QNTRACE(QStringLiteral("Emitting the request to expunge note: guid = ") - << expungedNoteGuid << QStringLiteral(", request id = ") + QNTRACE("Emitting the request to expunge note: guid = " + << expungedNoteGuid << ", request id = " << expungeNoteRequestId); Q_EMIT expungeNote(noteToExpunge, expungeNoteRequestId); } @@ -2025,8 +2044,8 @@ void RemoteToLocalSynchronizationManager::expungeFromServerToClient() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "expungeFromServerToClient")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "expungeFromServerToClient"); expungeNotes(); expungeNotebooks(); @@ -2039,24 +2058,27 @@ void RemoteToLocalSynchronizationManager::checkExpungesCompletion() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "checkExpungesCompletion")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "checkExpungesCompletion"); if (m_expungedTags.isEmpty() && m_expungeTagRequestIds.isEmpty() && m_expungedNotebooks.isEmpty() && m_expungeNotebookRequestIds.isEmpty() && - m_expungedSavedSearches.isEmpty() && m_expungeSavedSearchRequestIds.isEmpty() && - m_expungedLinkedNotebooks.isEmpty() && m_expungeLinkedNotebookRequestIds.isEmpty() && + m_expungedSavedSearches.isEmpty() && + m_expungeSavedSearchRequestIds.isEmpty() && + m_expungedLinkedNotebooks.isEmpty() && + m_expungeLinkedNotebookRequestIds.isEmpty() && m_expungedNotes.isEmpty() && m_expungeNoteRequestIds.isEmpty()) { - QNDEBUG(QStringLiteral("No pending expunge requests")); + QNDEBUG("No pending expunge requests"); if (syncingLinkedNotebooksContent()) { m_expungeNotelessTagsRequestId = QUuid::createUuid(); - QNTRACE(QStringLiteral("Emitting the request to expunge noteless tags ") - << QStringLiteral("from local storage: request id = ") + QNTRACE("Emitting the request to expunge noteless tags " + << "from local storage: request id = " << m_expungeNotelessTagsRequestId); - Q_EMIT expungeNotelessTagsFromLinkedNotebooks(m_expungeNotelessTagsRequestId); + Q_EMIT expungeNotelessTagsFromLinkedNotebooks( + m_expungeNotelessTagsRequestId); } else if (!m_expungedFromServerToClient) { @@ -2068,27 +2090,23 @@ } else { - QNDEBUG(QStringLiteral("Expunges not complete yet: still have ") - << m_expungedTags.size() - << QStringLiteral(" tags pending expunging, ") - << m_expungeTagRequestIds.size() - << QStringLiteral(" expunge tag requests, ") - << m_expungedNotebooks.size() - << QStringLiteral(" notebooks pending expunging, ") + QNDEBUG("Expunges not complete yet: still have " + << m_expungedTags.size() << " tags pending expunging, " + << m_expungeTagRequestIds.size() << " expunge tag requests, " + << m_expungedNotebooks.size() << " notebooks pending expunging, " << m_expungeNotebookRequestIds.size() - << QStringLiteral(" expunge notebook requests, ") + << " expunge notebook requests, " << m_expungedSavedSearches.size() - << QStringLiteral(" saved searches pending expunging, ") + << " saved searches pending expunging, " << m_expungeSavedSearchRequestIds.size() - << QStringLiteral(" expunge saved search requests, ") + << " expunge saved search requests, " << m_expungedLinkedNotebooks.size() - << QStringLiteral(" linked notebooks pending expunging, ") + << " linked notebooks pending expunging, " << m_expungeLinkedNotebookRequestIds.size() - << QStringLiteral(" expunge linked notebook requests, ") - << m_expungedNotes.size() - << QStringLiteral(" notes pendinig expunging, ") + << " expunge linked notebook requests, " + << m_expungedNotes.size() << " notes pendinig expunging, " << m_expungeNoteRequestIds.size() - << QStringLiteral(" expunge note requests")); + << " expunge note requests"); } } @@ -2106,25 +2124,23 @@ QString RemoteToLocalSynchronizationManager::checkAndAddLinkedNotebookBinding<Notebook>( Notebook & notebook) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "checkAndAddLinkedNotebookBinding<Notebook>: ") - << notebook); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "checkAndAddLinkedNotebookBinding<Notebook>: " << notebook); if (!notebook.hasGuid()) { - QNDEBUG(QStringLiteral("The notebook has no guid")); + QNDEBUG("The notebook has no guid"); return QString(); } auto it = m_linkedNotebookGuidsByNotebookGuids.find(notebook.guid()); if (it == m_linkedNotebookGuidsByNotebookGuids.end()) { - QNDEBUG(QStringLiteral("Found no linked notebook guid for notebook guid ") + QNDEBUG("Found no linked notebook guid for notebook guid " << notebook.guid()); return QString(); } notebook.setLinkedNotebookGuid(it.value()); - QNDEBUG(QStringLiteral("Set linked notebook guid ") << it.value() - << QStringLiteral(" to the notebook")); + QNDEBUG("Set linked notebook guid " << it.value() << " to the notebook"); // NOTE: the notebook coming from the linked notebook might be marked as // default and/or last used which might not make much sense in the context @@ -2140,24 +2156,22 @@ QString RemoteToLocalSynchronizationManager::checkAndAddLinkedNotebookBinding<Tag>( Tag & tag) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "checkAndAddLinkedNotebookBinding<Tag>: ") << tag); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "checkAndAddLinkedNotebookBinding<Tag>: " << tag); if (!tag.hasGuid()) { - QNDEBUG(QStringLiteral("The tag has no guid")); + QNDEBUG("The tag has no guid"); return QString(); } auto it = m_linkedNotebookGuidsByTagGuids.find(tag.guid()); if (it == m_linkedNotebookGuidsByTagGuids.end()) { - QNDEBUG(QStringLiteral("Found no linked notebook guid for tag guid ") - << tag.guid()); + QNDEBUG("Found no linked notebook guid for tag guid " << tag.guid()); return QString(); } tag.setLinkedNotebookGuid(it.value()); - QNDEBUG(QStringLiteral("Set linked notebook guid ") << it.value() - << QStringLiteral(" to the tag")); + QNDEBUG("Set linked notebook guid " << it.value() << " to the tag"); return it.value(); } @@ -2166,8 +2180,8 @@ void RemoteToLocalSynchronizationManager::emitFindByGuidRequest<qevercloud::Tag>( const qevercloud::Tag & qecTag) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "emitFindByGuidRequest<Tag>: tag = ") << qecTag); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "emitFindByGuidRequest<Tag>: tag = " << qecTag); if (Q_UNLIKELY(!qecTag.guid.isSet())) { @@ -2175,7 +2189,7 @@ QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", "Internal error: detected attempt to find tag " "by guid using tag which doesn't have a guid")); - QNWARNING(errorDescription << QStringLiteral(": ") << qecTag); + QNWARNING(errorDescription << ": " << qecTag); Q_EMIT failure(errorDescription); return; } @@ -2187,9 +2201,8 @@ QUuid requestId = QUuid::createUuid(); Q_UNUSED(m_findTagByGuidRequestIds.insert(requestId)); - QNTRACE(QStringLiteral("Emitting the request to find tag in the local storage: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", tag: ") << tag); + QNTRACE("Emitting the request to find tag in the local storage: " + << "request id = " << requestId << ", tag: " << tag); Q_EMIT findTag(tag, requestId); } @@ -2197,9 +2210,8 @@ void RemoteToLocalSynchronizationManager::emitFindByGuidRequest<qevercloud::SavedSearch>( const qevercloud::SavedSearch & qecSearch) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "emitFindByGuidRequest<SavedSearch>: search = ") - << qecSearch); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "emitFindByGuidRequest<SavedSearch>: search = " << qecSearch); if (Q_UNLIKELY(!qecSearch.guid.isSet())) { ErrorString errorDescription( @@ -2207,7 +2219,7 @@ "Internal error: detected attempt to find saved " "search by guid using saved search which doesn't " "have a guid")); - QNWARNING(errorDescription << QStringLiteral(": ") << qecSearch); + QNWARNING(errorDescription << ": " << qecSearch); Q_EMIT failure(errorDescription); return; } @@ -2218,9 +2230,9 @@ QUuid requestId = QUuid::createUuid(); Q_UNUSED(m_findSavedSearchByGuidRequestIds.insert(requestId)); - QNTRACE(QStringLiteral("Emitting the request to find saved search " - "in the local storage: request id = ") << requestId - << QStringLiteral(", saved search: ") << search); + QNTRACE("Emitting the request to find saved search " + << "in the local storage: request id = " << requestId + << ", saved search: " << search); Q_EMIT findSavedSearch(search, requestId); } @@ -2228,16 +2240,15 @@ void RemoteToLocalSynchronizationManager::emitFindByGuidRequest<qevercloud::Notebook>( const qevercloud::Notebook & qecNotebook) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "emitFindByGuidRequest<Notebook>: notebook = ") - << qecNotebook); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "emitFindByGuidRequest<Notebook>: notebook = " << qecNotebook); if (Q_UNLIKELY(!qecNotebook.guid.isSet())) { ErrorString errorDescription( QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", "Internal error: detected attempt to find notebook " "by guid using notebook which doesn't have a guid")); - QNWARNING(errorDescription << QStringLiteral(": ") << qecNotebook); + QNWARNING(errorDescription << ": " << qecNotebook); Q_EMIT failure(errorDescription); return; } @@ -2249,9 +2260,9 @@ QUuid requestId = QUuid::createUuid(); Q_UNUSED(m_findNotebookByGuidRequestIds.insert(requestId)); - QNTRACE(QStringLiteral("Emitting the request to find notebook " - "in the local storage: request id = ") << requestId - << QStringLiteral(", notebook: ") << notebook); + QNTRACE("Emitting the request to find notebook " + << "in the local storage: request id = " << requestId + << ", notebook: " << notebook); Q_EMIT findNotebook(notebook, requestId); } @@ -2259,8 +2270,8 @@ void RemoteToLocalSynchronizationManager::emitFindByGuidRequest<qevercloud::LinkedNotebook>( const qevercloud::LinkedNotebook & qecLinkedNotebook) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "emitFindByGuidRequest<LinkedNotebook>: linked notebook = ") + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "emitFindByGuidRequest<LinkedNotebook>: linked notebook = " << qecLinkedNotebook); if (Q_UNLIKELY(!qecLinkedNotebook.guid.isSet())) { @@ -2269,7 +2280,7 @@ "Internal error: detected attempt to find linked " "notebook by guid using linked notebook which " "doesn't have a guid")); - QNWARNING(errorDescription << QStringLiteral(": ") << qecLinkedNotebook); + QNWARNING(errorDescription << ": " << qecLinkedNotebook); Q_EMIT failure(errorDescription); return; } @@ -2278,9 +2289,9 @@ QUuid requestId = QUuid::createUuid(); Q_UNUSED(m_findLinkedNotebookRequestIds.insert(requestId)); - QNTRACE(QStringLiteral("Emitting the request to find linked notebook " - "in the local storage: request id = ") << requestId - << QStringLiteral(", linked notebook: ") << linkedNotebook); + QNTRACE("Emitting the request to find linked notebook " + << "in the local storage: request id = " << requestId + << ", linked notebook: " << linkedNotebook); Q_EMIT findLinkedNotebook(linkedNotebook, requestId); } @@ -2288,15 +2299,15 @@ void RemoteToLocalSynchronizationManager::emitFindByGuidRequest<qevercloud::Note>( const qevercloud::Note & qecNote) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "emitFindByGuidRequest<Note>: note = ") << qecNote); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "emitFindByGuidRequest<Note>: note = " << qecNote); if (Q_UNLIKELY(!qecNote.guid.isSet())) { ErrorString errorDescription( QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", "Internal error: detected attempt to find note " "by guid using note which doesn't have a guid")); - QNWARNING(errorDescription << QStringLiteral(": ") << qecNote); + QNWARNING(errorDescription << ": " << qecNote); Q_EMIT failure(errorDescription); return; } @@ -2306,7 +2317,7 @@ QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", "Internal error: the note from the Evernote " "service has no notebook guid")); - QNWARNING(errorDescription << QStringLiteral(": ") << qecNote); + QNWARNING(errorDescription << ": " << qecNote); Q_EMIT failure(errorDescription); return; } @@ -2318,9 +2329,8 @@ QUuid requestId = QUuid::createUuid(); Q_UNUSED(m_findNoteByGuidRequestIds.insert(requestId)); - QNTRACE(QStringLiteral("Emitting the request to find note in the local storage: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", note: ") << note); + QNTRACE("Emitting the request to find note in the local storage: " + << "request id = " << requestId << ", note: " << note); LocalStorageManager::GetNoteOptions options = LocalStorageManager::GetNoteOption::WithResourceMetadata; Q_EMIT findNote(note, options, requestId); @@ -2330,8 +2340,8 @@ void RemoteToLocalSynchronizationManager::emitFindByGuidRequest<qevercloud::Resource>( const qevercloud::Resource & qecResource) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "emitFindByGuidRequest<Resource>: resource = ") + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "emitFindByGuidRequest<Resource>: resource = " << qecResource); if (Q_UNLIKELY(!qecResource.guid.isSet())) { @@ -2339,7 +2349,7 @@ QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", "Internal error: detected attempt to find resource " "by guid using resource which doesn't have a guid")); - QNWARNING(errorDescription << QStringLiteral(": ") << qecResource); + QNWARNING(errorDescription << ": " << qecResource); Q_EMIT failure(errorDescription); return; } @@ -2348,8 +2358,9 @@ ErrorString errorDescription( QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", "Internal error: detected attempt to find resource " - "by guid using resource which doesn't have a note guid")); - QNWARNING(errorDescription << QStringLiteral(": ") << qecResource); + "by guid using resource which doesn't have " + "a note guid")); + QNWARNING(errorDescription << ": " << qecResource); Q_EMIT failure(errorDescription); return; } @@ -2370,9 +2381,9 @@ QUuid requestId = QUuid::createUuid(); Q_UNUSED(m_findResourceByGuidRequestIds.insert(requestId)); - QNTRACE(QStringLiteral("Emitting the request to find resource " - "in the local storage: request id = ") << requestId - << QStringLiteral(", resource: ") << resource); + QNTRACE("Emitting the request to find resource " + << "in the local storage: request id = " << requestId + << ", resource: " << resource); LocalStorageManager::GetResourceOptions options(0); Q_EMIT findResource(resource, options, requestId); } @@ -2385,9 +2396,9 @@ auto it = m_addLinkedNotebookRequestIds.find(requestId); if (it != m_addLinkedNotebookRequestIds.end()) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("onAddLinkedNotebookCompleted: linked notebook = ") - << linkedNotebook << QStringLiteral(", request id = ") << requestId); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "onAddLinkedNotebookCompleted: linked notebook = " + << linkedNotebook << ", request id = " << requestId); Q_UNUSED(m_addLinkedNotebookRequestIds.erase(it)) checkServerDataMergeCompletion(); @@ -2410,9 +2421,9 @@ auto it = m_updateLinkedNotebookRequestIds.find(requestId); if (it != m_updateLinkedNotebookRequestIds.end()) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("onUpdateLinkedNotebookCompleted: linkedNotebook = ") - << linkedNotebook << QStringLiteral(", requestId = ") << requestId); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "onUpdateLinkedNotebookCompleted: linkedNotebook = " + << linkedNotebook << ", requestId = " << requestId); Q_UNUSED(m_updateLinkedNotebookRequestIds.erase(it)); checkServerDataMergeCompletion(); @@ -2425,10 +2436,10 @@ QSet<QUuid>::iterator it = m_updateLinkedNotebookRequestIds.find(requestId); if (it != m_updateLinkedNotebookRequestIds.end()) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "onUpdateLinkedNotebookFailed: linkedNotebook = ") - << linkedNotebook << QStringLiteral(", errorDescription = ") - << errorDescription << QStringLiteral(", requestId = ") << requestId); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "onUpdateLinkedNotebookFailed: linkedNotebook = " + << linkedNotebook << ", errorDescription = " + << errorDescription << ", requestId = " << requestId); ErrorString error(QT_TR_NOOP("Failed to update a linked notebook " "in the local storage")); @@ -2447,7 +2458,7 @@ m_expungeLinkedNotebookRequestIds); if (Q_UNLIKELY(!linkedNotebook.hasGuid())) { - QNWARNING(QStringLiteral("Detected expunging of a linked notebook without guid: ") + QNWARNING("Detected expunging of a linked notebook without guid: " << linkedNotebook); return; } @@ -2509,12 +2520,11 @@ return; } - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("onListAllLinkedNotebooksCompleted: limit = ") - << limit << QStringLiteral(", offset = ") << offset - << QStringLiteral(", order = ") << order - << QStringLiteral(", order direction = ") << orderDirection - << QStringLiteral(", requestId = ") << requestId); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "onListAllLinkedNotebooksCompleted: limit = " << limit + << ", offset = " << offset << ", order = " << order + << ", order direction = " << orderDirection + << ", requestId = " << requestId); m_listAllLinkedNotebooksRequestId = QUuid(); m_allLinkedNotebooks = linkedNotebooks; @@ -2533,14 +2543,12 @@ return; } - QNWARNING(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("onListAllLinkedNotebooksFailed: limit = ") - << limit << QStringLiteral(", offset = ") << offset - << QStringLiteral(", order = ") << order - << QStringLiteral(", order direction = ") - << orderDirection << QStringLiteral(", error description = ") - << errorDescription << QStringLiteral("; request id = ") - << requestId); + QNWARNING("RemoteToLocalSynchronizationManager::" + << "onListAllLinkedNotebooksFailed: limit = " << limit + << ", offset = " << offset << ", order = " << order + << ", order direction = " << orderDirection + << ", error description = " << errorDescription + << "; request id = " << requestId); m_allLinkedNotebooksListed = false; @@ -2552,61 +2560,59 @@ Q_EMIT failure(error); } -void RemoteToLocalSynchronizationManager::onAddNotebookCompleted(Notebook notebook, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onAddNotebookCompleted( + Notebook notebook, QUuid requestId) { onAddDataElementCompleted(notebook, requestId, QStringLiteral("Notebook"), m_addNotebookRequestIds); } -void RemoteToLocalSynchronizationManager::onAddNotebookFailed(Notebook notebook, - ErrorString errorDescription, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onAddNotebookFailed( + Notebook notebook, ErrorString errorDescription, QUuid requestId) { onAddDataElementFailed(notebook, requestId, errorDescription, QStringLiteral("Notebook"), m_addNotebookRequestIds); } -void RemoteToLocalSynchronizationManager::onUpdateNotebookCompleted(Notebook notebook, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onUpdateNotebookCompleted( + Notebook notebook, QUuid requestId) { onUpdateDataElementCompleted(notebook, requestId, QStringLiteral("Notebook"), m_updateNotebookRequestIds); } -void RemoteToLocalSynchronizationManager::onUpdateNotebookFailed(Notebook notebook, - ErrorString errorDescription, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onUpdateNotebookFailed( + Notebook notebook, ErrorString errorDescription, QUuid requestId) { onUpdateDataElementFailed(notebook, requestId, errorDescription, - QStringLiteral("Notebook"), m_updateNotebookRequestIds); + QStringLiteral("Notebook"), + m_updateNotebookRequestIds); } -void RemoteToLocalSynchronizationManager::onExpungeNotebookCompleted(Notebook notebook, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onExpungeNotebookCompleted( + Notebook notebook, QUuid requestId) { onExpungeDataElementCompleted(notebook, requestId, QStringLiteral("Notebook"), m_expungeNotebookRequestIds); } -void RemoteToLocalSynchronizationManager::onExpungeNotebookFailed(Notebook notebook, - ErrorString errorDescription, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onExpungeNotebookFailed( + Notebook notebook, ErrorString errorDescription, QUuid requestId) { onExpungeDataElementFailed(notebook, requestId, errorDescription, - QStringLiteral("Notebook"), m_expungeNotebookRequestIds); + QStringLiteral("Notebook"), + m_expungeNotebookRequestIds); } -void RemoteToLocalSynchronizationManager::onAddNoteCompleted(Note note, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onAddNoteCompleted( + Note note, QUuid requestId) { onAddDataElementCompleted(note, requestId, QStringLiteral("Note"), m_addNoteRequestIds); } -void RemoteToLocalSynchronizationManager::onAddNoteFailed(Note note, - ErrorString errorDescription, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onAddNoteFailed( + Note note, ErrorString errorDescription, QUuid requestId) { onAddDataElementFailed(note, requestId, errorDescription, QStringLiteral("Note"), m_addNoteRequestIds); @@ -2620,9 +2626,9 @@ auto it = m_updateNoteRequestIds.find(requestId); if (it != m_updateNoteRequestIds.end()) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("onUpdateNoteCompleted: note = ") << note - << QStringLiteral("\nRequestId = ") << requestId); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "onUpdateNoteCompleted: note = " << note + << "\nRequestId = " << requestId); Q_UNUSED(m_updateNoteRequestIds.erase(it)); @@ -2634,9 +2640,9 @@ auto tit = m_updateNoteWithThumbnailRequestIds.find(requestId); if (tit != m_updateNoteWithThumbnailRequestIds.end()) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("onUpdateNoteCompleted: note with updated thumbnail = ") - << note << QStringLiteral("\nRequestId = ") << requestId); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "onUpdateNoteCompleted: note with updated thumbnail = " + << note << "\nRequestId = " << requestId); Q_UNUSED(m_updateNoteWithThumbnailRequestIds.erase(tit)) @@ -2651,10 +2657,10 @@ auto mdit = m_resourcesByMarkNoteOwningResourceDirtyRequestIds.find(requestId); if (mdit != m_resourcesByMarkNoteOwningResourceDirtyRequestIds.end()) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("onUpdateNoteCompleted: note owning added or ") - << QStringLiteral("updated resource was marked as dirty: request id = ") - << requestId << QStringLiteral(", note: ") << note); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "onUpdateNoteCompleted: note owning added or " + << "updated resource was marked as dirty: request id = " + << requestId << ", note: " << note); Resource resource = mdit.value(); Q_UNUSED(m_resourcesByMarkNoteOwningResourceDirtyRequestIds.erase(mdit)) @@ -2673,19 +2679,18 @@ auto it = m_updateNoteRequestIds.find(requestId); if (it != m_updateNoteRequestIds.end()) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("onUpdateNoteFailed: note = ") << note - << QStringLiteral("\nErrorDescription = ") << errorDescription - << QStringLiteral("\nRequestId = ") << requestId); + QNWARNING("RemoteToLocalSynchronizationManager::" + << "onUpdateNoteFailed: note = " << note + << "\nErrorDescription = " << errorDescription + << "\nRequestId = " << requestId); Q_UNUSED(m_updateNoteRequestIds.erase(it)) - ErrorString error(QT_TR_NOOP("Failed to update the note in the local storage")); + ErrorString error(QT_TR_NOOP("Failed to update the note in " + "the local storage")); error.additionalBases().append(errorDescription.base()); error.additionalBases().append(errorDescription.additionalBases()); error.details() = errorDescription.details(); - QNWARNING(error); - Q_EMIT failure(error); return; } @@ -2693,13 +2698,10 @@ auto tit = m_updateNoteWithThumbnailRequestIds.find(requestId); if (tit != m_updateNoteWithThumbnailRequestIds.end()) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("onUpdateNoteFailed: note with thumbnail = ") - << note << QStringLiteral("\nErrorDescription = ") - << errorDescription << QStringLiteral("\nRequestId = ") - << requestId); - - QNWARNING(errorDescription); + QNWARNING("RemoteToLocalSynchronizationManager::" + << "onUpdateNoteFailed: note with thumbnail = " << note + << "\nErrorDescription = " << errorDescription + << "\nRequestId = " << requestId); Q_UNUSED(m_updateNoteWithThumbnailRequestIds.erase(tit)) @@ -2713,10 +2715,10 @@ auto mdit = m_resourcesByMarkNoteOwningResourceDirtyRequestIds.find(requestId); if (mdit != m_resourcesByMarkNoteOwningResourceDirtyRequestIds.end()) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::onUpdateNoteFailed: ") - << QStringLiteral("failed to mark the resource owning note as dirty: ") - << errorDescription << QStringLiteral(", request id = ") << requestId - << QStringLiteral(", note: ") << note); + QNWARNING("RemoteToLocalSynchronizationManager::onUpdateNoteFailed: " + << "failed to mark the resource owning note as dirty: " + << errorDescription << ", request id = " << requestId + << ", note: " << note); Q_UNUSED(m_resourcesByMarkNoteOwningResourceDirtyRequestIds.erase(mdit)) @@ -2725,15 +2727,13 @@ error.additionalBases().append(errorDescription.base()); error.additionalBases().append(errorDescription.additionalBases()); error.details() = errorDescription.details(); - QNWARNING(error); - Q_EMIT failure(error); return; } } -void RemoteToLocalSynchronizationManager::onExpungeNoteCompleted(Note note, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onExpungeNoteCompleted( + Note note, QUuid requestId) { onExpungeDataElementCompleted(note, requestId, QStringLiteral("Note"), m_expungeNoteRequestIds); @@ -2746,39 +2746,37 @@ QStringLiteral("Note"), m_expungeNoteRequestIds); } -void RemoteToLocalSynchronizationManager::onAddResourceCompleted(Resource resource, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onAddResourceCompleted( + Resource resource, QUuid requestId) { onAddDataElementCompleted(resource, requestId, QStringLiteral("Resource"), m_addResourceRequestIds); } -void RemoteToLocalSynchronizationManager::onAddResourceFailed(Resource resource, - ErrorString errorDescription, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onAddResourceFailed( + Resource resource, ErrorString errorDescription, QUuid requestId) { onAddDataElementFailed(resource, requestId, errorDescription, QStringLiteral("Resource"), m_addResourceRequestIds); } -void RemoteToLocalSynchronizationManager::onUpdateResourceCompleted(Resource resource, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onUpdateResourceCompleted( + Resource resource, QUuid requestId) { onUpdateDataElementCompleted<Resource>(resource, requestId, QStringLiteral("Resource"), m_updateResourceRequestIds); } -void RemoteToLocalSynchronizationManager::onUpdateResourceFailed(Resource resource, - ErrorString errorDescription, - QUuid requestId) +void RemoteToLocalSynchronizationManager::onUpdateResourceFailed( + Resource resource, ErrorString errorDescription, QUuid requestId) { auto it = m_updateResourceRequestIds.find(requestId); if (it != m_updateResourceRequestIds.end()) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("onUpdateResourceFailed: resource = ") - << resource << QStringLiteral("\nrequestId = ") << requestId); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "onUpdateResourceFailed: resource = " + << resource << "\nrequestId = " << requestId); ErrorString error(QT_TR_NOOP("Failed to update the resource " "in the local storage")); @@ -2793,12 +2791,12 @@ bool status, QString resourceGuid, QString noteGuid, ErrorString errorDescription) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "onInkNoteImageDownloadFinished: status = ") - << (status ? QStringLiteral("true") : QStringLiteral("false")) - << QStringLiteral(", resource guid = ") << resourceGuid - << QStringLiteral(", note guid = ") << noteGuid - << QStringLiteral(", error description = ") << errorDescription); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "onInkNoteImageDownloadFinished: status = " + << (status ? "true" : "false") + << ", resource guid = " << resourceGuid + << ", note guid = " << noteGuid + << ", error description = " << errorDescription); if (!status) { QNWARNING(errorDescription); @@ -2812,8 +2810,8 @@ } else { - QNDEBUG(QStringLiteral("No such combination of note guid and resource guid " - "was found pending ink note image download")); + QNDEBUG("No such combination of note guid and resource guid " + "was found pending ink note image download"); } } @@ -2821,17 +2819,16 @@ bool status, QString noteGuid, QByteArray downloadedThumbnailImageData, ErrorString errorDescription) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("onNoteThumbnailDownloadingFinished: status = ") - << (status ? QStringLiteral("true") : QStringLiteral("false")) - << QStringLiteral(", note guid = ") << noteGuid - << QStringLiteral(", error description = ") << errorDescription); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "onNoteThumbnailDownloadingFinished: status = " + << (status ? "true" : "false") << ", note guid = " << noteGuid + << ", error description = " << errorDescription); auto it = m_notesPendingThumbnailDownloadByGuid.find(noteGuid); if (Q_UNLIKELY(it == m_notesPendingThumbnailDownloadByGuid.end())) { - QNDEBUG(QStringLiteral("Received note thumbnail downloaded event " - "for note which was not pending it; the slot " - "invoking must be the stale one, ignoring it")); + QNDEBUG("Received note thumbnail downloaded event " + "for note which was not pending it; the slot " + "invoking must be the stale one, ignoring it"); return; } @@ -2850,9 +2847,9 @@ QUuid updateNoteRequestId = QUuid::createUuid(); Q_UNUSED(m_updateNoteWithThumbnailRequestIds.insert(updateNoteRequestId)) - QNTRACE(QStringLiteral("Emitting the request to update note with downloaded " - "thumbnail: request id = ") << updateNoteRequestId - << QStringLiteral(", note: ") << note); + QNTRACE("Emitting the request to update note with downloaded " + << "thumbnail: request id = " << updateNoteRequestId + << ", note: " << note); Q_EMIT updateNote(note, LocalStorageManager::UpdateNoteOptions(0), updateNoteRequestId); } @@ -2860,8 +2857,8 @@ void RemoteToLocalSynchronizationManager::onAuthenticationInfoReceived( QString authToken, QString shardId, qevercloud::Timestamp expirationTime) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "onAuthenticationInfoReceived: expiration time = ") + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "onAuthenticationInfoReceived: expiration time = " << printableDateTimeFromTimestamp(expirationTime)); bool wasPending = m_pendingAuthenticationTokenAndShardId; @@ -2885,8 +2882,8 @@ QHash<QString, QPair<QString,QString> > authenticationTokensAndShardIdsByLinkedNotebookGuid, QHash<QString, qevercloud::Timestamp> authenticationTokenExpirationTimesByLinkedNotebookGuid) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "onAuthenticationTokensForLinkedNotebooksReceived")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "onAuthenticationTokensForLinkedNotebooksReceived"); bool wasPending = m_pendingAuthenticationTokensForLinkedNotebooks; @@ -2897,8 +2894,7 @@ m_pendingAuthenticationTokensForLinkedNotebooks = false; if (!wasPending) { - QNDEBUG(QStringLiteral("Authentication tokens for linked notebooks " - "were not requested")); + QNDEBUG("Authentication tokens for linked notebooks were not requested"); return; } @@ -2913,12 +2909,12 @@ QHash<QString,qint32> lastUpdateCountByLinkedNotebookGuid, QHash<QString,qevercloud::Timestamp> lastSyncTimeByLinkedNotebookGuid) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("onLastSyncParametersReceived: last update count = ") - << lastUpdateCount << QStringLiteral(", last sync time = ") - << lastSyncTime << QStringLiteral(", last update counts per linked notebook = ") + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "onLastSyncParametersReceived: last update count = " + << lastUpdateCount << ", last sync time = " + << lastSyncTime << ", last update counts per linked notebook = " << lastUpdateCountByLinkedNotebookGuid - << QStringLiteral(", last sync time per linked notebook = ") + << ", last sync time per linked notebook = " << lastSyncTimeByLinkedNotebookGuid); m_lastUpdateCount = lastUpdateCount; @@ -2946,11 +2942,12 @@ start(m_lastUsnOnStart); } -void RemoteToLocalSynchronizationManager::setDownloadNoteThumbnails(const bool flag) +void RemoteToLocalSynchronizationManager::setDownloadNoteThumbnails( + const bool flag) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("setDownloadNoteThumbnails: flag = ") - << (flag ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "setDownloadNoteThumbnails: flag = " + << (flag ? "true" : "false")); ApplicationSettings appSettings(account(), SYNCHRONIZATION_PERSISTENCE_NAME); appSettings.beginGroup(SYNC_SETTINGS_KEY_GROUP); @@ -2958,11 +2955,12 @@ appSettings.endGroup(); } -void RemoteToLocalSynchronizationManager::setDownloadInkNoteImages(const bool flag) +void RemoteToLocalSynchronizationManager::setDownloadInkNoteImages( + const bool flag) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("setDownloadInkNoteImages: flag = ") - << (flag ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "setDownloadInkNoteImages: flag = " + << (flag ? "true" : "false")); ApplicationSettings appSettings(account(), SYNCHRONIZATION_PERSISTENCE_NAME); appSettings.beginGroup(SYNC_SETTINGS_KEY_GROUP); @@ -2970,10 +2968,11 @@ appSettings.endGroup(); } -void RemoteToLocalSynchronizationManager::setInkNoteImagesStoragePath(const QString & path) +void RemoteToLocalSynchronizationManager::setInkNoteImagesStoragePath( + const QString & path) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "setInkNoteImagesStoragePath: path = ") << path); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "setInkNoteImagesStoragePath: path = " << path); QString actualPath = path; @@ -2984,30 +2983,28 @@ bool res = pathDir.mkpath(path); if (!res) { actualPath = defaultInkNoteImageStoragePath(); - QNWARNING(QStringLiteral("Could not create folder for ink note images ") - << QStringLiteral("storage: ") << path - << QStringLiteral(", fallback to using the default path ") + QNWARNING("Could not create folder for ink note images " + << "storage: " << path + << ", fallback to using the default path " << actualPath); } else { - QNDEBUG(QStringLiteral("Successfully created the folder for " - "ink note images storage: ") << actualPath); + QNDEBUG("Successfully created the folder for " + << "ink note images storage: " << actualPath); } } else if (Q_UNLIKELY(!pathInfo.isDir())) { actualPath = defaultInkNoteImageStoragePath(); - QNWARNING(QStringLiteral("The specified ink note images storage path is ") - << QStringLiteral("not a directory: ") << path - << QStringLiteral(", fallback to using the default path ") - << actualPath); + QNWARNING("The specified ink note images storage path is " + << "not a directory: " << path + << ", fallback to using the default path " << actualPath); } else if (Q_UNLIKELY(!pathInfo.isWritable())) { actualPath = defaultInkNoteImageStoragePath(); - QNWARNING(QStringLiteral("The specified ink note images storage path is ") - << QStringLiteral("not writable: ") << path - << QStringLiteral(", fallback to using the default path ") - << actualPath); + QNWARNING("The specified ink note images storage path is " + << "not writable: " << path + << ", fallback to using the default path " << actualPath); } ApplicationSettings appSettings(account(), SYNCHRONIZATION_PERSISTENCE_NAME); @@ -3019,31 +3016,31 @@ void RemoteToLocalSynchronizationManager::collectNonProcessedItemsSmallestUsns( qint32 & usn, QHash<QString,qint32> & usnByLinkedNotebookGuid) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "collectNonProcessedItemsSmallestUsns")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "collectNonProcessedItemsSmallestUsns"); usn = -1; usnByLinkedNotebookGuid.clear(); - QNDEBUG(QStringLiteral("User own data sync chunks downloaded = ") + QNDEBUG("User own data sync chunks downloaded = " << (m_syncChunksDownloaded - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", all linked notebooks listed = ") + ? "true" + : "false") + << ", all linked notebooks listed = " << (m_allLinkedNotebooksListed - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", linked notebook sync chunks downloaded = ") + ? "true" + : "false") + << ", linked notebook sync chunks downloaded = " << (m_linkedNotebooksSyncChunksDownloaded - ? QStringLiteral("true") - : QStringLiteral("false"))); + ? "true" + : "false")); if (m_syncChunksDownloaded && !syncingLinkedNotebooksContent()) { qint32 smallestUsn = findSmallestUsnOfNonSyncedItems(); if (smallestUsn > 0) { - QNDEBUG(QStringLiteral("Found the smallest USN of non-processed ") - << QStringLiteral("items within the user's own account: ") + QNDEBUG("Found the smallest USN of non-processed " + << "items within the user's own account: " << smallestUsn); // NOTE: decrement this USN because that would give the USN // *after which* the next sync should start @@ -3059,16 +3056,16 @@ const LinkedNotebook & linkedNotebook = *it; if (Q_UNLIKELY(!linkedNotebook.hasGuid())) { - QNWARNING(QStringLiteral("Detected a linked notebook without guid: ") + QNWARNING("Detected a linked notebook without guid: " << linkedNotebook); continue; } qint32 smallestUsn = findSmallestUsnOfNonSyncedItems(linkedNotebook.guid()); if (smallestUsn >= 0) { - QNDEBUG(QStringLiteral("Found the smallest USN of non-processed ") - << QStringLiteral("items within linked notebook with guid ") - << linkedNotebook.guid() << QStringLiteral(": ") << smallestUsn); + QNDEBUG("Found the smallest USN of non-processed " + << "items within linked notebook with guid " + << linkedNotebook.guid() << ": " << smallestUsn); usnByLinkedNotebookGuid[linkedNotebook.guid()] = (smallestUsn - 1); continue; } @@ -3083,7 +3080,7 @@ if (Q_UNLIKELY(!qecNote.guid.isSet())) { errorDescription.setBase(QT_TR_NOOP("Internal error: just downloaded " "note has no guid")); - QNWARNING(errorDescription << QStringLiteral(", note: ") << qecNote); + QNWARNING(errorDescription << ", note: " << qecNote); Q_EMIT failure(errorDescription); return; } @@ -3106,11 +3103,11 @@ return; } - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("onGetNoteAsyncFinished: error code = ") - << errorCode << QStringLiteral(", rate limit seconds = ") - << rateLimitSeconds << QStringLiteral(", error description: ") - << errorDescription << QStringLiteral(", note: ") << qecNote); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "onGetNoteAsyncFinished: error code = " + << errorCode << ", rate limit seconds = " + << rateLimitSeconds << ", error description: " + << errorDescription << ", note: " << qecNote); Note note; @@ -3192,25 +3189,24 @@ if (shouldDownloadThumbnailsForNotes() && note.hasResources()) { - QNDEBUG(QStringLiteral("The added or updated note contains resources, " - "need to download the thumbnails for it")); + QNDEBUG("The added or updated note contains resources, " + "need to download the thumbnails for it"); pNotebook = getNotebookPerNote(note); if (pNotebook) { bool res = setupNoteThumbnailDownloading(note, *pNotebook); if (Q_UNLIKELY(!res)) { - QNDEBUG(QStringLiteral("Wasn't able to set up the note " - "thumbnail downloading")); + QNDEBUG("Wasn't able to set up the note thumbnail downloading"); } } else { bool res = findNotebookForNoteThumbnailDownloading(note); if (Q_UNLIKELY(!res)) { - QNDEBUG(QStringLiteral("Wasn't able to set up the search for " - "the notebook of the note for which " - "the thumbnail was meant to be downloaded")); + QNDEBUG("Wasn't able to set up the search for " + "the notebook of the note for which " + "the thumbnail was meant to be downloaded"); } } } @@ -3225,8 +3221,8 @@ if (shouldDownloadInkNoteImages() && note.hasResources() && note.isInkNote()) { - QNDEBUG(QStringLiteral("The added or updated note is the ink note, need " - "to download the ink note image for it")); + QNDEBUG("The added or updated note is the ink note, need " + "to download the ink note image for it"); if (!pNotebook) { pNotebook = getNotebookPerNote(note); @@ -3236,18 +3232,16 @@ { bool res = setupInkNoteImageDownloadingForNote(note, *pNotebook); if (Q_UNLIKELY(!res)) { - QNDEBUG(QStringLiteral("Wasn't able to set up the ink note " - "images downloading")); + QNDEBUG("Wasn't able to set up the ink note images downloading"); } } else { bool res = findNotebookForInkNoteImageDownloading(note); if (Q_UNLIKELY(!res)) { - QNDEBUG(QStringLiteral("Wasn't able to set up the search for " - "the notebook of the note for which " - "the ink note images were meant to be " - "downloaded")); + QNDEBUG("Wasn't able to set up the search for the notebook " + "of the note for which the ink note images were meant " + "to be downloaded"); } } } @@ -3265,9 +3259,8 @@ LocalStorageManager::UpdateNoteOption::UpdateResourceMetadata | LocalStorageManager::UpdateNoteOption::UpdateResourceBinaryData | LocalStorageManager::UpdateNoteOption::UpdateTags); - QNTRACE(QStringLiteral("Emitting the request to update note in local storage: ") - << QStringLiteral("request id = ") << updateNoteRequestId - << QStringLiteral(", note; ") << note); + QNTRACE("Emitting the request to update note in local storage: " + << "request id = " << updateNoteRequestId << ", note; " << note); Q_EMIT updateNote(note, options, updateNoteRequestId); } @@ -3275,16 +3268,16 @@ qint32 errorCode, qevercloud::Resource qecResource, qint32 rateLimitSeconds, ErrorString errorDescription) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("onGetResourceAsyncFinished: error code = ") - << errorCode << QStringLiteral(", rate limit seconds = ") - << rateLimitSeconds << QStringLiteral(", error description: ") - << errorDescription << QStringLiteral(", resource: ") << qecResource); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "onGetResourceAsyncFinished: error code = " + << errorCode << ", rate limit seconds = " + << rateLimitSeconds << ", error description: " + << errorDescription << ", resource: " << qecResource); if (Q_UNLIKELY(!qecResource.guid.isSet())) { errorDescription.setBase(QT_TR_NOOP("Internal error: just downloaded " "resource has no guid")); - QNWARNING(errorDescription << QStringLiteral(", resource: ") << qecResource); + QNWARNING(errorDescription << ", resource: " << qecResource); Q_EMIT failure(errorDescription); return; } @@ -3320,7 +3313,7 @@ if (Q_UNLIKELY(!needToAddResource && !needToUpdateResource)) { errorDescription.setBase(QT_TR_NOOP("Internal error: the downloaded resource " "was not expected")); - QNWARNING(errorDescription << QStringLiteral(", resource: ") << resource); + QNWARNING(errorDescription << ", resource: " << resource); Q_EMIT failure(errorDescription); return; } @@ -3383,36 +3376,34 @@ QUuid addResourceRequestId = QUuid::createUuid(); Q_UNUSED(m_addResourceRequestIds.insert(addResourceRequestId)); - QNTRACE(QStringLiteral("Emitting the request to add resource ") - << QStringLiteral("to the local storage: request id = ") - << addResourceRequestId << QStringLiteral(", resource: ") - << resource); + QNTRACE("Emitting the request to add resource " + << "to the local storage: request id = " + << addResourceRequestId << ", resource: " << resource); Q_EMIT addResource(resource, addResourceRequestId); } else { QUuid updateResourceRequestId = QUuid::createUuid(); Q_UNUSED(m_updateResourceRequestIds.insert(updateResourceRequestId)) - QNTRACE(QStringLiteral("Emitting the request to update resource: ") - << QStringLiteral("request id = ") << updateResourceRequestId - << QStringLiteral(", resource: ") << resource); + QNTRACE("Emitting the request to update resource: " + << "request id = " << updateResourceRequestId + << ", resource: " << resource); Q_EMIT updateResource(resource, updateResourceRequestId); } note.setDirty(true); QUuid markNoteDirtyRequestId = QUuid::createUuid(); m_resourcesByMarkNoteOwningResourceDirtyRequestIds[markNoteDirtyRequestId] = resource; - QNTRACE(QStringLiteral("Emitting the request to mark the resource owning note ") - << QStringLiteral("as the dirty one: request id = ") - << markNoteDirtyRequestId << QStringLiteral(", resource: ") << resource - << QStringLiteral("\nNote: ") << note); + QNTRACE("Emitting the request to mark the resource owning note " + << "as the dirty one: request id = " << markNoteDirtyRequestId + << ", resource: " << resource << "\nNote: " << note); Q_EMIT updateNote(note, LocalStorageManager::UpdateNoteOptions(0), markNoteDirtyRequestId); } void RemoteToLocalSynchronizationManager::onTagSyncCacheFilled() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::onTagSyncCacheFilled")); + QNDEBUG("RemoteToLocalSynchronizationManager::onTagSyncCacheFilled"); TagSyncCache * pTagSyncCache = qobject_cast<TagSyncCache*>(sender()); if (Q_UNLIKELY(!pTagSyncCache)) { @@ -3441,21 +3432,21 @@ Q_UNUSED(m_linkedNotebookGuidsPendingTagSyncCachesFill.erase(it)) if (m_linkedNotebookGuidsPendingTagSyncCachesFill.isEmpty()) { - QNDEBUG(QStringLiteral("No more linked notebook guids pending tag " - "sync caches fill")); + QNDEBUG("No more linked notebook guids pending tag sync caches fill"); startFeedingDownloadedTagsToLocalStorageOneByOne(m_tags); } else { - QNDEBUG(QStringLiteral("Still have ") + QNDEBUG("Still have " << m_linkedNotebookGuidsPendingTagSyncCachesFill.size() - << QStringLiteral(" linked notebook guids pending tag sync caches fill")); + << " linked notebook guids pending tag sync caches fill"); } } -void RemoteToLocalSynchronizationManager::onTagSyncCacheFailure(ErrorString errorDescription) +void RemoteToLocalSynchronizationManager::onTagSyncCacheFailure( + ErrorString errorDescription) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::onTagSyncCacheFailure: ") + QNDEBUG("RemoteToLocalSynchronizationManager::onTagSyncCacheFailure: " << errorDescription); Q_EMIT failure(errorDescription); } @@ -3463,9 +3454,8 @@ void RemoteToLocalSynchronizationManager::onNotebookSyncConflictResolverFinished( qevercloud::Notebook remoteNotebook) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("onNotebookSyncConflictResolverFinished: ") - << remoteNotebook); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "onNotebookSyncConflictResolverFinished: " << remoteNotebook); NotebookSyncConflictResolver * pResolver = qobject_cast<NotebookSyncConflictResolver*>(sender()); @@ -3484,10 +3474,10 @@ void RemoteToLocalSynchronizationManager::onNotebookSyncConflictResolverFailure( qevercloud::Notebook remoteNotebook, ErrorString errorDescription) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("onNotebookSyncConflictResolverFailure: ") - << QStringLiteral("error description = ") << errorDescription - << QStringLiteral(", remote notebook: ") << remoteNotebook); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "onNotebookSyncConflictResolverFailure: " + << "error description = " << errorDescription + << ", remote notebook: " << remoteNotebook); NotebookSyncConflictResolver * pResolver = qobject_cast<NotebookSyncConflictResolver*>(sender()); @@ -3503,8 +3493,8 @@ void RemoteToLocalSynchronizationManager::onTagSyncConflictResolverFinished( qevercloud::Tag remoteTag) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "onTagSyncConflictResolverFinished: ") << remoteTag); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "onTagSyncConflictResolverFinished: " << remoteTag); TagSyncConflictResolver * pResolver = qobject_cast<TagSyncConflictResolver*>(sender()); @@ -3523,9 +3513,9 @@ void RemoteToLocalSynchronizationManager::onTagSyncConflictResolverFailure( qevercloud::Tag remoteTag, ErrorString errorDescription) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("onTagSyncConflictResolverFailure: error description = ") - << errorDescription << QStringLiteral(", remote tag: ") << remoteTag); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "onTagSyncConflictResolverFailure: error description = " + << errorDescription << ", remote tag: " << remoteTag); TagSyncConflictResolver * pResolver = qobject_cast<TagSyncConflictResolver*>(sender()); @@ -3541,8 +3531,8 @@ void RemoteToLocalSynchronizationManager::onSavedSearchSyncConflictResolverFinished( qevercloud::SavedSearch remoteSavedSearch) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("onSavedSearchSyncConflictResolverFinished: ") + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "onSavedSearchSyncConflictResolverFinished: " << remoteSavedSearch); SavedSearchSyncConflictResolver * pResolver = @@ -3560,10 +3550,10 @@ void RemoteToLocalSynchronizationManager::onSavedSearchSyncConflictResolverFailure( qevercloud::SavedSearch remoteSavedSearch, ErrorString errorDescription) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("onSavedSearchSyncConflictResolverFailure: ") - << QStringLiteral("error description = ") << errorDescription - << QStringLiteral(", remote saved search: ") << remoteSavedSearch); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "onSavedSearchSyncConflictResolverFailure: " + << "error description = " << errorDescription + << ", remote saved search: " << remoteSavedSearch); SavedSearchSyncConflictResolver * pResolver = qobject_cast<SavedSearchSyncConflictResolver*>(sender()); @@ -3579,8 +3569,8 @@ void RemoteToLocalSynchronizationManager::onNoteSyncConflictResolverFinished( qevercloud::Note note) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("onNoteSyncConflictResolverFinished: note guid = ") + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "onNoteSyncConflictResolverFinished: note guid = " << (note.guid.isSet() ? note.guid.ref() : QStringLiteral("<not set>"))); NoteSyncConflictResolver * pResolver = @@ -3599,11 +3589,10 @@ void RemoteToLocalSynchronizationManager::onNoteSyncConflictResolvedFailure( qevercloud::Note note, ErrorString errorDescription) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("onNoteSyncConflictResolvedFailure: note guid = ") + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "onNoteSyncConflictResolvedFailure: note guid = " << (note.guid.isSet() ? note.guid.ref() : QStringLiteral("<not set>")) - << QStringLiteral(", error description = ") - << errorDescription); + << ", error description = " << errorDescription); NoteSyncConflictResolver * pResolver = qobject_cast<NoteSyncConflictResolver*>(sender()); @@ -3619,17 +3608,17 @@ void RemoteToLocalSynchronizationManager::onNoteSyncConflictRateLimitExceeded( qint32 rateLimitSeconds) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("onNoteSyncConflictRateLimitExceeded: ") - << QStringLiteral("rate limit seconds = ") << rateLimitSeconds); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "onNoteSyncConflictRateLimitExceeded: " + << "rate limit seconds = " << rateLimitSeconds); Q_EMIT rateLimitExceeded(rateLimitSeconds); } void RemoteToLocalSynchronizationManager::onNoteSyncConflictAuthenticationExpired() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "onNoteSyncConflictAuthenticationExpired")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "onNoteSyncConflictAuthenticationExpired"); NoteSyncConflictResolver * pResolver = qobject_cast<NoteSyncConflictResolver*>(sender()); @@ -3669,8 +3658,8 @@ void RemoteToLocalSynchronizationManager::onFullSyncStaleDataItemsExpungerFinished() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "onFullSyncStaleDataItemsExpungerFinished")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "onFullSyncStaleDataItemsExpungerFinished"); QString linkedNotebookGuid; @@ -3686,7 +3675,8 @@ } else { - auto it = m_fullSyncStaleDataItemsExpungersByLinkedNotebookGuid.find(linkedNotebookGuid); + auto it = m_fullSyncStaleDataItemsExpungersByLinkedNotebookGuid.find( + linkedNotebookGuid); if (it != m_fullSyncStaleDataItemsExpungersByLinkedNotebookGuid.end()) { Q_UNUSED(m_fullSyncStaleDataItemsExpungersByLinkedNotebookGuid.erase(it)) } @@ -3697,8 +3687,8 @@ if (linkedNotebookGuid.isEmpty()) { - QNDEBUG(QStringLiteral("Finished analyzing and expunging stuff from user's " - "own account after the non-first full sync")); + QNDEBUG("Finished analyzing and expunging stuff from user's " + "own account after the non-first full sync"); m_expungedFromServerToClient = true; startLinkedNotebooksSync(); @@ -3706,15 +3696,13 @@ else { if (!m_fullSyncStaleDataItemsExpungersByLinkedNotebookGuid.isEmpty()) { - QNDEBUG(QStringLiteral("Still pending the finish of ") + QNDEBUG("Still pending the finish of " << m_fullSyncStaleDataItemsExpungersByLinkedNotebookGuid.size() - << QStringLiteral(" FullSyncStaleDataItemsExpungers " - "for linked notebooks")); + << " FullSyncStaleDataItemsExpungers for linked notebooks"); return; } - QNDEBUG(QStringLiteral("All FullSyncStaleDataItemsExpungers for linked " - "notebooks finished")); + QNDEBUG("All FullSyncStaleDataItemsExpungers for linked notebooks finished"); launchExpungingOfNotelessTagsFromLinkedNotebooks(); } } @@ -3722,9 +3710,8 @@ void RemoteToLocalSynchronizationManager::onFullSyncStaleDataItemsExpungerFailure( ErrorString errorDescription) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("onFullSyncStaleDataItemsExpungerFailure: ") - << errorDescription); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "onFullSyncStaleDataItemsExpungerFailure: " << errorDescription); QString linkedNotebookGuid; @@ -3740,7 +3727,8 @@ } else { - auto it = m_fullSyncStaleDataItemsExpungersByLinkedNotebookGuid.find(linkedNotebookGuid); + auto it = m_fullSyncStaleDataItemsExpungersByLinkedNotebookGuid.find( + linkedNotebookGuid); if (it != m_fullSyncStaleDataItemsExpungersByLinkedNotebookGuid.end()) { Q_UNUSED(m_fullSyncStaleDataItemsExpungersByLinkedNotebookGuid.erase(it)) } @@ -3749,22 +3737,23 @@ junkFullSyncStaleDataItemsExpunger(*pExpunger); } - QNWARNING(QStringLiteral("Failed to analyze and expunge stale stuff after ") - << QStringLiteral("the non-first full sync: ") << errorDescription - << QStringLiteral("; linked notebook guid = ") << linkedNotebookGuid); + QNWARNING("Failed to analyze and expunge stale stuff after " + << "the non-first full sync: " << errorDescription + << "; linked notebook guid = " << linkedNotebookGuid); Q_EMIT failure(errorDescription); } void RemoteToLocalSynchronizationManager::connectToLocalStorage() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::connectToLocalStorage")); + QNDEBUG("RemoteToLocalSynchronizationManager::connectToLocalStorage"); if (m_connectedToLocalStorage) { - QNDEBUG(QStringLiteral("Already connected to the local storage")); + QNDEBUG("Already connected to the local storage"); return; } - LocalStorageManagerAsync & localStorageManagerAsync = m_manager.localStorageManagerAsync(); + LocalStorageManagerAsync & localStorageManagerAsync = + m_manager.localStorageManagerAsync(); // Connect local signals with localStorageManagerAsync's slots QObject::connect(this, @@ -4415,10 +4404,10 @@ void RemoteToLocalSynchronizationManager::disconnectFromLocalStorage() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::disconnectFromLocalStorage")); + QNDEBUG("RemoteToLocalSynchronizationManager::disconnectFromLocalStorage"); if (!m_connectedToLocalStorage) { - QNDEBUG(QStringLiteral("Not connected to local storage at the moment")); + QNDEBUG("Not connected to local storage at the moment"); return; } @@ -5003,7 +4992,7 @@ void RemoteToLocalSynchronizationManager::resetCurrentSyncState() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::resetCurrentSyncState")); + QNDEBUG("RemoteToLocalSynchronizationManager::resetCurrentSyncState"); m_lastUpdateCount = 0; m_lastSyncTime = 0; @@ -5022,7 +5011,7 @@ void RemoteToLocalSynchronizationManager::launchSync() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::launchSync")); + QNDEBUG("RemoteToLocalSynchronizationManager::launchSync"); if (m_authenticationToken.isEmpty()) { m_pendingAuthenticationTokenAndShardId = true; @@ -5031,10 +5020,9 @@ } if (m_onceSyncDone && (m_lastSyncMode == SyncMode::FullSync)) { - QNDEBUG(QStringLiteral("Performing full sync even though it has been " - "performed at some moment in the past; " - "collecting synced guids for full sync stale " - "data items expunger")); + QNDEBUG("Performing full sync even though it has been performed at " + "some moment in the past; collecting synced guids for full " + "sync stale data items expunger"); collectSyncedGuidsForFullSyncStaleDataItemsExpunger(); } @@ -5054,25 +5042,25 @@ return; } - QNDEBUG(QStringLiteral("The local lists of tags and notebooks waiting " - "for adding/updating are empty, checking if there " - "are notes to process")); + QNDEBUG("The local lists of tags and notebooks waiting for adding/updating " + "are empty, checking if there are notes to process"); launchNotesSync(ContentSource::UserAccount); if (!m_notes.isEmpty() || notesSyncInProgress()) { - QNDEBUG(QStringLiteral("Synchronizing notes")); - // NOTE: the sync of individual resources as well as expunging of - // various data items will be launched asynchronously - // if current sync is incremental after the notes are synced + QNDEBUG("Synchronizing notes"); + /** + * NOTE: the sync of individual resources as well as expunging of + * various data items will be launched asynchronously + * if current sync is incremental after the notes are synced + */ return; } - QNDEBUG(QStringLiteral("The local list of notes waiting for " - "adding/updating is empty")); + QNDEBUG("The local list of notes waiting for adding/updating is empty"); if (m_lastSyncMode != SyncMode::IncrementalSync) { - QNDEBUG(QStringLiteral("Running full sync => no sync for individual " - "resources or expunging stuff is needed")); + QNDEBUG("Running full sync => no sync for individual " + "resources or expunging stuff is needed"); return; } @@ -5081,22 +5069,26 @@ launchResourcesSync(ContentSource::UserAccount); if (!m_resources.isEmpty() || resourcesSyncInProgress()) { - QNDEBUG(QStringLiteral("Resources sync in progress")); + QNDEBUG("Resources sync in progress"); return; } } - // If there's nothing to sync for user's own account, check if something needs - // to be expunged, if yes, do it, otherwirse launch the linked notebooks sync + /** + * If there's nothing to sync for user's own account, check if something + * needs to be expunged, if yes, do it, otherwirse launch the linked + * notebooks sync + */ checkServerDataMergeCompletion(); } -bool RemoteToLocalSynchronizationManager::checkProtocolVersion(ErrorString & errorDescription) +bool RemoteToLocalSynchronizationManager::checkProtocolVersion( + ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::checkProtocolVersion")); + QNDEBUG("RemoteToLocalSynchronizationManager::checkProtocolVersion"); if (m_edamProtocolVersionChecked) { - QNDEBUG(QStringLiteral("Already checked the protocol version, skipping it")); + QNDEBUG("Already checked the protocol version, skipping it"); return true; } @@ -5111,17 +5103,21 @@ { if (!errorDescription.isEmpty()) { - ErrorString fullErrorDescription(QT_TR_NOOP("EDAM protocol version check failed")); - fullErrorDescription.additionalBases().append(errorDescription.base()); - fullErrorDescription.additionalBases().append(errorDescription.additionalBases()); + ErrorString fullErrorDescription( + QT_TR_NOOP("EDAM protocol version check failed")); + fullErrorDescription.additionalBases().append( + errorDescription.base()); + fullErrorDescription.additionalBases().append( + errorDescription.additionalBases()); fullErrorDescription.details() = errorDescription.details(); errorDescription = fullErrorDescription; } else { errorDescription.setBase( - QT_TR_NOOP("Evernote service reports the currently used protocol version " - "can no longer be used for the communication with it")); + QT_TR_NOOP("Evernote service reports the currently used " + "protocol version can no longer be used for " + "the communication with it")); errorDescription.details() = QString::number(edamProtocolVersionMajor); errorDescription.details() += QStringLiteral("."); errorDescription.details() += QString::number(edamProtocolVersionMinor); @@ -5132,7 +5128,7 @@ } m_edamProtocolVersionChecked = true; - QNDEBUG(QStringLiteral("Successfully checked the protocol version")); + QNDEBUG("Successfully checked the protocol version"); return true; } @@ -5140,21 +5136,17 @@ const bool waitIfRateLimitReached, ErrorString & errorDescription, const bool writeUserDataToLocalStorage) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::syncUserImpl: ") - << QStringLiteral("wait if rate limit reached = ") - << (waitIfRateLimitReached - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", write user data to local storage = ") - << (writeUserDataToLocalStorage - ? QStringLiteral("true") - : QStringLiteral("false"))); + QNDEBUG("RemoteToLocalSynchronizationManager::syncUserImpl: " + << "wait if rate limit reached = " + << (waitIfRateLimitReached ? "true" : "false") + << ", write user data to local storage = " + << (writeUserDataToLocalStorage ? "true" : "false")); if (m_user.hasId() && m_user.hasServiceLevel()) { - QNDEBUG(QStringLiteral("User id and service level are set, that means " - "the user info has already been synchronized once " - "during the current session, won't do it again")); + QNDEBUG("User id and service level are set, that means " + "the user info has already been synchronized once " + "during the current session, won't do it again"); return true; } @@ -5165,25 +5157,27 @@ { if (rateLimitSeconds < 0) { - errorDescription.setBase(QT_TR_NOOP("Rate limit reached but the number " - "of seconds to wait is incorrect")); + errorDescription.setBase( + QT_TR_NOOP("Rate limit reached but the number " + "of seconds to wait is incorrect")); errorDescription.details() = QString::number(rateLimitSeconds); QNWARNING(errorDescription); return false; } - QNDEBUG(QStringLiteral("Rate limit exceeded, need to wait for ") - << rateLimitSeconds << QStringLiteral(" seconds")); + QNDEBUG("Rate limit exceeded, need to wait for " + << rateLimitSeconds << " seconds"); if (waitIfRateLimitReached) { int timerId = startTimer(SEC_TO_MSEC(rateLimitSeconds)); if (Q_UNLIKELY(timerId == 0)) { - ErrorString errorMessage(QT_TR_NOOP("Failed to start a timer to " - "postpone the Evernote API call " - "due to rate limit exceeding")); + ErrorString errorMessage( + QT_TR_NOOP("Failed to start a timer to postpone the " + "Evernote API call due to rate limit exceeding")); errorMessage.additionalBases().append(errorDescription.base()); - errorMessage.additionalBases().append(errorDescription.additionalBases()); + errorMessage.additionalBases().append( + errorDescription.additionalBases()); errorMessage.details() = errorDescription.details(); errorDescription = errorMessage; QNDEBUG(errorDescription); @@ -5210,7 +5204,8 @@ } else if (errorCode != 0) { - ErrorString errorMessage(QT_TR_NOOP("Failed to download the latest user info")); + ErrorString errorMessage( + QT_TR_NOOP("Failed to download the latest user info")); errorMessage.additionalBases().append(errorDescription.base()); errorMessage.additionalBases().append(errorDescription.additionalBases()); errorMessage.details() = errorDescription.details(); @@ -5234,12 +5229,12 @@ void RemoteToLocalSynchronizationManager::launchWritingUserDataToLocalStorage() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "launchWritingUserDataToLocalStorage")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "launchWritingUserDataToLocalStorage"); if (m_onceAddedOrUpdatedUserInLocalStorage) { - QNDEBUG(QStringLiteral("Already added or updated the user data " - "in the local storage, no need to do that again")); + QNDEBUG("Already added or updated the user data " + "in the local storage, no need to do that again"); return; } @@ -5247,25 +5242,24 @@ // See if this user's entry already exists in the local storage or not m_findUserRequestId = QUuid::createUuid(); - QNTRACE(QStringLiteral("Emitting request to find user in the local storage ") - << QStringLiteral("database: request id = ") << m_findUserRequestId - << QStringLiteral(", user = ") << m_user); + QNTRACE("Emitting request to find user in the local storage " + << "database: request id = " << m_findUserRequestId + << ", user = " << m_user); Q_EMIT findUser(m_user, m_findUserRequestId); } bool RemoteToLocalSynchronizationManager::checkAndSyncAccountLimits( const bool waitIfRateLimitReached, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("checkAndSyncAccountLimits: wait if rate limit reached = ") - << (waitIfRateLimitReached - ? QStringLiteral("true") - : QStringLiteral("false"))); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "checkAndSyncAccountLimits: wait if rate limit reached = " + << (waitIfRateLimitReached ? "true" : "false")); if (Q_UNLIKELY(!m_user.hasId())) { ErrorString error(QT_TR_NOOP("Detected the attempt to synchronize " - "the account limits before the user id was set")); + "the account limits before the user id " + "was set")); QNWARNING(error); Q_EMIT failure(error); return false; @@ -5279,14 +5273,14 @@ appSettings.value(keyGroup + ACCOUNT_LIMITS_LAST_SYNC_TIME_KEY); if (!accountLimitsLastSyncTime.isNull()) { - QNTRACE(QStringLiteral("Found non-null last sync time for account limits: ") + QNTRACE("Found non-null last sync time for account limits: " << accountLimitsLastSyncTime); bool conversionResult = false; qint64 timestamp = accountLimitsLastSyncTime.toLongLong(&conversionResult); if (conversionResult) { - QNTRACE(QStringLiteral("Successfully read last sync time for account limits: ") + QNTRACE("Successfully read last sync time for account limits: " << printableDateTimeFromTimestamp(timestamp)); qint64 currentTimestamp = QDateTime::currentMSecsSinceEpoch(); qint64 diff = currentTimestamp - timestamp; @@ -5304,15 +5298,13 @@ bool RemoteToLocalSynchronizationManager::syncAccountLimits( const bool waitIfRateLimitReached, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::syncAccountLimits: ") - << QStringLiteral("wait if rate limit reached = ") - << (waitIfRateLimitReached - ? QStringLiteral("true") - : QStringLiteral("false"))); + QNDEBUG("RemoteToLocalSynchronizationManager::syncAccountLimits: " + << "wait if rate limit reached = " + << (waitIfRateLimitReached ? "true" : "false")); if (Q_UNLIKELY(!m_user.hasServiceLevel())) { - errorDescription.setBase(QT_TR_NOOP("No Evernote service level was found " - "for the current user")); + errorDescription.setBase(QT_TR_NOOP("No Evernote service level was " + "found for the current user")); QNDEBUG(errorDescription); return false; } @@ -5332,18 +5324,19 @@ return false; } - QNDEBUG(QStringLiteral("Rate limit exceeded, need to wait for ") - << rateLimitSeconds << QStringLiteral(" seconds")); + QNDEBUG("Rate limit exceeded, need to wait for " + << rateLimitSeconds << " seconds"); if (waitIfRateLimitReached) { int timerId = startTimer(SEC_TO_MSEC(rateLimitSeconds)); if (Q_UNLIKELY(timerId == 0)) { ErrorString errorMessage( - QT_TR_NOOP("Failed to start a timer to postpone the Evernote API call " - "due to rate limit exceeding")); + QT_TR_NOOP("Failed to start a timer to postpone the " + "Evernote API call due to rate limit exceeding")); errorMessage.additionalBases().append(errorDescription.base()); - errorMessage.additionalBases().append(errorDescription.additionalBases()); + errorMessage.additionalBases().append( + errorDescription.additionalBases()); errorMessage.details() = errorDescription.details(); errorDescription = errorMessage; QNWARNING(errorDescription); @@ -5386,12 +5379,12 @@ void RemoteToLocalSynchronizationManager::readSavedAccountLimits() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::readSavedAccountLimits")); + QNDEBUG("RemoteToLocalSynchronizationManager::readSavedAccountLimits"); if (Q_UNLIKELY(!m_user.hasId())) { - ErrorString error(QT_TR_NOOP("Detected the attempt to read the saved account " - "limits before the user id was set")); + ErrorString error(QT_TR_NOOP("Detected the attempt to read the saved " + "account limits before the user id was set")); QNWARNING(error); Q_EMIT failure(error); return; @@ -5407,7 +5400,7 @@ appSettings.value(keyGroup + ACCOUNT_LIMITS_USER_MAIL_LIMIT_DAILY_KEY); if (!userMailLimitDaily.isNull()) { - QNTRACE(QStringLiteral("Found non-null user mail limit daily account limit: ") + QNTRACE("Found non-null user mail limit daily account limit: " << userMailLimitDaily); bool conversionResult = false; qint32 value = userMailLimitDaily.toInt(&conversionResult); @@ -5415,23 +5408,23 @@ m_accountLimits.userMailLimitDaily = value; } else { - QNWARNING(QStringLiteral("Failed to convert user mail limit daily " - "account limit to qint32: ") << userMailLimitDaily); + QNWARNING("Failed to convert user mail limit daily " + << "account limit to qint32: " << userMailLimitDaily); } } QVariant noteSizeMax = appSettings.value(keyGroup + ACCOUNT_LIMITS_NOTE_SIZE_MAX_KEY); if (!noteSizeMax.isNull()) { - QNTRACE(QStringLiteral("Found non-null note size max: ") << noteSizeMax); + QNTRACE("Found non-null note size max: " << noteSizeMax); bool conversionResult = false; qint64 value = noteSizeMax.toLongLong(&conversionResult); if (conversionResult) { m_accountLimits.noteSizeMax = value; } else { - QNWARNING(QStringLiteral("Failed to convert note size max account " - "limit to qint64: ") << noteSizeMax); + QNWARNING("Failed to convert note size max account limit to qint64: " + << noteSizeMax); } } @@ -5439,16 +5432,15 @@ appSettings.value(keyGroup + ACCOUNT_LIMITS_RESOURCE_SIZE_MAX_KEY); if (!resourceSizeMax.isNull()) { - QNTRACE(QStringLiteral("Found non-null resource size max: ") - << resourceSizeMax); + QNTRACE("Found non-null resource size max: " << resourceSizeMax); bool conversionResult = false; qint64 value = resourceSizeMax.toLongLong(&conversionResult); if (conversionResult) { m_accountLimits.resourceSizeMax = value; } else { - QNWARNING(QStringLiteral("Failed to convert resource size max account " - "limit to qint64: ") << resourceSizeMax); + QNWARNING("Failed to convert resource size max account " + << "limit to qint64: " << resourceSizeMax); } } @@ -5456,7 +5448,7 @@ appSettings.value(keyGroup + ACCOUNT_LIMITS_USER_LINKED_NOTEBOOK_MAX_KEY); if (!userLinkedNotebookMax.isNull()) { - QNTRACE(QStringLiteral("Found non-null user linked notebook max: ") + QNTRACE("Found non-null user linked notebook max: " << userLinkedNotebookMax); bool conversionResult = false; qint32 value = userLinkedNotebookMax.toInt(&conversionResult); @@ -5464,22 +5456,22 @@ m_accountLimits.userLinkedNotebookMax = value; } else { - QNWARNING(QStringLiteral("Failed to convert user linked notebook max " - "account limit to qint32: ") << userLinkedNotebookMax); + QNWARNING("Failed to convert user linked notebook max " + << "account limit to qint32: " << userLinkedNotebookMax); } } QVariant uploadLimit = appSettings.value(keyGroup + ACCOUNT_LIMITS_UPLOAD_LIMIT_KEY); if (!uploadLimit.isNull()) { - QNTRACE(QStringLiteral("Found non-null upload limit: ") << uploadLimit); + QNTRACE("Found non-null upload limit: " << uploadLimit); bool conversionResult = false; qint64 value = uploadLimit.toLongLong(&conversionResult); if (conversionResult) { m_accountLimits.uploadLimit = value; } else { - QNWARNING(QStringLiteral("Failed to convert upload limit to qint64: ") + QNWARNING("Failed to convert upload limit to qint64: " << uploadLimit); } } @@ -5488,7 +5480,7 @@ appSettings.value(keyGroup + ACCOUNT_LIMITS_USER_NOTE_COUNT_MAX_KEY); if (!userNoteCountMax.isNull()) { - QNTRACE(QStringLiteral("Found non-null user note count max: ") + QNTRACE("Found non-null user note count max: " << userNoteCountMax); bool conversionResult = false; qint32 value = userNoteCountMax.toInt(&conversionResult); @@ -5496,7 +5488,7 @@ m_accountLimits.userNoteCountMax = value; } else { - QNWARNING(QStringLiteral("Failed to convert user note count max to qint32: ") + QNWARNING("Failed to convert user note count max to qint32: " << userNoteCountMax); } } @@ -5505,7 +5497,7 @@ appSettings.value(keyGroup + ACCOUNT_LIMITS_USER_NOTEBOOK_COUNT_MAX_KEY); if (!userNotebookCountMax.isNull()) { - QNTRACE(QStringLiteral("Found non-null user notebook count max: ") + QNTRACE("Found non-null user notebook count max: " << userNotebookCountMax); bool conversionResult = false; qint32 value = userNotebookCountMax.toInt(&conversionResult); @@ -5513,8 +5505,8 @@ m_accountLimits.userNotebookCountMax = value; } else { - QNWARNING(QStringLiteral("Failed to convert user notebook count " - "max to qint32: ") << userNotebookCountMax); + QNWARNING("Failed to convert user notebook count " + << "max to qint32: " << userNotebookCountMax); } } @@ -5522,15 +5514,14 @@ appSettings.value(keyGroup + ACCOUNT_LIMITS_USER_TAG_COUNT_MAX_KEY); if (!userTagCountMax.isNull()) { - QNTRACE(QStringLiteral("Found non-null user tag count max: ") - << userTagCountMax); + QNTRACE("Found non-null user tag count max: " << userTagCountMax); bool conversionResult = false; qint32 value = userTagCountMax.toInt(&conversionResult); if (conversionResult) { m_accountLimits.userTagCountMax = value; } else { - QNWARNING(QStringLiteral("Failed to convert user tag count max to qint32: ") + QNWARNING("Failed to convert user tag count max to qint32: " << userTagCountMax); } } @@ -5539,15 +5530,14 @@ appSettings.value(keyGroup + ACCOUNT_LIMITS_NOTE_TAG_COUNT_MAX_KEY); if (!noteTagCountMax.isNull()) { - QNTRACE(QStringLiteral("Found non-null note tag cont max: ") - << noteTagCountMax); + QNTRACE("Found non-null note tag cont max: " << noteTagCountMax); bool conversionResult = false; qint32 value = noteTagCountMax.toInt(&conversionResult); if (conversionResult) { m_accountLimits.noteTagCountMax = value; } else { - QNWARNING(QStringLiteral("Failed to convert note tag count max to qint32: ") + QNWARNING("Failed to convert note tag count max to qint32: " << noteTagCountMax); } } @@ -5556,15 +5546,14 @@ appSettings.value(keyGroup + ACCOUNT_LIMITS_USER_SAVED_SEARCH_COUNT_MAX_KEY); if (!userSavedSearchesMax.isNull()) { - QNTRACE(QStringLiteral("Found non-null user saved search max: ") - << userSavedSearchesMax); + QNTRACE("Found non-null user saved search max: " << userSavedSearchesMax); bool conversionResult = false; qint32 value = userSavedSearchesMax.toInt(&conversionResult); if (conversionResult) { m_accountLimits.userSavedSearchesMax = value; } else { - QNWARNING(QStringLiteral("Failed to convert user saved search max to qint32: ") + QNWARNING("Failed to convert user saved search max to qint32: " << userSavedSearchesMax); } } @@ -5573,7 +5562,7 @@ appSettings.value(keyGroup + ACCOUNT_LIMITS_NOTE_RESOURCE_COUNT_MAX_KEY); if (!noteResourceCountMax.isNull()) { - QNTRACE(QStringLiteral("Found non-null note resource count max: ") + QNTRACE("Found non-null note resource count max: " << noteResourceCountMax); bool conversionResult = false; qint32 value = noteResourceCountMax.toInt(&conversionResult); @@ -5581,7 +5570,7 @@ m_accountLimits.noteResourceCountMax = value; } else { - QNWARNING(QStringLiteral("Failed to convert note resource count max to qint32: ") + QNWARNING("Failed to convert note resource count max to qint32: " << noteResourceCountMax); } } @@ -5591,8 +5580,7 @@ void RemoteToLocalSynchronizationManager::writeAccountLimitsToAppSettings() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "writeAccountLimitsToAppSettings")); + QNDEBUG("RemoteToLocalSynchronizationManager::writeAccountLimitsToAppSettings"); if (Q_UNLIKELY(!m_user.hasId())) { @@ -5672,10 +5660,8 @@ QList<QString> & expungedElements) { bool syncingUserAccountData = (contentSource == ContentSource::UserAccount); - QNTRACE(QStringLiteral("syncingUserAccountData = ") - << (syncingUserAccountData - ? QStringLiteral("true") - : QStringLiteral("false"))); + QNTRACE("syncingUserAccountData = " + << (syncingUserAccountData ? "true" : "false")); const auto & syncChunks = (syncingUserAccountData ? m_syncChunks @@ -5683,7 +5669,7 @@ container.clear(); int numSyncChunks = syncChunks.size(); - QNTRACE(QStringLiteral("Num sync chunks = ") << numSyncChunks); + QNTRACE("Num sync chunks = " << numSyncChunks); for(int i = 0; i < numSyncChunks; ++i) { const qevercloud::SyncChunk & syncChunk = syncChunks[i]; @@ -5697,7 +5683,7 @@ const ContentSource::type contentSource, const QString & typeName, ContainerType & container, QList<QString> & expungedElements) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::launchDataElementSync: ") + QNDEBUG("RemoteToLocalSynchronizationManager::launchDataElementSync: " << typeName); launchDataElementSyncCommon<ContainerType, ElementType>(contentSource, @@ -5705,7 +5691,7 @@ expungedElements); if (container.isEmpty()) { - QNDEBUG(QStringLiteral("No new or updated data items within the container")); + QNDEBUG("No new or updated data items within the container"); return; } @@ -5738,7 +5724,7 @@ const ContentSource::type contentSource, const QString & typeName, TagsContainer & container, QList<QString> & expungedElements) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::launchDataElementSync: ") + QNDEBUG("RemoteToLocalSynchronizationManager::launchDataElementSync: " << typeName); launchDataElementSyncCommon<TagsContainer, Tag>(contentSource, @@ -5746,7 +5732,7 @@ expungedElements); if (container.empty()) { - QNDEBUG(QStringLiteral("No data items within the container")); + QNDEBUG("No data items within the container"); return; } @@ -5757,8 +5743,9 @@ * to tags from linked notebook's owner account; these parent tags might * be unaccessible because no notes from the currently linked notebook * are labeled with those parent tags; the local storage would reject - * the attempts to insert tags without existing parents so need to manually - * remove parent tag guids referring to inaccessible tags from the tags being synced; + * the attempts to insert tags without existing parents so need to + * manually remove parent tag guids referring to inaccessible tags + * from the tags being synced; * * First try to find all parent tags within the list of downloaded tags: * if that succeeds, there's no need to try finding the parent tags within @@ -5767,7 +5754,8 @@ std::set<QString> guidsOfTagsWithMissingParentTag; const auto & tagIndexByGuid = container.get<ByGuid>(); - for(auto it = tagIndexByGuid.begin(), end = tagIndexByGuid.end(); it != end; ++it) + for(auto it = tagIndexByGuid.begin(), end = tagIndexByGuid.end(); + it != end; ++it) { const qevercloud::Tag & tag = *it; if (Q_UNLIKELY(!tag.guid.isSet())) { @@ -5784,8 +5772,8 @@ } Q_UNUSED(guidsOfTagsWithMissingParentTag.insert(tag.guid.ref())) - QNDEBUG(QStringLiteral("Detected tag which parent is not within " - "the list of downloaded tags: ") << tag); + QNDEBUG("Detected tag which parent is not within " + << "the list of downloaded tags: " << tag); } if (!guidsOfTagsWithMissingParentTag.empty()) @@ -5799,12 +5787,12 @@ auto linkedNotebookGuidIt = m_linkedNotebookGuidsByTagGuids.find(*it); if (linkedNotebookGuidIt != m_linkedNotebookGuidsByTagGuids.end()) { - auto insertResult = - affectedLinkedNotebookGuids.insert(linkedNotebookGuidIt.value()); + auto insertResult = affectedLinkedNotebookGuids.insert( + linkedNotebookGuidIt.value()); if (insertResult.second) { - QNDEBUG(QStringLiteral("Guid of linked notebook for which " - "TagSyncCache is required to ensure " - "there are no inaccessible parent tags: ") + QNDEBUG("Guid of linked notebook for which " + << "TagSyncCache is required to ensure " + << "there are no inaccessible parent tags: " << linkedNotebookGuidIt.value()); } } @@ -5822,9 +5810,9 @@ TagSyncCache * pTagSyncCache = new TagSyncCache(m_manager.localStorageManagerAsync(), linkedNotebookGuid, this); - tagSyncCacheIt = - m_tagSyncCachesByLinkedNotebookGuids.insert(linkedNotebookGuid, - pTagSyncCache); + tagSyncCacheIt = m_tagSyncCachesByLinkedNotebookGuids.insert( + linkedNotebookGuid, + pTagSyncCache); } TagSyncCache * pTagSyncCache = tagSyncCacheIt.value(); @@ -5856,9 +5844,9 @@ } if (!m_linkedNotebookGuidsPendingTagSyncCachesFill.isEmpty()) { - QNDEBUG(QStringLiteral("Pending TagSyncCaches filling for ") + QNDEBUG("Pending TagSyncCaches filling for " << m_linkedNotebookGuidsPendingTagSyncCachesFill.size() - << QStringLiteral(" linked notebook guids")); + << " linked notebook guids"); return; } } @@ -5869,7 +5857,7 @@ void RemoteToLocalSynchronizationManager::launchTagsSync() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::launchTagsSync")); + QNDEBUG("RemoteToLocalSynchronizationManager::launchTagsSync"); m_pendingTagsSyncStart = false; launchDataElementSync<TagsContainer, Tag>(ContentSource::UserAccount, QStringLiteral("Tag"), m_tags, @@ -5878,7 +5866,7 @@ void RemoteToLocalSynchronizationManager::launchSavedSearchSync() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::launchSavedSearchSync")); + QNDEBUG("RemoteToLocalSynchronizationManager::launchSavedSearchSync"); launchDataElementSync<SavedSearchesList, SavedSearch>( ContentSource::UserAccount, QStringLiteral("Saved search"), m_savedSearches, m_expungedSavedSearches); @@ -5886,7 +5874,7 @@ void RemoteToLocalSynchronizationManager::launchLinkedNotebookSync() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::launchLinkedNotebookSync")); + QNDEBUG("RemoteToLocalSynchronizationManager::launchLinkedNotebookSync"); m_pendingLinkedNotebooksSyncStart = false; launchDataElementSync<LinkedNotebooksList, LinkedNotebook>( ContentSource::UserAccount, QStringLiteral("Linked notebook"), @@ -5895,25 +5883,28 @@ void RemoteToLocalSynchronizationManager::launchNotebookSync() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::launchNotebookSync")); + QNDEBUG("RemoteToLocalSynchronizationManager::launchNotebookSync"); m_pendingNotebooksSyncStart = false; launchDataElementSync<NotebooksList, Notebook>(ContentSource::UserAccount, QStringLiteral("Notebook"), - m_notebooks, m_expungedNotebooks); + m_notebooks, + m_expungedNotebooks); } void RemoteToLocalSynchronizationManager::collectSyncedGuidsForFullSyncStaleDataItemsExpunger() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "collectSyncedGuidsForFullSyncStaleDataItemsExpunger")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "collectSyncedGuidsForFullSyncStaleDataItemsExpunger"); m_fullSyncStaleDataItemsSyncedGuids.m_syncedNotebookGuids.clear(); m_fullSyncStaleDataItemsSyncedGuids.m_syncedTagGuids.clear(); m_fullSyncStaleDataItemsSyncedGuids.m_syncedNoteGuids.clear(); m_fullSyncStaleDataItemsSyncedGuids.m_syncedSavedSearchGuids.clear(); - m_fullSyncStaleDataItemsSyncedGuids.m_syncedNotebookGuids.reserve(m_notebooks.size()); - for(auto it = m_notebooks.constBegin(), end = m_notebooks.constEnd(); it != end; ++it) + m_fullSyncStaleDataItemsSyncedGuids.m_syncedNotebookGuids.reserve( + m_notebooks.size()); + for(auto it = m_notebooks.constBegin(), end = m_notebooks.constEnd(); + it != end; ++it) { const qevercloud::Notebook & notebook = *it; if (notebook.guid.isSet()) { @@ -5958,8 +5949,8 @@ void RemoteToLocalSynchronizationManager::launchFullSyncStaleDataItemsExpunger() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "launchFullSyncStaleDataItemsExpunger")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "launchFullSyncStaleDataItemsExpunger"); if (m_pFullSyncStaleDataItemsExpunger) { junkFullSyncStaleDataItemsExpunger(*m_pFullSyncStaleDataItemsExpunger); @@ -5984,15 +5975,14 @@ QNSLOT(RemoteToLocalSynchronizationManager, onFullSyncStaleDataItemsExpungerFailure,ErrorString), Qt::ConnectionType(Qt::UniqueConnection | Qt::QueuedConnection)); - QNDEBUG(QStringLiteral("Starting FullSyncStaleDataItemsExpunger for user's " - "own content")); + QNDEBUG("Starting FullSyncStaleDataItemsExpunger for user's own content"); m_pFullSyncStaleDataItemsExpunger->start(); } bool RemoteToLocalSynchronizationManager::launchFullSyncStaleDataItemsExpungersForLinkedNotebooks() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "launchFullSyncStaleDataItemsExpungersForLinkedNotebooks")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "launchFullSyncStaleDataItemsExpungersForLinkedNotebooks"); bool foundLinkedNotebookEligibleForFullSyncStaleDataItemsExpunging = false; @@ -6001,42 +5991,42 @@ { const LinkedNotebook & linkedNotebook = *it; if (Q_UNLIKELY(!linkedNotebook.hasGuid())) { - QNWARNING(QStringLiteral("Skipping linked notebook without guid: ") + QNWARNING("Skipping linked notebook without guid: " << linkedNotebook); continue; } const QString & linkedNotebookGuid = linkedNotebook.guid(); - QNTRACE(QStringLiteral("Examining linked notebook with guid ") - << linkedNotebookGuid); + QNTRACE("Examining linked notebook with guid " << linkedNotebookGuid); auto fullSyncIt = m_linkedNotebookGuidsForWhichFullSyncWasPerformed.find(linkedNotebookGuid); if (fullSyncIt == m_linkedNotebookGuidsForWhichFullSyncWasPerformed.end()) { - QNTRACE(QStringLiteral("It doesn't appear that full sync was performed ") - << QStringLiteral("for linked notebook with guid ") - << linkedNotebookGuid << QStringLiteral(" in the past")); + QNTRACE("It doesn't appear that full sync was performed " + << "for linked notebook with guid " + << linkedNotebookGuid << " in the past"); continue; } auto onceFullSyncIt = m_linkedNotebookGuidsOnceFullySynced.find(linkedNotebookGuid); if (onceFullSyncIt == m_linkedNotebookGuidsOnceFullySynced.end()) { - QNTRACE(QStringLiteral("It appears the full sync was performed for ") - << QStringLiteral("the first time for linked notebook with guid ") + QNTRACE("It appears the full sync was performed for " + << "the first time for linked notebook with guid " << linkedNotebookGuid); continue; } - QNDEBUG(QStringLiteral("The contents of a linked notebook with guid ") + QNDEBUG("The contents of a linked notebook with guid " << linkedNotebookGuid - << QStringLiteral(" were fully synced after being fully synced " - "in the past, need to seek for stale data items " - "and expunge them")); + << " were fully synced after being fully synced " + << "in the past, need to seek for stale data items " + << "and expunge them"); foundLinkedNotebookEligibleForFullSyncStaleDataItemsExpunging = true; FullSyncStaleDataItemsExpunger::SyncedGuids syncedGuids; for(auto nit = m_linkedNotebookGuidsByNotebookGuids.constBegin(), - nend = m_linkedNotebookGuidsByNotebookGuids.constEnd(); nit != nend; ++nit) + nend = m_linkedNotebookGuidsByNotebookGuids.constEnd(); + nit != nend; ++nit) { const QString & currentLinkedNotebookGuid = nit.value(); if (currentLinkedNotebookGuid != linkedNotebookGuid) { @@ -6078,12 +6068,13 @@ NotebookSyncCache * pNotebookSyncCache = new NotebookSyncCache(m_manager.localStorageManagerAsync(), linkedNotebookGuid, this); - notebookSyncCacheIt = - m_notebookSyncCachesByLinkedNotebookGuids.insert(linkedNotebookGuid, - pNotebookSyncCache); + notebookSyncCacheIt = m_notebookSyncCachesByLinkedNotebookGuids.insert( + linkedNotebookGuid, + pNotebookSyncCache); } - auto tagSyncCacheIt = m_tagSyncCachesByLinkedNotebookGuids.find(linkedNotebookGuid); + auto tagSyncCacheIt = m_tagSyncCachesByLinkedNotebookGuids.find( + linkedNotebookGuid); if (tagSyncCacheIt == m_tagSyncCachesByLinkedNotebookGuids.end()) { TagSyncCache * pTagSyncCache = @@ -6100,7 +6091,8 @@ *tagSyncCacheIt.value(), m_savedSearchSyncCache, syncedGuids, linkedNotebookGuid, this); - m_fullSyncStaleDataItemsExpungersByLinkedNotebookGuid[linkedNotebookGuid] = pExpunger; + m_fullSyncStaleDataItemsExpungersByLinkedNotebookGuid[linkedNotebookGuid] = + pExpunger; QObject::connect(pExpunger, QNSIGNAL(FullSyncStaleDataItemsExpunger,finished), this, @@ -6115,8 +6107,8 @@ onFullSyncStaleDataItemsExpungerFailure,ErrorString), Qt::ConnectionType(Qt::UniqueConnection | Qt::QueuedConnection)); - QNDEBUG(QStringLiteral("Starting FullSyncStaleDataItemsExpunger for ") - << QStringLiteral("the content from linked notebook with guid ") + QNDEBUG("Starting FullSyncStaleDataItemsExpunger for " + << "the content from linked notebook with guid " << linkedNotebookGuid); pExpunger->start(); } @@ -6126,27 +6118,23 @@ void RemoteToLocalSynchronizationManager::launchExpungingOfNotelessTagsFromLinkedNotebooks() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "launchExpungingOfNotelessTagsFromLinkedNotebooks")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "launchExpungingOfNotelessTagsFromLinkedNotebooks"); m_expungeNotelessTagsRequestId = QUuid::createUuid(); - QNTRACE(QStringLiteral("Emitting the request to expunge noteless tags ") - << QStringLiteral("from linked notebooks: ") << m_expungeNotelessTagsRequestId); + QNTRACE("Emitting the request to expunge noteless tags " + << "from linked notebooks: " << m_expungeNotelessTagsRequestId); Q_EMIT expungeNotelessTagsFromLinkedNotebooks(m_expungeNotelessTagsRequestId); } bool RemoteToLocalSynchronizationManager::syncingLinkedNotebooksContent() const { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("syncingLinkedNotebooksContent: last sync mode = ") - << m_lastSyncMode << QStringLiteral(", full note contents downloaded = ") - << (m_fullNoteContentsDownloaded - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", expunged from server to client = ") - << (m_expungedFromServerToClient - ? QStringLiteral("true") - : QStringLiteral("false"))); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "syncingLinkedNotebooksContent: last sync mode = " + << m_lastSyncMode << ", full note contents downloaded = " + << (m_fullNoteContentsDownloaded ? "true" : "false") + << ", expunged from server to client = " + << (m_expungedFromServerToClient ? "true" : "false")); if (m_lastSyncMode == SyncMode::FullSync) { return m_fullNoteContentsDownloaded; @@ -6158,43 +6146,43 @@ void RemoteToLocalSynchronizationManager::checkAndIncrementNoteDownloadProgress( const QString & noteGuid) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("checkAndIncrementNoteDownloadProgress: note guid = ") + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "checkAndIncrementNoteDownloadProgress: note guid = " << noteGuid); if (m_originalNumberOfNotes == 0) { - QNDEBUG(QStringLiteral("No notes to download")); + QNDEBUG("No notes to download"); return; } if (m_resourceGuidsPendingInkNoteImageDownloadPerNoteGuid.contains(noteGuid)) { - QNDEBUG(QStringLiteral("Found still pending ink note image download(s) " - "for this note guid, won't increment the note " - "download progress")); + QNDEBUG("Found still pending ink note image download(s) " + "for this note guid, won't increment the note " + "download progress"); return; } if (m_notesPendingThumbnailDownloadByGuid.contains(noteGuid)) { - QNDEBUG(QStringLiteral("Found still pending note thumbnail download for " - "this note guid, won't increment the note download " - "progress")); + QNDEBUG("Found still pending note thumbnail download for " + "this note guid, won't increment the note download " + "progress"); return; } if (Q_UNLIKELY(m_numNotesDownloaded == m_originalNumberOfNotes)) { - QNWARNING(QStringLiteral("The count of downloaded notes (") << m_numNotesDownloaded - << QStringLiteral(") is already equal to the original number of notes (") - << m_originalNumberOfNotes << QStringLiteral("), won't increment it further")); + QNWARNING("The count of downloaded notes (" << m_numNotesDownloaded + << ") is already equal to the original number of notes (" + << m_originalNumberOfNotes << "), won't increment it further"); return; } ++m_numNotesDownloaded; - QNTRACE(QStringLiteral("Incremented the number of downloaded notes to ") + QNTRACE("Incremented the number of downloaded notes to " << m_numNotesDownloaded - << QStringLiteral(", the total number of notes to download = ") + << ", the total number of notes to download = " << m_originalNumberOfNotes); if (syncingLinkedNotebooksContent()) { @@ -6209,12 +6197,12 @@ void RemoteToLocalSynchronizationManager::checkAndIncrementResourceDownloadProgress( const QString & resourceGuid) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("checkAndIncrementResourceDownloadProgress: ") - << QStringLiteral("resource guid = ") << resourceGuid); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "checkAndIncrementResourceDownloadProgress: " + << "resource guid = " << resourceGuid); if (m_originalNumberOfResources == 0) { - QNDEBUG(QStringLiteral("No resources to download")); + QNDEBUG("No resources to download"); return; } @@ -6224,26 +6212,26 @@ { if (it.value() == resourceGuid) { - QNDEBUG(QStringLiteral("The resource is still pending finding notebook " - "for ink note image downloading")); + QNDEBUG("The resource is still pending finding notebook " + "for ink note image downloading"); return; } } if (Q_UNLIKELY(m_numResourcesDownloaded == m_originalNumberOfResources)) { - QNWARNING(QStringLiteral("The count of downloaded resources (") + QNWARNING("The count of downloaded resources (" << m_numResourcesDownloaded - << QStringLiteral(") is already equal to the original number ") - << QStringLiteral("of resources (") << m_originalNumberOfResources - << QStringLiteral("(, won't increment it further")); + << ") is already equal to the original number " + << "of resources (" << m_originalNumberOfResources + << "(, won't increment it further"); return; } ++m_numResourcesDownloaded; - QNTRACE(QStringLiteral("Incremented the number of downloaded resources to ") + QNTRACE("Incremented the number of downloaded resources to " << m_numResourcesDownloaded - << QStringLiteral(", the total number of resources to download = ") + << ", the total number of resources to download = " << m_originalNumberOfResources); if (syncingLinkedNotebooksContent()) { @@ -6267,31 +6255,29 @@ !m_updateNotebookRequestIds.isEmpty() || !m_expungeNotebookRequestIds.isEmpty())) { - QNDEBUG(QStringLiteral("Notebooks sync is in progress: there are ") - << m_notebooks.size() - << QStringLiteral(" notebooks pending processing and/or ") + QNDEBUG("Notebooks sync is in progress: there are " << m_notebooks.size() + << " notebooks pending processing and/or " << m_notebooksPendingAddOrUpdate.size() - << QStringLiteral(" notebooks pending add or update within " - "the local storage: pending ") - << m_addNotebookRequestIds.size() - << QStringLiteral(" add notebook requests and/or ") + << " notebooks pending add or update within the local storage: " + << "pending " << m_addNotebookRequestIds.size() + << " add notebook requests and/or " << m_updateNotebookRequestIds.size() - << QStringLiteral(" update notebook requests and/or ") + << " update notebook requests and/or " << m_findNotebookByGuidRequestIds.size() - << QStringLiteral(" find notebook by guid requests and/or ") + << " find notebook by guid requests and/or " << m_findNotebookByNameRequestIds.size() - << QStringLiteral(" find notebook by name requests and/or ") + << " find notebook by name requests and/or " << m_expungeNotebookRequestIds.size() - << QStringLiteral(" expunge notebook requests")); + << " expunge notebook requests"); return true; } QList<NotebookSyncConflictResolver*> notebookSyncConflictResolvers = findChildren<NotebookSyncConflictResolver*>(); if (!notebookSyncConflictResolvers.isEmpty()) { - QNDEBUG(QStringLiteral("Notebooks sync is in progress: there are ") + QNDEBUG("Notebooks sync is in progress: there are " << notebookSyncConflictResolvers.size() - << QStringLiteral(" active notebook sync conflict resolvers")); + << " active notebook sync conflict resolvers"); return true; } @@ -6309,31 +6295,31 @@ !m_updateTagRequestIds.isEmpty() || !m_expungeTagRequestIds.isEmpty())) { - QNDEBUG(QStringLiteral("Tags sync is in progress: there are ") + QNDEBUG("Tags sync is in progress: there are " << m_tagsPendingProcessing.size() - << QStringLiteral(" tags pending processing and/or ") + << " tags pending processing and/or " << m_tagsPendingAddOrUpdate.size() - << QStringLiteral(" tags pending add or update within " - "the local storage: pending ") + << " tags pending add or update within " + << "the local storage: pending " << m_addTagRequestIds.size() - << QStringLiteral(" add tag requests and/or ") + << " add tag requests and/or " << m_updateTagRequestIds.size() - << QStringLiteral(" update tag requests and/or ") + << " update tag requests and/or " << m_findTagByGuidRequestIds.size() - << QStringLiteral(" find tag by guid requests and/or ") + << " find tag by guid requests and/or " << m_findTagByNameRequestIds.size() - << QStringLiteral(" find tag by name requests and/or ") + << " find tag by name requests and/or " << m_expungeTagRequestIds.size() - << QStringLiteral(" expunge tag requests")); + << " expunge tag requests"); return true; } QList<TagSyncConflictResolver*> tagSyncConflictResolvers = findChildren<TagSyncConflictResolver*>(); if (!tagSyncConflictResolvers.isEmpty()) { - QNDEBUG(QStringLiteral("Tags sync is in progress: there are ") + QNDEBUG("Tags sync is in progress: there are " << tagSyncConflictResolvers.size() - << QStringLiteral(" active tag sync conflict resolvers")); + << " active tag sync conflict resolvers"); return true; } @@ -6360,35 +6346,33 @@ !m_updateNoteWithThumbnailRequestIds.isEmpty() || !noteSyncConflictResolvers.isEmpty()) { - QNDEBUG(QStringLiteral("Notes sync is in progress: there are ") + QNDEBUG("Notes sync is in progress: there are " << m_notesPendingAddOrUpdate.size() - << QStringLiteral(" notes pending add or update within " - "the local storage: pending ") - << m_addNoteRequestIds.size() - << QStringLiteral(" add note requests and/or ") - << m_updateNoteRequestIds.size() - << QStringLiteral(" update note requests and/or ") + << " notes pending add or update within " + << "the local storage: pending " << m_addNoteRequestIds.size() + << " add note requests and/or " << m_updateNoteRequestIds.size() + << " update note requests and/or " << m_findNoteByGuidRequestIds.size() - << QStringLiteral(" find note by guid requests and/or ") + << " find note by guid requests and/or " << m_notesToAddPerAPICallPostponeTimerId.size() - << QStringLiteral(" notes pending addition due to rate API limits and/or ") + << " notes pending addition due to rate API limits and/or " << m_notesToUpdatePerAPICallPostponeTimerId.size() - << QStringLiteral(" notes pending update due to rate API limits and/or ") + << " notes pending update due to rate API limits and/or " << m_notesPendingDownloadForAddingToLocalStorage.size() - << QStringLiteral(" notes pending download for adding to " - "the local storage and/or ") + << " notes pending download for adding to " + << "the local storage and/or " << m_notesPendingDownloadForUpdatingInLocalStorageByGuid.size() - << QStringLiteral(" notes pending download for updating " - "in the local stroage and/or ") + << " notes pending download for updating " + << "in the local stroage and/or " << m_notesPendingInkNoteImagesDownloadByFindNotebookRequestId.size() - << QStringLiteral(" notes pending ink note image download and/or ") + << " notes pending ink note image download and/or " << (m_notesPendingThumbnailDownloadByFindNotebookRequestId.size() + m_notesPendingThumbnailDownloadByGuid.size()) - << QStringLiteral(" notes pending thumbnail download and/or ") + << " notes pending thumbnail download and/or " << m_updateNoteWithThumbnailRequestIds.size() - << QStringLiteral(" update note with thumbnail requests and/or ") + << " update note with thumbnail requests and/or " << noteSyncConflictResolvers.size() - << QStringLiteral(" note sync conflict resolvers")); + << " note sync conflict resolvers"); return true; } @@ -6418,13 +6402,13 @@ switch(obj) { case RemoteToLocalSynchronizationManager::ContentSource::UserAccount: - strm << QStringLiteral("UserAccount"); + strm << "UserAccount"; break; case RemoteToLocalSynchronizationManager::ContentSource::LinkedNotebook: - strm << QStringLiteral("LinkedNotebook"); + strm << "LinkedNotebook"; break; default: - strm << QStringLiteral("Unknown"); + strm << "Unknown"; break; } @@ -6433,16 +6417,16 @@ void RemoteToLocalSynchronizationManager::checkNotebooksAndTagsSyncCompletionAndLaunchNotesAndResourcesSync() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "checkNotebooksAndTagsSyncCompletionAndLaunchNotesAndResourcesSync")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "checkNotebooksAndTagsSyncCompletionAndLaunchNotesAndResourcesSync"); if (m_pendingNotebooksSyncStart) { - QNDEBUG(QStringLiteral("Still pending notebook sync start")); + QNDEBUG("Still pending notebook sync start"); return; } if (m_pendingTagsSyncStart) { - QNDEBUG(QStringLiteral("Still pending tags sync start")); + QNDEBUG("Still pending tags sync start"); return; } @@ -6476,8 +6460,8 @@ * not getting inside this if block when syncing stuff from the linked * notebooks */ - QNDEBUG(QStringLiteral("The last sync mode is not incremental, " - "won't launch the sync of resources")); + QNDEBUG("The last sync mode is not incremental, " + "won't launch the sync of resources"); return; } @@ -6495,8 +6479,8 @@ void RemoteToLocalSynchronizationManager::checkNotesSyncCompletionAndLaunchResourcesSync() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "checkNotesSyncCompletionAndLaunchResourcesSync")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "checkNotesSyncCompletionAndLaunchResourcesSync"); if (m_lastSyncMode != SyncMode::IncrementalSync) { @@ -6504,15 +6488,15 @@ * NOTE: during the full sync the individual resources are not synced, * instead the full note contents including the resources are synced. * - * That works both for the content from user's own account and for the stuff - * from linked notebooks: the sync of linked notebooks' content might be - * full while the last sync of user's own content is incremental - * but in this case there won't be resources within the synch chunk - * downloaded for that linked notebook so there's no real problem with us - * not getting inside this if block when syncing stuff from the linked - * notebooks + * That works both for the content from user's own account and for + * the stuff from linked notebooks: the sync of linked notebooks' + * content might be full while the last sync of user's own content is + * incremental but in this case there won't be resources within the + * synch chunk downloaded for that linked notebook so there's no real + * problem with us not getting inside this if block when syncing stuff + * from the linked notebooks */ - QNDEBUG(QStringLiteral("Sync is not incremental, won't launch resources sync")); + QNDEBUG("Sync is not incremental, won't launch resources sync"); return; } @@ -6529,8 +6513,8 @@ void RemoteToLocalSynchronizationManager::launchResourcesSync( const ContentSource::type & contentSource) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("launchResourcesSync: content source = ") + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "launchResourcesSync: content source = " << contentSource); QList<QString> dummyList; @@ -6541,8 +6525,8 @@ void RemoteToLocalSynchronizationManager::checkLinkedNotebooksSyncAndLaunchLinkedNotebookContentSync() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("checkLinkedNotebooksSyncAndLaunchLinkedNotebookContentSync")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "checkLinkedNotebooksSyncAndLaunchLinkedNotebookContentSync"); if (m_updateLinkedNotebookRequestIds.isEmpty() && m_addLinkedNotebookRequestIds.isEmpty()) @@ -6555,8 +6539,8 @@ void RemoteToLocalSynchronizationManager::launchLinkedNotebooksContentsSync() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "launchLinkedNotebooksContentsSync")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "launchLinkedNotebooksContentsSync"); m_pendingTagsSyncStart = true; m_pendingNotebooksSyncStart = true; @@ -6583,15 +6567,16 @@ const qevercloud::Tag & tag = *it; if (!tag.guid.isSet()) { - ErrorString error(QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", - "Detected the attempt to map " - "the linked notebook guid to " - "a tag without guid")); + ErrorString error( + QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", + "Detected the attempt to map " + "the linked notebook guid to " + "a tag without guid")); if (tag.name.isSet()) { error.details() = tag.name.ref(); } - QNWARNING(error << QStringLiteral(", tag: ") << tag); + QNWARNING(error << ", tag: " << tag); Q_EMIT failure(error); return false; } @@ -6608,25 +6593,28 @@ const QString & linkedNotebookGuid, const RemoteToLocalSynchronizationManager::NotebooksList & notebooks) { - for(auto it = notebooks.constBegin(), end = notebooks.constEnd(); it != end; ++it) + for(auto it = notebooks.constBegin(), + end = notebooks.constEnd(); it != end; ++it) { const qevercloud::Notebook & notebook = *it; if (!notebook.guid.isSet()) { - ErrorString error(QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", - "Detected the attempt to map " - "the linked notebook guid to " - "a notebook without guid")); + ErrorString error( + QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", + "Detected the attempt to map " + "the linked notebook guid to " + "a notebook without guid")); if (notebook.name.isSet()) { error.details() = notebook.name.ref(); } - QNWARNING(error << QStringLiteral(", notebook: ") << notebook); + QNWARNING(error << ", notebook: " << notebook); Q_EMIT failure(error); return false; } - m_linkedNotebookGuidsByNotebookGuids[notebook.guid.ref()] = linkedNotebookGuid; + m_linkedNotebookGuidsByNotebookGuids[notebook.guid.ref()] = + linkedNotebookGuid; } return true; @@ -6643,19 +6631,21 @@ const qevercloud::Note & note = *it; if (!note.notebookGuid.isSet()) { - ErrorString error(QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", - "Can't map note to a linked notebook: " - "note has no notebook guid")); + ErrorString error( + QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", + "Can't map note to a linked notebook: " + "note has no notebook guid")); if (note.title.isSet()) { error.details() = note.title.ref(); } - QNWARNING(error << QStringLiteral(", note; ") << note); + QNWARNING(error << ", note; " << note); Q_EMIT failure(error); return false; } - m_linkedNotebookGuidsByNotebookGuids[note.notebookGuid.ref()] = linkedNotebookGuid; + m_linkedNotebookGuidsByNotebookGuids[note.notebookGuid.ref()] = + linkedNotebookGuid; } return true; @@ -6667,19 +6657,23 @@ const QString & linkedNotebookGuid, const RemoteToLocalSynchronizationManager::ResourcesList & resources) { - for(auto it = resources.constBegin(), end = resources.constEnd(); it != end; ++it) + for(auto it = resources.constBegin(), + end = resources.constEnd(); it != end; ++it) { const qevercloud::Resource & resource = *it; - if (!resource.guid.isSet()) { - ErrorString error(QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", - "Can't map resource to a linked " - "notebook: resource has no guid")); - QNWARNING(error << QStringLiteral(", resource: ") << resource); + if (!resource.guid.isSet()) + { + ErrorString error( + QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", + "Can't map resource to a linked " + "notebook: resource has no guid")); + QNWARNING(error << ", resource: " << resource); Q_EMIT failure(error); return false; } - m_linkedNotebookGuidsByResourceGuids[resource.guid.ref()] = linkedNotebookGuid; + m_linkedNotebookGuidsByResourceGuids[resource.guid.ref()] = + linkedNotebookGuid; } return true; @@ -6725,8 +6719,8 @@ void RemoteToLocalSynchronizationManager::startLinkedNotebooksSync() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "startLinkedNotebooksSync")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "startLinkedNotebooksSync"); if (!m_allLinkedNotebooksListed) { requestAllLinkedNotebooks(); @@ -6736,8 +6730,8 @@ const int numAllLinkedNotebooks = m_allLinkedNotebooks.size(); if (numAllLinkedNotebooks == 0) { - QNDEBUG(QStringLiteral("No linked notebooks are present within the account, " - "can finish the synchronization right away")); + QNDEBUG("No linked notebooks are present within the account, " + "can finish the synchronization right away"); m_linkedNotebooksSyncChunksDownloaded = true; finalize(); return; @@ -6768,23 +6762,24 @@ error.details() = linkedNotebook.username(); } - QNWARNING(error << QStringLiteral(", linked notebook: ") - << linkedNotebook); + QNWARNING(error << ", linked notebook: " << linkedNotebook); Q_EMIT failure(error); return false; } - if (!m_authenticationTokensAndShardIdsByLinkedNotebookGuid.contains(linkedNotebook.guid())) + if (!m_authenticationTokensAndShardIdsByLinkedNotebookGuid.contains( + linkedNotebook.guid())) { - QNDEBUG(QStringLiteral("Authentication token for linked notebook with guid ") - << linkedNotebook.guid() << QStringLiteral(" was not found; will ") - << QStringLiteral("request authentication tokens for all linked ") - << QStringLiteral("notebooks at once")); + QNDEBUG("Authentication token for linked notebook with guid " + << linkedNotebook.guid() << " was not found; will " + << "request authentication tokens for all linked " + << "notebooks at once"); requestAuthenticationTokensForAllLinkedNotebooks(); return false; } - auto it = m_authenticationTokenExpirationTimesByLinkedNotebookGuid.find(linkedNotebook.guid()); + auto it = m_authenticationTokenExpirationTimesByLinkedNotebookGuid.find( + linkedNotebook.guid()); if (it == m_authenticationTokenExpirationTimesByLinkedNotebookGuid.end()) { ErrorString error(QT_TR_NOOP("Can't find the cached expiration time " @@ -6793,7 +6788,7 @@ error.details() = linkedNotebook.username(); } - QNWARNING(error << QStringLiteral(", linked notebook: ") << linkedNotebook); + QNWARNING(error << ", linked notebook: " << linkedNotebook); Q_EMIT failure(error); return false; } @@ -6802,30 +6797,30 @@ const qevercloud::Timestamp currentTime = QDateTime::currentMSecsSinceEpoch(); if ((expirationTime - currentTime) < HALF_AN_HOUR_IN_MSEC) { - QNDEBUG(QStringLiteral("Authentication token for linked notebook with guid ") + QNDEBUG("Authentication token for linked notebook with guid " << linkedNotebook.guid() - << QStringLiteral(" is too close to expiration: its expiration time is ") + << " is too close to expiration: its expiration time is " << printableDateTimeFromTimestamp(expirationTime) - << QStringLiteral(", current time is ") + << ", current time is " << printableDateTimeFromTimestamp(currentTime) - << QStringLiteral("; will request new authentication tokens ") - << QStringLiteral("for all linked notebooks")); + << "; will request new authentication tokens " + << "for all linked notebooks"); requestAuthenticationTokensForAllLinkedNotebooks(); return false; } } - QNDEBUG(QStringLiteral("Got authentication tokens for all linked notebooks, " - "can proceed with their synchronization")); + QNDEBUG("Got authentication tokens for all linked notebooks, " + "can proceed with their synchronization"); return true; } void RemoteToLocalSynchronizationManager::requestAuthenticationTokensForAllLinkedNotebooks() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "requestAuthenticationTokensForAllLinkedNotebooks")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "requestAuthenticationTokensForAllLinkedNotebooks"); QVector<LinkedNotebookAuthData> linkedNotebookAuthData; const int numAllLinkedNotebooks = m_allLinkedNotebooks.size(); @@ -6843,8 +6838,7 @@ error.details() = currentLinkedNotebook.username(); } - QNWARNING(error << QStringLiteral(", linked notebook: ") - << currentLinkedNotebook); + QNWARNING(error << ", linked notebook: " << currentLinkedNotebook); Q_EMIT failure(error); return; } @@ -6857,8 +6851,7 @@ error.details() = currentLinkedNotebook.username(); } - QNWARNING(error << QStringLiteral(", linked notebook: ") - << currentLinkedNotebook); + QNWARNING(error << ", linked notebook: " << currentLinkedNotebook); Q_EMIT failure(error); return; } @@ -6873,8 +6866,7 @@ error.details() = currentLinkedNotebook.username(); } - QNWARNING(error << QStringLiteral(", linked notebook: ") - << currentLinkedNotebook); + QNWARNING(error << ", linked notebook: " << currentLinkedNotebook); Q_EMIT failure(error); return; } @@ -6887,8 +6879,7 @@ error.details() = currentLinkedNotebook.username(); } - QNWARNING(error << QStringLiteral(", linked notebook: ") - << currentLinkedNotebook); + QNWARNING(error << ", linked notebook: " << currentLinkedNotebook); Q_EMIT failure(error); return; } @@ -6920,7 +6911,7 @@ LocalStorageManager::OrderDirection::Ascending; m_listAllLinkedNotebooksRequestId = QUuid::createUuid(); - QNTRACE(QStringLiteral("Emitting the request to list linked notebooks: request id = ") + QNTRACE("Emitting the request to list linked notebooks: request id = " << m_listAllLinkedNotebooksRequestId); Q_EMIT listAllLinkedNotebooks(limit, offset, order, orderDirection, m_listAllLinkedNotebooksRequestId); @@ -6930,7 +6921,7 @@ const LinkedNotebook & linkedNotebook, const QString & authToken, qevercloud::SyncState & syncState, bool & asyncWait, bool & error) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::getLinkedNotebookSyncState")); + QNDEBUG("RemoteToLocalSynchronizationManager::getLinkedNotebookSyncState"); asyncWait = false; error = false; @@ -6961,10 +6952,11 @@ } qint32 rateLimitSeconds = 0; - qint32 errorCode = - pNoteStore->getLinkedNotebookSyncState(linkedNotebook.qevercloudLinkedNotebook(), - authToken, syncState, errorDescription, - rateLimitSeconds); + qint32 errorCode = pNoteStore->getLinkedNotebookSyncState( + linkedNotebook.qevercloudLinkedNotebook(), + authToken, syncState, errorDescription, + rateLimitSeconds); + if (errorCode == qevercloud::EDAMErrorCode::RATE_LIMIT_REACHED) { if (rateLimitSeconds < 0) { @@ -6992,8 +6984,8 @@ m_getLinkedNotebookSyncStateBeforeStartAPICallPostponeTimerId = timerId; - QNDEBUG(QStringLiteral("Rate limit exceeded, need to wait for ") - << rateLimitSeconds << QStringLiteral(" seconds")); + QNDEBUG("Rate limit exceeded, need to wait for " + << rateLimitSeconds << " seconds"); Q_EMIT rateLimitExceeded(rateLimitSeconds); asyncWait = true; return; @@ -7024,8 +7016,8 @@ bool RemoteToLocalSynchronizationManager::downloadLinkedNotebooksSyncChunks() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "downloadLinkedNotebooksSyncChunks")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "downloadLinkedNotebooksSyncChunks"); qevercloud::SyncChunk * pSyncChunk = Q_NULLPTR; @@ -7042,7 +7034,7 @@ error.details() = linkedNotebook.username(); } - QNWARNING(error << QStringLiteral(": ") << linkedNotebook); + QNWARNING(error << ": " << linkedNotebook); Q_EMIT failure(error); return false; } @@ -7074,27 +7066,26 @@ if (syncChunksDownloadedFlagIt != m_linkedNotebookGuidsForWhichSyncChunksWereDownloaded.end()) { - QNDEBUG(QStringLiteral("Sync chunks were already downloaded for ") - << QStringLiteral("the linked notebook with guid ") - << linkedNotebookGuid); + QNDEBUG("Sync chunks were already downloaded for " + << "the linked notebook with guid " << linkedNotebookGuid); continue; } qint32 afterUsn = lastUpdateCount; qint32 lastPreviousUsn = std::max(lastUpdateCount, 0); - QNDEBUG(QStringLiteral("Last previous USN for current linked notebook = ") - << lastPreviousUsn << QStringLiteral(" (linked notebook guid = ") - << linkedNotebookGuid << QStringLiteral(")")); + QNDEBUG("Last previous USN for current linked notebook = " + << lastPreviousUsn << " (linked notebook guid = " + << linkedNotebookGuid << ")"); if (m_onceSyncDone || (afterUsn != 0)) { auto syncStateIter = m_syncStatesByLinkedNotebookGuid.find(linkedNotebookGuid); if (syncStateIter == m_syncStatesByLinkedNotebookGuid.end()) { - QNTRACE(QStringLiteral("Found no cached sync state for linked ") - << QStringLiteral("notebook guid ") << linkedNotebookGuid - << QStringLiteral(", will try to receive it from ") - << QStringLiteral("the remote service")); + QNTRACE("Found no cached sync state for linked " + << "notebook guid " << linkedNotebookGuid + << ", will try to receive it from " + << "the remote service"); qevercloud::SyncState syncState; bool error = false; @@ -7103,14 +7094,8 @@ syncState, asyncWait, error); if (asyncWait || error) { - QNTRACE(QStringLiteral("Async wait = ") - << (asyncWait - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", error = ") - << (error - ? QStringLiteral("true") - : QStringLiteral("false"))); + QNTRACE("Async wait = " << (asyncWait ? "true" : "false") + << ", error = " << (error ? "true" : "false")); return false; } @@ -7120,24 +7105,24 @@ } const qevercloud::SyncState & syncState = syncStateIter.value(); - QNDEBUG(QStringLiteral("Sync state: ") << syncState - << QStringLiteral("\nLast sync time = ") + QNDEBUG("Sync state: " << syncState + << "\nLast sync time = " << printableDateTimeFromTimestamp(lastSyncTime) - << QStringLiteral(", last update count = ") << lastUpdateCount); + << ", last update count = " << lastUpdateCount); if (syncState.fullSyncBefore > lastSyncTime) { - QNDEBUG(QStringLiteral("Linked notebook sync state says the time " - "has come to do the full sync")); + QNDEBUG("Linked notebook sync state says the time " + "has come to do the full sync"); afterUsn = 0; fullSyncOnly = true; } else if (syncState.updateCount == lastUpdateCount) { - QNDEBUG(QStringLiteral("Server has no updates for data in this " - "linked notebook, continuing with the next one")); + QNDEBUG("Server has no updates for data in this " + "linked notebook, continuing with the next one"); Q_UNUSED(m_linkedNotebookGuidsForWhichSyncChunksWereDownloaded.insert( - linkedNotebookGuid)); + linkedNotebookGuid)); continue; } } @@ -7162,9 +7147,8 @@ { if (pSyncChunk) { afterUsn = pSyncChunk->chunkHighUSN; - QNTRACE(QStringLiteral("Updated afterUSN for linked notebook " - "to sync chunk's high USN: ") - << pSyncChunk->chunkHighUSN); + QNTRACE("Updated afterUSN for linked notebook to sync chunk's " + << "high USN: " << pSyncChunk->chunkHighUSN); } m_linkedNotebookSyncChunks.push_back(qevercloud::SyncChunk()); @@ -7208,8 +7192,8 @@ m_downloadLinkedNotebookSyncChunkAPICallPostponeTimerId = timerId; - QNDEBUG(QStringLiteral("Rate limit exceeded, need to wait for ") - << rateLimitSeconds << QStringLiteral(" seconds")); + QNDEBUG("Rate limit exceeded, need to wait for " + << rateLimitSeconds << " seconds"); Q_EMIT rateLimitExceeded(rateLimitSeconds); return false; } @@ -7238,19 +7222,17 @@ return false; } - QNDEBUG(QStringLiteral("Received sync chunk: ") << *pSyncChunk); + QNDEBUG("Received sync chunk: " << *pSyncChunk); lastSyncTime = std::max(pSyncChunk->currentTime, lastSyncTime); lastUpdateCount = std::max(pSyncChunk->updateCount, lastUpdateCount); - QNTRACE(QStringLiteral("Linked notebook's sync chunk current time: ") + QNTRACE("Linked notebook's sync chunk current time: " << printableDateTimeFromTimestamp(pSyncChunk->currentTime) - << QStringLiteral(", last sync time = ") + << ", last sync time = " << printableDateTimeFromTimestamp(lastSyncTime) - << QStringLiteral(", sync chunk update count = ") - << pSyncChunk->updateCount - << QStringLiteral(", last update count = ") - << lastUpdateCount); + << ", sync chunk update count = " << pSyncChunk->updateCount + << ", last update count = " << lastUpdateCount); Q_EMIT linkedNotebookSyncChunksDownloadProgress(pSyncChunk->chunkHighUSN, pSyncChunk->updateCount, @@ -7318,8 +7300,8 @@ pSyncChunk = Q_NULLPTR; } - QNDEBUG(QStringLiteral("Done. Processing content pointed to by linked notebooks " - "from buffered sync chunks")); + QNDEBUG("Done. Processing content pointed to by linked notebooks " + "from buffered sync chunks"); // don't need this anymore, it only served the purpose of preventing multiple // get sync state calls for the same linked notebook @@ -7333,8 +7315,8 @@ void RemoteToLocalSynchronizationManager::launchLinkedNotebooksTagsSync() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "launchLinkedNotebooksTagsSync")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "launchLinkedNotebooksTagsSync"); m_pendingTagsSyncStart = false; QList<QString> dummyList; @@ -7345,8 +7327,8 @@ void RemoteToLocalSynchronizationManager::launchLinkedNotebooksNotebooksSync() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "launchLinkedNotebooksNotebooksSync")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "launchLinkedNotebooksNotebooksSync"); m_pendingNotebooksSyncStart = false; @@ -7358,8 +7340,8 @@ void RemoteToLocalSynchronizationManager::checkServerDataMergeCompletion() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "checkServerDataMergeCompletion")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "checkServerDataMergeCompletion"); // Need to check whether we are still waiting for the response // from some add or update request @@ -7371,24 +7353,20 @@ m_addTagRequestIds.isEmpty(); if (!tagsReady) { - QNDEBUG(QStringLiteral("Tags are not ready, pending tags sync start = ") - << (m_pendingTagsSyncStart - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral("; there are ") - << m_tagsPendingProcessing.size() - << QStringLiteral(" tags pending processing and/or ") + QNDEBUG("Tags are not ready, pending tags sync start = " + << (m_pendingTagsSyncStart ? "true" : "false") + << "; there are " << m_tagsPendingProcessing.size() + << " tags pending processing and/or " << m_tagsPendingAddOrUpdate.size() - << QStringLiteral(" tags pending add or update within " - "the local storage: pending response for ") + << " tags pending add or update within " + << "the local storage: pending response for " << m_updateTagRequestIds.size() - << QStringLiteral(" tag update requests and/or ") - << m_addTagRequestIds.size() - << QStringLiteral(" tag add requests and/or ") + << " tag update requests and/or " << m_addTagRequestIds.size() + << " tag add requests and/or " << m_findTagByGuidRequestIds.size() - << QStringLiteral(" find tag by guid requests and/or ") + << " find tag by guid requests and/or " << m_findTagByNameRequestIds.size() - << QStringLiteral(" find tag by name requests")); + << " find tag by name requests"); return; } @@ -7400,20 +7378,20 @@ m_addSavedSearchRequestIds.isEmpty(); if (!searchesReady) { - QNDEBUG(QStringLiteral("Saved searches are not ready, there are ") + QNDEBUG("Saved searches are not ready, there are " << m_savedSearches.size() - << QStringLiteral(" saved searches pending processing and/or ") + << " saved searches pending processing and/or " << m_savedSearchesPendingAddOrUpdate.size() - << QStringLiteral(" saved searches pending add or update within " - "the local storage: pending response for ") + << " saved searches pending add or update within " + << "the local storage: pending response for " << m_updateSavedSearchRequestIds.size() - << QStringLiteral(" saved search update requests and/or ") + << " saved search update requests and/or " << m_addSavedSearchRequestIds.size() - << QStringLiteral(" saved search add requests and/or ") + << " saved search add requests and/or " << m_findSavedSearchByGuidRequestIds.size() - << QStringLiteral(" find saved search by guid requests and/or ") + << " find saved search by guid requests and/or " << m_findSavedSearchByNameRequestIds.size() - << QStringLiteral(" find saved search by name requests")); + << " find saved search by name requests"); return; } @@ -7425,22 +7403,20 @@ m_addLinkedNotebookRequestIds.isEmpty(); if (!linkedNotebooksReady) { - QNDEBUG(QStringLiteral("Linked notebooks are not ready, pending linked ") - << QStringLiteral("notebooks sync start = ") - << (m_pendingLinkedNotebooksSyncStart - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral("; there are ") << m_linkedNotebooks.size() - << QStringLiteral(" linked notebooks pending processing and/or ") + QNDEBUG("Linked notebooks are not ready, pending linked " + << "notebooks sync start = " + << (m_pendingLinkedNotebooksSyncStart ? "true" : "false") + << "; there are " << m_linkedNotebooks.size() + << " linked notebooks pending processing and/or " << m_linkedNotebooksPendingAddOrUpdate.size() - << QStringLiteral(" linked notebooks pending add or update within " - "the local storage: pending response for ") + << " linked notebooks pending add or update within " + "the local storage: pending response for " << m_updateLinkedNotebookRequestIds.size() - << QStringLiteral(" linked notebook update requests and/or ") + << " linked notebook update requests and/or " << m_addLinkedNotebookRequestIds.size() - << QStringLiteral(" linked notebook add requests and/or ") + << " linked notebook add requests and/or " << m_findLinkedNotebookRequestIds.size() - << QStringLiteral(" find linked notebook requests")); + << " find linked notebook requests"); return; } @@ -7453,23 +7429,21 @@ m_addNotebookRequestIds.isEmpty(); if (!notebooksReady) { - QNDEBUG(QStringLiteral("Notebooks are not ready, pending notebooks sync start = ") - << (m_pendingNotebooksSyncStart - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral("; there are ") << m_notebooks.size() - << QStringLiteral(" notebooks pending processing and/or ") + QNDEBUG("Notebooks are not ready, pending notebooks sync start = " + << (m_pendingNotebooksSyncStart ? "true" : "false") + << "; there are " << m_notebooks.size() + << " notebooks pending processing and/or " << m_notebooksPendingAddOrUpdate.size() - << QStringLiteral(" notebooks pending add or update within " - "the local storage: pending response for ") + << " notebooks pending add or update within " + << "the local storage: pending response for " << m_updateNotebookRequestIds.size() - << QStringLiteral(" notebook update requests and/or ") + << " notebook update requests and/or " << m_addNotebookRequestIds.size() - << QStringLiteral(" notebook add requests and/or ") + << " notebook add requests and/or " << m_findNotebookByGuidRequestIds.size() - << QStringLiteral(" find notebook by guid requests and/or ") + << " find notebook by guid requests and/or " << m_findNotebookByNameRequestIds.size() - << QStringLiteral(" find notebook by name requests")); + << " find notebook by name requests"); return; } @@ -7487,38 +7461,36 @@ m_updateNoteWithThumbnailRequestIds.isEmpty(); if (!notesReady) { - QNDEBUG(QStringLiteral("Notes are not ready, there are ") << m_notes.size() - << QStringLiteral(" notes pending processing and/or ") + QNDEBUG("Notes are not ready, there are " << m_notes.size() + << " notes pending processing and/or " << m_notesPendingAddOrUpdate.size() - << QStringLiteral(" notes pending add or update within " - "the local storage: pending response for ") + << " notes pending add or update within " + << "the local storage: pending response for " << m_updateNoteRequestIds.size() - << QStringLiteral(" note update requests and/or ") - << m_addNoteRequestIds.size() - << QStringLiteral(" note add requests and/or ") - << m_findNoteByGuidRequestIds.size() - << QStringLiteral(" find note by guid requests and/or ") + << " note update requests and/or " << m_addNoteRequestIds.size() + << " note add requests and/or " << m_findNoteByGuidRequestIds.size() + << " find note by guid requests and/or " << m_notesPendingDownloadForAddingToLocalStorage.size() - << QStringLiteral(" async full new note data downloads and/or ") + << " async full new note data downloads and/or " << m_notesPendingDownloadForUpdatingInLocalStorageByGuid.size() - << QStringLiteral(" async full existing note data downloads; also, there are ") + << " async full existing note data downloads; also, there are " << m_notesToAddPerAPICallPostponeTimerId.size() - << QStringLiteral(" postponed note add requests and/or ") + << " postponed note add requests and/or " << m_notesToUpdatePerAPICallPostponeTimerId.size() - << QStringLiteral(" postponed note update requests and/or ") + << " postponed note update requests and/or " << m_resourceGuidsPendingInkNoteImageDownloadPerNoteGuid.size() - << QStringLiteral(" note resources pending ink note image download " - "processing and/or ") + << " note resources pending ink note image download " + << "processing and/or " << m_notesPendingInkNoteImagesDownloadByFindNotebookRequestId.size() - << QStringLiteral(" find notebook requests for ink note image " - "download processing and/or ") + << " find notebook requests for ink note image " + << "download processing and/or " << m_notesPendingThumbnailDownloadByFindNotebookRequestId.size() - << QStringLiteral(" find notebook requests for note thumbnail " - "download processing and/or ") + << " find notebook requests for note thumbnail " + << "download processing and/or " << m_notesPendingThumbnailDownloadByGuid.size() - << QStringLiteral(" note thumbnail downloads and/or ") + << " note thumbnail downloads and/or " << m_updateNoteWithThumbnailRequestIds.size() - << QStringLiteral(" update note with downloaded thumbnails requests")); + << " update note with downloaded thumbnails requests"); return; } @@ -7540,35 +7512,35 @@ m_postponedConflictingResourceDataPerAPICallPostponeTimerId.isEmpty(); if (!resourcesReady) { - QNDEBUG(QStringLiteral("Resources are not ready, there are ") + QNDEBUG("Resources are not ready, there are " << m_resources.size() - << QStringLiteral(" resources pending processing and/or ") + << " resources pending processing and/or " << m_resourcesPendingAddOrUpdate.size() - << QStringLiteral(" resources pending add or update within " - "the local storage: pending response for ") + << " resources pending add or update within " + << "the local storage: pending response for " << m_updateResourceRequestIds.size() - << QStringLiteral(" resource update requests and/or ") + << " resource update requests and/or " << m_resourcesByMarkNoteOwningResourceDirtyRequestIds.size() - << QStringLiteral(" mark note owning resource as dirty requests and/or ") + << " mark note owning resource as dirty requests and/or " << m_addResourceRequestIds.size() - << QStringLiteral(" resource add requests and/or ") + << " resource add requests and/or " << m_resourcesByFindNoteRequestIds.size() - << QStringLiteral(" find note for resource requests and/or ") + << " find note for resource requests and/or " << m_findResourceByGuidRequestIds.size() - << QStringLiteral(" find resource requests and/or ") + << " find resource requests and/or " << m_inkNoteResourceDataPerFindNotebookRequestId.size() - << QStringLiteral(" resource find notebook for ink note image " - "download processing and/or ") + << " resource find notebook for ink note image " + << "download processing and/or " << m_resourcesPendingDownloadForAddingToLocalStorageWithNotesByResourceGuid.size() - << QStringLiteral(" async full new resource data downloads and/or ") + << " async full new resource data downloads and/or " << m_resourcesPendingDownloadForUpdatingInLocalStorageWithNotesByResourceGuid.size() - << QStringLiteral(" async full existing resource data downloads and/or ") + << " async full existing resource data downloads and/or " << m_resourcesToAddWithNotesPerAPICallPostponeTimerId.size() - << QStringLiteral(" postponed resource add requests and/or ") + << " postponed resource add requests and/or " << m_resourcesToUpdateWithNotesPerAPICallPostponeTimerId.size() - << QStringLiteral(" postponed resource update requests and/or ") + << " postponed resource update requests and/or " << m_postponedConflictingResourceDataPerAPICallPostponeTimerId.size() - << QStringLiteral(" postponed resource conflict resolutions")); + << " postponed resource conflict resolutions"); return; } } @@ -7578,32 +7550,32 @@ QList<NotebookSyncConflictResolver*> notebookSyncConflictResolvers = findChildren<NotebookSyncConflictResolver*>(); if (!notebookSyncConflictResolvers.isEmpty()) { - QNDEBUG(QStringLiteral("Still have ") << notebookSyncConflictResolvers.size() - << QStringLiteral(" pending notebook sync conflict resolutions")); + QNDEBUG("Still have " << notebookSyncConflictResolvers.size() + << " pending notebook sync conflict resolutions"); return; } QList<TagSyncConflictResolver*> tagSyncConflictResolvers = findChildren<TagSyncConflictResolver*>(); if (!tagSyncConflictResolvers.isEmpty()) { - QNDEBUG(QStringLiteral("Still have ") << tagSyncConflictResolvers.size() - << QStringLiteral(" pending tag sync conflict resolutions")); + QNDEBUG("Still have " << tagSyncConflictResolvers.size() + << " pending tag sync conflict resolutions"); return; } QList<SavedSearchSyncConflictResolver*> savedSearchSyncConflictResolvers = findChildren<SavedSearchSyncConflictResolver*>(); if (!savedSearchSyncConflictResolvers.isEmpty()) { - QNDEBUG(QStringLiteral("Still have ") << savedSearchSyncConflictResolvers.size() - << QStringLiteral(" pending saved search sync conflict resolutions")); + QNDEBUG("Still have " << savedSearchSyncConflictResolvers.size() + << " pending saved search sync conflict resolutions"); return; } QList<NoteSyncConflictResolver*> noteSyncConflictResolvers = findChildren<NoteSyncConflictResolver*>(); if (!noteSyncConflictResolvers.isEmpty()) { - QNDEBUG(QStringLiteral("Still have ") << noteSyncConflictResolvers.size() - << QStringLiteral(" pending note sync conflict resolutions")); + QNDEBUG("Still have " << noteSyncConflictResolvers.size() + << " pending note sync conflict resolutions"); return; } @@ -7611,20 +7583,20 @@ { if (!m_listAllLinkedNotebooksRequestId.isNull()) { - QNDEBUG(QStringLiteral("Pending list of all linked notebooks to " - "actually start the linked notebooks sync")); + QNDEBUG("Pending list of all linked notebooks to " + "actually start the linked notebooks sync"); return; } if (!m_linkedNotebookGuidsPendingTagSyncCachesFill.isEmpty()) { - QNDEBUG(QStringLiteral("Pending TagSyncCache fill for some linked " - "notebooks to actually start the sync of tags " - "from linked notebooks")); + QNDEBUG("Pending TagSyncCache fill for some linked " + "notebooks to actually start the sync of tags " + "from linked notebooks"); return; } - QNDEBUG(QStringLiteral("Synchronized the whole contents from linked notebooks")); + QNDEBUG("Synchronized the whole contents from linked notebooks"); if (!m_expungedNotes.isEmpty()) { expungeNotes(); @@ -7639,7 +7611,7 @@ } else { - QNDEBUG(QStringLiteral("Synchronized the whole contents from user's account")); + QNDEBUG("Synchronized the whole contents from user's account"); m_fullNoteContentsDownloaded = true; @@ -7650,10 +7622,10 @@ { if (m_onceSyncDone) { - QNDEBUG(QStringLiteral("Performed full sync even though it has " - "been performed at some moment in the past; " - "need to check for stale data items left " - "within the local storage and expunge them")); + QNDEBUG("Performed full sync even though it has " + "been performed at some moment in the past; " + "need to check for stale data items left " + "within the local storage and expunge them"); launchFullSyncStaleDataItemsExpunger(); return; } @@ -7672,27 +7644,27 @@ void RemoteToLocalSynchronizationManager::finalize() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::finalize: ") - << QStringLiteral("last update count = ") << m_lastUpdateCount - << QStringLiteral(", last sync time = ") + QNDEBUG("RemoteToLocalSynchronizationManager::finalize: " + << "last update count = " << m_lastUpdateCount + << ", last sync time = " << printableDateTimeFromTimestamp(m_lastSyncTime)); if (QuentierIsLogLevelActive(LogLevel::TraceLevel)) { - QNTRACE(QStringLiteral("Last update counts by linked notebook guids: ")); + QNTRACE("Last update counts by linked notebook guids: "); for(auto it = m_lastUpdateCountByLinkedNotebookGuid.constBegin(), - end = m_lastUpdateCountByLinkedNotebookGuid.constEnd(); it != end; ++it) + end = m_lastUpdateCountByLinkedNotebookGuid.constEnd(); + it != end; ++it) { - QNTRACE(QStringLiteral("guid = ") << it.key() - << QStringLiteral(", last update count = ") << it.value()); + QNTRACE("guid = " << it.key() << ", last update count = " + << it.value()); } - QNTRACE(QStringLiteral("Last sync times by linked notebook guids: ")); + QNTRACE("Last sync times by linked notebook guids: "); for(auto it = m_lastSyncTimeByLinkedNotebookGuid.constBegin(), end = m_lastSyncTimeByLinkedNotebookGuid.constEnd(); it != end; ++it) { - QNTRACE(QStringLiteral("guid = ") << it.key() - << QStringLiteral(", last sync time = ") + QNTRACE("guid = " << it.key() << ", last sync time = " << printableDateTimeFromTimestamp(it.value())); } } @@ -7708,7 +7680,7 @@ void RemoteToLocalSynchronizationManager::clear() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::clear")); + QNDEBUG("RemoteToLocalSynchronizationManager::clear"); disconnectFromLocalStorage(); @@ -7825,21 +7797,23 @@ m_pendingAuthenticationTokenAndShardId = false; - // NOTE: not clearing m_user: this information can be reused in subsequent syncs + // NOTE: not clearing m_user: this information can be reused in subsequent + // syncs m_findUserRequestId = QUuid(); m_addOrUpdateUserRequestId = QUuid(); m_onceAddedOrUpdatedUserInLocalStorage = false; - // NOTE: not clearing auth tokens, shard ids and auth tokens' expiration times - // for linked notebooks: this information can be reused in later syncs + // NOTE: not clearing auth tokens, shard ids and auth tokens' expiration + // times for linked notebooks: this information can be reused in later syncs m_pendingAuthenticationTokensForLinkedNotebooks = false; m_syncStatesByLinkedNotebookGuid.clear(); // NOTE: not clearing last synchronized USNs, sync times and update counts - // by linked notebook guid: this information can be reused in subsequent syncs + // by linked notebook guid: this information can be reused in subsequent + // syncs m_notebooks.clear(); m_notebooksPendingAddOrUpdate.clear(); @@ -8083,7 +8057,7 @@ void RemoteToLocalSynchronizationManager::clearAll() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::clearAll")); + QNDEBUG("RemoteToLocalSynchronizationManager::clearAll"); clear(); @@ -8111,8 +8085,8 @@ void RemoteToLocalSynchronizationManager::handleLinkedNotebookAdded( const LinkedNotebook & linkedNotebook) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("handleLinkedNotebookAdded: linked notebook = ") + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "handleLinkedNotebookAdded: linked notebook = " << linkedNotebook); unregisterLinkedNotebookPendingAddOrUpdate(linkedNotebook); @@ -8122,8 +8096,8 @@ } if (!linkedNotebook.hasGuid()) { - QNWARNING(QStringLiteral("Detected the addition of linked notebook " - "without guid to local storage!")); + QNWARNING("Detected the addition of linked notebook " + "without guid to local storage!"); return; } @@ -8131,10 +8105,10 @@ CompareItemByGuid<LinkedNotebook>(linkedNotebook.guid())); if (it != m_allLinkedNotebooks.end()) { - QNINFO(QStringLiteral("Detected the addition of linked notebook to " - "the local storage, however such linked notebook is " - "already present within the list of all linked " - "notebooks received previously from local storage")); + QNINFO("Detected the addition of linked notebook to " + "the local storage, however such linked notebook is " + "already present within the list of all linked " + "notebooks received previously from local storage"); *it = linkedNotebook; return; } @@ -8145,8 +8119,8 @@ void RemoteToLocalSynchronizationManager::handleLinkedNotebookUpdated( const LinkedNotebook & linkedNotebook) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("handleLinkedNotebookUpdated: linked notebook = ") + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "handleLinkedNotebookUpdated: linked notebook = " << linkedNotebook); unregisterLinkedNotebookPendingAddOrUpdate(linkedNotebook); @@ -8156,8 +8130,8 @@ } if (!linkedNotebook.hasGuid()) { - QNWARNING(QStringLiteral("Detected the updated linked notebook without " - "guid in local storage!")); + QNWARNING("Detected the updated linked notebook without " + "guid in local storage!"); return; } @@ -8165,10 +8139,10 @@ CompareItemByGuid<LinkedNotebook>(linkedNotebook.guid())); if (it == m_allLinkedNotebooks.end()) { - QNINFO(QStringLiteral("Detected the update of linked notebook to " - "the local storage, however such linked notebook is " - "not present within the list of all linked notebooks " - "received previously from local storage")); + QNINFO("Detected the update of linked notebook to " + "the local storage, however such linked notebook is " + "not present within the list of all linked notebooks " + "received previously from local storage"); m_allLinkedNotebooks << linkedNotebook; return; } @@ -8178,7 +8152,7 @@ void RemoteToLocalSynchronizationManager::timerEvent(QTimerEvent * pEvent) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::timerEvent")); + QNDEBUG("RemoteToLocalSynchronizationManager::timerEvent"); if (!pEvent) { ErrorString errorDescription(QT_TR_NOOP("Qt error: detected null pointer " @@ -8190,7 +8164,7 @@ int timerId = pEvent->timerId(); killTimer(timerId); - QNDEBUG(QStringLiteral("Killed timer with id ") << timerId); + QNDEBUG("Killed timer with id " << timerId); auto noteToAddIt = m_notesToAddPerAPICallPostponeTimerId.find(timerId); if (noteToAddIt != m_notesToAddPerAPICallPostponeTimerId.end()) { @@ -8209,18 +8183,24 @@ return; } - auto resourceToAddIt = m_resourcesToAddWithNotesPerAPICallPostponeTimerId.find(timerId); + auto resourceToAddIt = + m_resourcesToAddWithNotesPerAPICallPostponeTimerId.find(timerId); if (resourceToAddIt != m_resourcesToAddWithNotesPerAPICallPostponeTimerId.end()) { std::pair<Resource,Note> pair = resourceToAddIt.value(); - Q_UNUSED(m_resourcesToAddWithNotesPerAPICallPostponeTimerId.erase(resourceToAddIt)) + Q_UNUSED(m_resourcesToAddWithNotesPerAPICallPostponeTimerId.erase( + resourceToAddIt)) getFullResourceDataAsyncAndAddToLocalStorage(pair.first, pair.second); return; } - auto resourceToUpdateIt = m_resourcesToUpdateWithNotesPerAPICallPostponeTimerId.find(timerId); - if (resourceToUpdateIt != m_resourcesToUpdateWithNotesPerAPICallPostponeTimerId.end()) { + auto resourceToUpdateIt = + m_resourcesToUpdateWithNotesPerAPICallPostponeTimerId.find(timerId); + if (resourceToUpdateIt != + m_resourcesToUpdateWithNotesPerAPICallPostponeTimerId.end()) + { std::pair<Resource,Note> pair = resourceToUpdateIt.value(); - Q_UNUSED(m_resourcesToUpdateWithNotesPerAPICallPostponeTimerId.erase(resourceToUpdateIt)) + Q_UNUSED(m_resourcesToUpdateWithNotesPerAPICallPostponeTimerId.erase( + resourceToUpdateIt)) getFullResourceDataAsyncAndUpdateInLocalStorage(pair.first, pair.second); return; } @@ -8280,26 +8260,27 @@ void RemoteToLocalSynchronizationManager::getFullNoteDataAsync(const Note & note) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::getFullNoteDataAsync: ") + QNDEBUG("RemoteToLocalSynchronizationManager::getFullNoteDataAsync: " << note); if (!note.hasGuid()) { - ErrorString errorDescription(QT_TR_NOOP("Detected the attempt to get full " - "note's data for a note without guid")); + ErrorString errorDescription( + QT_TR_NOOP("Detected the attempt to get full " + "note's data for a note without guid")); APPEND_NOTE_DETAILS(errorDescription, note) - QNWARNING(errorDescription << QStringLiteral(": ") << note); + QNWARNING(errorDescription << ": " << note); Q_EMIT failure(errorDescription); return; } if (!note.hasNotebookGuid()) { - ErrorString errorDescription(QT_TR_NOOP("Detected the attempt to get full " - "note's data for a note without " - "notebook guid")); + ErrorString errorDescription( + QT_TR_NOOP("Detected the attempt to get full note's data for " + "a note without notebook guid")); APPEND_NOTE_DETAILS(errorDescription, note) - QNWARNING(errorDescription << QStringLiteral(": ") << note); + QNWARNING(errorDescription << ": " << note); Q_EMIT failure(errorDescription); return; } @@ -8312,17 +8293,19 @@ return; } - if (authToken.isEmpty()) { + if (authToken.isEmpty()) + { /** - * Empty authentication tokens should correspond to public linked notebooks; - * the official Evernote documentation (dev.evernote.com/media/pdf/edam-sync.pdf) - * says in this case the authentication token is not required, however, that is a lie, - * with empty authentication token EDAMUserException is thrown with PERMISSION_DENIED - * error code; instead for public notebooks the authentication token from - * the primary account should be used + * Empty authentication tokens should correspond to public linked + * notebooks; the official Evernote documentation + * (dev.evernote.com/media/pdf/edam-sync.pdf) says in this case + * the authentication token is not required, however, that is a lie, + * with empty authentication token EDAMUserException is thrown with + * PERMISSION_DENIED error code; instead for public notebooks + * the authentication token from the primary account should be used */ - QNDEBUG(QStringLiteral("No auth token for public linked notebook, will " - "use the account's default auth token")); + QNDEBUG("No auth token for public linked notebook, will " + "use the account's default auth token"); authToken = m_authenticationToken; } @@ -8345,7 +8328,7 @@ authToken, errorDescription); if (!res) { APPEND_NOTE_DETAILS(errorDescription, note) - QNWARNING(errorDescription << QStringLiteral(", note: ") << note); + QNWARNING(errorDescription << ", note: " << note); Q_EMIT failure(errorDescription); } } @@ -8353,9 +8336,8 @@ void RemoteToLocalSynchronizationManager::getFullNoteDataAsyncAndAddToLocalStorage( const Note & note) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("getFullNoteDataAsyncAndAddToLocalStorage: ") - << note); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "getFullNoteDataAsyncAndAddToLocalStorage: " << note); if (Q_UNLIKELY(!note.hasGuid())) { @@ -8364,7 +8346,7 @@ "has no guid")); APPEND_NOTE_DETAILS(errorDescription, note) - QNWARNING(errorDescription << QStringLiteral(", note: ") << note); + QNWARNING(errorDescription << ", note: " << note); Q_EMIT failure(errorDescription); return; } @@ -8373,14 +8355,14 @@ auto it = m_notesPendingDownloadForAddingToLocalStorage.find(noteGuid); if (Q_UNLIKELY(it != m_notesPendingDownloadForAddingToLocalStorage.end())) { - QNDEBUG(QStringLiteral("Note with guid ") << noteGuid - << QStringLiteral(" is already being downloaded")); + QNDEBUG("Note with guid " << noteGuid << " is already being downloaded"); return; } - QNTRACE(QStringLiteral("Adding note into the list of those pending download " - "for adding to the local storage: ") << note.qevercloudNote()); - m_notesPendingDownloadForAddingToLocalStorage[noteGuid] = note.qevercloudNote(); + QNTRACE("Adding note into the list of those pending download " + "for adding to the local storage: " << note.qevercloudNote()); + m_notesPendingDownloadForAddingToLocalStorage[noteGuid] = + note.qevercloudNote(); getFullNoteDataAsync(note); } @@ -8388,9 +8370,8 @@ void RemoteToLocalSynchronizationManager::getFullNoteDataAsyncAndUpdateInLocalStorage( const Note & note) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("getFullNoteDataAsyncAndUpdateInLocalStorage: ") - << note); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "getFullNoteDataAsyncAndUpdateInLocalStorage: " << note); if (Q_UNLIKELY(!note.hasGuid())) { @@ -8399,7 +8380,7 @@ "has no guid")); APPEND_NOTE_DETAILS(errorDescription, note) - QNWARNING(errorDescription << QStringLiteral(", note: ") << note); + QNWARNING(errorDescription << ", note: " << note); Q_EMIT failure(errorDescription); return; } @@ -8408,13 +8389,12 @@ auto it = m_notesPendingDownloadForUpdatingInLocalStorageByGuid.find(noteGuid); if (Q_UNLIKELY(it != m_notesPendingDownloadForUpdatingInLocalStorageByGuid.end())) { - QNDEBUG(QStringLiteral("Note with guid ") << noteGuid - << QStringLiteral(" is already being downloaded")); + QNDEBUG("Note with guid " << noteGuid << " is already being downloaded"); return; } - QNTRACE(QStringLiteral("Adding note guid into the list of those pending " - "download for update in the local storage: ") << noteGuid); + QNTRACE("Adding note guid into the list of those pending " + "download for update in the local storage: " << noteGuid); m_notesPendingDownloadForUpdatingInLocalStorageByGuid[noteGuid] = note; getFullNoteDataAsync(note); @@ -8423,17 +8403,17 @@ void RemoteToLocalSynchronizationManager::getFullResourceDataAsync( const Resource & resource, const Note & resourceOwningNote) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("getFullResourceDataAsync: resource = ") << resource - << QStringLiteral("\nResource owning note: ") << resourceOwningNote); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "getFullResourceDataAsync: resource = " << resource + << "\nResource owning note: " << resourceOwningNote); if (!resource.hasGuid()) { ErrorString errorDescription(QT_TR_NOOP("Detected the attempt to get full " "resource's data for a resource " "without guid")); APPEND_NOTE_DETAILS(errorDescription, resourceOwningNote); - QNWARNING(errorDescription << QStringLiteral("\nResource: ") << resource - << QStringLiteral("\nResource owning note: ") << resourceOwningNote); + QNWARNING(errorDescription << "\nResource: " << resource + << "\nResource owning note: " << resourceOwningNote); Q_EMIT failure(errorDescription); return; } @@ -8443,12 +8423,13 @@ QString authToken; INoteStore * pNoteStore = Q_NULLPTR; - auto linkedNotebookGuidIt = m_linkedNotebookGuidsByResourceGuids.find(resource.guid()); + auto linkedNotebookGuidIt = m_linkedNotebookGuidsByResourceGuids.find( + resource.guid()); if (linkedNotebookGuidIt == m_linkedNotebookGuidsByResourceGuids.end()) { - QNDEBUG(QStringLiteral("Found no linked notebook corresponding to ") - << QStringLiteral("the resource with guid ") << resource.guid() - << QStringLiteral(", using the note store for the user's own account")); + QNDEBUG("Found no linked notebook corresponding to " + << "the resource with guid " << resource.guid() + << ", using the note store for the user's own account"); pNoteStore = &(m_manager.noteStore()); authToken = m_authenticationToken; } @@ -8456,15 +8437,18 @@ { const QString & linkedNotebookGuid = linkedNotebookGuidIt.value(); - auto authTokenIt = m_authenticationTokensAndShardIdsByLinkedNotebookGuid.find(linkedNotebookGuid); - if (Q_UNLIKELY(authTokenIt == m_authenticationTokensAndShardIdsByLinkedNotebookGuid.end())) + auto authTokenIt = + m_authenticationTokensAndShardIdsByLinkedNotebookGuid.find( + linkedNotebookGuid); + if (Q_UNLIKELY(authTokenIt == + m_authenticationTokensAndShardIdsByLinkedNotebookGuid.end())) { ErrorString errorDescription(QT_TR_NOOP("Can't find the authentication " "token corresponding to " "the linked notebook")); APPEND_NOTE_DETAILS(errorDescription, resourceOwningNote) - QNWARNING(errorDescription << QStringLiteral("; resource: ") << resource - << QStringLiteral("\nResource owning note: ") << resourceOwningNote); + QNWARNING(errorDescription << "; resource: " << resource + << "\nResource owning note: " << resourceOwningNote); Q_EMIT failure(errorDescription); return; } @@ -8491,8 +8475,8 @@ "URL corresponding to " "the linked notebook")); APPEND_NOTE_DETAILS(errorDescription, resourceOwningNote) - QNWARNING(errorDescription << QStringLiteral("; resource: ") << resource - << QStringLiteral("\nResource owning note: ") << resourceOwningNote); + QNWARNING(errorDescription << "; resource: " << resource + << "\nResource owning note: " << resourceOwningNote); Q_EMIT failure(errorDescription); return; } @@ -8506,8 +8490,8 @@ ErrorString errorDescription(QT_TR_NOOP("Can't find or create " "note store for ")); APPEND_NOTE_DETAILS(errorDescription, resourceOwningNote) - QNWARNING(errorDescription << QStringLiteral("; resource: ") << resource - << QStringLiteral("\nResource owning note: ") << resourceOwningNote); + QNWARNING(errorDescription << "; resource: " << resource + << "\nResource owning note: " << resourceOwningNote); Q_EMIT failure(errorDescription); return; } @@ -8518,8 +8502,8 @@ "store url for the linked " "notebook's note store")); APPEND_NOTE_DETAILS(errorDescription, resourceOwningNote) - QNWARNING(errorDescription << QStringLiteral("; resource: ") << resource - << QStringLiteral("\nResource owning note: ") << resourceOwningNote); + QNWARNING(errorDescription << "; resource: " << resource + << "\nResource owning note: " << resourceOwningNote); Q_EMIT failure(errorDescription); return; } @@ -8534,9 +8518,9 @@ Qt::ConnectionType(Qt::UniqueConnection | Qt::QueuedConnection)); - QNDEBUG(QStringLiteral("Using INoteStore corresponding to the linked ") - << QStringLiteral("notebook with guid ") << linkedNotebookGuid - << QStringLiteral(", note store url = ") << pNoteStore->noteStoreUrl()); + QNDEBUG("Using INoteStore corresponding to the linked " + << "notebook with guid " << linkedNotebookGuid + << ", note store url = " << pNoteStore->noteStoreUrl()); } ErrorString errorDescription; @@ -8548,8 +8532,8 @@ errorDescription); if (!res) { APPEND_NOTE_DETAILS(errorDescription, resourceOwningNote); - QNWARNING(errorDescription << QStringLiteral("; resource: ") << resource - << QStringLiteral("\nResource owning note: ") << resourceOwningNote); + QNWARNING(errorDescription << "; resource: " << resource + << "\nResource owning note: " << resourceOwningNote); Q_EMIT failure(errorDescription); } } @@ -8557,33 +8541,36 @@ void RemoteToLocalSynchronizationManager::getFullResourceDataAsyncAndAddToLocalStorage( const Resource & resource, const Note & resourceOwningNote) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("getFullResourceDataAsyncAndAddToLocalStorage: resource = ") - << resource << QStringLiteral("\nResource owning note: ") << resourceOwningNote); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "getFullResourceDataAsyncAndAddToLocalStorage: resource = " + << resource << "\nResource owning note: " << resourceOwningNote); if (Q_UNLIKELY(!resource.hasGuid())) { - ErrorString errorDescription(QT_TR_NOOP("Internal error: the synced resource " - "to be added to the local storage " - "has no guid")); - QNWARNING(errorDescription << QStringLiteral(", resource: ") << resource - << QStringLiteral("\nResource owning note: ") << resourceOwningNote); + ErrorString errorDescription( + QT_TR_NOOP("Internal error: the synced resource to be added to " + "the local storage has no guid")); + QNWARNING(errorDescription << ", resource: " << resource + << "\nResource owning note: " << resourceOwningNote); Q_EMIT failure(errorDescription); return; } QString resourceGuid = resource.guid(); - auto it = m_resourcesPendingDownloadForAddingToLocalStorageWithNotesByResourceGuid.find(resourceGuid); - if (Q_UNLIKELY(it != m_resourcesPendingDownloadForAddingToLocalStorageWithNotesByResourceGuid.end())) { - QNDEBUG(QStringLiteral("Resource with guid ") << resourceGuid - << QStringLiteral(" is already being downloaded")); + auto it = + m_resourcesPendingDownloadForAddingToLocalStorageWithNotesByResourceGuid.find( + resourceGuid); + if (Q_UNLIKELY(it != + m_resourcesPendingDownloadForAddingToLocalStorageWithNotesByResourceGuid.end())) + { + QNDEBUG("Resource with guid " << resourceGuid + << " is already being downloaded"); return; } - QNTRACE(QStringLiteral("Adding resource guid into the list of those pending ") - << QStringLiteral("download for adding to the local storage: ") - << resourceGuid); + QNTRACE("Adding resource guid into the list of those pending " + << "download for adding to the local storage: " << resourceGuid); m_resourcesPendingDownloadForAddingToLocalStorageWithNotesByResourceGuid[resourceGuid] = std::pair<Resource,Note>(resource, resourceOwningNote); @@ -8593,57 +8580,60 @@ void RemoteToLocalSynchronizationManager::getFullResourceDataAsyncAndUpdateInLocalStorage( const Resource & resource, const Note & resourceOwningNote) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("getFullResourceDataAsyncAndUpdateInLocalStorage: resource = ") - << resource << QStringLiteral("\nResource owning note: ") << resourceOwningNote); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "getFullResourceDataAsyncAndUpdateInLocalStorage: resource = " + << resource << "\nResource owning note: " << resourceOwningNote); if (Q_UNLIKELY(!resource.hasGuid())) { - ErrorString errorDescription(QT_TR_NOOP("Internal error: the synced resource " - "to be updated in the local storage " - "has no guid")); - QNWARNING(errorDescription << QStringLiteral(", resource: ") << resource - << QStringLiteral("\nResource owning note: ") << resourceOwningNote); + ErrorString errorDescription( + QT_TR_NOOP("Internal error: the synced resource to be updated " + "in the local storage has no guid")); + QNWARNING(errorDescription << ", resource: " << resource + << "\nResource owning note: " << resourceOwningNote); Q_EMIT failure(errorDescription); return; } QString resourceGuid = resource.guid(); - auto it = m_resourcesPendingDownloadForUpdatingInLocalStorageWithNotesByResourceGuid.find(resourceGuid); - if (Q_UNLIKELY(it != m_resourcesPendingDownloadForUpdatingInLocalStorageWithNotesByResourceGuid.end())) { - QNDEBUG(QStringLiteral("Resource with guid ") << resourceGuid - << QStringLiteral(" is already being downloaded")); + auto it = + m_resourcesPendingDownloadForUpdatingInLocalStorageWithNotesByResourceGuid.find( + resourceGuid); + if (Q_UNLIKELY(it != + m_resourcesPendingDownloadForUpdatingInLocalStorageWithNotesByResourceGuid.end())) + { + QNDEBUG("Resource with guid " << resourceGuid + << " is already being downloaded"); return; } - QNTRACE(QStringLiteral("Adding resource guid into the list of those pending ") - << QStringLiteral("download for update in the local storage: ") - << resourceGuid); + QNTRACE("Adding resource guid into the list of those pending " + << "download for update in the local storage: " << resourceGuid); m_resourcesPendingDownloadForUpdatingInLocalStorageWithNotesByResourceGuid[resourceGuid] = std::pair<Resource,Note>(resource, resourceOwningNote); getFullResourceDataAsync(resource, resourceOwningNote); } -void RemoteToLocalSynchronizationManager::downloadSyncChunksAndLaunchSync(qint32 afterUsn) +void RemoteToLocalSynchronizationManager::downloadSyncChunksAndLaunchSync( + qint32 afterUsn) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("downloadSyncChunksAndLaunchSync: after USN = ") - << afterUsn); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "downloadSyncChunksAndLaunchSync: after USN = " << afterUsn); INoteStore & noteStore = m_manager.noteStore(); qevercloud::SyncChunk * pSyncChunk = Q_NULLPTR; qint32 lastPreviousUsn = std::max(m_lastUpdateCount, 0); - QNDEBUG(QStringLiteral("Last previous USN: ") << lastPreviousUsn); + QNDEBUG("Last previous USN: " << lastPreviousUsn); while(!pSyncChunk || (pSyncChunk->chunkHighUSN < pSyncChunk->updateCount)) { if (pSyncChunk) { afterUsn = pSyncChunk->chunkHighUSN; - QNTRACE(QStringLiteral("Updated after USN to sync chunk's high USN: ") + QNTRACE("Updated after USN to sync chunk's high USN: " << pSyncChunk->chunkHighUSN); } @@ -8716,29 +8706,26 @@ return; } - QNDEBUG(QStringLiteral("Received sync chunk: ") << *pSyncChunk); + QNDEBUG("Received sync chunk: " << *pSyncChunk); m_lastSyncTime = std::max(pSyncChunk->currentTime, m_lastSyncTime); m_lastUpdateCount = std::max(pSyncChunk->updateCount, m_lastUpdateCount); - QNTRACE(QStringLiteral("Sync chunk current time: ") + QNTRACE("Sync chunk current time: " << printableDateTimeFromTimestamp(pSyncChunk->currentTime) - << QStringLiteral(", last sync time = ") + << ", last sync time = " << printableDateTimeFromTimestamp(m_lastSyncTime) - << QStringLiteral(", sync chunk high USN = ") - << pSyncChunk->chunkHighUSN - << QStringLiteral(", sync chunk update count = ") - << pSyncChunk->updateCount - << QStringLiteral(", last update count = ") - << m_lastUpdateCount); + << ", sync chunk high USN = " << pSyncChunk->chunkHighUSN + << ", sync chunk update count = " << pSyncChunk->updateCount + << ", last update count = " << m_lastUpdateCount); Q_EMIT syncChunksDownloadProgress(pSyncChunk->chunkHighUSN, pSyncChunk->updateCount, lastPreviousUsn); } - QNDEBUG(QStringLiteral("Done. Processing tags, saved searches, linked notebooks " - "and notebooks from buffered sync chunks")); + QNDEBUG("Done. Processing tags, saved searches, linked notebooks " + "and notebooks from buffered sync chunks"); m_lastSyncChunksDownloadedUsn = afterUsn; m_syncChunksDownloaded = true; @@ -8750,8 +8737,8 @@ const Notebook * RemoteToLocalSynchronizationManager::getNotebookPerNote( const Note & note) const { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("getNotebookPerNote: note = ") << note); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "getNotebookPerNote: note = " << note); QString noteGuid = (note.hasGuid() ? note.guid() : QString()); QString noteLocalUid = note.localUid(); @@ -8768,13 +8755,13 @@ void RemoteToLocalSynchronizationManager::handleAuthExpiration() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::handleAuthExpiration")); + QNDEBUG("RemoteToLocalSynchronizationManager::handleAuthExpiration"); if (syncingLinkedNotebooksContent()) { if (m_pendingAuthenticationTokensForLinkedNotebooks) { - QNDEBUG(QStringLiteral("Already pending authentication tokens " - "for linked notebooks")); + QNDEBUG("Already pending authentication tokens " + "for linked notebooks"); return; } @@ -8783,8 +8770,7 @@ else { if (m_pendingAuthenticationTokenAndShardId) { - QNDEBUG(QStringLiteral("Already pending the authentication token " - "and shard id")); + QNDEBUG("Already pending the authentication token and shard id"); return; } @@ -8793,11 +8779,10 @@ } } -bool RemoteToLocalSynchronizationManager::checkUserAccountSyncState(bool & asyncWait, - bool & error, - qint32 & afterUsn) +bool RemoteToLocalSynchronizationManager::checkUserAccountSyncState( + bool & asyncWait, bool & error, qint32 & afterUsn) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::checkUserAccountSyncState")); + QNDEBUG("RemoteToLocalSynchronizationManager::checkUserAccountSyncState"); asyncWait = false; error = false; @@ -8805,14 +8790,15 @@ ErrorString errorDescription; qint32 rateLimitSeconds = 0; qevercloud::SyncState state; - qint32 errorCode = - m_manager.noteStore().getSyncState(state, errorDescription, rateLimitSeconds); + qint32 errorCode = m_manager.noteStore().getSyncState( + state, errorDescription, rateLimitSeconds); if (errorCode == qevercloud::EDAMErrorCode::RATE_LIMIT_REACHED) { if (rateLimitSeconds < 0) { - errorDescription.setBase(QT_TR_NOOP("Rate limit reached but the number " - "of seconds to wait is incorrect")); + errorDescription.setBase( + QT_TR_NOOP("Rate limit reached but the number " + "of seconds to wait is incorrect")); errorDescription.details() = QString::number(rateLimitSeconds); Q_EMIT failure(errorDescription); error = true; @@ -8823,9 +8809,9 @@ startTimer(SEC_TO_MSEC(rateLimitSeconds)); if (Q_UNLIKELY(m_getSyncStateBeforeStartAPICallPostponeTimerId == 0)) { - errorDescription.setBase(QT_TR_NOOP("Failed to start a timer to postpone " - "the Evernote API call due to " - "rate limit exceeding")); + errorDescription.setBase( + QT_TR_NOOP("Failed to start a timer to postpone the Evernote " + "API call due to rate limit exceeding")); Q_EMIT failure(errorDescription); error = true; } @@ -8849,54 +8835,52 @@ return false; } - QNDEBUG(QStringLiteral("Sync state: ") << state - << QStringLiteral("\nLast sync time = ") + QNDEBUG("Sync state: " << state << "\nLast sync time = " << printableDateTimeFromTimestamp(m_lastSyncTime) - << QStringLiteral("; last update count = ") << m_lastUpdateCount); + << "; last update count = " << m_lastUpdateCount); if (state.fullSyncBefore > m_lastSyncTime) { - QNDEBUG(QStringLiteral("Sync state says the time has come to do the full sync")); + QNDEBUG("Sync state says the time has come to do the full sync"); afterUsn = 0; m_lastSyncMode = SyncMode::FullSync; } else if (state.updateCount == m_lastUpdateCount) { - QNDEBUG(QStringLiteral("Server has no updates for user's data since the last sync")); + QNDEBUG("Server has no updates for user's data since the last sync"); return false; } return true; } -bool RemoteToLocalSynchronizationManager::checkLinkedNotebooksSyncStates(bool & asyncWait, - bool & error) +bool RemoteToLocalSynchronizationManager::checkLinkedNotebooksSyncStates( + bool & asyncWait, bool & error) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "checkLinkedNotebooksSyncStates")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "checkLinkedNotebooksSyncStates"); asyncWait = false; error = false; if (!m_allLinkedNotebooksListed) { - QNTRACE(QStringLiteral("The list of all linked notebooks was not obtained " - "from the local storage yet, need to wait for it " - "to happen")); + QNTRACE("The list of all linked notebooks was not obtained " + "from the local storage yet, need to wait for it to happen"); requestAllLinkedNotebooks(); asyncWait = true; return false; } if (m_allLinkedNotebooks.isEmpty()) { - QNTRACE(QStringLiteral("The list of all linked notebooks is empty, " - "nothing to check sync states for")); + QNTRACE("The list of all linked notebooks is empty, " + "nothing to check sync states for"); return false; } if (m_pendingAuthenticationTokensForLinkedNotebooks) { - QNTRACE(QStringLiteral("Pending authentication tokens for linked notebook " - "flag is set, need to wait for auth tokens")); + QNTRACE("Pending authentication tokens for linked notebook " + "flag is set, need to wait for auth tokens"); asyncWait = true; return false; } @@ -8910,8 +8894,7 @@ ErrorString errorMessage(QT_TR_NOOP("Internal error: found a linked " "notebook without guid")); Q_EMIT failure(errorMessage); - QNWARNING(errorMessage << QStringLiteral(", linked notebook: ") - << linkedNotebook); + QNWARNING(errorMessage << ", linked notebook: " << linkedNotebook); error = true; return false; } @@ -8934,27 +8917,25 @@ return false; } - QNDEBUG(QStringLiteral("Sync state: ") << state - << QStringLiteral("\nLast update count = ") << lastUpdateCount); + QNDEBUG("Sync state: " << state << "\nLast update count = " + << lastUpdateCount); if (state.updateCount == lastUpdateCount) { - QNTRACE(QStringLiteral("Evernote service has no updates for the linked " - "notebook with guid ") << linkedNotebookGuid); + QNTRACE("Evernote service has no updates for the linked " + << "notebook with guid " << linkedNotebookGuid); continue; } else { - QNTRACE(QStringLiteral("Detected mismatch in update counts for ") - << QStringLiteral("the linked notebook with guid ") - << linkedNotebookGuid - << QStringLiteral(": last update count = ") << lastUpdateCount - << QStringLiteral(", sync state's update count: ") - << state.updateCount); + QNTRACE("Detected mismatch in update counts for " + << "the linked notebook with guid " << linkedNotebookGuid + << ": last update count = " << lastUpdateCount + << ", sync state's update count: " << state.updateCount); return true; } } - QNTRACE(QStringLiteral("Checked sync states for all linked notebooks, " - "found no updates from Evernote service")); + QNTRACE("Checked sync states for all linked notebooks, " + "found no updates from Evernote service"); return false; } @@ -8970,9 +8951,9 @@ notebook.linkedNotebookGuid()); if (Q_UNLIKELY(it == m_authenticationTokensAndShardIdsByLinkedNotebookGuid.end())) { - QNWARNING(QStringLiteral("Can't download an ink note image: no " - "authentication token and shard id for " - "linked notebook: ") << notebook); + QNWARNING("Can't download an ink note image: no " + << "authentication token and shard id for " + << "linked notebook: " << notebook); return; } @@ -8989,33 +8970,33 @@ bool RemoteToLocalSynchronizationManager::findNotebookForInkNoteImageDownloading( const Note & note) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("findNotebookForInkNoteImageDownloading: note local uid = ") - << note.localUid() << QStringLiteral(", note guid = ") + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "findNotebookForInkNoteImageDownloading: note local uid = " + << note.localUid() << ", note guid = " << (note.hasGuid() ? note.guid() : QStringLiteral("<empty>"))); if (Q_UNLIKELY(!note.hasGuid())) { - QNWARNING(QStringLiteral("Can't find notebook for ink note image " - "downloading: note has no guid: ") << note); + QNWARNING("Can't find notebook for ink note image " + << "downloading: note has no guid: " << note); return false; } if (Q_UNLIKELY(!note.hasResources())) { - QNWARNING(QStringLiteral("Can't find notebook for ink note image " - "downloading: note has no resources: ") << note); + QNWARNING("Can't find notebook for ink note image " + << "downloading: note has no resources: " << note); return false; } if (Q_UNLIKELY(!note.isInkNote())) { - QNWARNING(QStringLiteral("Can't find notebook for ink note image " - "downloading: note is not an ink note: ") << note); + QNWARNING("Can't find notebook for ink note image " + << "downloading: note is not an ink note: " << note); return false; } if (Q_UNLIKELY(!note.hasNotebookLocalUid() && !note.hasNotebookGuid())) { - QNWARNING(QStringLiteral("Can't find notebook for ink note image downloading: " - "the note has neither notebook local uid " - "nor notebook guid: ") << note); + QNWARNING("Can't find notebook for ink note image downloading: " + << "the note has neither notebook local uid " + << "nor notebook guid: " << note); return false; } @@ -9036,8 +9017,8 @@ /** * NOTE: technically, here we don't start downloading the ink note image yet; * but it is necessary to insert the resource guids per note guid into - * the container right here in order to prevent multiple ink note image downloads - * for the same note during the sync process + * the container right here in order to prevent multiple ink note image + * downloads for the same note during the sync process */ const QList<Resource> resources = note.resources(); for(auto it = resources.constBegin(), end = resources.constEnd(); it != end; ++it) @@ -9056,10 +9037,10 @@ } } - QNTRACE(QStringLiteral("Emitting the request to find a notebook for the ink ") - << QStringLiteral("note images download setup: ") << requestId - << QStringLiteral(", note guid = ") << noteGuid - << QStringLiteral(", notebook: ") << dummyNotebook); + QNTRACE("Emitting the request to find a notebook for the ink " + << "note images download setup: " << requestId + << ", note guid = " << noteGuid + << ", notebook: " << dummyNotebook); Q_EMIT findNotebook(dummyNotebook, requestId); return true; @@ -9069,25 +9050,28 @@ const QString & resourceGuid, const int resourceHeight, const int resourceWidth, const QString & noteGuid, const Notebook & notebook) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("setupInkNoteImageDownloading: resource guid = ") - << resourceGuid << QStringLiteral(", resource height = ") - << resourceHeight << QStringLiteral(", resource width = ") - << resourceWidth << QStringLiteral(", note guid = ") << noteGuid - << QStringLiteral(", notebook: ") << notebook); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "setupInkNoteImageDownloading: resource guid = " + << resourceGuid << ", resource height = " + << resourceHeight << ", resource width = " + << resourceWidth << ", note guid = " << noteGuid + << ", notebook: " << notebook); QString authToken, shardId; bool isPublicNotebook = false; authenticationInfoForNotebook(notebook, authToken, shardId, isPublicNotebook); - if (m_resourceGuidsPendingInkNoteImageDownloadPerNoteGuid.contains(noteGuid, resourceGuid)) { - QNDEBUG(QStringLiteral("Already downloading the ink note image for note guid ") - << noteGuid << QStringLiteral(" and resource guid ") << resourceGuid); + if (m_resourceGuidsPendingInkNoteImageDownloadPerNoteGuid.contains( + noteGuid, resourceGuid)) + { + QNDEBUG("Already downloading the ink note image for note guid " + << noteGuid << " and resource guid " << resourceGuid); return; } - Q_UNUSED(m_resourceGuidsPendingInkNoteImageDownloadPerNoteGuid.insert(noteGuid, - resourceGuid)) + Q_UNUSED(m_resourceGuidsPendingInkNoteImageDownloadPerNoteGuid.insert( + noteGuid, resourceGuid)) + QString storageFolderPath = inkNoteImagesStoragePath(); InkNoteImageDownloader * pDownloader = @@ -9120,32 +9104,33 @@ bool RemoteToLocalSynchronizationManager::setupInkNoteImageDownloadingForNote( const Note & note, const Notebook & notebook) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("setupInkNoteImageDownloadingForNote: note local uid = ") - << note.localUid() << QStringLiteral(", note guid = ") + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "setupInkNoteImageDownloadingForNote: note local uid = " + << note.localUid() << ", note guid = " << (note.hasGuid() ? note.guid() : QStringLiteral("<empty>")) - << QStringLiteral(", notebook = ") << notebook); + << ", notebook = " << notebook); if (Q_UNLIKELY(!note.hasGuid())) { - QNWARNING(QStringLiteral("Can't set up the ink note images downloading: " - "the note has no guid: ") << note); + QNWARNING("Can't set up the ink note images downloading: " + << "the note has no guid: " << note); return false; } if (Q_UNLIKELY(!note.hasResources())) { - QNWARNING(QStringLiteral("Can't set up the ink note images downloading: " - "the note has no resources: ") << note); + QNWARNING("Can't set up the ink note images downloading: " + << "the note has no resources: " << note); return false; } if (Q_UNLIKELY(!note.isInkNote())) { - QNWARNING(QStringLiteral("Can't set up the ink note images downloading: " - "the note is not an ink note: ") << note); + QNWARNING("Can't set up the ink note images downloading: " + << "the note is not an ink note: " << note); return false; } const QList<Resource> resources = note.resources(); - for(auto it = resources.constBegin(), end = resources.constEnd(); it != end; ++it) + for(auto it = resources.constBegin(), + end = resources.constEnd(); it != end; ++it) { const Resource & resource = *it; @@ -9164,21 +9149,21 @@ bool RemoteToLocalSynchronizationManager::findNotebookForNoteThumbnailDownloading( const Note & note) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("findNotebookForNoteThumbnailDownloading: note local uid = ") - << note.localUid() << QStringLiteral(", note guid = ") + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "findNotebookForNoteThumbnailDownloading: note local uid = " + << note.localUid() << ", note guid = " << (note.hasGuid() ? note.guid() : QStringLiteral("<empty>"))); if (Q_UNLIKELY(!note.hasGuid())) { - QNWARNING(QStringLiteral("Can't find notebook for note thumbnail downloading: " - "note has no guid: ") << note); + QNWARNING("Can't find notebook for note thumbnail downloading: " + << "note has no guid: " << note); return false; } if (Q_UNLIKELY(!note.hasNotebookLocalUid() && !note.hasNotebookGuid())) { - QNWARNING(QStringLiteral("Can't find notebook for note thumbnail downloading: " - "the note has neither notebook local uid " - "nor notebook guid: ") << note); + QNWARNING("Can't find notebook for note thumbnail downloading: the note " + << "has neither notebook local uid nor notebook guid: " + << note); return false; } @@ -9204,10 +9189,9 @@ */ m_notesPendingThumbnailDownloadByGuid[noteGuid] = note; - QNTRACE(QStringLiteral("Emitting the request to find a notebook for the note ") - << QStringLiteral("thumbnail download setup: ") << requestId - << QStringLiteral(", note guid = ") << noteGuid - << QStringLiteral(", notebook: ") << dummyNotebook); + QNTRACE("Emitting the request to find a notebook for the note " + << "thumbnail download setup: " << requestId << ", note guid = " + << noteGuid << ", notebook: " << dummyNotebook); Q_EMIT findNotebook(dummyNotebook, requestId); return true; @@ -9216,14 +9200,14 @@ bool RemoteToLocalSynchronizationManager::setupNoteThumbnailDownloading( const Note & note, const Notebook & notebook) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("setupNoteThumbnailDownloading: note guid = ") + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "setupNoteThumbnailDownloading: note guid = " << (note.hasGuid() ? note.guid() : QStringLiteral("<empty>")) - << QStringLiteral(", notebook: ") << notebook); + << ", notebook: " << notebook); if (Q_UNLIKELY(!note.hasGuid())) { - QNWARNING(QStringLiteral("Can't setup downloading the thumbnail: ") - << QStringLiteral("note has no guid: ") << note); + QNWARNING("Can't setup downloading the thumbnail: note has no guid: " + << note); return false; } @@ -9236,8 +9220,7 @@ NoteThumbnailDownloader * pDownloader = new NoteThumbnailDownloader(m_host, noteGuid, authToken, shardId, - /* from public linked notebook = */ isPublicNotebook, - this); + isPublicNotebook, this); QObject::connect(pDownloader, QNSIGNAL(NoteThumbnailDownloader,finished, bool,QString,QByteArray,ErrorString), @@ -9254,8 +9237,8 @@ void RemoteToLocalSynchronizationManager::launchNoteSyncConflictResolver( const Note & localConflict, const qevercloud::Note & remoteNote) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("launchNoteSyncConflictResolver: remote note guid = ") + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "launchNoteSyncConflictResolver: remote note guid = " << (remoteNote.guid.isSet() ? remoteNote.guid.ref() : QStringLiteral("<not set>"))); @@ -9272,9 +9255,8 @@ if (resolverRemoteNote.guid.isSet() && (resolverRemoteNote.guid.ref() == remoteNote.guid.ref())) { - QNDEBUG(QStringLiteral("Note sync conflict resolver already exists ") - << QStringLiteral("for remote note with guid ") - << remoteNote.guid.ref()); + QNDEBUG("Note sync conflict resolver already exists " + << "for remote note with guid " << remoteNote.guid.ref()); return; } } @@ -9285,8 +9267,9 @@ remoteNote, localConflict, this); QObject::connect(pResolver, QNSIGNAL(NoteSyncConflictResolver,finished,qevercloud::Note), - this, QNSLOT(RemoteToLocalSynchronizationManager, - onNoteSyncConflictResolverFinished,qevercloud::Note), + this, + QNSLOT(RemoteToLocalSynchronizationManager, + onNoteSyncConflictResolverFinished,qevercloud::Note), Qt::ConnectionType(Qt::UniqueConnection | Qt::QueuedConnection)); QObject::connect(pResolver, @@ -9332,8 +9315,8 @@ Note RemoteToLocalSynchronizationManager::createConflictingNote( const Note & originalNote, const qevercloud::Note * pRemoteNote) const { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("createConflictingNote: original note local uid = ") + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "createConflictingNote: original note local uid = " << originalNote.localUid()); Note conflictingNote(originalNote); @@ -9381,16 +9364,14 @@ if (conflictingNote.hasTitle()) { conflictingNoteTitle = conflictingNote.title() + - QStringLiteral(" - ") + - tr("conflicting"); + QStringLiteral(" - ") + tr("conflicting"); } else { QString previewText = conflictingNote.plainText(); if (!previewText.isEmpty()) { previewText.truncate(12); - conflictingNoteTitle = previewText + - QStringLiteral("... - ") + + conflictingNoteTitle = previewText + QStringLiteral("... - ") + tr("conflicting"); } else { @@ -9411,11 +9392,11 @@ conflictingNote.notebookGuid()); if (notebookIt != m_expungedNotebooks.constEnd()) { - QNDEBUG(QStringLiteral("Conflicting note's original notebook is ") - << QStringLiteral("about to be expunged (guid = ") + QNDEBUG("Conflicting note's original notebook is " + << "about to be expunged (guid = " << conflictingNote.notebookGuid() - << QStringLiteral("), using the remote note's notebook (guid = ") - << pRemoteNote->notebookGuid.ref() << QStringLiteral(")")); + << "), using the remote note's notebook (guid = " + << pRemoteNote->notebookGuid.ref() << ")"); conflictingNote.setNotebookLocalUid(QString()); conflictingNote.setNotebookGuid(pRemoteNote->notebookGuid.ref()); } @@ -9500,39 +9481,36 @@ void RemoteToLocalSynchronizationManager::checkNonSyncedItemForSmallestUsn( const T & item, const QString & linkedNotebookGuid, qint32 & smallestUsn) const { - QNTRACE(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("checkNonSyncedItemForSmallestUsn: linked notebook guid = ") - << linkedNotebookGuid << QStringLiteral(", item: ") << item); + QNTRACE("RemoteToLocalSynchronizationManager::" + << "checkNonSyncedItemForSmallestUsn: linked notebook guid = " + << linkedNotebookGuid << ", item: " << item); if (Q_UNLIKELY(!item.updateSequenceNum.isSet())) { - QNWARNING(QStringLiteral("Skipping item with empty update sequence number: ") - << item); + QNWARNING("Skipping item with empty update sequence number: " << item); return; } if (Q_UNLIKELY(!item.guid.isSet())) { - QNWARNING(QStringLiteral("Skipping item without guid: ") << item); + QNWARNING("Skipping item without guid: " << item); return; } QString itemLinkedNotebookGuid = findLinkedNotebookGuidForItem(item); if (itemLinkedNotebookGuid != linkedNotebookGuid) { - QNTRACE(QStringLiteral("Skipping item as it doesn't match by linked ") - << QStringLiteral("notebook guid: item's linked notebook guid is ") + QNTRACE("Skipping item as it doesn't match by linked " + << "notebook guid: item's linked notebook guid is " << itemLinkedNotebookGuid - << QStringLiteral(" while the requested one is ") - << linkedNotebookGuid); + << " while the requested one is " << linkedNotebookGuid); return; } - QNTRACE(QStringLiteral("Checking item with USN ") - << item.updateSequenceNum.ref() << QStringLiteral(": ") << item); + QNTRACE("Checking item with USN " << item.updateSequenceNum.ref() + << ": " << item); if ((smallestUsn < 0) || (item.updateSequenceNum.ref() < smallestUsn)) { smallestUsn = item.updateSequenceNum.ref(); - QNTRACE(QStringLiteral("Updated smallest non-processed items USN to ") - << smallestUsn); + QNTRACE("Updated smallest non-processed items USN to " << smallestUsn); } } @@ -9627,8 +9605,8 @@ qint32 RemoteToLocalSynchronizationManager::findSmallestUsnOfNonSyncedItems( const QString & linkedNotebookGuid) const { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("findSmallestUsnOfNonSyncedItems: linked notebook guid = ") + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "findSmallestUsnOfNonSyncedItems: linked notebook guid = " << linkedNotebookGuid); qint32 smallestUsn = -1; @@ -9663,14 +9641,16 @@ if (syncingNotebooks || syncingTags) { - QNTRACE(QStringLiteral("The sync of notes hasn't started yet, checking " - "notes from sync chunks")); + QNTRACE("The sync of notes hasn't started yet, checking " + "notes from sync chunks"); - const QVector<qevercloud::SyncChunk> & syncChunks = (linkedNotebookGuid.isEmpty() - ? m_syncChunks - : m_linkedNotebookSyncChunks); + const QVector<qevercloud::SyncChunk> & syncChunks = + (linkedNotebookGuid.isEmpty() + ? m_syncChunks + : m_linkedNotebookSyncChunks); - for(auto it = syncChunks.constBegin(), end = syncChunks.constEnd(); it != end; ++it) + for(auto it = syncChunks.constBegin(), + end = syncChunks.constEnd(); it != end; ++it) { const qevercloud::SyncChunk & syncChunk = *it; if (!syncChunk.notes.isSet()) { @@ -9684,101 +9664,102 @@ } else { - QNTRACE(QStringLiteral("The sync of notes has already started, " - "checking notes from pending lists")); + QNTRACE("The sync of notes has already started, " + "checking notes from pending lists"); - QNTRACE(QStringLiteral("Collecting from m_notes, smallest USN before: ") - << smallestUsn); + QNTRACE("Collecting from m_notes, smallest USN before: " << smallestUsn); checkNonSyncedItemsContainerForSmallestUsn(m_notes, linkedNotebookGuid, smallestUsn); - QNTRACE(QStringLiteral("Collected from m_notes, smallest USN after: ") + QNTRACE("Collected from m_notes, smallest USN after: " << smallestUsn); - QNTRACE(QStringLiteral("Collecting from m_notesPendingAddOrUpdate, " - "smallest USN before: ") << smallestUsn); + QNTRACE("Collecting from m_notesPendingAddOrUpdate, " + << "smallest USN before: " << smallestUsn); checkNonSyncedItemsContainerForSmallestUsn(m_notesPendingAddOrUpdate, linkedNotebookGuid, smallestUsn); - QNTRACE(QStringLiteral("Collected from m_notesPendingAddOrUpdate, " - "smallest USN after: ") << smallestUsn); - - QNTRACE(QStringLiteral("Collecting from m_notesToAddPerAPICallPostponeTimerId, " - "smallest USN before: ") << smallestUsn); - checkNonSyncedItemsContainerForSmallestUsn(m_notesToAddPerAPICallPostponeTimerId, - linkedNotebookGuid, - smallestUsn); - QNTRACE(QStringLiteral("Collected from m_notesToAddPerAPICallPostponeTimerId, " - "smallest USN after: ") << smallestUsn); + QNTRACE("Collected from m_notesPendingAddOrUpdate, " + << "smallest USN after: " << smallestUsn); - QNTRACE(QStringLiteral("Collecting from m_notesToUpdatePerAPICallPostponeTimerId, " - "smallest USN before: ") << smallestUsn); - checkNonSyncedItemsContainerForSmallestUsn(m_notesToUpdatePerAPICallPostponeTimerId, - linkedNotebookGuid, - smallestUsn); - QNTRACE(QStringLiteral("Collected from m_notesToUpdatePerAPICallPostponeTimerId, " - "smallest USN after: ") << smallestUsn); + QNTRACE("Collecting from m_notesToAddPerAPICallPostponeTimerId, " + << "smallest USN before: " << smallestUsn); + checkNonSyncedItemsContainerForSmallestUsn( + m_notesToAddPerAPICallPostponeTimerId, + linkedNotebookGuid, smallestUsn); + QNTRACE("Collected from m_notesToAddPerAPICallPostponeTimerId, " + << "smallest USN after: " << smallestUsn); + + QNTRACE("Collecting from m_notesToUpdatePerAPICallPostponeTimerId, " + << "smallest USN before: " << smallestUsn); + checkNonSyncedItemsContainerForSmallestUsn( + m_notesToUpdatePerAPICallPostponeTimerId, + linkedNotebookGuid, smallestUsn); + QNTRACE("Collected from m_notesToUpdatePerAPICallPostponeTimerId, " + << "smallest USN after: " << smallestUsn); // Also need to check for notes which are currently pending download // for adding to local storage or for updating within the local storage - QNTRACE(QStringLiteral("Collecting from m_notesPendingDownloadForAddingToLocalStorage, " - "smallest USN before: ") << smallestUsn); - checkNonSyncedItemsContainerForSmallestUsn(m_notesPendingDownloadForAddingToLocalStorage, - linkedNotebookGuid, - smallestUsn); - QNTRACE(QStringLiteral("Collected from m_notesPendingDownloadForAddingToLocalStorage, " - "smallest USN after: ") << smallestUsn); - - QNTRACE(QStringLiteral("Collecting from m_notesPendingDownloadForUpdatingInLocalStorageByGuid, " - "smallest USN before: ") << smallestUsn); - checkNonSyncedItemsContainerForSmallestUsn(m_notesPendingDownloadForUpdatingInLocalStorageByGuid, - linkedNotebookGuid, - smallestUsn); - QNTRACE(QStringLiteral("Collected from m_notesPendingDownloadForUpdatingInLocalStorageByGuid, " - "smallest USN after: ") << smallestUsn); + QNTRACE("Collecting from m_notesPendingDownloadForAddingToLocalStorage, " + << "smallest USN before: " << smallestUsn); + checkNonSyncedItemsContainerForSmallestUsn( + m_notesPendingDownloadForAddingToLocalStorage, + linkedNotebookGuid, smallestUsn); + QNTRACE("Collected from m_notesPendingDownloadForAddingToLocalStorage, " + << "smallest USN after: " << smallestUsn); + + QNTRACE("Collecting from m_notesPendingDownloadForUpdatingInLocalStorageByGuid, " + << "smallest USN before: " << smallestUsn); + checkNonSyncedItemsContainerForSmallestUsn( + m_notesPendingDownloadForUpdatingInLocalStorageByGuid, + linkedNotebookGuid, smallestUsn); + QNTRACE("Collected from m_notesPendingDownloadForUpdatingInLocalStorageByGuid, " + << "smallest USN after: " << smallestUsn); // Also need to check for notes which might be pending the download of // ink note image or thumbnail (these downloads should not cause API limit // breach since they are not fully a part of Evernote API but just to be // on the safe side) - QNTRACE(QStringLiteral("Collecting from m_notesPendingInkNoteImagesDownloadByFindNotebookRequestId, " - "smallest USN before: ") << smallestUsn); - checkNonSyncedItemsContainerForSmallestUsn(m_notesPendingInkNoteImagesDownloadByFindNotebookRequestId, - linkedNotebookGuid, - smallestUsn); - QNTRACE(QStringLiteral("Collected from m_notesPendingInkNoteImagesDownloadByFindNotebookRequestId, " - "smallest USN after: ") << smallestUsn); + QNTRACE("Collecting from m_notesPendingInkNoteImagesDownloadByFindNotebookRequestId, " + << "smallest USN before: " << smallestUsn); + checkNonSyncedItemsContainerForSmallestUsn( + m_notesPendingInkNoteImagesDownloadByFindNotebookRequestId, + linkedNotebookGuid, smallestUsn); + QNTRACE("Collected from m_notesPendingInkNoteImagesDownloadByFindNotebookRequestId, " + "smallest USN after: " << smallestUsn); + + QNTRACE("Collecting from m_notesPendingThumbnailDownloadByFindNotebookRequestId, " + << "smallest USN before: " << smallestUsn); + checkNonSyncedItemsContainerForSmallestUsn( + m_notesPendingThumbnailDownloadByFindNotebookRequestId, + linkedNotebookGuid, smallestUsn); + QNTRACE("Collected from m_notesPendingThumbnailDownloadByFindNotebookRequestId, " + << "smallest USN before: " << smallestUsn); + + QNTRACE("Collecting from m_notesPendingThumbnailDownloadByGuid, " + << "smallest USN before: " << smallestUsn); + checkNonSyncedItemsContainerForSmallestUsn( + m_notesPendingThumbnailDownloadByGuid, + linkedNotebookGuid, smallestUsn); + QNTRACE("Collected from m_notesPendingThumbnailDownloadByGuid, " + << "smallest USN after: " << smallestUsn); - QNTRACE(QStringLiteral("Collecting from m_notesPendingThumbnailDownloadByFindNotebookRequestId, " - "smallest USN before: ") << smallestUsn); - checkNonSyncedItemsContainerForSmallestUsn(m_notesPendingThumbnailDownloadByFindNotebookRequestId, - linkedNotebookGuid, - smallestUsn); - QNTRACE(QStringLiteral("Collected from m_notesPendingThumbnailDownloadByFindNotebookRequestId, " - "smallest USN before: ") << smallestUsn); - - QNTRACE(QStringLiteral("Collecting from m_notesPendingThumbnailDownloadByGuid, " - "smallest USN before: ") << smallestUsn); - checkNonSyncedItemsContainerForSmallestUsn(m_notesPendingThumbnailDownloadByGuid, - linkedNotebookGuid, - smallestUsn); - QNTRACE(QStringLiteral("Collected from m_notesPendingThumbnailDownloadByGuid, " - "smallest USN after: ") << smallestUsn); - - QNTRACE(QStringLiteral("Overall smallest USN after collecting it from notes: ") + QNTRACE("Overall smallest USN after collecting it from notes: " << smallestUsn); } if (syncingNotebooks || syncingTags || notesSyncInProgress()) { - QNTRACE(QStringLiteral("The sync of resources hasn't started yet, " - "checking resources from sync chunks")); + QNTRACE("The sync of resources hasn't started yet, " + "checking resources from sync chunks"); - const QVector<qevercloud::SyncChunk> & syncChunks = (linkedNotebookGuid.isEmpty() - ? m_syncChunks - : m_linkedNotebookSyncChunks); + const QVector<qevercloud::SyncChunk> & syncChunks = + (linkedNotebookGuid.isEmpty() + ? m_syncChunks + : m_linkedNotebookSyncChunks); - for(auto it = syncChunks.constBegin(), end = syncChunks.constEnd(); it != end; ++it) + for(auto it = syncChunks.constBegin(), + end = syncChunks.constEnd(); it != end; ++it) { const qevercloud::SyncChunk & syncChunk = *it; if (!syncChunk.resources.isSet()) { @@ -9792,31 +9773,33 @@ } else { - QNTRACE(QStringLiteral("The sync of resources has already started, " - "checking resources from pending lists")); + QNTRACE("The sync of resources has already started, " + "checking resources from pending lists"); - checkNonSyncedItemsContainerForSmallestUsn(m_resources, - linkedNotebookGuid, - smallestUsn); - checkNonSyncedItemsContainerForSmallestUsn(m_resourcesPendingAddOrUpdate, - linkedNotebookGuid, - smallestUsn); - checkNonSyncedItemsContainerForSmallestUsn(m_resourcesToAddWithNotesPerAPICallPostponeTimerId, - linkedNotebookGuid, - smallestUsn); - checkNonSyncedItemsContainerForSmallestUsn(m_resourcesToUpdateWithNotesPerAPICallPostponeTimerId, - linkedNotebookGuid, - smallestUsn); + checkNonSyncedItemsContainerForSmallestUsn( + m_resources, linkedNotebookGuid, smallestUsn); + + checkNonSyncedItemsContainerForSmallestUsn( + m_resourcesPendingAddOrUpdate, linkedNotebookGuid, smallestUsn); + + checkNonSyncedItemsContainerForSmallestUsn( + m_resourcesToAddWithNotesPerAPICallPostponeTimerId, + linkedNotebookGuid, smallestUsn); + + checkNonSyncedItemsContainerForSmallestUsn( + m_resourcesToUpdateWithNotesPerAPICallPostponeTimerId, + linkedNotebookGuid, smallestUsn); } - QNTRACE(QStringLiteral("Overall smallest USN: ") << smallestUsn); + QNTRACE("Overall smallest USN: " << smallestUsn); return smallestUsn; } -void RemoteToLocalSynchronizationManager::registerTagPendingAddOrUpdate(const Tag & tag) +void RemoteToLocalSynchronizationManager::registerTagPendingAddOrUpdate( + const Tag & tag) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("registerTagPendingAddOrUpdate: ") << tag); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "registerTagPendingAddOrUpdate: " << tag); if (!tag.hasGuid()) { return; @@ -9833,8 +9816,8 @@ void RemoteToLocalSynchronizationManager::registerSavedSearchPendingAddOrUpdate( const SavedSearch & search) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "registerSavedSearchPendingAddOrUpdate: ") << search); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "registerSavedSearchPendingAddOrUpdate: " << search); if (!search.hasGuid()) { return; @@ -9852,9 +9835,8 @@ void RemoteToLocalSynchronizationManager::registerLinkedNotebookPendingAddOrUpdate( const LinkedNotebook & linkedNotebook) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("registerLinkedNotebookPendingAddOrUpdate: ") - << linkedNotebook); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "registerLinkedNotebookPendingAddOrUpdate: " << linkedNotebook); if (!linkedNotebook.hasGuid()) { return; @@ -9872,8 +9854,8 @@ void RemoteToLocalSynchronizationManager::registerNotebookPendingAddOrUpdate( const Notebook & notebook) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "registerNotebookPendingAddOrUpdate: ") << notebook); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "registerNotebookPendingAddOrUpdate: " << notebook); if (!notebook.hasGuid()) { return; @@ -9888,10 +9870,11 @@ } } -void RemoteToLocalSynchronizationManager::registerNotePendingAddOrUpdate(const Note & note) +void RemoteToLocalSynchronizationManager::registerNotePendingAddOrUpdate( + const Note & note) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "registerNotePendingAddOrUpdate: ") << note); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "registerNotePendingAddOrUpdate: " << note); if (!note.hasGuid()) { return; @@ -9908,8 +9891,8 @@ void RemoteToLocalSynchronizationManager::registerResourcePendingAddOrUpdate( const Resource & resource) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "registerResourcePendingAddOrUpdate: ") << resource); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "registerResourcePendingAddOrUpdate: " << resource); if (!resource.hasGuid()) { return; @@ -9917,7 +9900,8 @@ auto it = std::find_if(m_resourcesPendingAddOrUpdate.begin(), m_resourcesPendingAddOrUpdate.end(), - CompareItemByGuid<ResourcesList::value_type>(resource.guid())); + CompareItemByGuid<ResourcesList::value_type>( + resource.guid())); if (it == m_resourcesPendingAddOrUpdate.end()) { m_resourcesPendingAddOrUpdate << resource.qevercloudResource(); } @@ -9926,8 +9910,8 @@ void RemoteToLocalSynchronizationManager::unregisterTagPendingAddOrUpdate( const Tag & tag) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "unregisterTagPendingAddOrUpdate: ") << tag); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "unregisterTagPendingAddOrUpdate: " << tag); if (!tag.hasGuid()) { return; @@ -9944,8 +9928,8 @@ void RemoteToLocalSynchronizationManager::unregisterSavedSearchPendingAddOrUpdate( const SavedSearch & search) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "unregisterSavedSearchPendingAddOrUpdate: ") << search); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "unregisterSavedSearchPendingAddOrUpdate: " << search); if (!search.hasGuid()) { return; @@ -9963,9 +9947,8 @@ void RemoteToLocalSynchronizationManager::unregisterLinkedNotebookPendingAddOrUpdate( const LinkedNotebook & linkedNotebook) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("unregisterLinkedNotebookPendingAddOrUpdate: ") - << linkedNotebook); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "unregisterLinkedNotebookPendingAddOrUpdate: " << linkedNotebook); if (!linkedNotebook.hasGuid()) { return; @@ -9983,8 +9966,8 @@ void RemoteToLocalSynchronizationManager::unregisterNotebookPendingAddOrUpdate( const Notebook & notebook) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "unregisterNotebookPendingAddOrUpdate: ") << notebook); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "unregisterNotebookPendingAddOrUpdate: " << notebook); if (!notebook.hasGuid()) { return; @@ -9992,7 +9975,8 @@ auto it = std::find_if(m_notebooksPendingAddOrUpdate.begin(), m_notebooksPendingAddOrUpdate.end(), - CompareItemByGuid<NotebooksList::value_type>(notebook.guid())); + CompareItemByGuid<NotebooksList::value_type>( + notebook.guid())); if (it != m_notebooksPendingAddOrUpdate.end()) { Q_UNUSED(m_notebooksPendingAddOrUpdate.erase(it)) } @@ -10001,8 +9985,8 @@ void RemoteToLocalSynchronizationManager::unregisterNotePendingAddOrUpdate( const Note & note) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "unregisterNotePendingAddOrUpdate: ") << note); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "unregisterNotePendingAddOrUpdate: " << note); if (!note.hasGuid()) { return; @@ -10019,8 +10003,8 @@ void RemoteToLocalSynchronizationManager::unregisterNotePendingAddOrUpdate( const qevercloud::Note & note) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "unregisterNotePendingAddOrUpdate: ") << note); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "unregisterNotePendingAddOrUpdate: " << note); if (!note.guid.isSet()) { return; @@ -10028,7 +10012,8 @@ auto it = std::find_if(m_notesPendingAddOrUpdate.begin(), m_notesPendingAddOrUpdate.end(), - CompareItemByGuid<NotesList::value_type>(note.guid.ref())); + CompareItemByGuid<NotesList::value_type>( + note.guid.ref())); if (it != m_notesPendingAddOrUpdate.end()) { Q_UNUSED(m_notesPendingAddOrUpdate.erase(it)) } @@ -10037,8 +10022,8 @@ void RemoteToLocalSynchronizationManager::unregisterResourcePendingAddOrUpdate( const Resource & resource) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "unregisterResourcePendingAddOrUpdate: ") << resource); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "unregisterResourcePendingAddOrUpdate: " << resource); if (!resource.hasGuid()) { return; @@ -10046,7 +10031,8 @@ auto it = std::find_if(m_resourcesPendingAddOrUpdate.begin(), m_resourcesPendingAddOrUpdate.end(), - CompareItemByGuid<ResourcesList::value_type>(resource.guid())); + CompareItemByGuid<ResourcesList::value_type>( + resource.guid())); if (it != m_resourcesPendingAddOrUpdate.end()) { Q_UNUSED(m_resourcesPendingAddOrUpdate.erase(it)) } @@ -10055,9 +10041,9 @@ void RemoteToLocalSynchronizationManager::overrideLocalNoteWithRemoteNote( Note & localNote, const qevercloud::Note & remoteNote) const { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("overrideLocalNoteWithRemoteNote: local note = ") - << localNote << QStringLiteral("\nRemote note: ") << remoteNote); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "overrideLocalNoteWithRemoteNote: local note = " + << localNote << "\nRemote note: " << remoteNote); // Need to clear out the tag local uids from the local note so that // the local storage uses tag guids list from the remote note instead @@ -10122,7 +10108,7 @@ { const qevercloud::Resource & updatedResource = *uit; if (Q_UNLIKELY(!updatedResource.guid.isSet())) { - QNWARNING(QStringLiteral("Skipping resource from remote note without guid: ") + QNWARNING("Skipping resource from remote note without guid: " << updatedResource); continue; } @@ -10153,7 +10139,7 @@ } localNote.setResources(amendedResources); - QNTRACE(QStringLiteral("Local note after overriding: ") << localNote); + QNTRACE("Local note after overriding: " << localNote); } void RemoteToLocalSynchronizationManager::processResourceConflictAsNoteConflict( @@ -10186,8 +10172,9 @@ { if (Q_UNLIKELY(rateLimitSeconds < 0)) { - errorDescription.setBase(QT_TR_NOOP("Rate limit reached but the number " - "of seconds to wait is incorrect")); + errorDescription.setBase( + QT_TR_NOOP("Rate limit reached but the number " + "of seconds to wait is incorrect")); errorDescription.details() = QString::number(rateLimitSeconds); Q_EMIT failure(errorDescription); return; @@ -10196,9 +10183,10 @@ int timerId = startTimer(SEC_TO_MSEC(rateLimitSeconds)); if (Q_UNLIKELY(timerId == 0)) { - errorDescription.setBase(QT_TR_NOOP("Failed to start a timer to postpone " - "the Evernote API call due to rate " - "limit exceeding")); + errorDescription.setBase( + QT_TR_NOOP("Failed to start a timer to postpone " + "the Evernote API call due to rate " + "limit exceeding")); Q_EMIT failure(errorDescription); return; } @@ -10207,7 +10195,8 @@ data.m_remoteNote = remoteNote; data.m_localConflictingNote = localConflictingNote; data.m_remoteNoteResourceWithoutFullData = remoteNoteResource; - m_postponedConflictingResourceDataPerAPICallPostponeTimerId[timerId] = data; + m_postponedConflictingResourceDataPerAPICallPostponeTimerId[timerId] = + data; Q_EMIT rateLimitExceeded(rateLimitSeconds); return; @@ -10219,7 +10208,8 @@ } else if (errorCode != 0) { - ErrorString errorMessage(QT_TR_NOOP("Failed to download full resource data")); + ErrorString errorMessage( + QT_TR_NOOP("Failed to download full resource data")); errorMessage.additionalBases().append(errorDescription.base()); errorMessage.additionalBases().append(errorDescription.additionalBases()); errorMessage.details() = errorDescription.details(); @@ -10265,9 +10255,9 @@ LocalStorageManager::UpdateNoteOption::UpdateResourceMetadata | LocalStorageManager::UpdateNoteOption::UpdateResourceBinaryData | LocalStorageManager::UpdateNoteOption::UpdateTags); - QNTRACE(QStringLiteral("Emitting the request to update the remote note ") - << QStringLiteral("in the local storage: request id = ") - << updateNoteRequestId << QStringLiteral(", note; ") << remoteNote); + QNTRACE("Emitting the request to update the remote note " + << "in the local storage: request id = " + << updateNoteRequestId << ", note; " << remoteNote); Q_EMIT updateNote(remoteNote, options, updateNoteRequestId); // Add local conflicting note @@ -10276,11 +10266,11 @@ void RemoteToLocalSynchronizationManager::syncNextTagPendingProcessing() { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "syncNextTagPendingProcessing")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "syncNextTagPendingProcessing"); if (m_tagsPendingProcessing.isEmpty()) { - QNDEBUG(QStringLiteral("No tags pending for processing, nothing more to sync")); + QNDEBUG("No tags pending for processing, nothing more to sync"); return; } @@ -10291,8 +10281,8 @@ void RemoteToLocalSynchronizationManager::removeNoteResourcesFromSyncChunks( const Note & note) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("removeNoteResourcesFromSyncChunks: note guid = ") + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "removeNoteResourcesFromSyncChunks: note guid = " << (note.hasGuid() ? note.guid() : QStringLiteral("<not set>")) << ", local uid = " << note.localUid()); @@ -10316,8 +10306,8 @@ const Resource & resource, QVector<qevercloud::SyncChunk> & syncChunks) { if (Q_UNLIKELY(!resource.hasGuid())) { - QNWARNING(QStringLiteral("Can't remove resource from sync chunks ") - << QStringLiteral("as it has no guid: ") << resource); + QNWARNING("Can't remove resource from sync chunks " + << "as it has no guid: " << resource); return; } @@ -10333,9 +10323,9 @@ { if (rit->guid.isSet() && (rit->guid.ref() == resource.guid())) { Q_UNUSED(syncChunk.resources->erase(rit)) - QNDEBUG(QStringLiteral("Note: removed resource from sync chunk " - "because it was downloaded along with " - "the note containing it: ") << resource); + QNDEBUG("Note: removed resource from sync chunk " + << "because it was downloaded along with " + << "the note containing it: " << resource); break; } } @@ -10345,8 +10335,8 @@ void RemoteToLocalSynchronizationManager::junkFullSyncStaleDataItemsExpunger( FullSyncStaleDataItemsExpunger & expunger) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("junkFullSyncStaleDataItemsExpunger: linked notebook guid = ") + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "junkFullSyncStaleDataItemsExpunger: linked notebook guid = " << expunger.linkedNotebookGuid()); QObject::disconnect(&expunger, @@ -10368,19 +10358,23 @@ { authToken.resize(0); - if (!note.hasGuid()) { - errorDescription.setBase(QT_TR_NOOP("Detected the attempt to get full " - "note's data for a note without guid")); + if (!note.hasGuid()) + { + errorDescription.setBase( + QT_TR_NOOP("Detected the attempt to get full " + "note's data for a note without guid")); APPEND_NOTE_DETAILS(errorDescription, note) - QNWARNING(errorDescription << QStringLiteral(": ") << note); + QNWARNING(errorDescription << ": " << note); return Q_NULLPTR; } - if (!note.hasNotebookGuid()) { - errorDescription.setBase(QT_TR_NOOP("Detected the attempt to get full note's " - "data for a note without notebook guid")); + if (!note.hasNotebookGuid()) + { + errorDescription.setBase( + QT_TR_NOOP("Detected the attempt to get full note's " + "data for a note without notebook guid")); APPEND_NOTE_DETAILS(errorDescription, note) - QNWARNING(errorDescription << QStringLiteral(": ") << note); + QNWARNING(errorDescription << ": " << note); return Q_NULLPTR; } @@ -10392,9 +10386,9 @@ m_linkedNotebookGuidsByNotebookGuids.find(note.notebookGuid()); if (linkedNotebookGuidIt == m_linkedNotebookGuidsByNotebookGuids.end()) { - QNDEBUG(QStringLiteral("Found no linked notebook corresponding to notebook guid ") + QNDEBUG("Found no linked notebook corresponding to notebook guid " << note.notebookGuid() - << QStringLiteral(", using the note store for the user's own account")); + << ", using the note store for the user's own account"); pNoteStore = &(m_manager.noteStore()); authToken = m_authenticationToken; return pNoteStore; @@ -10403,13 +10397,15 @@ const QString & linkedNotebookGuid = linkedNotebookGuidIt.value(); auto authTokenIt = - m_authenticationTokensAndShardIdsByLinkedNotebookGuid.find(linkedNotebookGuid); - if (Q_UNLIKELY(authTokenIt == m_authenticationTokensAndShardIdsByLinkedNotebookGuid.end())) + m_authenticationTokensAndShardIdsByLinkedNotebookGuid.find( + linkedNotebookGuid); + if (Q_UNLIKELY(authTokenIt == + m_authenticationTokensAndShardIdsByLinkedNotebookGuid.end())) { errorDescription.setBase(QT_TR_NOOP("Can't find the authentication token " "corresponding to the linked notebook")); APPEND_NOTE_DETAILS(errorDescription, note) - QNWARNING(errorDescription << QStringLiteral(": ") << note); + QNWARNING(errorDescription << ": " << note); return Q_NULLPTR; } @@ -10432,7 +10428,7 @@ errorDescription.setBase(QT_TR_NOOP("Can't find the note store URL " "corresponding to the linked notebook")); APPEND_NOTE_DETAILS(errorDescription, note) - QNWARNING(errorDescription << QStringLiteral(": ") << note); + QNWARNING(errorDescription << ": " << note); return Q_NULLPTR; } @@ -10444,15 +10440,17 @@ if (Q_UNLIKELY(!pNoteStore)) { errorDescription.setBase(QT_TR_NOOP("Can't find or create note store for ")); APPEND_NOTE_DETAILS(errorDescription, note) - QNWARNING(errorDescription << QStringLiteral(": ") << note); + QNWARNING(errorDescription << ": " << note); return Q_NULLPTR; } - if (Q_UNLIKELY(pNoteStore->noteStoreUrl().isEmpty())) { - errorDescription.setBase(QT_TR_NOOP("Internal error: empty note store url " - "for the linked notebook's note store")); + if (Q_UNLIKELY(pNoteStore->noteStoreUrl().isEmpty())) + { + errorDescription.setBase( + QT_TR_NOOP("Internal error: empty note store url " + "for the linked notebook's note store")); APPEND_NOTE_DETAILS(errorDescription, note) - QNWARNING(errorDescription << QStringLiteral(": ") << note); + QNWARNING(errorDescription << ": " << note); return Q_NULLPTR; } @@ -10466,8 +10464,8 @@ Qt::ConnectionType(Qt::UniqueConnection | Qt::QueuedConnection)); - QNDEBUG(QStringLiteral("Using INoteStore corresponding to linked notebook with guid ") - << linkedNotebookGuid << QStringLiteral(", note store url = ") + QNDEBUG("Using INoteStore corresponding to linked notebook with guid " + << linkedNotebookGuid << ", note store url = " << pNoteStore->noteStoreUrl()); return pNoteStore; } @@ -10475,9 +10473,9 @@ void RemoteToLocalSynchronizationManager::checkAndRemoveInaccessibleParentTagGuidsForTagsFromLinkedNotebook( const QString & linkedNotebookGuid, const TagSyncCache & tagSyncCache) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("checkAndRemoveInaccessibleParentTagGuidsForTagsFromLinkedNotebook: ") - << QStringLiteral("linked notebook guid = ") << linkedNotebookGuid); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "checkAndRemoveInaccessibleParentTagGuidsForTagsFromLinkedNotebook: " + << "linked notebook guid = " << linkedNotebookGuid); const QHash<QString, QString> & nameByGuidHash = tagSyncCache.nameByGuidHash(); @@ -10507,10 +10505,9 @@ continue; } - QNDEBUG(QStringLiteral("Tag with guid ") << tag.parentGuid.ref() - << QStringLiteral(" was not found within the tag sync cache, ") - << QStringLiteral("removing it as parent guid from tag: ") - << tag); + QNDEBUG("Tag with guid " << tag.parentGuid.ref() + << " was not found within the tag sync cache, " + << "removing it as parent guid from tag: " << tag); qevercloud::Tag tagCopy(tag); tagCopy.parentGuid.clear(); @@ -10521,8 +10518,8 @@ void RemoteToLocalSynchronizationManager::startFeedingDownloadedTagsToLocalStorageOneByOne( const TagsContainer & container) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "startFeedingDownloadedTagsToLocalStorageOneByOne")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "startFeedingDownloadedTagsToLocalStorageOneByOne"); m_tagsPendingProcessing.reserve(static_cast<int>(container.size())); const auto & tagIndexByGuid = container.get<ByGuid>(); @@ -10552,13 +10549,13 @@ switch(obj) { case RemoteToLocalSynchronizationManager::SyncMode::FullSync: - strm << QStringLiteral("FullSync"); + strm << "FullSync"; break; case RemoteToLocalSynchronizationManager::SyncMode::IncrementalSync: - strm << QStringLiteral("IncrementalSync"); + strm << "IncrementalSync"; break; default: - strm << QStringLiteral("<unknown>"); + strm << "<unknown>"; break; } @@ -10569,13 +10566,13 @@ void RemoteToLocalSynchronizationManager::appendDataElementsFromSyncChunkToContainer <TagsContainer>(const qevercloud::SyncChunk & syncChunk, TagsContainer & container) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "appendDataElementsFromSyncChunkToContainer: tags")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "appendDataElementsFromSyncChunkToContainer: tags"); if (syncChunk.tags.isSet()) { const auto & tags = syncChunk.tags.ref(); - QNDEBUG(QStringLiteral("Appending ") << tags.size() << QStringLiteral(" tags")); + QNDEBUG("Appending " << tags.size() << " tags"); for(auto it = tags.constBegin(), end = tags.constEnd(); it != end; ++it) { container.insert(*it); } @@ -10596,8 +10593,7 @@ if (syncChunk.expungedTags.isSet()) { const auto & expungedTags = syncChunk.expungedTags.ref(); - QNDEBUG(QStringLiteral("Processing ") << expungedTags.size() - << QStringLiteral(" expunged tags")); + QNDEBUG("Processing " << expungedTags.size() << " expunged tags"); auto & tagIndexByGuid = container.get<ByGuid>(); @@ -10629,19 +10625,20 @@ const qevercloud::SyncChunk & syncChunk, RemoteToLocalSynchronizationManager::SavedSearchesList & container) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "appendDataElementsFromSyncChunkToContainer: saved searches")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "appendDataElementsFromSyncChunkToContainer: saved searches"); if (syncChunk.searches.isSet()) { const auto & savedSearches = syncChunk.searches.ref(); - QNDEBUG(QStringLiteral("Appending ") << savedSearches.size() - << QStringLiteral(" saved searches")); + QNDEBUG("Appending " << savedSearches.size() << " saved searches"); container.append(savedSearches); - for(auto it = m_expungedSavedSearches.begin(); it != m_expungedSavedSearches.end(); ) + for(auto it = m_expungedSavedSearches.begin(); + it != m_expungedSavedSearches.end(); ) { - auto searchIt = std::find_if(savedSearches.constBegin(), savedSearches.constEnd(), + auto searchIt = std::find_if(savedSearches.constBegin(), + savedSearches.constEnd(), CompareItemByGuid<qevercloud::SavedSearch>(*it)); if (searchIt == savedSearches.constEnd()) { ++it; @@ -10655,8 +10652,8 @@ if (syncChunk.expungedSearches.isSet()) { const auto & expungedSearches = syncChunk.expungedSearches.ref(); - QNDEBUG(QStringLiteral("Processing ") << expungedSearches.size() - << QStringLiteral(" expunged saved searches")); + QNDEBUG("Processing " << expungedSearches.size() + << " expunged saved searches"); const auto expungedSearchesEnd = expungedSearches.end(); for(auto eit = expungedSearches.begin(); eit != expungedSearchesEnd; ++eit) @@ -10677,15 +10674,15 @@ const qevercloud::SyncChunk & syncChunk, RemoteToLocalSynchronizationManager::LinkedNotebooksList & container) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("appendDataElementsFromSyncChunkToContainer: ") - << QStringLiteral("linked notebooks")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "appendDataElementsFromSyncChunkToContainer: " + << "linked notebooks"); if (syncChunk.linkedNotebooks.isSet()) { const auto & linkedNotebooks = syncChunk.linkedNotebooks.ref(); - QNDEBUG(QStringLiteral("Appending ") << linkedNotebooks.size() - << QStringLiteral(" linked notebooks")); + QNDEBUG("Appending " << linkedNotebooks.size() + << " linked notebooks"); container.append(linkedNotebooks); for(auto it = m_expungedLinkedNotebooks.begin(); @@ -10706,8 +10703,8 @@ if (syncChunk.expungedLinkedNotebooks.isSet()) { const auto & expungedLinkedNotebooks = syncChunk.expungedLinkedNotebooks.ref(); - QNDEBUG(QStringLiteral("Processing ") << expungedLinkedNotebooks.size() - << QStringLiteral(" expunged linked notebooks")); + QNDEBUG("Processing " << expungedLinkedNotebooks.size() + << " expunged linked notebooks"); const auto expungedLinkedNotebooksEnd = expungedLinkedNotebooks.end(); for(auto eit = expungedLinkedNotebooks.begin(); @@ -10729,19 +10726,19 @@ const qevercloud::SyncChunk & syncChunk, RemoteToLocalSynchronizationManager::NotebooksList & container) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "appendDataElementsFromSyncChunkToContainer: notebooks")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "appendDataElementsFromSyncChunkToContainer: notebooks"); if (syncChunk.notebooks.isSet()) { const auto & notebooks = syncChunk.notebooks.ref(); - QNDEBUG(QStringLiteral("Appending ") << notebooks.size() - << QStringLiteral(" notebooks")); + QNDEBUG("Appending " << notebooks.size() << " notebooks"); container.append(notebooks); for(auto it = m_expungedNotebooks.begin(); it != m_expungedNotebooks.end(); ) { - auto notebookIt = std::find_if(notebooks.constBegin(), notebooks.constEnd(), + auto notebookIt = std::find_if(notebooks.constBegin(), + notebooks.constEnd(), CompareItemByGuid<qevercloud::Notebook>(*it)); if (notebookIt == notebooks.constEnd()) { ++it; @@ -10755,8 +10752,8 @@ if (syncChunk.expungedNotebooks.isSet()) { const auto & expungedNotebooks = syncChunk.expungedNotebooks.ref(); - QNDEBUG(QStringLiteral("Processing ") << expungedNotebooks.size() - << QStringLiteral(" expunged notebooks")); + QNDEBUG("Processing " << expungedNotebooks.size() + << " expunged notebooks"); const auto expungedNotebooksEnd = expungedNotebooks.end(); for(auto eit = expungedNotebooks.begin(); eit != expungedNotebooksEnd; ++eit) @@ -10777,14 +10774,13 @@ const qevercloud::SyncChunk & syncChunk, RemoteToLocalSynchronizationManager::NotesList & container) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "appendDataElementsFromSyncChunkToContainer: notes")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "appendDataElementsFromSyncChunkToContainer: notes"); if (syncChunk.notes.isSet()) { const auto & syncChunkNotes = syncChunk.notes.ref(); - QNDEBUG(QStringLiteral("Appending ") << syncChunkNotes.size() - << QStringLiteral(" notes")); + QNDEBUG("Appending " << syncChunkNotes.size() << " notes"); container.append(syncChunkNotes); for(auto it = m_expungedNotes.begin(); it != m_expungedNotes.end(); ) @@ -10804,8 +10800,7 @@ if (syncChunk.expungedNotes.isSet()) { const auto & expungedNotes = syncChunk.expungedNotes.ref(); - QNDEBUG(QStringLiteral("Processing ") << expungedNotes.size() - << QStringLiteral(" expunged notes")); + QNDEBUG("Processing " << expungedNotes.size() << " expunged notes"); const auto expungedNotesEnd = expungedNotes.end(); for(auto eit = expungedNotes.begin(); eit != expungedNotesEnd; ++eit) @@ -10822,11 +10817,12 @@ if (syncChunk.expungedNotebooks.isSet()) { const auto & expungedNotebooks = syncChunk.expungedNotebooks.ref(); - QNDEBUG(QStringLiteral("Processing ") << expungedNotebooks.size() - << QStringLiteral(" expunged notebooks")); + QNDEBUG("Processing " << expungedNotebooks.size() + << " expunged notebooks"); const auto expungedNotebooksEnd = expungedNotebooks.end(); - for(auto eit = expungedNotebooks.begin(); eit != expungedNotebooksEnd; ++eit) + for(auto eit = expungedNotebooks.begin(); + eit != expungedNotebooksEnd; ++eit) { const QString & expungedNotebookGuid = *eit; @@ -10853,16 +10849,15 @@ const qevercloud::SyncChunk & syncChunk, RemoteToLocalSynchronizationManager::ResourcesList & container) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "appendDataElementsFromSyncChunkToContainer: resources")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "appendDataElementsFromSyncChunkToContainer: resources"); if (!syncChunk.resources.isSet()) { return; } const QList<qevercloud::Resource> & resources = syncChunk.resources.ref(); - QNDEBUG(QStringLiteral("Appending ") << resources.size() - << QStringLiteral(" resources")); + QNDEBUG("Appending " << resources.size() << " resources"); // Need to filter out those resources which belong to the notes which will // be downloaded along with their whole content, resources included or to @@ -10875,19 +10870,18 @@ { const qevercloud::Resource & resource = *it; if (Q_UNLIKELY(!resource.noteGuid.isSet())) { - QNWARNING(QStringLiteral("Skipping resource without note guid: ") - << resource); + QNWARNING("Skipping resource without note guid: " << resource); continue; } - QNTRACE(QStringLiteral("Checking whether resource belongs to a note ") - << QStringLiteral("pending downloading or already downloaded one: ") + QNTRACE("Checking whether resource belongs to a note " + << "pending downloading or already downloaded one: " << resource); auto ngit = m_guidsOfProcessedNonExpungedNotes.find(resource.noteGuid.ref()); if (ngit != m_guidsOfProcessedNonExpungedNotes.end()) { - QNTRACE(QStringLiteral("Skipping resource as it belongs to the note ") - << QStringLiteral("which whole content has already been downloaded: ") + QNTRACE("Skipping resource as it belongs to the note " + << "which whole content has already been downloaded: " << resource); continue; } @@ -10897,14 +10891,14 @@ nend = m_notes.constEnd(); nit != nend; ++nit) { const qevercloud::Note & note = *nit; - QNTRACE(QStringLiteral("Checking note: ") << note); + QNTRACE("Checking note: " << note); if (Q_UNLIKELY(!note.guid.isSet())) { continue; } if (note.guid.ref() == resource.noteGuid.ref()) { - QNTRACE(QStringLiteral("Resource belongs to a note pending downloading: ") + QNTRACE("Resource belongs to a note pending downloading: " << note); foundNote = true; break; @@ -10912,19 +10906,19 @@ } if (foundNote) { - QNTRACE(QStringLiteral("Skipping resource as it belongs to the note " - "which while content would be downloaded " - "a bit later: ") << resource); + QNTRACE("Skipping resource as it belongs to the note " + << "which while content would be downloaded " + << "a bit later: " << resource); continue; } - QNTRACE(QStringLiteral("Appending the resource which does not belong " - "to any note pending downloading")); + QNTRACE("Appending the resource which does not belong " + "to any note pending downloading"); filteredResources << resource; } - QNTRACE(QStringLiteral("Will append " ) << filteredResources.size() - << QStringLiteral(" resources to the container")); + QNTRACE("Will append " << filteredResources.size() + << " resources to the container"); container.append(filteredResources); } @@ -10933,8 +10927,8 @@ ContainerType & container, const ElementType & element, const QString & /* targetLinkedNotebookGuid */, const QString & typeName) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::findItemByName<") - << typeName << QStringLiteral(">")); + QNDEBUG("RemoteToLocalSynchronizationManager::findItemByName<" + << typeName << ">"); if (!element.hasName()) { SET_CANT_FIND_BY_NAME_ERROR(); @@ -10967,7 +10961,7 @@ TagsContainer & tagsContainer, const Tag & element, const QString & targetLinkedNotebookGuid, const QString & typeName) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::findItemByName<Tag>")); + QNDEBUG("RemoteToLocalSynchronizationManager::findItemByName<Tag>"); if (!element.hasName()) { SET_CANT_FIND_BY_NAME_ERROR(); @@ -11034,11 +11028,11 @@ NotebooksList & container, const Notebook & element, const QString & targetLinkedNotebookGuid, const QString & typeName) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::findItemByName<Notebook>")); + QNDEBUG("RemoteToLocalSynchronizationManager::findItemByName<Notebook>"); - // Attempt to find this data element by name within the list of elements waiting - // for processing; first simply try the front element from the list to avoid - // the costly lookup + // Attempt to find this data element by name within the list of elements + // waiting for processing; first simply try the front element from the list + // to avoid the costly lookup if (!element.hasName()) { SET_CANT_FIND_BY_NAME_ERROR(); Q_EMIT failure(errorDescription); @@ -11070,8 +11064,8 @@ * As notebook name is unique only within user's own account or * within a single linked notebook, there can be name collisions * between linked notebooks. So need to ensure the linked notebook - * guid corresponding to the current notebook is the same as the target - * linked notebook guid + * guid corresponding to the current notebook is the same as the + * target linked notebook guid */ if (!notebook.guid.isSet()) { @@ -11099,8 +11093,8 @@ typename ContainerType::iterator RemoteToLocalSynchronizationManager::findItemByGuid( ContainerType & container, const ElementType & element, const QString & typeName) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::findItemByGuid<") - << typeName << QStringLiteral(">")); + QNDEBUG("RemoteToLocalSynchronizationManager::findItemByGuid<" + << typeName << ">"); if (!element.hasGuid()) { SET_CANT_FIND_BY_GUID_ERROR(); @@ -11132,8 +11126,8 @@ RemoteToLocalSynchronizationManager::findItemByGuid<TagsContainer, Tag>( TagsContainer & tagsContainer, const Tag & element, const QString & typeName) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "findItemByGuid<TagsContainer, Tag>")); + QNDEBUG("RemoteToLocalSynchronizationManager::" + "findItemByGuid<TagsContainer, Tag>"); if (!element.hasGuid()) { SET_CANT_FIND_BY_GUID_ERROR(); @@ -11271,27 +11265,27 @@ void RemoteToLocalSynchronizationManager::emitFindByNameRequest<Tag>( const Tag & tag, const QString & linkedNotebookGuid) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::emitFindByNameRequest<Tag>: ") - << tag << QStringLiteral("\nLinked notebook guid = ") << linkedNotebookGuid); + QNDEBUG("RemoteToLocalSynchronizationManager::emitFindByNameRequest<Tag>: " + << tag << "\nLinked notebook guid = " << linkedNotebookGuid); if (!tag.hasName()) { - ErrorString errorDescription(QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", - "Detected tag from the remote " - "storage which needs to be " - "searched by name in the local " - "storage but it has no name set")); - QNWARNING(errorDescription << QStringLiteral(": ") << tag); + ErrorString errorDescription( + QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", + "Detected tag from the remote storage which " + "needs to be searched by name in the local " + "storage but it has no name set")); + QNWARNING(errorDescription << ": " << tag); Q_EMIT failure(errorDescription); return; } QUuid findElementRequestId = QUuid::createUuid(); Q_UNUSED(m_findTagByNameRequestIds.insert(findElementRequestId)); - m_linkedNotebookGuidsByFindTagByNameRequestIds[findElementRequestId] = linkedNotebookGuid; - QNTRACE(QStringLiteral("Emitting the request to find tag in the local storage: ") - << QStringLiteral("request id = ") << findElementRequestId - << QStringLiteral(", tag: ") << tag); + m_linkedNotebookGuidsByFindTagByNameRequestIds[findElementRequestId] = + linkedNotebookGuid; + QNTRACE("Emitting the request to find tag in the local storage: " + << "request id = " << findElementRequestId << ", tag: " << tag); Q_EMIT findTag(tag, findElementRequestId); } @@ -11299,27 +11293,26 @@ void RemoteToLocalSynchronizationManager::emitFindByNameRequest<SavedSearch>( const SavedSearch & search, const QString & /* linked notebook guid */) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::" - "emitFindByNameRequest<SavedSearch>: ") << search); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "emitFindByNameRequest<SavedSearch>: " << search); - if (!search.hasName()) { - ErrorString errorDescription(QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", - "Detected saved search " - "from the remote storage " - "which needs to be searched " - "by name in the local storage " - "but it has no name set")); - QNWARNING(errorDescription << QStringLiteral(": ") << search); + if (!search.hasName()) + { + ErrorString errorDescription( + QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", + "Detected saved search from the remote storage " + "which needs to be searched by name in the local " + "storage but it has no name set")); + QNWARNING(errorDescription << ": " << search); Q_EMIT failure(errorDescription); return; } QUuid findElementRequestId = QUuid::createUuid(); Q_UNUSED(m_findSavedSearchByNameRequestIds.insert(findElementRequestId)); - QNTRACE(QStringLiteral("Emitting the request to find saved search ") - << QStringLiteral("in the local storage: request id = ") - << findElementRequestId << QStringLiteral(", saved search: ") - << search); + QNTRACE("Emitting the request to find saved search " + << "in the local storage: request id = " << findElementRequestId + << ", saved search: " << search); Q_EMIT findSavedSearch(search, findElementRequestId); } @@ -11327,9 +11320,9 @@ void RemoteToLocalSynchronizationManager::emitFindByNameRequest<Notebook>( const Notebook & notebook, const QString & linkedNotebookGuid) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::") - << QStringLiteral("emitFindByNameRequest<Notebook>: ") << notebook - << QStringLiteral("\nLinked notebook guid = ") << linkedNotebookGuid); + QNDEBUG("RemoteToLocalSynchronizationManager::" + << "emitFindByNameRequest<Notebook>: " << notebook + << "\nLinked notebook guid = " << linkedNotebookGuid); if (!notebook.hasName()) { @@ -11338,7 +11331,7 @@ "Detected notebook from the remote storage " "which needs to be searched by name in the local " "storage but it has no name set")); - QNWARNING(errorDescription << QStringLiteral(": ") << notebook); + QNWARNING(errorDescription << ": " << notebook); Q_EMIT failure(errorDescription); return; } @@ -11347,9 +11340,9 @@ Q_UNUSED(m_findNotebookByNameRequestIds.insert(findElementRequestId)); m_linkedNotebookGuidsByFindNotebookByNameRequestIds[findElementRequestId] = linkedNotebookGuid; - QNTRACE(QStringLiteral("Emitting the request to find notebook in the local ") - << QStringLiteral("storage by name: request id = ") - << findElementRequestId << QStringLiteral(", notebook: ") << notebook); + QNTRACE("Emitting the request to find notebook in the local " + << "storage by name: request id = " + << findElementRequestId << ", notebook: " << notebook); Q_EMIT findNotebook(notebook, findElementRequestId); } @@ -11364,9 +11357,9 @@ return false; } - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::onFoundDuplicateByName<") - << typeName << QStringLiteral(">: ") << typeName << QStringLiteral(" = ") - << element << QStringLiteral(", requestId = ") << requestId); + QNDEBUG("RemoteToLocalSynchronizationManager::onFoundDuplicateByName<" + << typeName << ">: " << typeName << " = " + << element << ", requestId = " << requestId); Q_UNUSED(findElementRequestIds.erase(rit)); @@ -11405,7 +11398,7 @@ "Found a data item without the update sequence " "number within the sync chunk")); SET_ITEM_TYPE_TO_ERROR(); - QNWARNING(errorDescription << QStringLiteral(": ") << remoteElement); + QNWARNING(errorDescription << ": " << remoteElement); Q_EMIT failure(errorDescription); return true; } @@ -11416,7 +11409,7 @@ QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", "Found a data item without guid within the sync chunk")); SET_ITEM_TYPE_TO_ERROR(); - QNWARNING(errorDescription << QStringLiteral(": ") << remoteElement); + QNWARNING(errorDescription << ": " << remoteElement); Q_EMIT failure(errorDescription); return true; } @@ -11457,9 +11450,9 @@ return false; } - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::onFoundDuplicateByGuid<") - << typeName << QStringLiteral(">: ") << typeName << QStringLiteral(" = ") - << element << QStringLiteral(", requestId = ") << requestId); + QNDEBUG("RemoteToLocalSynchronizationManager::onFoundDuplicateByGuid<" + << typeName << ">: " << typeName << " = " + << element << ", requestId = " << requestId); Q_UNUSED(findByGuidRequestIds.erase(rit)); @@ -11471,7 +11464,7 @@ "Could not find the remote item by guid when " "reported of duplicate by guid in the local storage")); SET_ITEM_TYPE_TO_ERROR(); - QNWARNING(errorDescription << QStringLiteral(": ") << element); + QNWARNING(errorDescription << ": " << element); Q_EMIT failure(errorDescription); return true; } @@ -11485,7 +11478,7 @@ "Found a remote data item without the update " "sequence number")); SET_ITEM_TYPE_TO_ERROR(); - QNWARNING(errorDescription << QStringLiteral(": ") << remoteElement); + QNWARNING(errorDescription << ": " << remoteElement); Q_EMIT failure(errorDescription); return true; } @@ -11526,23 +11519,24 @@ return false; } - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::onNoDuplicateByGuid<") - << typeName << QStringLiteral(">: ") << element - << QStringLiteral(", errorDescription = ") << errorDescription - << QStringLiteral(", requestId = ") << requestId); + QNDEBUG("RemoteToLocalSynchronizationManager::onNoDuplicateByGuid<" + << typeName << ">: " << element + << ", errorDescription = " << errorDescription + << ", requestId = " << requestId); Q_UNUSED(findElementRequestIds.erase(rit)); - typename ContainerType::iterator it = findItemByGuid(container, element, typeName); + auto it = findItemByGuid(container, element, typeName); if (it == container.end()) { return true; } - // This element wasn't found in the local storage by guid, need to check whether - // the element with similar name exists + // This element wasn't found in the local storage by guid, need to check + // whether the element with similar name exists ElementType elementToFindByName(*it); elementToFindByName.unsetLocalUid(); - QString linkedNotebookGuid = checkAndAddLinkedNotebookBinding(elementToFindByName); + QString linkedNotebookGuid = + checkAndAddLinkedNotebookBinding(elementToFindByName); elementToFindByName.setGuid(QString()); emitFindByNameRequest(elementToFindByName, linkedNotebookGuid); @@ -11561,10 +11555,10 @@ return false; } - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::onNoDuplicateByName<") - << typeName << QStringLiteral(">: ") << element - << QStringLiteral(", errorDescription = ") << errorDescription - << QStringLiteral(", requestId = ") << requestId); + QNDEBUG("RemoteToLocalSynchronizationManager::onNoDuplicateByName<" + << typeName << ">: " << element + << ", errorDescription = " << errorDescription + << ", requestId = " << requestId); Q_UNUSED(findElementRequestIds.erase(rit)); @@ -11586,9 +11580,8 @@ } } - typename ContainerType::iterator it = findItemByName(container, element, - targetLinkedNotebookGuid, - typeName); + auto it = findItemByName(container, element, targetLinkedNotebookGuid, + typeName); if (it == container.end()) { return true; } @@ -11599,7 +11592,7 @@ QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", "Internal error: found data item without guid " "within those from the downloaded sync chunks")); - QNWARNING(error << QStringLiteral(": ") << *it); + QNWARNING(error << ": " << *it); Q_EMIT failure(error); return true; } @@ -11623,17 +11616,17 @@ RemoteToLocalSynchronizationManager::resolveSyncConflict( const qevercloud::Notebook & remoteNotebook, const Notebook & localConflict) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::resolveSyncConflict") - << QStringLiteral("<Notebook>: remote notebook = ") << remoteNotebook - << QStringLiteral("\nLocal conflicting notebook: ") << localConflict); + QNDEBUG("RemoteToLocalSynchronizationManager::resolveSyncConflict" + << "<Notebook>: remote notebook = " << remoteNotebook + << "\nLocal conflicting notebook: " << localConflict); if (Q_UNLIKELY(!remoteNotebook.guid.isSet())) { ErrorString error( QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", - "Can't resolve the conflict between remote and local " - "notebooks: the remote notebook has no guid")); - QNWARNING(error << QStringLiteral(", remote notebook: ") << remoteNotebook); + "Can't resolve the conflict between remote and " + "local notebooks: the remote notebook has no guid")); + QNWARNING(error << ", remote notebook: " << remoteNotebook); Q_EMIT failure(error); return ResolveSyncConflictStatus::Ready; } @@ -11646,35 +11639,36 @@ { const NotebookSyncConflictResolver * pResolver = *it; if (Q_UNLIKELY(!pResolver)) { - QNWARNING(QStringLiteral("Skipping the null pointer to notebook " - "sync conflict resolver")); + QNWARNING("Skipping the null pointer to notebook " + "sync conflict resolver"); continue; } - const qevercloud::Notebook & resolverRemoteNotebook = pResolver->remoteNotebook(); + const qevercloud::Notebook & resolverRemoteNotebook = + pResolver->remoteNotebook(); if (Q_UNLIKELY(!resolverRemoteNotebook.guid.isSet())) { - QNWARNING(QStringLiteral("Skipping the resolver with remote notebook " - "containing no guid: ") << resolverRemoteNotebook); + QNWARNING("Skipping the resolver with remote notebook " + << "containing no guid: " << resolverRemoteNotebook); continue; } if (resolverRemoteNotebook.guid.ref() != remoteNotebook.guid.ref()) { - QNTRACE(QStringLiteral("Skipping the existing notebook sync conflict ") - << QStringLiteral("resolver processing remote notebook ") - << QStringLiteral("with another guid: ") << resolverRemoteNotebook); + QNTRACE("Skipping the existing notebook sync conflict " + << "resolver processing remote notebook " + << "with another guid: " << resolverRemoteNotebook); continue; } const Notebook & resolverLocalConflict = pResolver->localConflict(); if (resolverLocalConflict.localUid() != localConflict.localUid()) { - QNTRACE(QStringLiteral("Skipping the existing notebook sync conflict ") - << QStringLiteral("resolver processing local conflict with ") - << QStringLiteral("another local uid: ") << resolverLocalConflict); + QNTRACE("Skipping the existing notebook sync conflict " + << "resolver processing local conflict with " + << "another local uid: " << resolverLocalConflict); continue; } - QNDEBUG(QStringLiteral("Found existing notebook sync conflict resolver " - "for this pair of remote and local notebooks")); + QNDEBUG("Found existing notebook sync conflict resolver " + "for this pair of remote and local notebooks"); return ResolveSyncConflictStatus::Pending; } @@ -11704,7 +11698,8 @@ } NotebookSyncConflictResolver * pResolver = - new NotebookSyncConflictResolver(remoteNotebook, remoteNotebookLinkedNotebookGuid, + new NotebookSyncConflictResolver(remoteNotebook, + remoteNotebookLinkedNotebookGuid, localConflict, *pCache, m_manager.localStorageManagerAsync(), this); @@ -11733,12 +11728,12 @@ template <> RemoteToLocalSynchronizationManager::ResolveSyncConflictStatus::type -RemoteToLocalSynchronizationManager::resolveSyncConflict(const qevercloud::Tag & remoteTag, - const Tag & localConflict) +RemoteToLocalSynchronizationManager::resolveSyncConflict( + const qevercloud::Tag & remoteTag, const Tag & localConflict) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::resolveSyncConflict") - << QStringLiteral("<Tag>: remote tag = ") << remoteTag - << QStringLiteral("\nLocal conflicting tag: ") << localConflict); + QNDEBUG("RemoteToLocalSynchronizationManager::resolveSyncConflict" + << "<Tag>: remote tag = " << remoteTag + << "\nLocal conflicting tag: " << localConflict); if (Q_UNLIKELY(!remoteTag.guid.isSet())) { @@ -11746,7 +11741,7 @@ "Can't resolve the conflict between " "remote and local tags: the remote " "tag has no guid")); - QNWARNING(error << QStringLiteral(", remote tag: ") << remoteTag); + QNWARNING(error << ", remote tag: " << remoteTag); Q_EMIT failure(error); return ResolveSyncConflictStatus::Ready; } @@ -11759,35 +11754,35 @@ { const TagSyncConflictResolver * pResolver = *it; if (Q_UNLIKELY(!pResolver)) { - QNWARNING(QStringLiteral("Skipping the null pointer to tag sync " - "conflict resolver")); + QNWARNING("Skipping the null pointer to tag sync " + "conflict resolver"); continue; } const qevercloud::Tag & resolverRemoteTag = pResolver->remoteTag(); if (Q_UNLIKELY(!resolverRemoteTag.guid.isSet())) { - QNWARNING(QStringLiteral("Skipping the resolver with remote tag " - "containing no guid: ") << resolverRemoteTag); + QNWARNING("Skipping the resolver with remote tag " + << "containing no guid: " << resolverRemoteTag); continue; } if (resolverRemoteTag.guid.ref() != remoteTag.guid.ref()) { - QNTRACE(QStringLiteral("Skipping the existing tag sync conflict " - "resolver processing remote tag with another guid: ") + QNTRACE("Skipping the existing tag sync conflict " + << "resolver processing remote tag with another guid: " << resolverRemoteTag); continue; } const Tag & resolverLocalConflict = pResolver->localConflict(); if (resolverLocalConflict.localUid() != localConflict.localUid()) { - QNTRACE(QStringLiteral("Skipping the existing tag sync conflict resolver ") - << QStringLiteral("processing local conflict with another local uid: ") + QNTRACE("Skipping the existing tag sync conflict resolver " + << "processing local conflict with another local uid: " << resolverLocalConflict); continue; } - QNDEBUG(QStringLiteral("Found existing tag sync conflict resolver for " - "this pair of remote and local tags")); + QNDEBUG("Found existing tag sync conflict resolver for " + "this pair of remote and local tags"); return ResolveSyncConflictStatus::Pending; } @@ -11847,9 +11842,9 @@ const qevercloud::SavedSearch & remoteSavedSearch, const SavedSearch & localConflict) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::resolveSyncConflict") - << QStringLiteral("<SavedSearch>: remote saved search = ") - << remoteSavedSearch << QStringLiteral("\nLocal conflicting saved search: ") + QNDEBUG("RemoteToLocalSynchronizationManager::resolveSyncConflict" + << "<SavedSearch>: remote saved search = " + << remoteSavedSearch << "\nLocal conflicting saved search: " << localConflict); if (Q_UNLIKELY(!remoteSavedSearch.guid.isSet())) @@ -11858,8 +11853,7 @@ "Can't resolve the conflict between " "remote and local saved searches: " "the remote saved search has no guid")); - QNWARNING(error << QStringLiteral(", remote saved search: ") - << remoteSavedSearch); + QNWARNING(error << ", remote saved search: " << remoteSavedSearch); Q_EMIT failure(error); return ResolveSyncConflictStatus::Ready; } @@ -11872,38 +11866,38 @@ { const SavedSearchSyncConflictResolver * pResolver = *it; if (Q_UNLIKELY(!pResolver)) { - QNWARNING(QStringLiteral("Skipping the null pointer to saved search " - "sync conflict resolver")); + QNWARNING("Skipping the null pointer to saved search " + "sync conflict resolver"); continue; } const qevercloud::SavedSearch & resolverRemoteSavedSearch = pResolver->remoteSavedSearch(); if (Q_UNLIKELY(!resolverRemoteSavedSearch.guid.isSet())) { - QNWARNING(QStringLiteral("Skipping the existing saved search sync ") - << QStringLiteral("conflict resolver processing remote saved ") - << QStringLiteral("search with another guid: ") + QNWARNING("Skipping the existing saved search sync " + << "conflict resolver processing remote saved " + << "search with another guid: " << resolverRemoteSavedSearch); continue; } if (resolverRemoteSavedSearch.guid.ref() != remoteSavedSearch.guid.ref()) { - QNTRACE(QStringLiteral("Skipping the existing saved search sync conflict ") - << QStringLiteral("resolver processing remote saved search ") - << QStringLiteral("with another guid: ") << resolverRemoteSavedSearch); + QNTRACE("Skipping the existing saved search sync conflict " + << "resolver processing remote saved search " + << "with another guid: " << resolverRemoteSavedSearch); continue; } const SavedSearch & resolverLocalConflict = pResolver->localConflict(); if (resolverLocalConflict.localUid() != localConflict.localUid()) { - QNTRACE(QStringLiteral("Skipping the existing saved search sync ") - << QStringLiteral("conflict resolver processing local conflict ") - << QStringLiteral("with another local uid: ") << resolverLocalConflict); + QNTRACE("Skipping the existing saved search sync " + << "conflict resolver processing local conflict " + << "with another local uid: " << resolverLocalConflict); continue; } - QNDEBUG(QStringLiteral("Found existing saved search conflict resolver " - "for this pair of remote and local saved searches")); + QNDEBUG("Found existing saved search conflict resolver " + "for this pair of remote and local saved searches"); return ResolveSyncConflictStatus::Pending; } @@ -11940,16 +11934,16 @@ RemoteToLocalSynchronizationManager::resolveSyncConflict( const qevercloud::Note & remoteNote, const Note & localConflict) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::resolveSyncConflict") - << QStringLiteral("<Note>: remote note = ") << remoteNote - << QStringLiteral("\nLocal conflicting note: ") << localConflict); + QNDEBUG("RemoteToLocalSynchronizationManager::resolveSyncConflict" + << "<Note>: remote note = " << remoteNote + << "\nLocal conflicting note: " << localConflict); if (Q_UNLIKELY(!remoteNote.guid.isSet())) { ErrorString errorDescription( QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", "Found a remote note without guid set")); - QNWARNING(errorDescription << QStringLiteral(", note: ") << remoteNote); + QNWARNING(errorDescription << ", note: " << remoteNote); Q_EMIT failure(errorDescription); return ResolveSyncConflictStatus::Ready; } @@ -11958,8 +11952,9 @@ { ErrorString errorDescription( QT_TRANSLATE_NOOP("RemoteToLocalSynchronizationManager", - "Found a remote note without update sequence number set")); - QNWARNING(errorDescription << QStringLiteral(", note: ") << remoteNote); + "Found a remote note without update sequence " + "number set")); + QNWARNING(errorDescription << ", note: " << remoteNote); Q_EMIT failure(errorDescription); return ResolveSyncConflictStatus::Ready; } @@ -11968,9 +11963,9 @@ localConflict.hasUpdateSequenceNumber() && (localConflict.updateSequenceNumber() >= remoteNote.updateSequenceNum.ref())) { - QNDEBUG(QStringLiteral("The local conflicting note's update sequence number ") - << QStringLiteral("is greater than or equal to the remote note's one => ") - << QStringLiteral(" the remote note shouldn't override the local note")); + QNDEBUG("The local conflicting note's update sequence number " + "is greater than or equal to the remote note's one => " + " the remote note shouldn't override the local note"); return ResolveSyncConflictStatus::Ready; } @@ -11984,11 +11979,10 @@ const qevercloud::LinkedNotebook & remoteLinkedNotebook, const LinkedNotebook & localConflict) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::resolveSyncConflict") - << QStringLiteral("<LinkedNotebook>: remote linked notebook = ") + QNDEBUG("RemoteToLocalSynchronizationManager::resolveSyncConflict" + << "<LinkedNotebook>: remote linked notebook = " << remoteLinkedNotebook - << QStringLiteral("\nLocal conflicting linked notebook: ") - << localConflict); + << "\nLocal conflicting linked notebook: " << localConflict); // NOTE: since linked notebook is just a pointer to a notebook in another // user's account, it makes little sense to even attempt to resolve any @@ -12003,17 +11997,18 @@ QUuid updateLinkedNotebookRequestId = QUuid::createUuid(); Q_UNUSED(m_updateLinkedNotebookRequestIds.insert(updateLinkedNotebookRequestId)); - QNTRACE(QStringLiteral("Emitting the request to update linked notebook: request id = ") - << updateLinkedNotebookRequestId << QStringLiteral(", linked notebook: ") + QNTRACE("Emitting the request to update linked notebook: request id = " + << updateLinkedNotebookRequestId << ", linked notebook: " << linkedNotebook); Q_EMIT updateLinkedNotebook(linkedNotebook, updateLinkedNotebookRequestId); return ResolveSyncConflictStatus::Pending; } -bool RemoteToLocalSynchronizationManager::sortTagsByParentChildRelations(TagsList & tagList) +bool RemoteToLocalSynchronizationManager::sortTagsByParentChildRelations( + TagsList & tagList) { - QNDEBUG(QStringLiteral("RemoteToLocalSynchronizationManager::sortTagsByParentChildRelations")); + QNDEBUG("RemoteToLocalSynchronizationManager::sortTagsByParentChildRelations"); ErrorString errorDescription; bool res = ::quentier::sortTagsByParentChildRelations(tagList, errorDescription); @@ -12029,11 +12024,11 @@ QTextStream & RemoteToLocalSynchronizationManager::PostponedConflictingResourceData::print( QTextStream & strm) const { - strm << QStringLiteral("PostponedConflictingResourceData: {\n Remote note:\n") - << m_remoteNote << QStringLiteral("\n\n Local conflicting note:\n") + strm << "PostponedConflictingResourceData: {\n Remote note:\n" + << m_remoteNote << "\n\n Local conflicting note:\n" << m_localConflictingNote - << QStringLiteral("\n\n Remote note's resource without full data:\n") - << m_remoteNoteResourceWithoutFullData << QStringLiteral("\n};\n"); + << "\n\n Remote note's resource without full data:\n" + << m_remoteNoteResourceWithoutFullData << "\n};\n"; return strm; } @@ -12047,9 +12042,8 @@ return m_manager.m_manager.localStorageManagerAsync(); } -INoteStore * NoteSyncConflictResolverManager::noteStoreForNote(const Note & note, - QString & authToken, - ErrorString & errorDescription) +INoteStore * NoteSyncConflictResolverManager::noteStoreForNote( + const Note & note, QString & authToken, ErrorString & errorDescription) { authToken.resize(0); errorDescription.clear(); diff -Nru libquentier-0.5.0/src/synchronization/SavedSearchSyncCache.cpp libquentier-0.5.0/src/synchronization/SavedSearchSyncCache.cpp --- libquentier-0.5.0/src/synchronization/SavedSearchSyncCache.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/SavedSearchSyncCache.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -37,7 +37,7 @@ void SavedSearchSyncCache::clear() { - QNDEBUG(QStringLiteral("SavedSearchSyncCache::clear")); + QNDEBUG("SavedSearchSyncCache::clear"); disconnectFromLocalStorage(); @@ -65,11 +65,11 @@ void SavedSearchSyncCache::fill() { - QNDEBUG(QStringLiteral("SavedSearchSyncCache::fill")); + QNDEBUG("SavedSearchSyncCache::fill"); if (m_connectedToLocalStorage) { - QNDEBUG(QStringLiteral("Already connected to the local storage, no need " - "to do anything")); + QNDEBUG("Already connected to the local storage, no need " + "to do anything"); return; } @@ -88,12 +88,10 @@ return; } - QNDEBUG(QStringLiteral("SavedSearchSyncCache::onListSavedSearchesComplete: ") - << QStringLiteral("flag = ") << flag << QStringLiteral(", limit = ") - << limit << QStringLiteral(", offset = ") << offset - << QStringLiteral(", order = ") << order - << QStringLiteral(", order direction = ") - << orderDirection << QStringLiteral(", request id = ") << requestId); + QNDEBUG("SavedSearchSyncCache::onListSavedSearchesComplete: " + << "flag = " << flag << ", limit = " << limit << ", offset = " + << offset << ", order = " << order << ", order direction = " + << orderDirection << ", request id = " << requestId); for(auto it = foundSearches.constBegin(), end = foundSearches.constEnd(); it != end; ++it) @@ -104,9 +102,9 @@ m_listSavedSearchesRequestId = QUuid(); if (foundSearches.size() == static_cast<int>(limit)) { - QNTRACE(QStringLiteral("The number of found saved searches matches " - "the limit, requesting more saved searches " - "from the local storage")); + QNTRACE("The number of found saved searches matches " + "the limit, requesting more saved searches " + "from the local storage"); m_offset += limit; requestSavedSearchesList(); return; @@ -126,16 +124,16 @@ return; } - QNDEBUG(QStringLiteral("SavedSearchSyncCache::onListSavedSearchesFailed: ") - << QStringLiteral("flag = ") << flag << QStringLiteral(", limit = ") - << limit << QStringLiteral(", offset = ") << offset - << QStringLiteral(", order = ") << order - << QStringLiteral(", order direction = ") << orderDirection - << QStringLiteral(", error description = ") << errorDescription - << QStringLiteral(", request id = ") << requestId); + QNDEBUG("SavedSearchSyncCache::onListSavedSearchesFailed: " + << "flag = " << flag << ", limit = " + << limit << ", offset = " << offset + << ", order = " << order + << ", order direction = " << orderDirection + << ", error description = " << errorDescription + << ", request id = " << requestId); - QNWARNING(QStringLiteral("Failed to cache the saved search information " - "required for the sync: ") << errorDescription); + QNWARNING("Failed to cache the saved search information " + << "required for the sync: " << errorDescription); m_savedSearchNameByLocalUid.clear(); m_savedSearchNameByGuid.clear(); @@ -146,43 +144,43 @@ Q_EMIT failure(errorDescription); } -void SavedSearchSyncCache::onAddSavedSearchComplete(SavedSearch search, - QUuid requestId) +void SavedSearchSyncCache::onAddSavedSearchComplete( + SavedSearch search, QUuid requestId) { - QNDEBUG(QStringLiteral("SavedSearchSyncCache::onAddSavedSearchComplete: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", saved search: ") << search); + QNDEBUG("SavedSearchSyncCache::onAddSavedSearchComplete: " + << "request id = " << requestId + << ", saved search: " << search); processSavedSearch(search); } -void SavedSearchSyncCache::onUpdateSavedSearchComplete(SavedSearch search, - QUuid requestId) +void SavedSearchSyncCache::onUpdateSavedSearchComplete( + SavedSearch search, QUuid requestId) { - QNDEBUG(QStringLiteral("SavedSearchSyncCache::onUpdateSavedSearchComplete: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", saved search: ") << search); + QNDEBUG("SavedSearchSyncCache::onUpdateSavedSearchComplete: " + << "request id = " << requestId + << ", saved search: " << search); removeSavedSearch(search.localUid()); processSavedSearch(search); } -void SavedSearchSyncCache::onExpungeSavedSearchComplete(SavedSearch search, - QUuid requestId) +void SavedSearchSyncCache::onExpungeSavedSearchComplete( + SavedSearch search, QUuid requestId) { - QNDEBUG(QStringLiteral("SavedSearchSyncCache::onExpungeSavedSearchComplete: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", saved search: ") << search); + QNDEBUG("SavedSearchSyncCache::onExpungeSavedSearchComplete: " + << "request id = " << requestId + << ", saved search: " << search); removeSavedSearch(search.localUid()); } void SavedSearchSyncCache::connectToLocalStorage() { - QNDEBUG(QStringLiteral("SavedSearchSyncCache::connectToLocalStorage")); + QNDEBUG("SavedSearchSyncCache::connectToLocalStorage"); if (m_connectedToLocalStorage) { - QNDEBUG(QStringLiteral("Already connected to the local storage")); + QNDEBUG("Already connected to the local storage"); return; } @@ -259,10 +257,10 @@ void SavedSearchSyncCache::disconnectFromLocalStorage() { - QNDEBUG(QStringLiteral("SavedSearchSyncCache::disconnectFromLocalStorage")); + QNDEBUG("SavedSearchSyncCache::disconnectFromLocalStorage"); if (!m_connectedToLocalStorage) { - QNDEBUG(QStringLiteral("Not connected to local storage at the moment")); + QNDEBUG("Not connected to local storage at the moment"); return; } @@ -333,13 +331,13 @@ void SavedSearchSyncCache::requestSavedSearchesList() { - QNDEBUG(QStringLiteral("SavedSearchSyncCache::requestSavedSearchesList")); + QNDEBUG("SavedSearchSyncCache::requestSavedSearchesList"); m_listSavedSearchesRequestId = QUuid::createUuid(); - QNTRACE(QStringLiteral("Emitting the request to list saved searches: ") - << QStringLiteral("request id = ") << m_listSavedSearchesRequestId - << QStringLiteral(", offset = ") << m_offset); + QNTRACE("Emitting the request to list saved searches: " + << "request id = " << m_listSavedSearchesRequestId + << ", offset = " << m_offset); Q_EMIT listSavedSearches(LocalStorageManager::ListAll, m_limit, m_offset, LocalStorageManager::ListSavedSearchesOrder::NoOrder, @@ -349,13 +347,13 @@ void SavedSearchSyncCache::removeSavedSearch(const QString & savedSearchLocalUid) { - QNDEBUG(QStringLiteral("SavedSearchSyncCache::removeSavedSearch: local uid = ") + QNDEBUG("SavedSearchSyncCache::removeSavedSearch: local uid = " << savedSearchLocalUid); auto localUidIt = m_savedSearchNameByLocalUid.find(savedSearchLocalUid); if (Q_UNLIKELY(localUidIt == m_savedSearchNameByLocalUid.end())) { - QNDEBUG(QStringLiteral("The saved search name was not found in the cache " - "by local uid")); + QNDEBUG("The saved search name was not found in the cache " + "by local uid"); return; } @@ -364,8 +362,8 @@ auto guidIt = m_savedSearchNameByGuid.find(name); if (Q_UNLIKELY(guidIt == m_savedSearchNameByGuid.end())) { - QNDEBUG(QStringLiteral("The saved search guid was not found in the cache " - "by name")); + QNDEBUG("The saved search guid was not found in the cache " + "by name"); return; } @@ -379,8 +377,8 @@ auto nameIt = m_savedSearchNameByGuid.find(guid); if (Q_UNLIKELY(nameIt == m_savedSearchNameByGuid.end())) { - QNDEBUG(QStringLiteral("The saved search name was not found in the cache " - "by guid")); + QNDEBUG("The saved search name was not found in the cache " + "by guid"); return; } @@ -389,7 +387,7 @@ void SavedSearchSyncCache::processSavedSearch(const SavedSearch & search) { - QNDEBUG(QStringLiteral("SavedSearchSyncCache::processSavedSearch: ") << search); + QNDEBUG("SavedSearchSyncCache::processSavedSearch: " << search); if (search.hasGuid()) { @@ -407,7 +405,7 @@ } if (!search.hasName()) { - QNDEBUG(QStringLiteral("Skipping the saved search without a name")); + QNDEBUG("Skipping the saved search without a name"); return; } diff -Nru libquentier-0.5.0/src/synchronization/SavedSearchSyncCache.h libquentier-0.5.0/src/synchronization/SavedSearchSyncCache.h --- libquentier-0.5.0/src/synchronization/SavedSearchSyncCache.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/SavedSearchSyncCache.h 2019-07-11 10:46:53.000000000 +0000 @@ -58,11 +58,12 @@ void failure(ErrorString errorDescription); // private signals - void listSavedSearches(LocalStorageManager::ListObjectsOptions flag, - size_t limit, size_t offset, - LocalStorageManager::ListSavedSearchesOrder::type order, - LocalStorageManager::OrderDirection::type orderDirection, - QUuid requestId); + void listSavedSearches( + LocalStorageManager::ListObjectsOptions flag, + size_t limit, size_t offset, + LocalStorageManager::ListSavedSearchesOrder::type order, + LocalStorageManager::OrderDirection::type orderDirection, + QUuid requestId); public Q_SLOTS: /** @@ -74,16 +75,19 @@ void fill(); private Q_SLOTS: - void onListSavedSearchesComplete(LocalStorageManager::ListObjectsOptions flag, - size_t limit, size_t offset, - LocalStorageManager::ListSavedSearchesOrder::type order, - LocalStorageManager::OrderDirection::type orderDirection, - QList<SavedSearch> foundSearches, QUuid requestId); - void onListSavedSearchesFailed(LocalStorageManager::ListObjectsOptions flag, - size_t limit, size_t offset, - LocalStorageManager::ListSavedSearchesOrder::type order, - LocalStorageManager::OrderDirection::type orderDirection, - ErrorString errorDescription, QUuid requestId); + void onListSavedSearchesComplete( + LocalStorageManager::ListObjectsOptions flag, + size_t limit, size_t offset, + LocalStorageManager::ListSavedSearchesOrder::type order, + LocalStorageManager::OrderDirection::type orderDirection, + QList<SavedSearch> foundSearches, QUuid requestId); + + void onListSavedSearchesFailed( + LocalStorageManager::ListObjectsOptions flag, + size_t limit, size_t offset, + LocalStorageManager::ListSavedSearchesOrder::type order, + LocalStorageManager::OrderDirection::type orderDirection, + ErrorString errorDescription, QUuid requestId); void onAddSavedSearchComplete(SavedSearch search, QUuid requestId); void onUpdateSavedSearchComplete(SavedSearch search, QUuid requestId); diff -Nru libquentier-0.5.0/src/synchronization/SavedSearchSyncConflictResolver.cpp libquentier-0.5.0/src/synchronization/SavedSearchSyncConflictResolver.cpp --- libquentier-0.5.0/src/synchronization/SavedSearchSyncConflictResolver.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/SavedSearchSyncConflictResolver.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -43,39 +43,45 @@ void SavedSearchSyncConflictResolver::start() { - QNDEBUG(QStringLiteral("SavedSearchSyncConflictResolver::start")); + QNDEBUG("SavedSearchSyncConflictResolver::start"); if (m_started) { - QNDEBUG(QStringLiteral("Already started")); + QNDEBUG("Already started"); return; } m_started = true; - if (Q_UNLIKELY(!m_remoteSavedSearch.guid.isSet())) { - ErrorString error(QT_TR_NOOP("Can't resolve the conflict between remote " - "and local saved searches: the remote saved " - "search has no guid set")); - QNWARNING(error << QStringLiteral(": ") << m_remoteSavedSearch); + if (Q_UNLIKELY(!m_remoteSavedSearch.guid.isSet())) + { + ErrorString error( + QT_TR_NOOP("Can't resolve the conflict between remote " + "and local saved searches: the remote saved " + "search has no guid set")); + QNWARNING(error << ": " << m_remoteSavedSearch); Q_EMIT failure(m_remoteSavedSearch, error); return; } - if (Q_UNLIKELY(!m_remoteSavedSearch.name.isSet())) { - ErrorString error(QT_TR_NOOP("Can't resolve the conflict between remote " - "and local saved searches: the remote saved " - "search has no name set")); - QNWARNING(error << QStringLiteral(": ") << m_remoteSavedSearch); + if (Q_UNLIKELY(!m_remoteSavedSearch.name.isSet())) + { + ErrorString error( + QT_TR_NOOP("Can't resolve the conflict between remote " + "and local saved searches: the remote saved " + "search has no name set")); + QNWARNING(error << ": " << m_remoteSavedSearch); Q_EMIT failure(m_remoteSavedSearch, error); return; } - if (Q_UNLIKELY(!m_localConflict.hasGuid() && !m_localConflict.hasName())) { - ErrorString error(QT_TR_NOOP("Can't resolve the conflict between remote " - "and local saved searches: the local " - "conflicting saved search has neither guid " - "not name set")); - QNWARNING(error << QStringLiteral(": ") << m_localConflict); + if (Q_UNLIKELY(!m_localConflict.hasGuid() && !m_localConflict.hasName())) + { + ErrorString error( + QT_TR_NOOP("Can't resolve the conflict between remote " + "and local saved searches: the local " + "conflicting saved search has neither guid " + "not name set")); + QNWARNING(error << ": " << m_localConflict); Q_EMIT failure(m_remoteSavedSearch, error); return; } @@ -93,21 +99,19 @@ } } -void SavedSearchSyncConflictResolver::onAddSavedSearchComplete(SavedSearch search, - QUuid requestId) +void SavedSearchSyncConflictResolver::onAddSavedSearchComplete( + SavedSearch search, QUuid requestId) { if (requestId != m_addSavedSearchRequestId) { return; } - QNDEBUG(QStringLiteral("SavedSearchSyncConflictResolver::onAddSavedSearchComplete: ") - << QStringLiteral("requets id = ") << requestId - << QStringLiteral(", saved search: ") << search); + QNDEBUG("SavedSearchSyncConflictResolver::onAddSavedSearchComplete: " + << "requets id = " << requestId << ", saved search: " << search); if (m_state == State::PendingRemoteSavedSearchAdoptionInLocalStorage) { - QNDEBUG(QStringLiteral("Successfully added the remote saved search " - "to the local storage")); + QNDEBUG("Successfully added the remote saved search to the local storage"); Q_EMIT finished(m_remoteSavedSearch); } else @@ -115,58 +119,58 @@ ErrorString error(QT_TR_NOOP("Internal error: wrong state on receiving " "the confirmation about the saved search " "addition from the local storage")); - QNWARNING(error << QStringLiteral(", saved search: ") << search); + QNWARNING(error << ", saved search: " << search); Q_EMIT failure(m_remoteSavedSearch, error); } } -void SavedSearchSyncConflictResolver::onAddSavedSearchFailed(SavedSearch search, - ErrorString errorDescription, - QUuid requestId) +void SavedSearchSyncConflictResolver::onAddSavedSearchFailed( + SavedSearch search, ErrorString errorDescription, QUuid requestId) { if (requestId != m_addSavedSearchRequestId) { return; } - QNDEBUG(QStringLiteral("SavedSearchSyncConflictResolver::onAddSavedSearchFailed: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", error description = ") << errorDescription - << QStringLiteral("; saved search: ") << search); + QNDEBUG("SavedSearchSyncConflictResolver::onAddSavedSearchFailed: " + << "request id = " << requestId + << ", error description = " << errorDescription + << "; saved search: " << search); Q_EMIT failure(m_remoteSavedSearch, errorDescription); } -void SavedSearchSyncConflictResolver::onUpdateSavedSearchComplete(SavedSearch search, - QUuid requestId) +void SavedSearchSyncConflictResolver::onUpdateSavedSearchComplete( + SavedSearch search, QUuid requestId) { if (requestId != m_updateSavedSearchRequestId) { return; } - QNDEBUG(QStringLiteral("SavedSearchSyncConflictResolver::onUpdateSavedSearchComplete: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", saved search: ") << search); + QNDEBUG("SavedSearchSyncConflictResolver::onUpdateSavedSearchComplete: " + << "request id = " << requestId << ", saved search: " << search); if (m_state == State::OverrideLocalChangesWithRemoteChanges) { - QNDEBUG(QStringLiteral("Successfully overridden the local changes with " - "remote changes")); + QNDEBUG("Successfully overridden the local changes with remote changes"); Q_EMIT finished(m_remoteSavedSearch); return; } else if (m_state == State::PendingConflictingSavedSearchRenaming) { - QNDEBUG(QStringLiteral("Successfully renamed the local saved search " - "conflicting by name with the remote search")); + QNDEBUG("Successfully renamed the local saved search " + "conflicting by name with the remote search"); - // Now need o find the duplicate of the remote saved search by guid: - // 1) if one exists, update it from the remote changes - notwithstanding - // its "dirty" state - // 2) if one doesn't exist, add it to the local storage - - // The cache should have been filled by that moment, otherwise how could - // the local saved search conflicting by name be renamed properly? - if (Q_UNLIKELY(!m_cache.isFilled())) { + /** + * Now need to find the duplicate of the remote saved search by guid: + * 1) if one exists, update it from the remote changes - notwithstanding + * its "dirty" state + * 2) if one doesn't exist, add it to the local storage + + * The cache should have been filled by that moment, otherwise how could + * the local saved search conflicting by name be renamed properly? + */ + if (Q_UNLIKELY(!m_cache.isFilled())) + { ErrorString error(QT_TR_NOOP("Internal error: the cache of saved " "search info is not filled while it " "should have been")); @@ -181,25 +185,24 @@ auto it = nameByGuidHash.find(m_remoteSavedSearch.guid.ref()); if (it == nameByGuidHash.end()) { - QNDEBUG(QStringLiteral("Found no duplicate of the remote saved search " - "by guid, adding new saved search " - "to the local storage")); + QNDEBUG("Found no duplicate of the remote saved search by guid, " + "adding new saved search to the local storage"); SavedSearch search(m_remoteSavedSearch); search.setDirty(false); search.setLocal(false); m_addSavedSearchRequestId = QUuid::createUuid(); - QNTRACE(QStringLiteral("Emitting the request to add saved search: ") - << QStringLiteral("request id = ") << m_addSavedSearchRequestId - << QStringLiteral(", saved search: ") << search); + QNTRACE("Emitting the request to add saved search: " + << "request id = " << m_addSavedSearchRequestId + << ", saved search: " << search); Q_EMIT addSavedSearch(search, m_addSavedSearchRequestId); } else { - QNDEBUG(QStringLiteral("The duplicate by guid exists in the local " - "storage, updating it with the state " - "of the remote saved search")); + QNDEBUG("The duplicate by guid exists in the local " + "storage, updating it with the state " + "of the remote saved search"); SavedSearch search(m_localConflict); search.qevercloudSavedSearch() = m_remoteSavedSearch; @@ -207,17 +210,16 @@ search.setLocal(false); m_updateSavedSearchRequestId = QUuid::createUuid(); - QNTRACE(QStringLiteral("Emitting the request to update saved search: ") - << QStringLiteral("request id = ") << m_updateSavedSearchRequestId - << QStringLiteral(", saved search: ") << search); + QNTRACE("Emitting the request to update saved search: " + << "request id = " << m_updateSavedSearchRequestId + << ", saved search: " << search); Q_EMIT updateSavedSearch(search, m_updateSavedSearchRequestId); } } else if (m_state == State::PendingRemoteSavedSearchAdoptionInLocalStorage) { - QNDEBUG(QStringLiteral("Successfully finalized the sequence of actions " - "required for resolving the conflict of saved " - "searches")); + QNDEBUG("Successfully finalized the sequence of actions " + "required for resolving the conflict of saved searches"); Q_EMIT finished(m_remoteSavedSearch); } else @@ -225,7 +227,7 @@ ErrorString error(QT_TR_NOOP("Internal eerror: wrong state on receiving " "the confirmation about the saved search " "update from the local storage")); - QNWARNING(error << QStringLiteral(", saved search: ") << search); + QNWARNING(error << ", saved search: " << search); Q_EMIT failure(m_remoteSavedSearch, error); } } @@ -237,24 +239,23 @@ return; } - QNDEBUG(QStringLiteral("SavedSearchSyncConflictResolver::onUpdateSavedSearchFailed: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", error description = ") << errorDescription - << QStringLiteral(" saved search: ") << search); + QNDEBUG("SavedSearchSyncConflictResolver::onUpdateSavedSearchFailed: " + << "request id = " << requestId + << ", error description = " << errorDescription + << " saved search: " << search); Q_EMIT failure(m_remoteSavedSearch, errorDescription); } -void SavedSearchSyncConflictResolver::onFindSavedSearchComplete(SavedSearch search, - QUuid requestId) +void SavedSearchSyncConflictResolver::onFindSavedSearchComplete( + SavedSearch search, QUuid requestId) { if (requestId != m_findSavedSearchRequestId) { return; } - QNDEBUG(QStringLiteral("SavedSearchSyncConflictResolver::onFindSavedSearchComplete: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", saved search: ") << search); + QNDEBUG("SavedSearchSyncConflictResolver::onFindSavedSearchComplete: " + << "request id = " << requestId << ", saved search: " << search); m_findSavedSearchRequestId = QUuid(); @@ -269,10 +270,10 @@ return; } - QNDEBUG(QStringLiteral("SavedSearchSyncConflictResolver::onFindSavedSearchFailed: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", error description = ") << errorDescription - << QStringLiteral(", saved search: ") << search); + QNDEBUG("SavedSearchSyncConflictResolver::onFindSavedSearchFailed: " + << "request id = " << requestId + << ", error description = " << errorDescription + << ", saved search: " << search); m_findSavedSearchRequestId = QUuid(); @@ -283,10 +284,10 @@ void SavedSearchSyncConflictResolver::onCacheFilled() { - QNDEBUG(QStringLiteral("SavedSearchSyncConflictResolver::onCacheFilled")); + QNDEBUG("SavedSearchSyncConflictResolver::onCacheFilled"); if (!m_pendingCacheFilling) { - QNDEBUG(QStringLiteral("Not pending the cache filling")); + QNDEBUG("Not pending the cache filling"); return; } @@ -301,18 +302,18 @@ ErrorString error(QT_TR_NOOP("Internal error: wrong state on receiving " "the saved search info cache filling " "notification")); - QNWARNING(error << QStringLiteral(", state = ") << m_state); + QNWARNING(error << ", state = " << m_state); Q_EMIT failure(m_remoteSavedSearch, error); } } void SavedSearchSyncConflictResolver::onCacheFailed(ErrorString errorDescription) { - QNDEBUG(QStringLiteral("SavedSearchSyncConflictResolver::onCacheFailed: ") + QNDEBUG("SavedSearchSyncConflictResolver::onCacheFailed: " << errorDescription); if (!m_pendingCacheFilling) { - QNDEBUG(QStringLiteral("Not pending the cache filling")); + QNDEBUG("Not pending the cache filling"); return; } @@ -322,7 +323,7 @@ void SavedSearchSyncConflictResolver::connectToLocalStorage() { - QNDEBUG(QStringLiteral("SavedSearchSyncConflictResolver::connectToLocalStorage")); + QNDEBUG("SavedSearchSyncConflictResolver::connectToLocalStorage"); // Connect local signals to local storage manager async's slots QObject::connect(this, @@ -394,8 +395,8 @@ void SavedSearchSyncConflictResolver::processSavedSearchesConflictByGuid() { - QNDEBUG(QStringLiteral("SavedSearchSyncConflictResolver::" - "processSavedSearchesConflictByGuid")); + QNDEBUG("SavedSearchSyncConflictResolver::" + "processSavedSearchesConflictByGuid"); // Need to understand whether there's a duplicate by name in the local storage // for the new state of the remote saved search @@ -405,24 +406,27 @@ const QHash<QString,QString> & guidByNameHash = m_cache.guidByNameHash(); auto it = guidByNameHash.find(m_remoteSavedSearch.name.ref().toLower()); if (it == guidByNameHash.end()) { - QNDEBUG(QStringLiteral("As deduced by the existing tag info cache, " - "there is no local tag with the same name " - "as the name from the new state of the remote " - "tag, can safely override the local changes " - "with the remote changes: ") << m_remoteSavedSearch); + QNDEBUG("As deduced by the existing tag info cache, " + << "there is no local tag with the same name " + << "as the name from the new state of the remote " + << "tag, can safely override the local changes " + << "with the remote changes: " << m_remoteSavedSearch); overrideLocalChangesWithRemoteChanges(); return; } - // NOTE: no else block because even if we know the duplicate saved search - // by name exists, we still need to have its full state in order to rename it + /** + * NOTE: no else block because even if we know the duplicate saved + * search by name exists, we still need to have its full state in order + * to rename it + */ } SavedSearch dummySearch; dummySearch.unsetLocalUid(); dummySearch.setName(m_remoteSavedSearch.name.ref()); m_findSavedSearchRequestId = QUuid::createUuid(); - QNTRACE(QStringLiteral("Emitting the request to find saved search: request id = ") - << m_findSavedSearchRequestId << QStringLiteral(", saved search: ") + QNTRACE("Emitting the request to find saved search: request id = " + << m_findSavedSearchRequestId << ", saved search: " << dummySearch); Q_EMIT findSavedSearch(dummySearch, m_findSavedSearchRequestId); } @@ -430,29 +434,29 @@ void SavedSearchSyncConflictResolver::processSavedSearchesConflictByName( const SavedSearch & localConflict) { - QNDEBUG(QStringLiteral("SavedSearchSyncConflictResolver::") - << QStringLiteral("processSavedSearchesConflictByName: local conflict = ") + QNDEBUG("SavedSearchSyncConflictResolver::" + << "processSavedSearchesConflictByName: local conflict = " << localConflict); if (localConflict.hasGuid() && (localConflict.guid() == m_remoteSavedSearch.guid.ref())) { - QNDEBUG(QStringLiteral("The conflicting saved searches match by name and " - "guid => the changes from the remote " - "saved search should override the local changes")); + QNDEBUG("The conflicting saved searches match by name and " + "guid => the changes from the remote " + "saved search should override the local changes"); overrideLocalChangesWithRemoteChanges(); return; } - QNDEBUG(QStringLiteral("The conflicting saved searches match by name but " - "not by guid => should rename the local conflicting " - "saved search to \"free\" the name it occupies")); + QNDEBUG("The conflicting saved searches match by name but " + "not by guid => should rename the local conflicting " + "saved search to \"free\" the name it occupies"); m_state = State::PendingConflictingSavedSearchRenaming; if (!m_cache.isFilled()) { - QNDEBUG(QStringLiteral("The cache of saved search info has not been filled yet")); + QNDEBUG("The cache of saved search info has not been filled yet"); QObject::connect(&m_cache, QNSIGNAL(SavedSearchSyncCache,filled), @@ -470,19 +474,19 @@ m_pendingCacheFilling = true; m_savedSearchToBeRenamed = localConflict; - QNTRACE(QStringLiteral("Emitting the request to fill the saved searches cache")); + QNTRACE("Emitting the request to fill the saved searches cache"); Q_EMIT fillSavedSearchesCache(); return; } - QNDEBUG(QStringLiteral("The cache of saved search info has already been filled")); + QNDEBUG("The cache of saved search info has already been filled"); renameConflictingLocalSavedSearch(localConflict); } void SavedSearchSyncConflictResolver::overrideLocalChangesWithRemoteChanges() { - QNDEBUG(QStringLiteral("SavedSearchSyncConflictResolver::" - "overrideLocalChangesWithRemoteChanges")); + QNDEBUG("SavedSearchSyncConflictResolver::" + "overrideLocalChangesWithRemoteChanges"); m_state = State::OverrideLocalChangesWithRemoteChanges; @@ -492,17 +496,16 @@ search.setLocal(false); m_updateSavedSearchRequestId = QUuid::createUuid(); - QNTRACE(QStringLiteral("Emitting the request to update saved search: request id = ") - << m_updateSavedSearchRequestId << QStringLiteral(" saved search: ") - << search); + QNTRACE("Emitting the request to update saved search: request id = " + << m_updateSavedSearchRequestId << " saved search: " << search); Q_EMIT updateSavedSearch(search, m_updateSavedSearchRequestId); } void SavedSearchSyncConflictResolver::renameConflictingLocalSavedSearch( const SavedSearch & localConflict) { - QNDEBUG(QStringLiteral("SavedSearchSyncConflictResolver::") - << QStringLiteral("renameConflictingLocalSavedSearch: local conflict = ") + QNDEBUG("SavedSearchSyncConflictResolver::" + << "renameConflictingLocalSavedSearch: local conflict = " << localConflict); QString name = (localConflict.hasName() @@ -530,9 +533,8 @@ search.setDirty(true); m_updateSavedSearchRequestId = QUuid::createUuid(); - QNTRACE(QStringLiteral("Emitting the request to update saved search: request id = ") - << m_updateSavedSearchRequestId << QStringLiteral(", saved search: ") - << search); + QNTRACE("Emitting the request to update saved search: request id = " + << m_updateSavedSearchRequestId << ", saved search: " << search); Q_EMIT updateSavedSearch(search, m_updateSavedSearchRequestId); } diff -Nru libquentier-0.5.0/src/synchronization/SavedSearchSyncConflictResolver.h libquentier-0.5.0/src/synchronization/SavedSearchSyncConflictResolver.h --- libquentier-0.5.0/src/synchronization/SavedSearchSyncConflictResolver.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/SavedSearchSyncConflictResolver.h 2019-07-11 10:46:53.000000000 +0000 @@ -64,14 +64,16 @@ private Q_SLOTS: void onAddSavedSearchComplete(SavedSearch search, QUuid requestId); - void onAddSavedSearchFailed(SavedSearch search, ErrorString errorDescription, + void onAddSavedSearchFailed(SavedSearch search, + ErrorString errorDescription, QUuid requestId); void onUpdateSavedSearchComplete(SavedSearch search, QUuid requestId); void onUpdateSavedSearchFailed(SavedSearch search, ErrorString errorDescription, QUuid requestId); void onFindSavedSearchComplete(SavedSearch search, QUuid requestId); - void onFindSavedSearchFailed(SavedSearch search, ErrorString errorDescription, + void onFindSavedSearchFailed(SavedSearch search, + ErrorString errorDescription, QUuid requestId); void onCacheFilled(); diff -Nru libquentier-0.5.0/src/synchronization/SendLocalChangesManager.cpp libquentier-0.5.0/src/synchronization/SendLocalChangesManager.cpp --- libquentier-0.5.0/src/synchronization/SendLocalChangesManager.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/SendLocalChangesManager.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -24,24 +24,25 @@ #include <quentier/logging/QuentierLogger.h> #include <QTimerEvent> -#define APPEND_NOTE_DETAILS(errorDescription, note) \ - if (note.hasTitle()) \ - { \ - errorDescription.details() = note.title(); \ - } \ - else if (note.hasContent()) \ - { \ - QString previewText = note.plainText(); \ - if (!previewText.isEmpty()) { \ - previewText.truncate(30); \ - errorDescription.details() = previewText; \ - } \ - } +#define APPEND_NOTE_DETAILS(errorDescription, note) \ + if (note.hasTitle()) \ + { \ + errorDescription.details() = note.title(); \ + } \ + else if (note.hasContent()) \ + { \ + QString previewText = note.plainText(); \ + if (!previewText.isEmpty()) { \ + previewText.truncate(30); \ + errorDescription.details() = previewText; \ + } \ + } \ +// APPEND_NOTE_DETAILS namespace quentier { -SendLocalChangesManager::SendLocalChangesManager(IManager & manager, - QObject * parent) : +SendLocalChangesManager::SendLocalChangesManager( + IManager & manager, QObject * parent) : QObject(parent), m_manager(manager), m_lastUpdateCount(0), @@ -86,11 +87,11 @@ } void SendLocalChangesManager::start( - const qint32 updateCount, QHash<QString,qint32> updateCountByLinkedNotebookGuid) + const qint32 updateCount, + QHash<QString,qint32> updateCountByLinkedNotebookGuid) { - QNDEBUG(QStringLiteral("SendLocalChangesManager::start: update count = ") - << updateCount - << QStringLiteral(", update count by linked notebook guid = ") + QNDEBUG("SendLocalChangesManager::start: update count = " + << updateCount << ", update count by linked notebook guid = " << updateCountByLinkedNotebookGuid); clear(); @@ -103,10 +104,10 @@ void SendLocalChangesManager::stop() { - QNDEBUG(QStringLiteral("SendLocalChangesManager::stop")); + QNDEBUG("SendLocalChangesManager::stop"); if (!m_active) { - QNDEBUG(QStringLiteral("Already stopped")); + QNDEBUG("Already stopped"); return; } @@ -117,25 +118,25 @@ } void SendLocalChangesManager::onAuthenticationTokensForLinkedNotebooksReceived( - QHash<QString,QPair<QString,QString> > authenticationTokensByLinkedNotebookGuid, - QHash<QString,qevercloud::Timestamp> authenticationTokenExpirationTimesByLinkedNotebookGuid) + QHash<QString,QPair<QString,QString> > authTokensByLinkedNotebookGuid, + QHash<QString,qevercloud::Timestamp> authTokenExpirationByLinkedNotebookGuid) { - QNDEBUG(QStringLiteral("SendLocalChangesManager::" - "onAuthenticationTokensForLinkedNotebooksReceived")); + QNDEBUG("SendLocalChangesManager::" + "onAuthenticationTokensForLinkedNotebooksReceived"); if (!m_pendingAuthenticationTokensForLinkedNotebooks) { - QNDEBUG(QStringLiteral("Authentication tokens for linked notebooks were " - "not requested by this object, won't do anything")); + QNDEBUG("Authentication tokens for linked notebooks were " + "not requested by this object, won't do anything"); return; } m_pendingAuthenticationTokensForLinkedNotebooks = false; m_authenticationTokensAndShardIdsByLinkedNotebookGuid = - authenticationTokensByLinkedNotebookGuid; + authTokensByLinkedNotebookGuid; m_authenticationTokenExpirationTimesByLinkedNotebookGuid = - authenticationTokenExpirationTimesByLinkedNotebookGuid; + authTokenExpirationByLinkedNotebookGuid; sendLocalChanges(); } @@ -156,26 +157,22 @@ if (userTagsListCompleted || (it != m_listDirtyTagsFromLinkedNotebooksRequestIds.end())) { - QNDEBUG(QStringLiteral("SendLocalChangesManager::onListDirtyTagsCompleted: ") - << QStringLiteral("flag = ") << flag << QStringLiteral(", limit = ") - << limit << QStringLiteral(", offset = ") << offset - << QStringLiteral(", order = ") << order - << QStringLiteral(", orderDirection = ") << orderDirection - << QStringLiteral(", linked notebook guid = ") << linkedNotebookGuid - << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", ") << tags.size() - << QStringLiteral(" tags listed")); + QNDEBUG("SendLocalChangesManager::onListDirtyTagsCompleted: " + << "flag = " << flag << ", limit = " << limit << ", offset = " + << offset << ", order = " << order << ", orderDirection = " + << orderDirection << ", linked notebook guid = " + << linkedNotebookGuid << ", requestId = " << requestId + << ", " << tags.size() << " tags listed"); m_tags << tags; if (userTagsListCompleted) { - QNTRACE(QStringLiteral("User's tags list is completed: ") - << m_tags.size() << QStringLiteral(" tags")); + QNTRACE("User's tags list is completed: " << m_tags.size() + << " tags"); m_listDirtyTagsRequestId = QUuid(); } else { - QNTRACE(QStringLiteral("Tags list is completed for one of " - "linked notebooks")); + QNTRACE("Tags list is completed for one of linked notebooks"); Q_UNUSED(m_listDirtyTagsFromLinkedNotebooksRequestIds.erase(it)); } @@ -199,14 +196,12 @@ if (userTagsListCompleted || (it != m_listDirtyTagsFromLinkedNotebooksRequestIds.end())) { - QNWARNING(QStringLiteral("SendLocalChangesManager::onListDirtyTagsFailed: ") - << QStringLiteral("flag = ") << flag << QStringLiteral(", limit = ") - << limit << QStringLiteral(", offset = ") << offset - << QStringLiteral(", order = ") << order - << QStringLiteral(", orderDirection = ") << orderDirection - << QStringLiteral(", linked notebook guid = ") << linkedNotebookGuid - << QStringLiteral(", error description = ") << errorDescription - << QStringLiteral(", requestId = ") << requestId); + QNWARNING("SendLocalChangesManager::onListDirtyTagsFailed: " + << "flag = " << flag << ", limit = " << limit << ", offset = " + << offset << ", order = " << order << ", orderDirection = " + << orderDirection << ", linked notebook guid = " + << linkedNotebookGuid << ", error description = " + << errorDescription << ", requestId = " << requestId); if (userTagsListCompleted) { m_listDirtyTagsRequestId = QUuid(); @@ -235,18 +230,14 @@ return; } - QNDEBUG(QStringLiteral("SendLocalChangesManager::onListDirtySavedSearchesCompleted: ") - << QStringLiteral("flag = ") << flag << QStringLiteral(", limit = ") - << limit << QStringLiteral(", offset = ") << offset - << QStringLiteral(", order = ") << order - << QStringLiteral(", orderDirection = ") << orderDirection - << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", ") << savedSearches.size() - << QStringLiteral(" saved searches listed")); + QNDEBUG("SendLocalChangesManager::onListDirtySavedSearchesCompleted: " + << "flag = " << flag << ", limit = " << limit << ", offset = " + << offset << ", order = " << order << ", orderDirection = " + << orderDirection << ", requestId = " << requestId << ", " + << savedSearches.size() << " saved searches listed"); m_savedSearches << savedSearches; - QNTRACE(QStringLiteral("Total ") << m_savedSearches.size() - << QStringLiteral(" dirty saved searches")); + QNTRACE("Total " << m_savedSearches.size() << " dirty saved searches"); m_listDirtySavedSearchesRequestId = QUuid(); @@ -260,21 +251,18 @@ LocalStorageManager::OrderDirection::type orderDirection, ErrorString errorDescription, QUuid requestId) { - QNTRACE(QStringLiteral("SendLocalChangesManager::onListDirtySavedSearchesFailed: ") - << QStringLiteral("request id = ") << requestId - << QStringLiteral(", error: ") << errorDescription); + QNTRACE("SendLocalChangesManager::onListDirtySavedSearchesFailed: " + << "request id = " << requestId << ", error: " << errorDescription); if (requestId != m_listDirtySavedSearchesRequestId) { return; } - QNWARNING(QStringLiteral("SendLocalChangesManager::onListDirtySavedSearchesFailed: ") - << QStringLiteral("flag = ") << flag << QStringLiteral(", limit = ") - << limit << QStringLiteral(", offset = ") << offset - << QStringLiteral(", order = ") << order - << QStringLiteral(", orderDirection = ") << orderDirection - << QStringLiteral(", errorDescription = ") << errorDescription - << QStringLiteral(", requestId = ") << requestId); + QNWARNING("SendLocalChangesManager::onListDirtySavedSearchesFailed: " + << "flag = " << flag << ", limit = " << limit << ", offset = " + << offset << ", order = " << order << ", orderDirection = " + << orderDirection << ", errorDescription = " << errorDescription + << ", requestId = " << requestId); m_listDirtySavedSearchesRequestId = QUuid(); @@ -302,21 +290,18 @@ if (userNotebooksListCompleted || (it != m_listDirtyNotebooksFromLinkedNotebooksRequestIds.end())) { - QNDEBUG(QStringLiteral("SendLocalChangesManager::onListDirtyNotebooksCompleted: ") - << QStringLiteral("flag = ") << flag << QStringLiteral(", limit = ") - << limit << QStringLiteral(", offset = ") << offset - << QStringLiteral(", order = ") << order - << QStringLiteral(", orderDirection = ") << orderDirection - << QStringLiteral(", linkedNotebookGuid = ") << linkedNotebookGuid - << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", ") << notebooks.size() - << QStringLiteral(" notebooks listed")); + QNDEBUG("SendLocalChangesManager::onListDirtyNotebooksCompleted: " + << "flag = " << flag << ", limit = " << limit << ", offset = " + << offset << ", order = " << order << ", orderDirection = " + << orderDirection << ", linkedNotebookGuid = " + << linkedNotebookGuid << ", requestId = " << requestId << ", " + << notebooks.size() << " notebooks listed"); m_notebooks << notebooks; if (userNotebooksListCompleted) { - QNTRACE(QStringLiteral("User's notebooks list is completed: ") - << m_notebooks.size() << QStringLiteral(" notebooks")); + QNTRACE("User's notebooks list is completed: " + << m_notebooks.size() << " notebooks"); m_listDirtyNotebooksRequestId = QUuid(); } else { @@ -343,13 +328,12 @@ if (userNotebooksListCompleted || (it != m_listDirtyNotebooksFromLinkedNotebooksRequestIds.end())) { - QNWARNING(QStringLiteral("SendLocalChangesManager::onListDirtyNotebooksFailed: ") - << QStringLiteral("flag = ") << flag << QStringLiteral(", limit = ") - << limit << QStringLiteral(", offset = ") << offset - << QStringLiteral(", order = ") << order - << QStringLiteral(", orderDirection = ") << orderDirection - << QStringLiteral(", linkedNotebookGuid = ") << linkedNotebookGuid - << QStringLiteral(", errorDescription = ") << errorDescription); + QNWARNING("SendLocalChangesManager::onListDirtyNotebooksFailed: " + << "flag = " << flag << ", limit = " << limit << ", offset = " + << offset << ", order = " << order << ", orderDirection = " + << orderDirection << ", linkedNotebookGuid = " + << linkedNotebookGuid << ", errorDescription = " + << errorDescription); if (userNotebooksListCompleted) { m_listDirtyNotebooksRequestId = QUuid(); @@ -383,22 +367,20 @@ if (userNotesListCompleted || (it != m_listDirtyNotesFromLinkedNotebooksRequestIds.end())) { - QNDEBUG(QStringLiteral("SendLocalChangesManager::onListDirtyNotesCompleted: ") - << QStringLiteral("flag = ") << flag - << QStringLiteral(", with resource metadata = ") + QNDEBUG("SendLocalChangesManager::onListDirtyNotesCompleted: " + << "flag = " << flag << ", with resource metadata = " << ((options & LocalStorageManager::GetNoteOption::WithResourceMetadata) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with resource binary data = ") + ? "true" + : "false") + << ", with resource binary data = " << ((options & LocalStorageManager::GetNoteOption::WithResourceBinaryData) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", limit = ") << limit << QStringLiteral(", offset = ") - << offset << QStringLiteral(", order = ") << order - << QStringLiteral(", orderDirection = ") << orderDirection - << QStringLiteral(", linked notebook guid = ") << linkedNotebookGuid - << QStringLiteral(", requestId = ") << requestId << QStringLiteral(", ") - << notes.size() << QStringLiteral(" notes listed")); + ? "true" + : "false") + << ", limit = " << limit << ", offset = " << offset + << ", order = " << order << ", orderDirection = " + << orderDirection << ", linked notebook guid = " + << linkedNotebookGuid << ", requestId = " << requestId << ", " + << notes.size() << " notes listed"); m_notes << notes; @@ -430,21 +412,19 @@ if (userNotesListCompleted || (it != m_listDirtyNotesFromLinkedNotebooksRequestIds.end())) { - QNWARNING(QStringLiteral("SendLocalChangesManager::onListDirtyNotesFailed: ") - << QStringLiteral("flag = ") << flag - << QStringLiteral(", with resource metadata = ") + QNWARNING("SendLocalChangesManager::onListDirtyNotesFailed: " + << "flag = " << flag << ", with resource metadata = " << ((options & LocalStorageManager::GetNoteOption::WithResourceMetadata) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with resource binary data = ") + ? "true" + : "false") + << ", with resource binary data = " << ((options & LocalStorageManager::GetNoteOption::WithResourceBinaryData) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", limit = ") << limit << QStringLiteral(", offset = ") - << offset << QStringLiteral(", order = ") << order - << QStringLiteral(", orderDirection = ") << orderDirection - << QStringLiteral(", linked notebook guid = ") << linkedNotebookGuid - << QStringLiteral(", requestId = ") << requestId); + ? "true" + : "false") + << ", limit = " << limit << ", offset = " << offset + << ", order = " << order << ", orderDirection = " + << orderDirection << ", linked notebook guid = " + << linkedNotebookGuid << ", requestId = " << requestId); if (userNotesListCompleted) { m_listDirtyNotesRequestId = QUuid(); @@ -473,13 +453,11 @@ return; } - QNDEBUG(QStringLiteral("SendLocalChangesManager::onListLinkedNotebooksCompleted: ") - << QStringLiteral("flag = ") << flag << QStringLiteral(", limit = ") - << limit << QStringLiteral(", offset = ") << offset - << QStringLiteral(", order = ") << order - << QStringLiteral(", orderDirection = ") << orderDirection - << QStringLiteral(", requestId = ") << requestId << QStringLiteral(", ") - << QStringLiteral(" linked notebooks listed")); + QNDEBUG("SendLocalChangesManager::onListLinkedNotebooksCompleted: " + << "flag = " << flag << ", limit = " << limit << ", offset = " + << offset << ", order = " << order << ", orderDirection = " + << orderDirection << ", requestId = " << requestId << ", " + << " linked notebooks listed"); const int numLinkedNotebooks = linkedNotebooks.size(); m_linkedNotebookAuthData.reserve(std::max(numLinkedNotebooks, 0)); @@ -493,15 +471,14 @@ const LinkedNotebook & linkedNotebook = linkedNotebooks[i]; if (!linkedNotebook.hasGuid()) { - ErrorString error(QT_TR_NOOP("Internal error: found a linked notebook " - "without guid")); + ErrorString error(QT_TR_NOOP("Internal error: found a linked " + "notebook without guid")); if (linkedNotebook.hasUsername()) { error.details() = linkedNotebook.username(); } Q_EMIT failure(error); - QNWARNING(error << QStringLiteral(", linked notebook: ") - << linkedNotebook); + QNWARNING(error << ", linked notebook: " << linkedNotebook); return; } @@ -545,13 +522,11 @@ return; } - QNWARNING(QStringLiteral("SendLocalChangesManager::onListLinkedNotebooksFailed: ") - << QStringLiteral( "flag = ") << flag << QStringLiteral(", limit = ") - << limit << QStringLiteral(", offset = ") << offset - << QStringLiteral(", order = ") << order - << QStringLiteral(", orderDirection = ") << orderDirection - << QStringLiteral(", errorDescription = ") << errorDescription - << QStringLiteral(", requestId = ") << requestId); + QNWARNING("SendLocalChangesManager::onListLinkedNotebooksFailed: " + << "flag = " << flag << ", limit = " << limit << ", offset = " + << offset << ", order = " << order << ", orderDirection = " + << orderDirection << ", errorDescription = " << errorDescription + << ", requestId = " << requestId); m_listLinkedNotebooksRequestId = QUuid(); @@ -570,8 +545,8 @@ return; } - QNDEBUG(QStringLiteral("SendLocalChangesManager::onUpdateTagCompleted: tag = ") - << tag << QStringLiteral("\nRequest id = ") << requestId); + QNDEBUG("SendLocalChangesManager::onUpdateTagCompleted: tag = " + << tag << "\nRequest id = " << requestId); Q_UNUSED(m_updateTagRequestIds.erase(it)); if (m_tags.isEmpty() && m_updateTagRequestIds.isEmpty()) { @@ -579,18 +554,17 @@ } } -void SendLocalChangesManager::onUpdateTagFailed(Tag tag, - ErrorString errorDescription, - QUuid requestId) +void SendLocalChangesManager::onUpdateTagFailed( + Tag tag, ErrorString errorDescription, QUuid requestId) { auto it = m_updateTagRequestIds.find(requestId); if (it == m_updateTagRequestIds.end()) { return; } - QNWARNING(QStringLiteral("SendLocalChangesManager::onUpdateTagFailed: tag = ") - << tag << QStringLiteral("\nRequest id = ") << requestId - << QStringLiteral(", error description = ") << errorDescription); + QNWARNING("SendLocalChangesManager::onUpdateTagFailed: tag = " + << tag << "\nRequest id = " << requestId + << ", error description = " << errorDescription); Q_UNUSED(m_updateTagRequestIds.erase(it)); @@ -601,17 +575,16 @@ Q_EMIT failure(error); } -void SendLocalChangesManager::onUpdateSavedSearchCompleted(SavedSearch savedSearch, - QUuid requestId) +void SendLocalChangesManager::onUpdateSavedSearchCompleted( + SavedSearch savedSearch, QUuid requestId) { auto it = m_updateSavedSearchRequestIds.find(requestId); if (it == m_updateSavedSearchRequestIds.end()) { return; } - QNDEBUG(QStringLiteral("SendLocalChangesManager::onUpdateSavedSearchCompleted: ") - << QStringLiteral("search = ") << savedSearch - << QStringLiteral("\nRequest id = ") << requestId); + QNDEBUG("SendLocalChangesManager::onUpdateSavedSearchCompleted: " + << "search = " << savedSearch << "\nRequest id = " << requestId); Q_UNUSED(m_updateSavedSearchRequestIds.erase(it)); if (m_savedSearches.isEmpty() && m_updateSavedSearchRequestIds.isEmpty()) { @@ -619,19 +592,18 @@ } } -void SendLocalChangesManager::onUpdateSavedSearchFailed(SavedSearch savedSearch, - ErrorString errorDescription, - QUuid requestId) +void SendLocalChangesManager::onUpdateSavedSearchFailed( + SavedSearch savedSearch, ErrorString errorDescription, QUuid requestId) { auto it = m_updateSavedSearchRequestIds.find(requestId); if (it == m_updateSavedSearchRequestIds.end()) { return; } - QNWARNING(QStringLiteral("SendLocalChangesManager::onUpdateSavedSearchFailed: ") - << QStringLiteral("saved search = ") << savedSearch - << QStringLiteral("\nRequest id = ") << requestId - << QStringLiteral(", error description = ") << errorDescription); + QNWARNING("SendLocalChangesManager::onUpdateSavedSearchFailed: " + << "saved search = " << savedSearch + << "\nRequest id = " << requestId + << ", error description = " << errorDescription); Q_UNUSED(m_updateSavedSearchRequestIds.erase(it)); @@ -643,17 +615,17 @@ Q_EMIT failure(error); } -void SendLocalChangesManager::onUpdateNotebookCompleted(Notebook notebook, - QUuid requestId) +void SendLocalChangesManager::onUpdateNotebookCompleted( + Notebook notebook, QUuid requestId) { auto it = m_updateNotebookRequestIds.find(requestId); if (it == m_updateNotebookRequestIds.end()) { return; } - QNDEBUG(QStringLiteral("SendLocalChangesManager::onUpdateNotebookCompleted: ") - << QStringLiteral("notebook = ") << notebook - << QStringLiteral("\nRequest id = ") << requestId); + QNDEBUG("SendLocalChangesManager::onUpdateNotebookCompleted: " + << "notebook = " << notebook + << "\nRequest id = " << requestId); Q_UNUSED(m_updateNotebookRequestIds.erase(it)); if (m_notebooks.isEmpty() && m_updateNotebookRequestIds.isEmpty()) { @@ -661,23 +633,23 @@ } } -void SendLocalChangesManager::onUpdateNotebookFailed(Notebook notebook, - ErrorString errorDescription, - QUuid requestId) +void SendLocalChangesManager::onUpdateNotebookFailed( + Notebook notebook, ErrorString errorDescription, QUuid requestId) { auto it = m_updateNotebookRequestIds.find(requestId); if (it == m_updateNotebookRequestIds.end()) { return; } - QNWARNING(QStringLiteral("SendLocalChangesManager::onUpdateNotebookFailed: ") - << QStringLiteral("notebook = ") << notebook - << QStringLiteral("\nRequest id = ") << requestId - << QStringLiteral(", error description = ") << errorDescription); + QNWARNING("SendLocalChangesManager::onUpdateNotebookFailed: " + << "notebook = " << notebook + << "\nRequest id = " << requestId + << ", error description = " << errorDescription); Q_UNUSED(m_updateNotebookRequestIds.erase(it)); - ErrorString error(QT_TR_NOOP("Failed to update a notebook in the local storage")); + ErrorString error(QT_TR_NOOP("Failed to update a notebook in the local " + "storage")); error.additionalBases().append(errorDescription.base()); error.additionalBases().append(errorDescription.additionalBases()); error.details() = errorDescription.details(); @@ -694,8 +666,8 @@ return; } - QNDEBUG(QStringLiteral("SendLocalChangesManager::onUpdateNoteCompleted: note = ") - << note << QStringLiteral("\nRequest id = ") << requestId); + QNDEBUG("SendLocalChangesManager::onUpdateNoteCompleted: note = " + << note << "\nRequest id = " << requestId); Q_UNUSED(m_updateNoteRequestIds.erase(it)); if (m_notes.isEmpty() && m_updateNoteRequestIds.isEmpty()) { @@ -714,9 +686,9 @@ return; } - QNWARNING(QStringLiteral("SendLocalChangesManager::onUpdateNoteFailed: note = ") - << note << QStringLiteral("\nRequest id = ") << requestId - << QStringLiteral(", error description = ") << errorDescription); + QNWARNING("SendLocalChangesManager::onUpdateNoteFailed: note = " + << note << "\nRequest id = " << requestId + << ", error description = " << errorDescription); Q_UNUSED(m_updateNoteRequestIds.erase(it)); @@ -727,17 +699,16 @@ Q_EMIT failure(error); } -void SendLocalChangesManager::onFindNotebookCompleted(Notebook notebook, - QUuid requestId) +void SendLocalChangesManager::onFindNotebookCompleted( + Notebook notebook, QUuid requestId) { auto it = m_findNotebookRequestIds.find(requestId); if (it == m_findNotebookRequestIds.end()) { return; } - QNDEBUG(QStringLiteral("SendLocalChangesManager::onFindNotebookCompleted: ") - << QStringLiteral("notebook = ") << notebook - << QStringLiteral("\nRequest id = ") << requestId); + QNDEBUG("SendLocalChangesManager::onFindNotebookCompleted: " + << "notebook = " << notebook << "\nRequest id = " << requestId); if (!notebook.hasGuid()) { @@ -748,7 +719,7 @@ errorDescription.details() = notebook.name(); } - QNWARNING(errorDescription << QStringLiteral(", notebook: ") << notebook); + QNWARNING(errorDescription << ", notebook: " << notebook); Q_EMIT failure(errorDescription); return; } @@ -761,9 +732,8 @@ } } -void SendLocalChangesManager::onFindNotebookFailed(Notebook notebook, - ErrorString errorDescription, - QUuid requestId) +void SendLocalChangesManager::onFindNotebookFailed( + Notebook notebook, ErrorString errorDescription, QUuid requestId) { auto it = m_findNotebookRequestIds.find(requestId); if (it == m_findNotebookRequestIds.end()) { @@ -772,13 +742,13 @@ Q_UNUSED(m_findNotebookRequestIds.erase(it)); - QNWARNING(errorDescription << QStringLiteral("; notebook: ") << notebook); + QNWARNING(errorDescription << "; notebook: " << notebook); Q_EMIT failure(errorDescription); } void SendLocalChangesManager::timerEvent(QTimerEvent * pEvent) { - QNDEBUG(QStringLiteral("SendLocalChangesManager::timerEvent")); + QNDEBUG("SendLocalChangesManager::timerEvent"); if (Q_UNLIKELY(!pEvent)) { ErrorString errorDescription(QT_TR_NOOP("Qt error: detected null pointer " @@ -790,7 +760,7 @@ int timerId = pEvent->timerId(); killTimer(timerId); - QNDEBUG(QStringLiteral("Killed timer with id ") << timerId); + QNDEBUG("Killed timer with id " << timerId); if (timerId == m_sendTagsPostponeTimerId) { @@ -816,10 +786,10 @@ void SendLocalChangesManager::connectToLocalStorage() { - QNDEBUG(QStringLiteral("SendLocalChangesManager::connectToLocalStorage")); + QNDEBUG("SendLocalChangesManager::connectToLocalStorage"); if (m_connectedToLocalStorage) { - QNDEBUG(QStringLiteral("Already connected to local storage")); + QNDEBUG("Already connected to local storage"); return; } @@ -1145,10 +1115,10 @@ void SendLocalChangesManager::disconnectFromLocalStorage() { - QNDEBUG(QStringLiteral("SendLocalChangesManager::disconnectFromLocalStorage")); + QNDEBUG("SendLocalChangesManager::disconnectFromLocalStorage"); if (!m_connectedToLocalStorage) { - QNDEBUG(QStringLiteral("Not connected to local storage at the moment")); + QNDEBUG("Not connected to local storage at the moment"); return; } @@ -1246,13 +1216,25 @@ QNSLOT(LocalStorageManagerAsync,onUpdateSavedSearchRequest, SavedSearch,QUuid)); QObject::disconnect(this, - QNSIGNAL(SendLocalChangesManager,updateNotebook,Notebook,QUuid), &localStorageManagerAsync, - QNSLOT(LocalStorageManagerAsync,onUpdateNotebookRequest,Notebook,QUuid)); - QObject::disconnect(this, QNSIGNAL(SendLocalChangesManager,updateNote,Note,LocalStorageManager::UpdateNoteOptions,QUuid), - &localStorageManagerAsync, QNSLOT(LocalStorageManagerAsync,onUpdateNoteRequest,Note,LocalStorageManager::UpdateNoteOptions,QUuid)); + QNSIGNAL(SendLocalChangesManager,updateNotebook, + Notebook,QUuid), + &localStorageManagerAsync, + QNSLOT(LocalStorageManagerAsync,onUpdateNotebookRequest, + Notebook,QUuid)); + QObject::disconnect(this, QNSIGNAL(SendLocalChangesManager,updateNote,Note, + LocalStorageManager::UpdateNoteOptions, + QUuid), + &localStorageManagerAsync, + QNSLOT(LocalStorageManagerAsync,onUpdateNoteRequest, + Note,LocalStorageManager::UpdateNoteOptions, + QUuid)); - QObject::disconnect(this, QNSIGNAL(SendLocalChangesManager,findNotebook,Notebook,QUuid), &localStorageManagerAsync, - QNSLOT(LocalStorageManagerAsync,onFindNotebookRequest,Notebook,QUuid)); + QObject::disconnect(this, + QNSIGNAL(SendLocalChangesManager,findNotebook, + Notebook,QUuid), + &localStorageManagerAsync, + QNSLOT(LocalStorageManagerAsync,onFindNotebookRequest, + Notebook,QUuid)); // Disconnect localStorageManagerAsync's signals from local slots QObject::disconnect(&localStorageManagerAsync, @@ -1483,25 +1465,26 @@ bool SendLocalChangesManager::requestStuffFromLocalStorage( const QString & linkedNotebookGuid) { - QNDEBUG(QStringLiteral("SendLocalChangesManager::requestStuffFromLocalStorage: ") - << QStringLiteral("linked notebook guid = ") - << linkedNotebookGuid << QStringLiteral(" (empty = ") + QNDEBUG("SendLocalChangesManager::requestStuffFromLocalStorage: " + << "linked notebook guid = " << linkedNotebookGuid << " (empty = " << (linkedNotebookGuid.isEmpty() - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", null = ") + ? "true" + : "false") + << ", null = " << (linkedNotebookGuid.isNull() - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(")")); + ? "true" + : "false") + << ")"); bool emptyLinkedNotebookGuid = linkedNotebookGuid.isEmpty(); if (!emptyLinkedNotebookGuid) { - auto it = m_linkedNotebookGuidsForWhichStuffWasRequestedFromLocalStorage.find(linkedNotebookGuid); + auto it = + m_linkedNotebookGuidsForWhichStuffWasRequestedFromLocalStorage.find( + linkedNotebookGuid); if (it != m_linkedNotebookGuidsForWhichStuffWasRequestedFromLocalStorage.end()) { - QNDEBUG(QStringLiteral("The stuff has already been requested from ") - << QStringLiteral("the local storage for linked notebook guid ") + QNDEBUG("The stuff has already been requested from " + << "the local storage for linked notebook guid " << linkedNotebookGuid); return false; } @@ -1527,8 +1510,8 @@ Q_UNUSED(m_listDirtyTagsFromLinkedNotebooksRequestIds.insert( listDirtyTagsRequestId)); } - QNTRACE(QStringLiteral("Emitting the request to fetch unsynchronized tags ") - << QStringLiteral("from the local storage: request id = ") + QNTRACE("Emitting the request to fetch unsynchronized tags " + << "from the local storage: request id = " << listDirtyTagsRequestId); Q_EMIT requestLocalUnsynchronizedTags(listDirtyObjectsFlag, limit, offset, tagsOrder, orderDirection, @@ -1540,14 +1523,15 @@ LocalStorageManager::ListSavedSearchesOrder::NoOrder; m_listDirtySavedSearchesRequestId = QUuid::createUuid(); - QNTRACE(QStringLiteral("Emitting the request to fetch unsynchronized ") - << QStringLiteral("saved searches from the local storage: request id = ") + QNTRACE("Emitting the request to fetch unsynchronized " + << "saved searches from the local storage: request id = " << m_listDirtySavedSearchesRequestId); - Q_EMIT requestLocalUnsynchronizedSavedSearches(listDirtyObjectsFlag, - limit, offset, - savedSearchesOrder, - orderDirection, - m_listDirtySavedSearchesRequestId); + Q_EMIT requestLocalUnsynchronizedSavedSearches( + listDirtyObjectsFlag, + limit, offset, + savedSearchesOrder, + orderDirection, + m_listDirtySavedSearchesRequestId); } LocalStorageManager::ListNotebooksOrder::type notebooksOrder = @@ -1562,13 +1546,14 @@ listDirtyNotebooksRequestId)); } - QNTRACE(QStringLiteral("Emitting the request to fetch unsynchronized notebooks ") - << QStringLiteral("from the local storage: request id = ") + QNTRACE("Emitting the request to fetch unsynchronized notebooks " + << "from the local storage: request id = " << listDirtyNotebooksRequestId); - Q_EMIT requestLocalUnsynchronizedNotebooks(listDirtyObjectsFlag, limit, - offset, notebooksOrder, - orderDirection, linkedNotebookGuid, - listDirtyNotebooksRequestId); + Q_EMIT requestLocalUnsynchronizedNotebooks( + listDirtyObjectsFlag, limit, + offset, notebooksOrder, + orderDirection, linkedNotebookGuid, + listDirtyNotebooksRequestId); LocalStorageManager::ListNotesOrder::type notesOrder = LocalStorageManager::ListNotesOrder::NoOrder; @@ -1581,15 +1566,16 @@ Q_UNUSED(m_listDirtyNotesFromLinkedNotebooksRequestIds.insert( listDirtyNotesRequestId)); } - QNTRACE(QStringLiteral("Emitting the request to fetch unsynchronized notes ") - << QStringLiteral("from the local storage: request id = ") + QNTRACE("Emitting the request to fetch unsynchronized notes " + << "from the local storage: request id = " << listDirtyNotesRequestId); LocalStorageManager::GetNoteOptions getNoteOptions( LocalStorageManager::GetNoteOption::WithResourceMetadata | LocalStorageManager::GetNoteOption::WithResourceBinaryData); - Q_EMIT requestLocalUnsynchronizedNotes(listDirtyObjectsFlag, getNoteOptions, - limit, offset, notesOrder, orderDirection, - linkedNotebookGuid, listDirtyNotesRequestId); + Q_EMIT requestLocalUnsynchronizedNotes( + listDirtyObjectsFlag, getNoteOptions, + limit, offset, notesOrder, orderDirection, + linkedNotebookGuid, listDirtyNotesRequestId); if (emptyLinkedNotebookGuid) { @@ -1598,8 +1584,8 @@ LocalStorageManager::ListLinkedNotebooksOrder::type linkedNotebooksOrder = LocalStorageManager::ListLinkedNotebooksOrder::NoOrder; m_listLinkedNotebooksRequestId = QUuid::createUuid(); - QNTRACE(QStringLiteral("Emitting the request to fetch unsynchronized ") - << QStringLiteral("linked notebooks from the local storage: request id = ") + QNTRACE("Emitting the request to fetch unsynchronized " + << "linked notebooks from the local storage: request id = " << m_listLinkedNotebooksRequestId); Q_EMIT requestLinkedNotebooksList(linkedNotebooksListOption, limit, offset, linkedNotebooksOrder, orderDirection, @@ -1616,48 +1602,47 @@ void SendLocalChangesManager::checkListLocalStorageObjectsCompletion() { - QNDEBUG(QStringLiteral("SendLocalChangesManager::" - "checkListLocalStorageObjectsCompletion")); + QNDEBUG("SendLocalChangesManager::" + "checkListLocalStorageObjectsCompletion"); if (!m_listDirtyTagsRequestId.isNull()) { - QNTRACE(QStringLiteral("The last request for the list of new and dirty " - "tags was not processed yet")); + QNTRACE("The last request for the list of new and dirty " + "tags was not processed yet"); return; } if (!m_listDirtySavedSearchesRequestId.isNull()) { - QNTRACE(QStringLiteral("The last request for the list of new and dirty " - "saved searches was not processed yet")); + QNTRACE("The last request for the list of new and dirty " + "saved searches was not processed yet"); return; } if (!m_listDirtyNotebooksRequestId.isNull()) { - QNTRACE(QStringLiteral("The last request for the list of new and dirty " - "notebooks was not processed yet")); + QNTRACE("The last request for the list of new and dirty " + "notebooks was not processed yet"); return; } if (!m_listDirtyNotesRequestId.isNull()) { - QNTRACE(QStringLiteral("The last request for the list of new and dirty " - "notes was not processed yet")); + QNTRACE("The last request for the list of new and dirty " + "notes was not processed yet"); return; } if (!m_listLinkedNotebooksRequestId.isNull()) { - QNTRACE(QStringLiteral("The last request for the list of linked notebooks " - "was not processed yet")); + QNTRACE("The last request for the list of linked notebooks " + "was not processed yet"); return; } if (!m_receivedDirtyLocalStorageObjectsFromUsersAccount) { m_receivedDirtyLocalStorageObjectsFromUsersAccount = true; - QNTRACE(QStringLiteral("Received all dirty objects from user's own account ") - << QStringLiteral("from the local storage: ") << m_tags.size() - << QStringLiteral(" tags, ") << m_savedSearches.size() - << QStringLiteral(" saved searches, ") << m_notebooks.size() - << QStringLiteral(" notebooks and ") << m_notes.size() - << QStringLiteral(" notes")); + QNTRACE("Received all dirty objects from user's own account " + << "from the local storage: " << m_tags.size() + << " tags, " << m_savedSearches.size() + << " saved searches, " << m_notebooks.size() + << " notebooks and " << m_notes.size() << " notes"); if (!m_tags.isEmpty() || !m_savedSearches.isEmpty() || !m_notebooks.isEmpty() || !m_notes.isEmpty()) @@ -1668,10 +1653,10 @@ if (!m_linkedNotebookAuthData.isEmpty()) { - QNTRACE(QStringLiteral("There are ") << m_linkedNotebookAuthData.size() - << QStringLiteral(" linked notebook guids, need to check if there " - "are those for which there is no pending request " - "to list stuff from the local storage yet")); + QNTRACE("There are " << m_linkedNotebookAuthData.size() + << " linked notebook guids, need to check if there " + << "are those for which there is no pending request " + << "to list stuff from the local storage yet"); bool requestedStuffForSomeLinkedNotebook = false; @@ -1684,35 +1669,35 @@ } if (requestedStuffForSomeLinkedNotebook) { - QNDEBUG(QStringLiteral("Sent one or more list stuff from linked " - "notebooks from the local storage request ids")); + QNDEBUG("Sent one or more list stuff from linked " + "notebooks from the local storage request ids"); return; } if (!m_listDirtyTagsFromLinkedNotebooksRequestIds.isEmpty()) { - QNTRACE(QStringLiteral("There are pending requests to list tags from " - "linked notebooks from the local storage: ") + QNTRACE("There are pending requests to list tags from " + << "linked notebooks from the local storage: " << m_listDirtyTagsFromLinkedNotebooksRequestIds.size()); return; } if (!m_listDirtyNotebooksFromLinkedNotebooksRequestIds.isEmpty()) { - QNTRACE(QStringLiteral("There are pending requests to list notebooks " - "from linked notebooks from the local storage: ") + QNTRACE("There are pending requests to list notebooks " + << "from linked notebooks from the local storage: " << m_listDirtyNotebooksFromLinkedNotebooksRequestIds.size()); return; } if (!m_listDirtyNotesFromLinkedNotebooksRequestIds.isEmpty()) { - QNTRACE(QStringLiteral("There are pending requests to list notes from " - "linked notebooks from the local storage: ") + QNTRACE("There are pending requests to list notes from " + << "linked notebooks from the local storage: " << m_listDirtyNotesFromLinkedNotebooksRequestIds.size()); return; } } m_receivedAllDirtyLocalStorageObjects = true; - QNTRACE(QStringLiteral("All relevant objects from the local storage have been listed")); + QNTRACE("All relevant objects from the local storage have been listed"); if (!m_tags.isEmpty() || !m_savedSearches.isEmpty() || !m_notebooks.isEmpty() || !m_notes.isEmpty()) @@ -1725,25 +1710,26 @@ } else { - QNINFO(QStringLiteral("No modified or new synchronizable objects were " - "found in the local storage, nothing to send to " - "Evernote service")); + QNINFO("No modified or new synchronizable objects were " + "found in the local storage, nothing to send to " + "Evernote service"); finalize(); } } void SendLocalChangesManager::sendLocalChanges() { - QNDEBUG(QStringLiteral("SendLocalChangesManager::sendLocalChanges")); + QNDEBUG("SendLocalChangesManager::sendLocalChanges"); if (!checkAndRequestAuthenticationTokensForLinkedNotebooks()) { return; } -#define CHECK_RATE_LIMIT() \ - if (rateLimitIsActive()) { \ - return; \ - } +#define CHECK_RATE_LIMIT() \ + if (rateLimitIsActive()) { \ + return; \ + } \ +// CHECK_RATE_LIMIT if (!m_tags.isEmpty()) { sendTags(); @@ -1761,16 +1747,18 @@ } if (!m_notes.isEmpty()) { - // NOTE: in case of API rate limits breaching this can be done multiple times - // but it's safer to do overwork than not to do some important missing piece - // so it's ok to repeatedly search for notebooks here + /** + * NOTE: in case of API rate limits breaching this can be done multiple + * times but it's safer to do overwork than not to do some important + * missing piece so it's ok to repeatedly search for notebooks here + */ findNotebooksForNotes(); } } void SendLocalChangesManager::sendTags() { - QNDEBUG(QStringLiteral("SendLocalChangesManager::sendTags")); + QNDEBUG("SendLocalChangesManager::sendTags"); ErrorString errorDescription; bool res = sortTagsByParentChildRelations(m_tags, errorDescription); @@ -1808,25 +1796,25 @@ } else { - errorDescription.setBase(QT_TR_NOOP("Couldn't find the auth token " - "for a linked notebook when " - "attempting to create or update " - "a tag from it")); + errorDescription.setBase( + QT_TR_NOOP("Couldn't find the auth token " + "for a linked notebook when attempting to " + "create or update a tag from it")); if (tag.hasName()) { errorDescription.details() = tag.name(); } - QNWARNING(errorDescription << QStringLiteral(", tag: ") << tag); + QNWARNING(errorDescription << ", tag: " << tag); auto sit = std::find_if(m_linkedNotebookAuthData.begin(), m_linkedNotebookAuthData.end(), CompareLinkedNotebookAuthDataByGuid( tag.linkedNotebookGuid())); if (sit == m_linkedNotebookAuthData.end()) { - QNWARNING(QStringLiteral("The linked notebook the tag refers " - "to was not found within the list " - "of linked notebooks received " - "from the local storage!")); + QNWARNING("The linked notebook the tag refers " + "to was not found within the list " + "of linked notebooks received " + "from the local storage!"); } Q_EMIT failure(errorDescription); @@ -1843,15 +1831,15 @@ } else { - errorDescription.setBase(QT_TR_NOOP("Couldn't find the note store " - "URL for a linked notebook " - "when attempting to create " - "or update a tag from it")); + errorDescription.setBase( + QT_TR_NOOP("Couldn't find the note store " + "URL for a linked notebook when attempting to " + "create or update a tag from it")); if (tag.hasName()) { errorDescription.details() = tag.name(); } - QNWARNING(errorDescription << QStringLiteral(", tag: ") << tag); + QNWARNING(errorDescription << ", tag: " << tag); Q_EMIT failure(errorDescription); return; @@ -1867,25 +1855,23 @@ linkedNotebook.setNoteStoreUrl(linkedNotebookNoteStoreUrl); pNoteStore = m_manager.noteStoreForLinkedNotebook(linkedNotebook); - if (Q_UNLIKELY(!pNoteStore)) { - errorDescription.setBase(QT_TR_NOOP("Can't send new or modified " - "tag: can't find or create " - "a note store for the linked " - "notebook")); - QNWARNING(errorDescription - << QStringLiteral(", linked notebook guid = ") + if (Q_UNLIKELY(!pNoteStore)) + { + errorDescription.setBase( + QT_TR_NOOP("Can't send new or modified tag: can't find or " + "create a note store for the linked notebook")); + QNWARNING(errorDescription << ", linked notebook guid = " << tag.linkedNotebookGuid()); Q_EMIT failure(errorDescription); return; } - if (Q_UNLIKELY(pNoteStore->noteStoreUrl().isEmpty())) { - ErrorString errorDescription(QT_TR_NOOP("Internal error: empty " - "note store url for " - "the linked notebook's " - "note store")); - QNWARNING(errorDescription - << QStringLiteral(", linked notebook guid = ") + if (Q_UNLIKELY(pNoteStore->noteStoreUrl().isEmpty())) + { + ErrorString errorDescription( + QT_TR_NOOP("Internal error: empty note store url for " + "the linked notebook's note store")); + QNWARNING(errorDescription << ", linked notebook guid = " << tag.linkedNotebookGuid()); Q_EMIT failure(errorDescription); return; @@ -1898,13 +1884,13 @@ bool creatingTag = !tag.hasUpdateSequenceNumber(); if (creatingTag) { - QNTRACE(QStringLiteral("Sending new tag: ") << tag); + QNTRACE("Sending new tag: " << tag); errorCode = pNoteStore->createTag(tag, errorDescription, rateLimitSeconds, linkedNotebookAuthToken); } else { - QNTRACE(QStringLiteral("Sending modified tag: ") << tag); + QNTRACE("Sending modified tag: " << tag); errorCode = pNoteStore->updateTag(tag, errorDescription, rateLimitSeconds, linkedNotebookAuthToken); @@ -1912,7 +1898,8 @@ if (errorCode == qevercloud::EDAMErrorCode::RATE_LIMIT_REACHED) { - if (rateLimitSeconds < 0) { + if (rateLimitSeconds < 0) + { errorDescription.setBase(QT_TR_NOOP("Rate limit reached but " "the number of seconds " "to wait is incorrect")); @@ -1923,7 +1910,8 @@ } int timerId = startTimer(SEC_TO_MSEC(rateLimitSeconds)); - if (Q_UNLIKELY(timerId == 0)) { + if (Q_UNLIKELY(timerId == 0)) + { errorDescription.setBase(QT_TR_NOOP("Failed to start a timer to " "postpone the Evernote API " "call due to rate limit " @@ -1935,11 +1923,11 @@ m_sendTagsPostponeTimerId = timerId; - QNINFO(QStringLiteral("Encountered API rate limits exceeding during ") - << QStringLiteral("the attempt to send new or modified tag, ") - << QStringLiteral(", will need to wait for ") - << rateLimitSeconds << QStringLiteral(" seconds")); - QNDEBUG(QStringLiteral("Send tags postpone timer id = ") << timerId); + QNINFO("Encountered API rate limits exceeding during " + << "the attempt to send new or modified tag, " + << ", will need to wait for " << rateLimitSeconds + << " seconds"); + QNDEBUG("Send tags postpone timer id = " << timerId); Q_EMIT rateLimitExceeded(rateLimitSeconds); return; @@ -1952,26 +1940,25 @@ } else { - auto cit = m_authenticationTokenExpirationTimesByLinkedNotebookGuid.find( - tag.linkedNotebookGuid()); + auto cit = + m_authenticationTokenExpirationTimesByLinkedNotebookGuid.find( + tag.linkedNotebookGuid()); if (cit == m_authenticationTokenExpirationTimesByLinkedNotebookGuid.end()) { - errorDescription.setBase(QT_TR_NOOP("Couldn't find " - "the expiration time of " - "a linked notebook's " - "authentication token")); - QNWARNING(errorDescription - << QStringLiteral(", linked notebook guid = ") + errorDescription.setBase( + QT_TR_NOOP("Couldn't find the expiration time of " + "a linked notebook's authentication token")); + QNWARNING(errorDescription << ", linked notebook guid = " << tag.linkedNotebookGuid()); Q_EMIT failure(errorDescription); } - else if (checkAndRequestAuthenticationTokensForLinkedNotebooks()) { - errorDescription.setBase(QT_TR_NOOP("Unexpected AUTH_EXPIRED " - "error: authentication " - "tokens for all linked " - "notebooks are still valid")); - QNWARNING(errorDescription - << QStringLiteral(", linked notebook guid = ") + else if (checkAndRequestAuthenticationTokensForLinkedNotebooks()) + { + errorDescription.setBase( + QT_TR_NOOP("Unexpected AUTH_EXPIRED error: " + "authentication tokens for all linked " + "notebooks are still valid")); + QNWARNING(errorDescription << ", linked notebook guid = " << tag.linkedNotebookGuid()); Q_EMIT failure(errorDescription); } @@ -1981,11 +1968,10 @@ } else if (errorCode == qevercloud::EDAMErrorCode::DATA_CONFLICT) { - QNINFO(QStringLiteral("Encountered DATA_CONFLICT exception while " - "trying to send new and/or modified tags, " - "it means the incremental sync should be " - "repeated before sending the changes " - "to Evernote service")); + QNINFO("Encountered DATA_CONFLICT exception while trying to send " + "new and/or modified tags, it means the incremental sync " + "should be repeated before sending the changes to Evernote " + "service"); Q_EMIT conflictDetected(); stop(); return; @@ -2001,14 +1987,15 @@ return; } - QNDEBUG(QStringLiteral("Successfully sent the tag to Evernote")); + QNDEBUG("Successfully sent the tag to Evernote"); // Now the tag should have obtained guid, need to set this guid // as parent tag guid for child tags if (Q_UNLIKELY(!tag.hasGuid())) { - ErrorString error(QT_TR_NOOP("The tag just sent to Evernote has no guid")); + ErrorString error( + QT_TR_NOOP("The tag just sent to Evernote has no guid")); if (tag.hasName()) { error.details() = tag.name(); } @@ -2033,20 +2020,20 @@ tag.setDirty(false); QUuid updateTagRequestId = QUuid::createUuid(); Q_UNUSED(m_updateTagRequestIds.insert(updateTagRequestId)) - QNTRACE(QStringLiteral("Emitting the request to update tag ") - << QStringLiteral("(remove dirty flag from it): request id = ") - << updateTagRequestId << QStringLiteral(", tag: ") << tag); + QNTRACE("Emitting the request to update tag " + << "(remove dirty flag from it): request id = " + << updateTagRequestId << ", tag: " << tag); Q_EMIT updateTag(tag, updateTagRequestId); if (!m_shouldRepeatIncrementalSync) { - QNTRACE(QStringLiteral("Checking if we are still in sync with " - "the remote service")); + QNTRACE("Checking if we are still in sync with the remote service"); - if (!tag.hasUpdateSequenceNumber()) { - errorDescription.setBase(QT_TR_NOOP("Tag's update sequence number " - "is not set after it being " - "sent to the service")); + if (!tag.hasUpdateSequenceNumber()) + { + errorDescription.setBase( + QT_TR_NOOP("Tag's update sequence number is not set after " + "it being sent to the service")); Q_EMIT failure(errorDescription); return; } @@ -2055,21 +2042,22 @@ if (!tag.hasLinkedNotebookGuid()) { pLastUpdateCount = &m_lastUpdateCount; - QNTRACE(QStringLiteral("Current tag does not belong to linked notebook")); + QNTRACE("Current tag does not belong to linked notebook"); } else { - QNTRACE(QStringLiteral("Current tag belongs to linked notebook with guid ") + QNTRACE("Current tag belongs to linked notebook with guid " << tag.linkedNotebookGuid()); auto lit = m_lastUpdateCountByLinkedNotebookGuid.find( tag.linkedNotebookGuid()); - if (lit == m_lastUpdateCountByLinkedNotebookGuid.end()) { - errorDescription.setBase(QT_TR_NOOP("Can't find the update " - "count per linked notebook " - "guid on attempt to check " - "the update count of tag " - "sent to Evernote service")); + if (lit == m_lastUpdateCountByLinkedNotebookGuid.end()) + { + errorDescription.setBase( + QT_TR_NOOP("Can't find the update count per linked " + "notebook guid on attempt to check the " + "update count of tag sent to Evernote " + "service")); Q_EMIT failure(errorDescription); return; } @@ -2079,14 +2067,14 @@ if (tag.updateSequenceNumber() == *pLastUpdateCount + 1) { *pLastUpdateCount = tag.updateSequenceNumber(); - QNTRACE(QStringLiteral("The client is in sync with the service; ") - << QStringLiteral("updated corresponding last update count to ") + QNTRACE("The client is in sync with the service; " + << "updated corresponding last update count to " << *pLastUpdateCount); } else { m_shouldRepeatIncrementalSync = true; Q_EMIT shouldRepeatIncrementalSync(); - QNTRACE(QStringLiteral("The client is not in sync with the service")); + QNTRACE("The client is not in sync with the service"); } } @@ -2095,11 +2083,11 @@ } if (numSentTags != 0) { - QNINFO(QStringLiteral("Sent ") << numSentTags - << QStringLiteral(" locally added/updated tags to Evernote")); + QNINFO("Sent " << numSentTags + << " locally added/updated tags to Evernote"); } else { - QNINFO(QStringLiteral("Found no locally added/modified tags to send to Evernote")); + QNINFO("Found no locally added/modified tags to send to Evernote"); } // Need to set tag guids for all dirty notes which have the corresponding @@ -2134,10 +2122,12 @@ } } - // If we got here, m_tags should be empty; m_updateTagRequestIds would unlikely - // be empty, it should only happen if updateNote signal-slot connection executed - // synchronously which is unlikely but still theoretically possible so accounting - // for this possibility + /** + * If we got here, m_tags should be empty; m_updateTagRequestIds would + * unlikely be empty, it should only happen if updateNote signal-slot + * connection executed synchronously which is unlikely but still + * theoretically possible so accounting for this possibility + */ if (m_updateTagRequestIds.isEmpty()) { checkSendLocalChangesAndDirtyFlagsRemovingUpdatesAndFinalize(); } @@ -2145,7 +2135,7 @@ void SendLocalChangesManager::sendSavedSearches() { - QNDEBUG(QStringLiteral("SendLocalChangesManager::sendSavedSearches")); + QNDEBUG("SendLocalChangesManager::sendSavedSearches"); ErrorString errorDescription; INoteStore & noteStore = m_manager.noteStore(); @@ -2161,19 +2151,20 @@ bool creatingSearch = !search.hasUpdateSequenceNumber(); if (creatingSearch) { - QNTRACE(QStringLiteral("Sending new saved search: ") << search); + QNTRACE("Sending new saved search: " << search); errorCode = noteStore.createSavedSearch(search, errorDescription, rateLimitSeconds); } else { - QNTRACE(QStringLiteral("Sending modified saved search: ") << search); + QNTRACE("Sending modified saved search: " << search); errorCode = noteStore.updateSavedSearch(search, errorDescription, rateLimitSeconds); } if (errorCode == qevercloud::EDAMErrorCode::RATE_LIMIT_REACHED) { - if (rateLimitSeconds < 0) { + if (rateLimitSeconds < 0) + { errorDescription.setBase(QT_TR_NOOP("Rate limit reached but " "the number of seconds " "to wait is incorrect")); @@ -2184,7 +2175,8 @@ } int timerId = startTimer(SEC_TO_MSEC(rateLimitSeconds)); - if (Q_UNLIKELY(timerId == 0)) { + if (Q_UNLIKELY(timerId == 0)) + { errorDescription.setBase(QT_TR_NOOP("Failed to start a timer " "to postpone the Evernote " "API call due to rate limit " @@ -2196,12 +2188,11 @@ m_sendSavedSearchesPostponeTimerId = timerId; - QNINFO(QStringLiteral("Encountered API rate limits exceeding during ") - << QStringLiteral("the attempt to send new or modified saved ") - << QStringLiteral("search, will need to wait for ") - << rateLimitSeconds << QStringLiteral(" seconds")); - QNDEBUG(QStringLiteral("Send saved searches postpone timer id = ") - << timerId); + QNINFO("Encountered API rate limits exceeding during " + << "the attempt to send new or modified saved " + << "search, will need to wait for " << rateLimitSeconds + << " seconds"); + QNDEBUG("Send saved searches postpone timer id = " << timerId); Q_EMIT rateLimitExceeded(rateLimitSeconds); return; @@ -2213,10 +2204,10 @@ } else if (errorCode == qevercloud::EDAMErrorCode::DATA_CONFLICT) { - QNINFO(QStringLiteral("Encountered DATA_CONFLICT exception while " - "trying to send new and/or modified saved searches, " - "it means the incremental sync should be repeated " - "before sending the changes to the service")); + QNINFO("Encountered DATA_CONFLICT exception while " + "trying to send new and/or modified saved searches, " + "it means the incremental sync should be repeated " + "before sending the changes to the service"); Q_EMIT conflictDetected(); stop(); return; @@ -2233,27 +2224,27 @@ return; } - QNDEBUG(QStringLiteral("Successfully sent the saved search to Evernote")); + QNDEBUG("Successfully sent the saved search to Evernote"); search.setDirty(false); QUuid updateSavedSearchRequestId = QUuid::createUuid(); Q_UNUSED(m_updateSavedSearchRequestIds.insert(updateSavedSearchRequestId)) - QNTRACE(QStringLiteral("Emitting the request to update saved search ") - << QStringLiteral("(remove the dirty flag from it): request id = ") - << updateSavedSearchRequestId << QStringLiteral(", saved search: ") + QNTRACE("Emitting the request to update saved search " + << "(remove the dirty flag from it): request id = " + << updateSavedSearchRequestId << ", saved search: " << search); Q_EMIT updateSavedSearch(search, updateSavedSearchRequestId); if (!m_shouldRepeatIncrementalSync) { - QNTRACE(QStringLiteral("Checking if we are still in sync with " - "the remote service")); + QNTRACE("Checking if we are still in sync with the remote service"); - if (!search.hasUpdateSequenceNumber()) { - errorDescription.setBase(QT_TR_NOOP("Internal error: saved search's " - "update sequence number is not " - "set after sending it " - "to Evernote service")); + if (!search.hasUpdateSequenceNumber()) + { + errorDescription.setBase( + QT_TR_NOOP("Internal error: saved search's update sequence " + "number is not set after sending it to Evernote " + "service")); QNWARNING(errorDescription); Q_EMIT failure(errorDescription); return; @@ -2261,13 +2252,12 @@ if (search.updateSequenceNumber() == m_lastUpdateCount + 1) { m_lastUpdateCount = search.updateSequenceNumber(); - QNDEBUG(QStringLiteral("The client is in sync with the service; ") - << QStringLiteral("updated last update count to ") - << m_lastUpdateCount); + QNDEBUG("The client is in sync with the service; " + << "updated last update count to " << m_lastUpdateCount); } else { m_shouldRepeatIncrementalSync = true; - QNDEBUG(QStringLiteral("The client is not in sync with the service")); + QNDEBUG("The client is not in sync with the service"); Q_EMIT shouldRepeatIncrementalSync(); } } @@ -2277,18 +2267,21 @@ } if (numSentSavedSearches != 0) { - QNINFO(QStringLiteral("Sent ") << numSentSavedSearches - << QStringLiteral(" locally added/updated saved searches to Evernote")); + QNINFO("Sent " << numSentSavedSearches + << " locally added/updated saved searches to Evernote"); } else { - QNINFO(QStringLiteral("Found no locally added/modified saved searches " - "to send to Evernote")); + QNINFO("Found no locally added/modified saved searches " + "to send to Evernote"); } - // If we got here, m_savedSearches should be empty; m_updateSavedSearchRequestIds - // would unlikely be empty, it should only happen if updateSavedSearch - // signal-slot connection executed synchronously which is unlikely but still - // theoretically possible so accounting for this possibility + /** + * If we got here, m_savedSearches should be empty; + * m_updateSavedSearchRequestIds would unlikely be empty, it should only + * happen if updateSavedSearch signal-slot connection executed synchronously + * which is unlikely but still theoretically possible so accounting for + * this possibility + */ if (m_updateSavedSearchRequestIds.isEmpty()) { checkSendLocalChangesAndDirtyFlagsRemovingUpdatesAndFinalize(); } @@ -2296,7 +2289,7 @@ void SendLocalChangesManager::sendNotebooks() { - QNDEBUG(QStringLiteral("SendLocalChangesManager::sendNotebooks")); + QNDEBUG("SendLocalChangesManager::sendNotebooks"); ErrorString errorDescription; @@ -2328,26 +2321,24 @@ } else { - errorDescription.setBase(QT_TR_NOOP("Couldn't find the auth token " - "for a linked notebook when " - "attempting to create or " - "update a notebook")); + errorDescription.setBase( + QT_TR_NOOP("Couldn't find the auth token for a linked " + "notebook when attempting to create or update " + "a notebook")); if (notebook.hasName()) { errorDescription.details() = notebook.name(); } - QNWARNING(errorDescription << QStringLiteral(", notebook: ") - << notebook); + QNWARNING(errorDescription << ", notebook: " << notebook); auto sit = std::find_if(m_linkedNotebookAuthData.begin(), m_linkedNotebookAuthData.end(), CompareLinkedNotebookAuthDataByGuid( notebook.linkedNotebookGuid())); if (sit == m_linkedNotebookAuthData.end()) { - QNWARNING(QStringLiteral("The linked notebook the notebook " - "refers to was not found within " - "the list of linked notebooks " - "received from the local storage")); + QNWARNING("The linked notebook the notebook refers to was " + "not found within the list of linked notebooks " + "received from the local storage"); } Q_EMIT failure(errorDescription); @@ -2364,17 +2355,15 @@ } else { - errorDescription.setBase(QT_TR_NOOP("Couldn't find the note store " - "URL for a linked notebook " - "when attempting to create " - "or update a notebook from it")); + errorDescription.setBase( + QT_TR_NOOP("Couldn't find the note store URL for a linked " + "notebook when attempting to create or update " + "a notebook from it")); if (notebook.hasName()) { errorDescription.details() = notebook.name(); } - QNWARNING(errorDescription << QStringLiteral(", notebook: ") - << notebook); - + QNWARNING(errorDescription << ", notebook: " << notebook); Q_EMIT failure(errorDescription); return; } @@ -2390,12 +2379,11 @@ pNoteStore = m_manager.noteStoreForLinkedNotebook(linkedNotebook); if (Q_UNLIKELY(!pNoteStore)) { - errorDescription.setBase(QT_TR_NOOP("Can't send new or modified " - "notebook: can't find or create " - "a note store for the linked " - "notebook")); - QNWARNING(errorDescription - << QStringLiteral(", linked notebook guid = ") + errorDescription.setBase( + QT_TR_NOOP("Can't send new or modified notebook: can't " + "find or create a note store for the linked " + "notebook")); + QNWARNING(errorDescription << ", linked notebook guid = " << notebook.linkedNotebookGuid()); Q_EMIT failure(errorDescription); return; @@ -2403,12 +2391,10 @@ if (Q_UNLIKELY(pNoteStore->noteStoreUrl().isEmpty())) { - ErrorString errorDescription(QT_TR_NOOP("Internal error: empty " - "note store url for " - "the linked notebook's " - "note store")); - QNWARNING(errorDescription - << QStringLiteral(", linked notebook guid = ") + ErrorString errorDescription( + QT_TR_NOOP("Internal error: empty note store url for " + "the linked notebook's note store")); + QNWARNING(errorDescription << ", linked notebook guid = " << notebook.linkedNotebookGuid()); Q_EMIT failure(errorDescription); return; @@ -2421,13 +2407,13 @@ bool creatingNotebook = !notebook.hasUpdateSequenceNumber(); if (creatingNotebook) { - QNTRACE(QStringLiteral("Sending new notebook: ") << notebook); + QNTRACE("Sending new notebook: " << notebook); errorCode = pNoteStore->createNotebook(notebook, errorDescription, rateLimitSeconds, linkedNotebookAuthToken); } else { - QNTRACE(QStringLiteral("Sending modified notebook: ") << notebook); + QNTRACE("Sending modified notebook: " << notebook); errorCode = pNoteStore->updateNotebook(notebook, errorDescription, rateLimitSeconds, linkedNotebookAuthToken); @@ -2435,7 +2421,8 @@ if (errorCode == qevercloud::EDAMErrorCode::RATE_LIMIT_REACHED) { - if (rateLimitSeconds < 0) { + if (rateLimitSeconds < 0) + { errorDescription.setBase(QT_TR_NOOP("Rate limit reached but " "the number of seconds " "to wait is incorrect")); @@ -2446,11 +2433,11 @@ } int timerId = startTimer(SEC_TO_MSEC(rateLimitSeconds)); - if (Q_UNLIKELY(timerId == 0)) { - errorDescription.setBase(QT_TR_NOOP("Failed to start a timer " - "to postpone the Evernote API " - "call due to rate limit " - "exceeding")); + if (Q_UNLIKELY(timerId == 0)) + { + errorDescription.setBase( + QT_TR_NOOP("Failed to start a timer to postpone the " + "Evernote API call due to rate limit exceeding")); QNWARNING(errorDescription); Q_EMIT failure(errorDescription); return; @@ -2458,12 +2445,11 @@ m_sendNotebooksPostponeTimerId = timerId; - QNINFO(QStringLiteral("Encountered API rate limits exceeding during ") - << QStringLiteral("the attempt to send new or modified notebook, ") - << QStringLiteral(", will need to wait for ") << rateLimitSeconds - << QStringLiteral(" seconds")); - QNDEBUG(QStringLiteral("Send notebooks postpone timer id = ") - << timerId); + QNINFO("Encountered API rate limits exceeding during " + << "the attempt to send new or modified notebook, " + << ", will need to wait for " << rateLimitSeconds + << " seconds"); + QNDEBUG("Send notebooks postpone timer id = " << timerId); Q_EMIT rateLimitExceeded(rateLimitSeconds); return; @@ -2475,26 +2461,26 @@ } else { - auto cit = m_authenticationTokenExpirationTimesByLinkedNotebookGuid.find( - notebook.linkedNotebookGuid()); - if (cit == m_authenticationTokenExpirationTimesByLinkedNotebookGuid.end()) + auto cit = + m_authenticationTokenExpirationTimesByLinkedNotebookGuid.find( + notebook.linkedNotebookGuid()); + if (cit == + m_authenticationTokenExpirationTimesByLinkedNotebookGuid.end()) { - errorDescription.setBase(QT_TR_NOOP("Couldn't find the linked " - "notebook auth token's " - "expiration time")); - QNWARNING(errorDescription - << QStringLiteral(", linked notebook guid = ") + errorDescription.setBase( + QT_TR_NOOP("Couldn't find the linked notebook auth " + "token's expiration time")); + QNWARNING(errorDescription << ", linked notebook guid = " << notebook.linkedNotebookGuid()); Q_EMIT failure(errorDescription); } else if (checkAndRequestAuthenticationTokensForLinkedNotebooks()) { - errorDescription.setBase(QT_TR_NOOP("Unexpected AUTH_EXPIRED " - "error: authentication " - "tokens for all linked " - "notebooks are still valid")); - QNWARNING(errorDescription - << QStringLiteral(", linked notebook guid = ") + errorDescription.setBase( + QT_TR_NOOP("Unexpected AUTH_EXPIRED error: " + "authentication tokens for all linked " + "notebooks are still valid")); + QNWARNING(errorDescription << ", linked notebook guid = " << notebook.linkedNotebookGuid()); Q_EMIT failure(errorDescription); } @@ -2504,10 +2490,10 @@ } else if (errorCode == qevercloud::EDAMErrorCode::DATA_CONFLICT) { - QNINFO(QStringLiteral("Encountered DATA_CONFLICT exception while " - "trying to send new and/or modified notebooks, " - "it means the incremental sync should be repeated " - "before sending the changes to the service")); + QNINFO("Encountered DATA_CONFLICT exception while " + "trying to send new and/or modified notebooks, " + "it means the incremental sync should be repeated " + "before sending the changes to the service"); Q_EMIT conflictDetected(); stop(); return; @@ -2524,7 +2510,7 @@ return; } - QNDEBUG(QStringLiteral("Successfully sent the notebook to Evernote")); + QNDEBUG("Successfully sent the notebook to Evernote"); if (Q_UNLIKELY(!notebook.hasGuid())) { @@ -2542,22 +2528,20 @@ notebook.setDirty(false); QUuid updateNotebookRequestId = QUuid::createUuid(); Q_UNUSED(m_updateNotebookRequestIds.insert(updateNotebookRequestId)) - QNTRACE(QStringLiteral("Emitting the request to update notebook ") - << QStringLiteral("(remove dirty flag from it): request id = ") - << updateNotebookRequestId << QStringLiteral(", notebook: ") - << notebook); + QNTRACE("Emitting the request to update notebook " + << "(remove dirty flag from it): request id = " + << updateNotebookRequestId << ", notebook: " << notebook); Q_EMIT updateNotebook(notebook, updateNotebookRequestId); if (!m_shouldRepeatIncrementalSync) { - QNTRACE(QStringLiteral("Checking if we are still in sync with " - "the remote service")); + QNTRACE("Checking if we are still in sync with the remote service"); if (!notebook.hasUpdateSequenceNumber()) { - errorDescription.setBase(QT_TR_NOOP("Notebook's update sequence " - "number is not set after it " - "was sent to Evernote service")); + errorDescription.setBase( + QT_TR_NOOP("Notebook's update sequence number is not set " + "after it was sent to Evernote service")); if (notebook.hasName()) { errorDescription.details() = notebook.name(); } @@ -2570,22 +2554,22 @@ if (!notebook.hasLinkedNotebookGuid()) { pLastUpdateCount = &m_lastUpdateCount; - QNTRACE(QStringLiteral("Current notebook does not belong to linked notebook")); + QNTRACE("Current notebook does not belong to linked notebook"); } else { - QNTRACE(QStringLiteral("Current notebook belongs to linked notebook ") - << QStringLiteral("with guid ") << notebook.linkedNotebookGuid()); + QNTRACE("Current notebook belongs to linked notebook " + << "with guid " << notebook.linkedNotebookGuid()); auto lit = m_lastUpdateCountByLinkedNotebookGuid.find( notebook.linkedNotebookGuid()); - if (lit == m_lastUpdateCountByLinkedNotebookGuid.end()) { - errorDescription.setBase(QT_TR_NOOP("Can't find the update " - "count per linked notebook " - "guid on attempt to check " - "the update count of " - "a notebook sent to " - "Evernote service")); + if (lit == m_lastUpdateCountByLinkedNotebookGuid.end()) + { + errorDescription.setBase( + QT_TR_NOOP("Can't find the update count per linked " + "notebook guid on attempt to check the " + "update count of a notebook sent to " + "Evernote service")); Q_EMIT failure(errorDescription); return; } @@ -2596,15 +2580,14 @@ if (notebook.updateSequenceNumber() == *pLastUpdateCount + 1) { *pLastUpdateCount = notebook.updateSequenceNumber(); - QNTRACE(QStringLiteral("The client is in sync with the service; ") - << QStringLiteral("updated last update count to ") - << *pLastUpdateCount); + QNTRACE("The client is in sync with the service; " + << "updated last update count to " << *pLastUpdateCount); } else { m_shouldRepeatIncrementalSync = true; Q_EMIT shouldRepeatIncrementalSync(); - QNTRACE(QStringLiteral("The client is not in sync with the service")); + QNTRACE("The client is not in sync with the service"); } } @@ -2613,12 +2596,11 @@ } if (numSentNotebooks != 0) { - QNINFO(QStringLiteral("Sent ") << numSentNotebooks - << QStringLiteral(" locally added/updated notebooks to Evernote")); + QNINFO("Sent " << numSentNotebooks + << " locally added/updated notebooks to Evernote"); } else { - QNINFO(QStringLiteral("Found no locally added/modified notebooks to send " - "to Evernote")); + QNINFO("Found no locally added/modified notebooks to send to Evernote"); } // Need to set notebook guids for all dirty notes which have the @@ -2627,26 +2609,29 @@ { Note & note = *nit; if (note.hasNotebookGuid()) { - QNDEBUG(QStringLiteral("Dirty note with local uid ") << note.localUid() - << QStringLiteral(" already has notebook guid: ") - << note.notebookGuid()); + QNDEBUG("Dirty note with local uid " << note.localUid() + << " already has notebook guid: " << note.notebookGuid()); continue; } - if (Q_UNLIKELY(!note.hasNotebookLocalUid())) { - ErrorString error(QT_TR_NOOP("Detected note which doesn't have neither " - "notebook guid not notebook local uid")); + if (Q_UNLIKELY(!note.hasNotebookLocalUid())) + { + ErrorString error( + QT_TR_NOOP("Detected note which doesn't have neither " + "notebook guid not notebook local uid")); APPEND_NOTE_DETAILS(error, note); - QNWARNING(errorDescription << QStringLiteral(", note: ") << note); + QNWARNING(errorDescription << ", note: " << note); Q_EMIT failure(errorDescription); return; } auto git = notebookGuidsByLocalUid.find(note.notebookLocalUid()); - if (Q_UNLIKELY(git == notebookGuidsByLocalUid.end())) { - ErrorString error(QT_TR_NOOP("Can't find the notebook guid for one of notes")); + if (Q_UNLIKELY(git == notebookGuidsByLocalUid.end())) + { + ErrorString error( + QT_TR_NOOP("Can't find the notebook guid for one of notes")); APPEND_NOTE_DETAILS(error, note); - QNWARNING(errorDescription << QStringLiteral(", note: ") << note); + QNWARNING(errorDescription << ", note: " << note); Q_EMIT failure(errorDescription); return; } @@ -2654,10 +2639,12 @@ note.setNotebookGuid(git.value()); } - // If we got here, m_notebooks should be empty; m_updateNotebookRequestIds - // would unlikely be empty, it should only happen if updateNotebook - // signal-slot connection executed synchronously which is unlikely but still - // theoretically possible so accounting for this possibility + /** + * If we got here, m_notebooks should be empty; m_updateNotebookRequestIds + * would unlikely be empty, it should only happen if updateNotebook + * signal-slot connection executed synchronously which is unlikely but still + * theoretically possible so accounting for this possibility + */ if (m_updateNotebookRequestIds.isEmpty()) { checkSendLocalChangesAndDirtyFlagsRemovingUpdatesAndFinalize(); } @@ -2665,7 +2652,7 @@ void SendLocalChangesManager::checkAndSendNotes() { - QNDEBUG(QStringLiteral("SendLocalChangesManager::checkAndSendNotes")); + QNDEBUG("SendLocalChangesManager::checkAndSendNotes"); if (m_tags.isEmpty() && m_notebooks.isEmpty() && m_findNotebookRequestIds.isEmpty()) @@ -2676,7 +2663,7 @@ void SendLocalChangesManager::sendNotes() { - QNDEBUG(QStringLiteral("SendLocalChangesManager::sendNotes")); + QNDEBUG("SendLocalChangesManager::sendNotes"); ErrorString errorDescription; size_t numSentNotes = 0; @@ -2689,10 +2676,12 @@ qint32 rateLimitSeconds = 0; qint32 errorCode = qevercloud::EDAMErrorCode::UNKNOWN; - if (!note.hasNotebookGuid()) { - errorDescription.setBase(QT_TR_NOOP("Found a note without notebook guid")); + if (!note.hasNotebookGuid()) + { + errorDescription.setBase( + QT_TR_NOOP("Found a note without notebook guid")); APPEND_NOTE_DETAILS(errorDescription, note) - QNWARNING(errorDescription << QStringLiteral(", note: ") << note); + QNWARNING(errorDescription << ", note: " << note); Q_EMIT failure(errorDescription); return; } @@ -2700,12 +2689,12 @@ auto nit = m_notebooksByGuidsCache.find(note.notebookGuid()); if (nit == m_notebooksByGuidsCache.end()) { - errorDescription.setBase(QT_TR_NOOP("Can't find the notebook for one " - "of notes about to be sent to " - "Evernote service")); + errorDescription.setBase( + QT_TR_NOOP("Can't find the notebook for one of notes about to " + "be sent to Evernote service")); APPEND_NOTE_DETAILS(errorDescription, note) - QNWARNING(errorDescription << QStringLiteral(", note: ") << note); + QNWARNING(errorDescription << ", note: " << note); Q_EMIT failure(errorDescription); return; } @@ -2727,12 +2716,11 @@ } else { - errorDescription.setBase(QT_TR_NOOP("Couldn't find the auth token " - "for a linked notebook when " - "attempting to create or " - "update a note from that notebook")); - QNWARNING(errorDescription << QStringLiteral(", notebook: ") - << notebook); + errorDescription.setBase( + QT_TR_NOOP("Couldn't find the auth token for a linked " + "notebook when attempting to create or " + "update a note from that notebook")); + QNWARNING(errorDescription << ", notebook: " << notebook); auto sit = std::find_if(m_linkedNotebookAuthData.begin(), m_linkedNotebookAuthData.end(), @@ -2758,17 +2746,15 @@ } else { - errorDescription.setBase(QT_TR_NOOP("Couldn't find the note store " - "URL for a linked notebook " - "when attempting to create " - "or update a note from it")); + errorDescription.setBase( + QT_TR_NOOP("Couldn't find the note store URL for a linked " + "notebook when attempting to create or update " + "a note from it")); if (notebook.hasName()) { errorDescription.details() = notebook.name(); } - QNWARNING(errorDescription << QStringLiteral(", notebook: ") - << notebook); - + QNWARNING(errorDescription << ", notebook: " << notebook); Q_EMIT failure(errorDescription); return; } @@ -2783,25 +2769,23 @@ linkedNotebook.setNoteStoreUrl(linkedNotebookNoteStoreUrl); pNoteStore = m_manager.noteStoreForLinkedNotebook(linkedNotebook); - if (Q_UNLIKELY(!pNoteStore)) { - errorDescription.setBase(QT_TR_NOOP("Can't send new or modified " - "note: can't find or create " - "a note store for the linked " - "notebook")); - QNWARNING(errorDescription - << QStringLiteral(", linked notebook guid = ") + if (Q_UNLIKELY(!pNoteStore)) + { + errorDescription.setBase( + QT_TR_NOOP("Can't send new or modified note: can't find or " + "create a note store for the linked notebook")); + QNWARNING(errorDescription << ", linked notebook guid = " << notebook.linkedNotebookGuid()); Q_EMIT failure(errorDescription); return; } - if (Q_UNLIKELY(pNoteStore->noteStoreUrl().isEmpty())) { - ErrorString errorDescription(QT_TR_NOOP("Internal error: empty " - "note store url for " - "the linked notebook's " - "note store")); - QNWARNING(errorDescription - << QStringLiteral(", linked notebook guid = ") + if (Q_UNLIKELY(pNoteStore->noteStoreUrl().isEmpty())) + { + ErrorString errorDescription( + QT_TR_NOOP("Internal error: empty note store url for " + "the linked notebook's note store")); + QNWARNING(errorDescription << ", linked notebook guid = " << notebook.linkedNotebookGuid()); Q_EMIT failure(errorDescription); return; @@ -2873,13 +2857,13 @@ bool creatingNote = !note.hasUpdateSequenceNumber(); if (creatingNote) { - QNTRACE(QStringLiteral("Sending new note: ") << note); + QNTRACE("Sending new note: " << note); errorCode = pNoteStore->createNote(note, errorDescription, rateLimitSeconds, linkedNotebookAuthToken); } else { - QNTRACE(QStringLiteral("Sending modified note: ") << note); + QNTRACE("Sending modified note: " << note); errorCode = pNoteStore->updateNote(note, errorDescription, rateLimitSeconds, linkedNotebookAuthToken); @@ -2887,10 +2871,11 @@ if (errorCode == qevercloud::EDAMErrorCode::RATE_LIMIT_REACHED) { - if (rateLimitSeconds < 0) { - errorDescription.setBase(QT_TR_NOOP("Rate limit reached but " - "the number of seconds to " - "wait is incorrect")); + if (rateLimitSeconds < 0) + { + errorDescription.setBase( + QT_TR_NOOP("Rate limit reached but the number of seconds " + "to wait is incorrect")); errorDescription.details() = QString::number(rateLimitSeconds); QNWARNING(errorDescription); Q_EMIT failure(errorDescription); @@ -2898,11 +2883,11 @@ } int timerId = startTimer(SEC_TO_MSEC(rateLimitSeconds)); - if (timerId == 0) { - errorDescription.setBase(QT_TR_NOOP("Failed to start a timer " - "to postpone the Evernote API " - "call due to rate limit " - "exceeding")); + if (timerId == 0) + { + errorDescription.setBase( + QT_TR_NOOP("Failed to start a timer to postpone the " + "Evernote API call due to rate limit exceeding")); QNWARNING(errorDescription); Q_EMIT failure(errorDescription); return; @@ -2910,11 +2895,11 @@ m_sendNotesPostponeTimerId = timerId; - QNINFO(QStringLiteral("Encountered API rate limits exceeding during ") - << QStringLiteral("the attempt to send new or modified note, ") - << QStringLiteral(", will need to wait for ") << rateLimitSeconds - << QStringLiteral(" seconds")); - QNDEBUG(QStringLiteral("Send notes postpone timer id = ") << timerId); + QNINFO("Encountered API rate limits exceeding during " + << "the attempt to send new or modified note, " + << ", will need to wait for " << rateLimitSeconds + << " seconds"); + QNDEBUG("Send notes postpone timer id = " << timerId); Q_EMIT rateLimitExceeded(rateLimitSeconds); return; @@ -2930,22 +2915,20 @@ notebook.linkedNotebookGuid()); if (cit == m_authenticationTokenExpirationTimesByLinkedNotebookGuid.end()) { - errorDescription.setBase(QT_TR_NOOP("Couldn't find the linked " - "notebook auth token's " - "expiration time")); - QNWARNING(errorDescription - << QStringLiteral(", linked notebook guid = ") + errorDescription.setBase( + QT_TR_NOOP("Couldn't find the linked notebook auth " + "token's expiration time")); + QNWARNING(errorDescription << ", linked notebook guid = " << notebook.linkedNotebookGuid()); Q_EMIT failure(errorDescription); } else if (checkAndRequestAuthenticationTokensForLinkedNotebooks()) { - errorDescription.setBase(QT_TR_NOOP("Unexpected AUTH_EXPIRED " - "error: authentication " - "tokens for all linked " - "notebooks are still valid")); - QNWARNING(errorDescription - << QStringLiteral(", linked notebook guid = ") + errorDescription.setBase( + QT_TR_NOOP("Unexpected AUTH_EXPIRED error: " + "authentication tokens for all linked " + "notebooks are still valid")); + QNWARNING(errorDescription << ", linked notebook guid = " << notebook.linkedNotebookGuid()); Q_EMIT failure(errorDescription); } @@ -2965,20 +2948,22 @@ return; } - QNDEBUG(QStringLiteral("Successfully sent the note to Evernote")); + QNDEBUG("Successfully sent the note to Evernote"); note.setDirty(false); QUuid updateNoteRequestId = QUuid::createUuid(); Q_UNUSED(m_updateNoteRequestIds.insert(updateNoteRequestId)) - QNTRACE(QStringLiteral("Emitting the request to update note (remove ") - << QStringLiteral("the dirty flag from it): request id = ") - << updateNoteRequestId << QStringLiteral(", note: ") << note); - - // NOTE: update of resources and tags is required here because otherwise - // we might end up with note which has only tag/resource local uids but - // no tag/resource guids (if the note's tags were local i.e. newly created - // tags/resources before the sync was launched) or, in case of resources, - // with the list of resources lacking USN values set + QNTRACE("Emitting the request to update note (remove " + << "the dirty flag from it): request id = " + << updateNoteRequestId << ", note: " << note); + + /** + * NOTE: update of resources and tags is required here because otherwise + * we might end up with note which has only tag/resource local uids but + * no tag/resource guids (if the note's tags were local i.e. newly created + * tags/resources before the sync was launched) or, in case of resources, + * with the list of resources lacking USN values set + */ LocalStorageManager::UpdateNoteOptions updateNoteOptions( LocalStorageManager::UpdateNoteOption::UpdateResourceMetadata | LocalStorageManager::UpdateNoteOption::UpdateResourceBinaryData | @@ -2987,13 +2972,13 @@ if (!m_shouldRepeatIncrementalSync) { - QNTRACE(QStringLiteral("Checking if we are still in sync with " - "Evernote service")); + QNTRACE("Checking if we are still in sync with Evernote service"); - if (!note.hasUpdateSequenceNumber()) { - errorDescription.setBase(QT_TR_NOOP("Note's update sequence number " - "is not set after it was sent " - "to Evernote service")); + if (!note.hasUpdateSequenceNumber()) + { + errorDescription.setBase( + QT_TR_NOOP("Note's update sequence number is not set after " + "it was sent to Evernote service")); Q_EMIT failure(errorDescription); return; } @@ -3002,24 +2987,22 @@ if (!notebook.hasLinkedNotebookGuid()) { pLastUpdateCount = &m_lastUpdateCount; - QNTRACE(QStringLiteral("Current note does not belong to any " - "linked notebook")); + QNTRACE("Current note does not belong to any linked notebook"); } else { - QNTRACE(QStringLiteral("Current note belongs to linked notebook ") - << QStringLiteral("with guid ") << notebook.linkedNotebookGuid()); + QNTRACE("Current note belongs to linked notebook with guid " + << notebook.linkedNotebookGuid()); auto lit = m_lastUpdateCountByLinkedNotebookGuid.find( notebook.linkedNotebookGuid()); if (lit == m_lastUpdateCountByLinkedNotebookGuid.end()) { - errorDescription.setBase(QT_TR_NOOP("Failed to find the update " - "count per linked notebook " - "guid on attempt to check " - "the update count of " - "a notebook sent to " - "Evernote service")); + errorDescription.setBase( + QT_TR_NOOP("Failed to find the update count per linked " + "notebook guid on attempt to check the " + "update count of a notebook sent to " + "Evernote service")); Q_EMIT failure(errorDescription); return; } @@ -3030,19 +3013,18 @@ if (note.updateSequenceNumber() == *pLastUpdateCount + 1) { *pLastUpdateCount = note.updateSequenceNumber(); - QNTRACE(QStringLiteral("The client is in sync with the service; ") - << QStringLiteral("updated last update count to ") - << *pLastUpdateCount); + QNTRACE("The client is in sync with the service; " + << "updated last update count to " << *pLastUpdateCount); } else { m_shouldRepeatIncrementalSync = true; Q_EMIT shouldRepeatIncrementalSync(); - QNTRACE(QStringLiteral("The client is not in sync with the service: ") - << QStringLiteral("last update count = ") << *pLastUpdateCount - << QStringLiteral(", note's update sequence number is ") + QNTRACE("The client is not in sync with the service: " + << "last update count = " << *pLastUpdateCount + << ", note's update sequence number is " << note.updateSequenceNumber() - << QStringLiteral(", whole note: ") << note); + << ", whole note: " << note); } } @@ -3051,17 +3033,18 @@ } if (numSentNotes != 0) { - QNINFO(QStringLiteral("Sent ") << numSentNotes - << QStringLiteral(" locally added/updated notes to Evernote")); + QNINFO("Sent " << numSentNotes + << " locally added/updated notes to Evernote"); } else { - QNINFO(QStringLiteral("Found no locally added/modified notes to send " - "to Evernote")); + QNINFO("Found no locally added/modified notes to send to Evernote"); } - // NOTE: as notes are sent the last, after sending them we must be done; - // the only possibly still pending transactions are those removing dirty - // flags from sent objects within the local storage + /** + * NOTE: as notes are sent the last, after sending them we must be done; + * the only possibly still pending transactions are those removing dirty + * flags from sent objects within the local storage + */ if (m_updateNoteRequestIds.isEmpty()) { checkDirtyFlagRemovingUpdatesAndFinalize(); } @@ -3069,12 +3052,13 @@ void SendLocalChangesManager::findNotebooksForNotes() { - QNDEBUG(QStringLiteral("SendLocalChangesManager::findNotebooksForNotes")); + QNDEBUG("SendLocalChangesManager::findNotebooksForNotes"); m_findNotebookRequestIds.clear(); QSet<QString> notebookGuids; - for(auto it = m_notes.constBegin(), end = m_notes.constEnd(); it != end; ++it) + for(auto it = m_notes.constBegin(), + end = m_notes.constEnd(); it != end; ++it) { const Note & note = *it; if (!note.hasNotebookGuid()) { @@ -3103,8 +3087,8 @@ Q_EMIT findNotebook(dummyNotebook, requestId); Q_UNUSED(m_findNotebookRequestIds.insert(requestId)); - QNTRACE(QStringLiteral("Sent find notebook request for notebook guid ") - << notebookGuid << QStringLiteral(", request id = ") << requestId); + QNTRACE("Sent find notebook request for notebook guid " + << notebookGuid << ", request id = " << requestId); } } else @@ -3123,8 +3107,8 @@ void SendLocalChangesManager::checkSendLocalChangesAndDirtyFlagsRemovingUpdatesAndFinalize() { - QNDEBUG(QStringLiteral("SendLocalChangesManager::" - "checkSendLocalChangesAndDirtyFlagsRemovingUpdatesAndFinalize")); + QNDEBUG("SendLocalChangesManager::" + "checkSendLocalChangesAndDirtyFlagsRemovingUpdatesAndFinalize"); if (m_tags.isEmpty() && m_savedSearches.isEmpty() && m_notebooks.isEmpty() && m_notes.isEmpty()) @@ -3133,52 +3117,52 @@ return; } - QNDEBUG(QStringLiteral("Still have ") << m_tags.size() - << QStringLiteral(" not yet sent tags, ") - << m_savedSearches.size() << QStringLiteral(" not yet sent saved searches, ") - << m_notebooks.size() << QStringLiteral(" not yet sent notebooks and ") - << m_notes.size() << QStringLiteral(" not yet sent notes")); + QNDEBUG("Still have " << m_tags.size() + << " not yet sent tags, " + << m_savedSearches.size() << " not yet sent saved searches, " + << m_notebooks.size() << " not yet sent notebooks and " + << m_notes.size() << " not yet sent notes"); sendLocalChanges(); } void SendLocalChangesManager::checkDirtyFlagRemovingUpdatesAndFinalize() { - QNDEBUG(QStringLiteral("SendLocalChangesManager::" - "checkDirtyFlagRemovingUpdatesAndFinalize")); + QNDEBUG("SendLocalChangesManager::" + "checkDirtyFlagRemovingUpdatesAndFinalize"); if (!m_updateTagRequestIds.isEmpty()) { - QNDEBUG(QStringLiteral("Still pending ") << m_updateTagRequestIds.size() - << QStringLiteral(" update tag requests")); + QNDEBUG("Still pending " << m_updateTagRequestIds.size() + << " update tag requests"); return; } if (!m_updateSavedSearchRequestIds.isEmpty()) { - QNDEBUG(QStringLiteral("Still pending ") << m_updateSavedSearchRequestIds.size() - << QStringLiteral(" update saved search requests")); + QNDEBUG("Still pending " << m_updateSavedSearchRequestIds.size() + << " update saved search requests"); return; } if (!m_updateNotebookRequestIds.isEmpty()) { - QNDEBUG(QStringLiteral("Still pending ") << m_updateNotebookRequestIds.size() - << QStringLiteral(" update notebook requests")); + QNDEBUG("Still pending " << m_updateNotebookRequestIds.size() + << " update notebook requests"); return; } if (!m_updateNoteRequestIds.isEmpty()) { - QNDEBUG(QStringLiteral("Still pending ") << m_updateNoteRequestIds.size() - << QStringLiteral(" update note requests")); + QNDEBUG("Still pending " << m_updateNoteRequestIds.size() + << " update note requests"); return; } - QNDEBUG(QStringLiteral("Found no pending update requests")); + QNDEBUG("Found no pending update requests"); finalize(); } void SendLocalChangesManager::finalize() { - QNDEBUG(QStringLiteral("SendLocalChangesManager::finalize: last update count = ") + QNDEBUG("SendLocalChangesManager::finalize: last update count = " << m_lastUpdateCount - << QStringLiteral(", last update count by linked notebook guid = ") + << ", last update count by linked notebook guid = " << m_lastUpdateCountByLinkedNotebookGuid); Q_EMIT finished(m_lastUpdateCount, m_lastUpdateCountByLinkedNotebookGuid); @@ -3188,7 +3172,7 @@ void SendLocalChangesManager::clear() { - QNDEBUG(QStringLiteral("SendLocalChangesManager::clear")); + QNDEBUG("SendLocalChangesManager::clear"); disconnectFromLocalStorage(); @@ -3231,8 +3215,10 @@ m_findNotebookRequestIds.clear(); - // NOTE: don't get any ideas on preserving the cache, it can easily get stale - // especially when disconnected from the local storage + /** + * NOTE: don't get any ideas on preserving the cache, it can easily get + * stale especially when disconnected from the local storage + */ m_notebooksByGuidsCache.clear(); killAllTimers(); @@ -3240,7 +3226,7 @@ void SendLocalChangesManager::killAllTimers() { - QNDEBUG(QStringLiteral("SendLocalChangesManager::killAllTimers")); + QNDEBUG("SendLocalChangesManager::killAllTimers"); if (m_sendTagsPostponeTimerId > 0) { killTimer(m_sendTagsPostponeTimerId); @@ -3265,12 +3251,11 @@ bool SendLocalChangesManager::checkAndRequestAuthenticationTokensForLinkedNotebooks() { - QNDEBUG(QStringLiteral("SendLocalChangesManager::" - "checkAndRequestAuthenticationTokensForLinkedNotebooks")); + QNDEBUG("SendLocalChangesManager::" + "checkAndRequestAuthenticationTokensForLinkedNotebooks"); if (m_linkedNotebookAuthData.isEmpty()) { - QNDEBUG(QStringLiteral("The list of linked notebook guids and share keys " - "is empty")); + QNDEBUG("The list of linked notebook guids and share keys is empty"); return true; } @@ -3281,9 +3266,10 @@ const QString & guid = authData.m_guid; if (guid.isEmpty()) { - ErrorString error(QT_TR_NOOP("Found empty linked notebook guid within " - "the list of linked notebook guids and " - "shared notebook global ids")); + ErrorString error( + QT_TR_NOOP("Found empty linked notebook guid within " + "the list of linked notebook guids and " + "shared notebook global ids")); QNWARNING(error); Q_EMIT failure(error); return false; @@ -3292,10 +3278,9 @@ auto it = m_authenticationTokensAndShardIdsByLinkedNotebookGuid.find(guid); if (it == m_authenticationTokensAndShardIdsByLinkedNotebookGuid.end()) { - QNDEBUG(QStringLiteral("Authentication token for linked notebook with guid ") - << guid << QStringLiteral(" was not found; will request " - "authentication tokens for all " - "linked notebooks at once")); + QNDEBUG("Authentication token for linked notebook with guid " + << guid << " was not found; will request authentication " + << "tokens for all linked notebooks at once"); m_pendingAuthenticationTokensForLinkedNotebooks = true; Q_EMIT requestAuthenticationTokensForLinkedNotebooks(m_linkedNotebookAuthData); return false; @@ -3304,9 +3289,10 @@ auto eit = m_authenticationTokenExpirationTimesByLinkedNotebookGuid.find(guid); if (eit == m_authenticationTokenExpirationTimesByLinkedNotebookGuid.end()) { - ErrorString error(QT_TR_NOOP("Can't find the cached expiration time " - "of a linked notebook's authentication token")); - QNWARNING(error << QStringLiteral(", linked notebook guid = ") << guid); + ErrorString error( + QT_TR_NOOP("Can't find the cached expiration time " + "of a linked notebook's authentication token")); + QNWARNING(error << ", linked notebook guid = " << guid); Q_EMIT failure(error); return false; } @@ -3315,14 +3301,14 @@ const qevercloud::Timestamp currentTime = QDateTime::currentMSecsSinceEpoch(); if ((expirationTime - currentTime) < HALF_AN_HOUR_IN_MSEC) { - QNDEBUG(QStringLiteral("Authentication token for linked notebook with guid ") - << guid << QStringLiteral(" is too close to expiration: its ") - << QStringLiteral("expiration time is ") + QNDEBUG("Authentication token for linked notebook with guid " + << guid << " is too close to expiration: its " + << "expiration time is " << printableDateTimeFromTimestamp(expirationTime) - << QStringLiteral(", current time is ") + << ", current time is " << printableDateTimeFromTimestamp(currentTime) - << QStringLiteral("; will request new authentication tokens ") - << QStringLiteral("for all linked notebooks")); + << "; will request new authentication tokens " + << "for all linked notebooks"); m_pendingAuthenticationTokensForLinkedNotebooks = true; Q_EMIT requestAuthenticationTokensForLinkedNotebooks( m_linkedNotebookAuthData); @@ -3330,15 +3316,15 @@ } } - QNDEBUG(QStringLiteral("Got authentication tokens for all linked notebooks, " - "can proceed with their synchronization")); + QNDEBUG("Got authentication tokens for all linked notebooks, " + "can proceed with their synchronization"); return true; } void SendLocalChangesManager::handleAuthExpiration() { - QNINFO(QStringLiteral("SendLocalChangesManager::handleAuthExpiration")); + QNINFO("SendLocalChangesManager::handleAuthExpiration"); Q_EMIT requestAuthenticationToken(); } diff -Nru libquentier-0.5.0/src/synchronization/SendLocalChangesManager.h libquentier-0.5.0/src/synchronization/SendLocalChangesManager.h --- libquentier-0.5.0/src/synchronization/SendLocalChangesManager.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/SendLocalChangesManager.h 2019-07-11 10:46:53.000000000 +0000 @@ -79,8 +79,8 @@ void stop(); void onAuthenticationTokensForLinkedNotebooksReceived( - QHash<QString,QPair<QString,QString> > authenticationTokensAndShardIdsByLinkedNotebookGuid, - QHash<QString,qevercloud::Timestamp> authenticationTokenExpirationTimesByLinkedNotebookGuid); + QHash<QString,QPair<QString,QString> > authTokensAndShardIdsByLinkedNotebookGuid, + QHash<QString,qevercloud::Timestamp> authTokenExpirationByLinkedNotebookGuid); // private signals: Q_SIGNALS: @@ -240,7 +240,7 @@ void disconnectFromLocalStorage(); bool requestStuffFromLocalStorage(const QString & linkedNotebookGuid = - QStringLiteral("")); + QLatin1String("")); void checkListLocalStorageObjectsCompletion(); diff -Nru libquentier-0.5.0/src/synchronization/SynchronizationManager_p.cpp libquentier-0.5.0/src/synchronization/SynchronizationManager_p.cpp --- libquentier-0.5.0/src/synchronization/SynchronizationManager_p.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/SynchronizationManager_p.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -170,12 +170,11 @@ void SynchronizationManagerPrivate::setAccount(const Account & account) { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::setAccount: ") - << account); + QNDEBUG("SynchronizationManagerPrivate::setAccount: " << account); Account currentAccount = m_pRemoteToLocalSyncManager->account(); if (currentAccount == account) { - QNDEBUG(QStringLiteral("The same account is already set, nothing to do")); + QNDEBUG("The same account is already set, nothing to do"); return; } @@ -195,22 +194,16 @@ void SynchronizationManagerPrivate::synchronize() { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::synchronize")); + QNDEBUG("SynchronizationManagerPrivate::synchronize"); if (m_authenticationInProgress || m_writingAuthToken || m_writingShardId) { ErrorString error(QT_TR_NOOP("Authentication is not finished yet, please wait")); - QNDEBUG(error << QStringLiteral(", authentication in progress = ") - << (m_authenticationInProgress - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", writing OAuth token = ") - << (m_writingAuthToken - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", writing shard id = ") - << (m_writingShardId - ? QStringLiteral("true") - : QStringLiteral("false"))); + QNDEBUG(error << ", authentication in progress = " + << (m_authenticationInProgress ? "true" : "false") + << ", writing OAuth token = " + << (m_writingAuthToken ? "true" : "false") + << ", writing shard id = " + << (m_writingShardId ? "true" : "false")); Q_EMIT notifyError(error); return; } @@ -221,24 +214,18 @@ void SynchronizationManagerPrivate::authenticate() { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::authenticate")); + QNDEBUG("SynchronizationManagerPrivate::authenticate"); if (m_authenticationInProgress || m_writingAuthToken || m_writingShardId) { ErrorString error(QT_TR_NOOP("Previous authentication is not finished " "yet, please wait")); - QNDEBUG(error << QStringLiteral(", authentication in progress = ") - << (m_authenticationInProgress - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", writing OAuth token = ") - << (m_writingAuthToken - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", writing shard id = ") - << (m_writingShardId - ? QStringLiteral("true") - : QStringLiteral("false"))); + QNDEBUG(error << ", authentication in progress = " + << (m_authenticationInProgress ? "true" : "false") + << ", writing OAuth token = " + << (m_writingAuthToken ? "true" : "false") + << ", writing shard id = " + << (m_writingShardId ? "true" : "false")); Q_EMIT authenticationFinished(/* success = */ false, error, Account()); return; } @@ -248,24 +235,18 @@ void SynchronizationManagerPrivate::authenticateCurrentAccount() { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::authenticateCurrentAccount")); + QNDEBUG("SynchronizationManagerPrivate::authenticateCurrentAccount"); if (m_authenticationInProgress || m_writingAuthToken || m_writingShardId) { ErrorString error(QT_TR_NOOP("Previous authentication is not finished " "yet, please wait")); - QNDEBUG(error << QStringLiteral(", authentication in progress = ") - << (m_authenticationInProgress - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", writing OAuth token = ") - << (m_writingAuthToken - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", writing shard id = ") - << (m_writingShardId - ? QStringLiteral("true") - : QStringLiteral("false"))); + QNDEBUG(error << ", authentication in progress = " + << (m_authenticationInProgress ? "true" : "false") + << ", writing OAuth token = " + << (m_writingAuthToken ? "true" : "false") + << ", writing shard id = " + << (m_writingShardId ? "true" : "false")); Q_EMIT authenticationFinished(/* success = */ false, error, Account()); return; } @@ -275,7 +256,7 @@ void SynchronizationManagerPrivate::stop() { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::stop")); + QNDEBUG("SynchronizationManagerPrivate::stop"); tryUpdateLastSyncStatus(); @@ -283,10 +264,11 @@ Q_EMIT stopSendingLocalChanges(); } -void SynchronizationManagerPrivate::revokeAuthentication(const qevercloud::UserID userId) +void SynchronizationManagerPrivate::revokeAuthentication( + const qevercloud::UserID userId) { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::revokeAuthentication: ") - << QStringLiteral("user id = ") << userId); + QNDEBUG("SynchronizationManagerPrivate::revokeAuthentication: user id = " + << userId); m_lastRevokedAuthenticationUserId = userId; @@ -333,12 +315,11 @@ qevercloud::Timestamp authTokenExpirationTime, QString shardId, QString noteStoreUrl, QString webApiUrlPrefix, ErrorString errorDescription) { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::onOAuthResult: ") - << (success ? QStringLiteral("success") : QStringLiteral("failure")) - << QStringLiteral(", user id = ") << userId - << QStringLiteral(", auth token expiration time = ") + QNDEBUG("SynchronizationManagerPrivate::onOAuthResult: " + << (success ? "success" : "failure") + << ", user id = " << userId << ", auth token expiration time = " << printableDateTimeFromTimestamp(authTokenExpirationTime) - << QStringLiteral(", error: ") << errorDescription); + << ", error: " << errorDescription); m_authenticationInProgress = false; @@ -353,7 +334,7 @@ authData.m_webApiUrlPrefix = webApiUrlPrefix; m_OAuthResult = authData; - QNDEBUG(QStringLiteral("OAuth result = ") << m_OAuthResult); + QNDEBUG("OAuth result = " << m_OAuthResult); Account previousAccount = m_pRemoteToLocalSyncManager->account(); @@ -364,13 +345,15 @@ m_pUserStore->setAuthenticationToken(authToken); ErrorString error; - bool res = m_pRemoteToLocalSyncManager->syncUser(userId, error, - /* write user data to - * local storage = */ false); + bool res = m_pRemoteToLocalSyncManager->syncUser( + userId, error, + /* write user data to * local storage = */ false); + if (Q_UNLIKELY(!res)) { - errorDescription.setBase(QT_TR_NOOP("Can't switch to new Evernote " - "account: failed to sync user data")); + errorDescription.setBase( + QT_TR_NOOP("Can't switch to new Evernote " + "account: failed to sync user data")); errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); @@ -385,9 +368,9 @@ const User & user = m_pRemoteToLocalSyncManager->user(); if (Q_UNLIKELY(!user.hasUsername())) { - errorDescription.setBase(QT_TR_NOOP("Can't switch to new Evernote " - "account: the synched user data " - "lacks username")); + errorDescription.setBase( + QT_TR_NOOP("Can't switch to new Evernote account: the synched " + "user data lacks username")); errorDescription.appendBase(error.base()); errorDescription.appendBase(error.additionalBases()); errorDescription.details() = error.details(); @@ -420,10 +403,10 @@ QUuid jobId, IKeychainService::ErrorCode::type errorCode, ErrorString errorDescription) { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::") - << QStringLiteral("onWritePasswordJobFinished: job id = ") << jobId - << QStringLiteral(", error code = ") << errorCode - << QStringLiteral(", error description = ") << errorDescription); + QNDEBUG("SynchronizationManagerPrivate::" + << "onWritePasswordJobFinished: job id = " << jobId + << ", error code = " << errorCode + << ", error description = " << errorDescription); if (jobId == m_writeAuthTokenJobId) { onWriteAuthTokenFinished(errorCode, errorDescription); @@ -435,14 +418,17 @@ return; } - auto writeAuthTokenIt = m_writeLinkedNotebookAuthTokenJobIdsWithLinkedNotebookGuids.right.find(jobId); - if (writeAuthTokenIt != m_writeLinkedNotebookAuthTokenJobIdsWithLinkedNotebookGuids.right.end()) + auto writeAuthTokenIt = + m_writeLinkedNotebookAuthTokenJobIdsWithLinkedNotebookGuids.right.find(jobId); + if (writeAuthTokenIt != + m_writeLinkedNotebookAuthTokenJobIdsWithLinkedNotebookGuids.right.end()) { - QNDEBUG(QStringLiteral("Write linked notebook auth token job finished: ") - << QStringLiteral("linked notebook guid = ") << writeAuthTokenIt->second); + QNDEBUG("Write linked notebook auth token job finished: " + << "linked notebook guid = " << writeAuthTokenIt->second); QString guid = writeAuthTokenIt->second; - Q_UNUSED(m_writeLinkedNotebookAuthTokenJobIdsWithLinkedNotebookGuids.right.erase(writeAuthTokenIt)) + Q_UNUSED(m_writeLinkedNotebookAuthTokenJobIdsWithLinkedNotebookGuids.right.erase( + writeAuthTokenIt)) auto pendingItemIt = m_linkedNotebookAuthTokensPendingWritingByGuid.find(guid); if (pendingItemIt != m_linkedNotebookAuthTokensPendingWritingByGuid.end()) @@ -450,19 +436,18 @@ // NOTE: ignore the status of previous write job for this key, // it doesn't matter if we need to write another token QString token = pendingItemIt.value(); - Q_UNUSED(m_linkedNotebookAuthTokensPendingWritingByGuid.erase(pendingItemIt)) - QNDEBUG(QStringLiteral("Writing postponed auth token for linked " - "notebook guid ") << guid); + Q_UNUSED(m_linkedNotebookAuthTokensPendingWritingByGuid.erase( + pendingItemIt)) + QNDEBUG("Writing postponed auth token for linked notebook guid " + << guid); QString keyPrefix = QCoreApplication::applicationName() + QStringLiteral("_") + m_host + QStringLiteral("_") + QString::number(m_OAuthResult.m_userId); - QUuid jobId = - m_pKeychainService->startWritePasswordJob(WRITE_LINKED_NOTEBOOK_AUTH_TOKEN_JOB, - keyPrefix + - LINKED_NOTEBOOK_AUTH_TOKEN_KEY_PART + - guid, - token); + QUuid jobId = m_pKeychainService->startWritePasswordJob( + WRITE_LINKED_NOTEBOOK_AUTH_TOKEN_JOB, + keyPrefix + LINKED_NOTEBOOK_AUTH_TOKEN_KEY_PART + guid, + token); m_writeLinkedNotebookAuthTokenJobIdsWithLinkedNotebookGuids.insert( JobIdWithGuidBimap::value_type(guid, jobId)); } @@ -486,14 +471,17 @@ return; } - auto writeShardIdIt = m_writeLinkedNotebookShardIdJobIdsWithLinkedNotebookGuids.right.find(jobId); - if (writeShardIdIt != m_writeLinkedNotebookShardIdJobIdsWithLinkedNotebookGuids.right.end()) + auto writeShardIdIt = + m_writeLinkedNotebookShardIdJobIdsWithLinkedNotebookGuids.right.find(jobId); + if (writeShardIdIt != + m_writeLinkedNotebookShardIdJobIdsWithLinkedNotebookGuids.right.end()) { - QNDEBUG(QStringLiteral("Write linked notebook shard id job finished: ") - << QStringLiteral("linked notebook guid = ") << writeShardIdIt->second); + QNDEBUG("Write linked notebook shard id job finished: " + << "linked notebook guid = " << writeShardIdIt->second); QString guid = writeShardIdIt->second; - Q_UNUSED(m_writeLinkedNotebookShardIdJobIdsWithLinkedNotebookGuids.right.erase(writeShardIdIt)) + Q_UNUSED(m_writeLinkedNotebookShardIdJobIdsWithLinkedNotebookGuids.right.erase( + writeShardIdIt)) auto pendingItemIt = m_linkedNotebookShardIdsPendingWritingByGuid.find(guid); if (pendingItemIt != m_linkedNotebookShardIdsPendingWritingByGuid.end()) @@ -502,18 +490,16 @@ // it doesn't matter if we need to write another shard id QString shardId = pendingItemIt.value(); Q_UNUSED(m_linkedNotebookShardIdsPendingWritingByGuid.erase(pendingItemIt)) - QNDEBUG(QStringLiteral("Writing postponed shard id ") << shardId - << QStringLiteral(" for linked notebook guid ") << guid); + QNDEBUG("Writing postponed shard id " << shardId + << " for linked notebook guid " << guid); QString keyPrefix = QCoreApplication::applicationName() + QStringLiteral("_") + m_host + QStringLiteral("_") + QString::number(m_OAuthResult.m_userId); - QUuid jobId = - m_pKeychainService->startWritePasswordJob(WRITE_LINKED_NOTEBOOK_SHARD_ID_JOB, - keyPrefix + - LINKED_NOTEBOOK_SHARD_ID_KEY_PART + - guid, - shardId); + QUuid jobId = m_pKeychainService->startWritePasswordJob( + WRITE_LINKED_NOTEBOOK_SHARD_ID_JOB, + keyPrefix + LINKED_NOTEBOOK_SHARD_ID_KEY_PART + guid, + shardId); m_writeLinkedNotebookShardIdJobIdsWithLinkedNotebookGuids.insert( JobIdWithGuidBimap::value_type(guid, jobId)); } @@ -537,17 +523,16 @@ return; } - QNDEBUG(QStringLiteral("Couldn't identify the write password from keychain job")); + QNDEBUG("Couldn't identify the write password from keychain job"); } void SynchronizationManagerPrivate::onReadPasswordJobFinished( QUuid jobId, IKeychainService::ErrorCode::type errorCode, ErrorString errorDescription, QString password) { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::onReadPasswordJobFinished: ") - << QStringLiteral("job id = ") << jobId - << QStringLiteral(", error code = ") << errorCode - << QStringLiteral(", error description = ") << errorDescription); + QNDEBUG("SynchronizationManagerPrivate::onReadPasswordJobFinished: " + << "job id = " << jobId << ", error code = " << errorCode + << ", error description = " << errorDescription); if (jobId == m_readAuthTokenJobId) { onReadAuthTokenFinished(errorCode, errorDescription, password); @@ -559,50 +544,59 @@ return; } - auto readAuthTokenIt = m_readLinkedNotebookAuthTokenJobIdsWithLinkedNotebookGuids.right.find(jobId); - if (readAuthTokenIt != m_readLinkedNotebookAuthTokenJobIdsWithLinkedNotebookGuids.right.end()) + auto readAuthTokenIt = + m_readLinkedNotebookAuthTokenJobIdsWithLinkedNotebookGuids.right.find(jobId); + if (readAuthTokenIt != + m_readLinkedNotebookAuthTokenJobIdsWithLinkedNotebookGuids.right.end()) { - QNDEBUG(QStringLiteral("Read linked notebook auth token job finished: ") - << QStringLiteral("linked notebook guid = ") << readAuthTokenIt->second); + QNDEBUG("Read linked notebook auth token job finished: " + << "linked notebook guid = " << readAuthTokenIt->second); if (errorCode == IKeychainService::ErrorCode::NoError) { - m_cachedLinkedNotebookAuthTokensAndShardIdsByGuid[readAuthTokenIt->second].first = password; + m_cachedLinkedNotebookAuthTokensAndShardIdsByGuid[readAuthTokenIt->second].first = + password; } else if (errorCode == IKeychainService::ErrorCode::EntryNotFound) { - Q_UNUSED(m_linkedNotebookGuidsWithoutLocalAuthData.insert(readAuthTokenIt->second)) + Q_UNUSED(m_linkedNotebookGuidsWithoutLocalAuthData.insert( + readAuthTokenIt->second)) } else { - QNWARNING(QStringLiteral("Failed to read linked notebook's authentication ") - << QStringLiteral("token from the keychain: error code = ") - << errorCode << QStringLiteral(", error description: ") - << errorDescription); - - // Try to recover by making user to authenticate again in the blind hope that - // the next time the persistence of auth settings in the keychain would work - Q_UNUSED(m_linkedNotebookGuidsWithoutLocalAuthData.insert(readAuthTokenIt->second)) + QNWARNING("Failed to read linked notebook's authentication " + << "token from the keychain: error code = " << errorCode + << ", error description: " << errorDescription); + + /** + * Try to recover by making user to authenticate again in the blind + * hope that the next time the persistence of auth settings in the + * keychain would work + */ + Q_UNUSED(m_linkedNotebookGuidsWithoutLocalAuthData.insert( + readAuthTokenIt->second)) } - Q_UNUSED(m_readLinkedNotebookAuthTokenJobIdsWithLinkedNotebookGuids.right.erase(readAuthTokenIt)) + Q_UNUSED(m_readLinkedNotebookAuthTokenJobIdsWithLinkedNotebookGuids.right.erase( + readAuthTokenIt)) if (m_readLinkedNotebookAuthTokenJobIdsWithLinkedNotebookGuids.empty() && m_readLinkedNotebookShardIdJobIdsWithLinkedNotebookGuids.empty()) { - QNDEBUG(QStringLiteral("No pending read linked notebook auth token " - "or shard id job")); + QNDEBUG("No pending read linked notebook auth token or shard id job"); authenticateToLinkedNotebooks(); } return; } - auto readShardIdIt = m_readLinkedNotebookShardIdJobIdsWithLinkedNotebookGuids.right.find(jobId); - if (readShardIdIt != m_readLinkedNotebookShardIdJobIdsWithLinkedNotebookGuids.right.end()) + auto readShardIdIt = + m_readLinkedNotebookShardIdJobIdsWithLinkedNotebookGuids.right.find(jobId); + if (readShardIdIt != + m_readLinkedNotebookShardIdJobIdsWithLinkedNotebookGuids.right.end()) { - QNDEBUG(QStringLiteral("Read linked notebook shard id job finished: ") - << QStringLiteral("linked notebook guid = ") << readShardIdIt->second); + QNDEBUG("Read linked notebook shard id job finished: " + << "linked notebook guid = " << readShardIdIt->second); if (errorCode == IKeychainService::ErrorCode::NoError) { @@ -614,23 +608,26 @@ } else { - QNWARNING(QStringLiteral("Failed to read linked notebook's authentication ") - << QStringLiteral("token from the keychain: error code = ") - << errorCode << QStringLiteral(", error description: ") - << errorDescription); - - // Try to recover by making user to authenticate again in the blind hope that - // the next time the persistence of auth settings in the keychain would work - Q_UNUSED(m_linkedNotebookGuidsWithoutLocalAuthData.insert(readShardIdIt->second)) + QNWARNING("Failed to read linked notebook's authentication " + << "token from the keychain: error code = " << errorCode + << ", error description: " << errorDescription); + + /** + * Try to recover by making user to authenticate again in the blind + * hope that the next time the persistence of auth settings in the + * keychain would work + */ + Q_UNUSED(m_linkedNotebookGuidsWithoutLocalAuthData.insert( + readShardIdIt->second)) } - Q_UNUSED(m_readLinkedNotebookShardIdJobIdsWithLinkedNotebookGuids.right.erase(readShardIdIt)) + Q_UNUSED(m_readLinkedNotebookShardIdJobIdsWithLinkedNotebookGuids.right.erase( + readShardIdIt)) if (m_readLinkedNotebookShardIdJobIdsWithLinkedNotebookGuids.empty() && m_readLinkedNotebookAuthTokenJobIdsWithLinkedNotebookGuids.empty()) { - QNDEBUG(QStringLiteral("No pending read linked notebook auth token " - "or shard id job")); + QNDEBUG("No pending read linked notebook auth token or shard id job"); authenticateToLinkedNotebooks(); } @@ -642,10 +639,9 @@ QUuid jobId, IKeychainService::ErrorCode::type errorCode, ErrorString errorDescription) { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::onDeletePasswordJobFinished: ") - << QStringLiteral("job id = ") << jobId - << QStringLiteral(", error code = ") << errorCode - << QStringLiteral(", error description = ") << errorDescription); + QNDEBUG("SynchronizationManagerPrivate::onDeletePasswordJobFinished: " + << "job id = " << jobId << ", error code = " << errorCode + << ", error description = " << errorDescription); if (jobId == m_deleteAuthTokenJobId) { onDeleteAuthTokenFinished(errorCode, errorDescription); @@ -657,15 +653,15 @@ return; } - QNDEBUG(QStringLiteral("Couldn't identify the delete password from keychain job")); + QNDEBUG("Couldn't identify the delete password from keychain job"); } void SynchronizationManagerPrivate::onRequestAuthenticationToken() { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::onRequestAuthenticationToken")); + QNDEBUG("SynchronizationManagerPrivate::onRequestAuthenticationToken"); if (validAuthentication()) { - QNDEBUG(QStringLiteral("Found valid auth token and shard id, returning them")); + QNDEBUG("Found valid auth token and shard id, returning them"); Q_EMIT sendAuthenticationTokenAndShardId(m_OAuthResult.m_authToken, m_OAuthResult.m_shardId, m_OAuthResult.m_expirationTime); @@ -678,8 +674,8 @@ void SynchronizationManagerPrivate::onRequestAuthenticationTokensForLinkedNotebooks( QVector<LinkedNotebookAuthData> linkedNotebookAuthData) { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::" - "onRequestAuthenticationTokensForLinkedNotebooks")); + QNDEBUG("SynchronizationManagerPrivate::" + "onRequestAuthenticationTokensForLinkedNotebooks"); m_linkedNotebookAuthDataPendingAuthentication = linkedNotebookAuthData; authenticateToLinkedNotebooks(); } @@ -705,23 +701,18 @@ QHash<QString,qint32> lastUpdateCountByLinkedNotebookGuid, QHash<QString,qevercloud::Timestamp> lastSyncTimeByLinkedNotebookGuid) { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::onRemoteToLocalSyncFinished: ") - << QStringLiteral("lastUpdateCount = ") << lastUpdateCount - << QStringLiteral(", lastSyncTime = ") - << printableDateTimeFromTimestamp(lastSyncTime)); + QNDEBUG("SynchronizationManagerPrivate::onRemoteToLocalSyncFinished: " + << "lastUpdateCount = " << lastUpdateCount + << ", lastSyncTime = " << printableDateTimeFromTimestamp(lastSyncTime)); bool somethingDownloaded = (m_lastUpdateCount != lastUpdateCount) || (m_lastUpdateCount != m_previousUpdateCount) || (m_cachedLinkedNotebookLastUpdateCountByGuid != lastUpdateCountByLinkedNotebookGuid); - QNTRACE(QStringLiteral("Something downloaded = ") - << (somethingDownloaded - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", m_lastUpdateCount = ") - << m_lastUpdateCount << QStringLiteral(", m_previousUpdateCount = ") - << m_previousUpdateCount - << QStringLiteral(", m_cachedLinkedNotebookLastUpdateCountByGuid = ") + QNTRACE("Something downloaded = " << (somethingDownloaded ? "true" : "false") + << ", m_lastUpdateCount = " << m_lastUpdateCount + << ", m_previousUpdateCount = " << m_previousUpdateCount + << ", m_cachedLinkedNotebookLastUpdateCountByGuid = " << m_cachedLinkedNotebookLastUpdateCountByGuid); m_lastUpdateCount = lastUpdateCount; @@ -741,7 +732,7 @@ void SynchronizationManagerPrivate::onRemoteToLocalSyncStopped() { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::onRemoteToLocalSyncStopped")); + QNDEBUG("SynchronizationManagerPrivate::onRemoteToLocalSyncStopped"); Q_EMIT remoteToLocalSyncStopped(); if (!m_pSendLocalChangesManager->active()) { @@ -752,7 +743,7 @@ void SynchronizationManagerPrivate::onRemoteToLocalSyncFailure( ErrorString errorDescription) { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::onRemoteToLocalSyncFailure: ") + QNDEBUG("SynchronizationManagerPrivate::onRemoteToLocalSyncFailure: " << errorDescription); Q_EMIT stopRemoteToLocalSync(); @@ -764,10 +755,10 @@ qint32 lastUpdateCount, qevercloud::Timestamp lastSyncTime) { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::") - << QStringLiteral("onRemoteToLocalSynchronizedContentFromUsersOwnAccount: ") - << QStringLiteral("last update count = ") << lastUpdateCount - << QStringLiteral(", last sync time = ") + QNDEBUG("SynchronizationManagerPrivate::" + << "onRemoteToLocalSynchronizedContentFromUsersOwnAccount: " + << "last update count = " << lastUpdateCount + << ", last sync time = " << printableDateTimeFromTimestamp(lastSyncTime)); m_lastUpdateCount = lastUpdateCount; @@ -778,8 +769,7 @@ void SynchronizationManagerPrivate::onShouldRepeatIncrementalSync() { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::" - "onShouldRepeatIncrementalSync")); + QNDEBUG("SynchronizationManagerPrivate::onShouldRepeatIncrementalSync"); m_shouldRepeatIncrementalSyncAfterSendingChanges = true; Q_EMIT willRepeatRemoteToLocalSyncAfterSendingChanges(); @@ -787,28 +777,31 @@ void SynchronizationManagerPrivate::onConflictDetectedDuringLocalChangesSending() { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::" - "onConflictDetectedDuringLocalChangesSending")); + QNDEBUG("SynchronizationManagerPrivate::" + "onConflictDetectedDuringLocalChangesSending"); Q_EMIT detectedConflictDuringLocalChangesSending(); m_pSendLocalChangesManager->stop(); - // NOTE: the detection of non-synchronized state with respect to remote - // service often precedes the actual conflict detection; need to drop this - // flag to prevent launching the incremental sync after sending the local - // changes after the incremental sync which we'd launch now + /** + * NOTE: the detection of non-synchronized state with respect to remote + * service often precedes the actual conflict detection; need to drop this + * flag to prevent launching the incremental sync after sending the local + * changes after the incremental sync which we'd launch now + */ m_shouldRepeatIncrementalSyncAfterSendingChanges = false; launchIncrementalSync(); } void SynchronizationManagerPrivate::onLocalChangesSent( - qint32 lastUpdateCount, QHash<QString,qint32> lastUpdateCountByLinkedNotebookGuid) + qint32 lastUpdateCount, + QHash<QString,qint32> lastUpdateCountByLinkedNotebookGuid) { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::onLocalChangesSent: ") - << QStringLiteral("last update count = ") << lastUpdateCount - << QStringLiteral(", last update count per linked notebook guid: ") + QNDEBUG("SynchronizationManagerPrivate::onLocalChangesSent: " + << "last update count = " << lastUpdateCount + << ", last update count per linked notebook guid: " << lastUpdateCountByLinkedNotebookGuid); bool somethingSent = (m_lastUpdateCount != lastUpdateCount) || @@ -821,14 +814,13 @@ updatePersistentSyncSettings(); if (m_shouldRepeatIncrementalSyncAfterSendingChanges) { - QNDEBUG(QStringLiteral("Repeating the incremental sync after sending " - "the changes")); + QNDEBUG("Repeating the incremental sync after sending the changes"); m_shouldRepeatIncrementalSyncAfterSendingChanges = false; launchIncrementalSync(); return; } - QNINFO(QStringLiteral("Finished the whole synchronization procedure!")); + QNINFO("Finished the whole synchronization procedure!"); bool somethingDownloaded = m_somethingDownloaded; m_somethingDownloaded = false; @@ -839,7 +831,7 @@ void SynchronizationManagerPrivate::onSendLocalChangesStopped() { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::onSendLocalChangesStopped")); + QNDEBUG("SynchronizationManagerPrivate::onSendLocalChangesStopped"); Q_EMIT sendLocalChangesStopped(); if (!m_pRemoteToLocalSyncManager->active()) { @@ -850,7 +842,7 @@ void SynchronizationManagerPrivate::onSendLocalChangesFailure( ErrorString errorDescription) { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::onSendLocalChangesFailure: ") + QNDEBUG("SynchronizationManagerPrivate::onSendLocalChangesFailure: " << errorDescription); stop(); @@ -859,18 +851,21 @@ void SynchronizationManagerPrivate::onRateLimitExceeded(qint32 secondsToWait) { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::onRateLimitExceeded")); + QNDEBUG("SynchronizationManagerPrivate::onRateLimitExceeded"); - // Before re-sending this signal to the outside world will attempt to collect - // the update sequence numbers for the next sync, either for user's own account - // or for each linked notebook - depending on what has been synced right before - // the Evernote API rate limit was exceeded. The collected update sequence numbers - // would be used to update the persistent sync settings. So that if the sync - // ends now before it's automatically restarted after the required waiting time - // (for example, user quits the app now), the next time we'll request the sync - // chunks after the last properly processed USN, either for user's own account - // or for linked notebooks, so that we won't re-download the same stuff over - // and over again and hit the rate limit at the very same sync stage + /** + * Before re-sending this signal to the outside world will attempt to + * collect the update sequence numbers for the next sync, either for user's + * own account or for each linked notebook - depending on what has been + * synced right before the Evernote API rate limit was exceeded. The + * collected update sequence numbers would be used to update the persistent + * sync settings. So that if the sync ends now before it's automatically + * restarted after the required waiting time (for example, user quits the + * app now), the next time we'll request the sync chunks after the last + * properly processed USN, either for user's own account or for linked + * notebooks, so that we won't re-download the same stuff over and over + * again and hit the rate limit at the very same sync stage + */ tryUpdateLastSyncStatus(); Q_EMIT rateLimitExceeded(secondsToWait); @@ -1155,7 +1150,7 @@ void SynchronizationManagerPrivate::readLastSyncParameters() { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::readLastSyncParameters")); + QNDEBUG("SynchronizationManagerPrivate::readLastSyncParameters"); m_pSyncStatePersistenceManager->getPersistentSyncState( m_pRemoteToLocalSyncManager->account(), @@ -1167,44 +1162,48 @@ m_onceReadLastSyncParams = true; } -void SynchronizationManagerPrivate::authenticateImpl(const AuthContext::type authContext) +void SynchronizationManagerPrivate::authenticateImpl( + const AuthContext::type authContext) { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::authenticateImpl: ") - << QStringLiteral("auth context = ") << authContext); + QNDEBUG("SynchronizationManagerPrivate::authenticateImpl: auth context = " + << authContext); m_authContext = authContext; if (m_authContext == AuthContext::NewUserRequest) { - QNDEBUG(QStringLiteral("Authentication of the new user is requested, " - "proceeding to OAuth")); + QNDEBUG("Authentication of the new user is requested, " + "proceeding to OAuth"); launchOAuth(); return; } if (m_OAuthResult.m_userId < 0) { - QNDEBUG(QStringLiteral("No current user id, launching the OAuth procedure")); + QNDEBUG("No current user id, launching the OAuth procedure"); launchOAuth(); return; } if (validAuthentication()) { - QNDEBUG(QStringLiteral("Found already valid authentication info")); + QNDEBUG("Found already valid authentication info"); finalizeAuthentication(); return; } - QNTRACE(QStringLiteral("Trying to restore persistent authentication settings...")); + QNTRACE("Trying to restore persistent authentication settings..."); ApplicationSettings appSettings(m_pRemoteToLocalSyncManager->account(), SYNCHRONIZATION_PERSISTENCE_NAME); - QString keyGroup = QStringLiteral("Authentication/") + m_host + QStringLiteral("/") + - QString::number(m_OAuthResult.m_userId) + QStringLiteral("/"); + QString keyGroup = QStringLiteral("Authentication/") + m_host + + QStringLiteral("/") + + QString::number(m_OAuthResult.m_userId) + + QStringLiteral("/"); - QVariant tokenExpirationValue = appSettings.value(keyGroup + EXPIRATION_TIMESTAMP_KEY); + QVariant tokenExpirationValue = + appSettings.value(keyGroup + EXPIRATION_TIMESTAMP_KEY); if (tokenExpirationValue.isNull()) { - QNINFO(QStringLiteral("Authentication token expiration timestamp was not " - "found within application settings, assuming it has " - "never been written & launching the OAuth procedure")); + QNINFO("Authentication token expiration timestamp was not " + "found within application settings, assuming it has " + "never been written & launching the OAuth procedure"); launchOAuth(); return; } @@ -1212,26 +1211,29 @@ bool conversionResult = false; qevercloud::Timestamp tokenExpirationTimestamp = tokenExpirationValue.toLongLong(&conversionResult); - if (!conversionResult) { - ErrorString error(QT_TR_NOOP("Internal error: failed to convert QVariant " - "with authentication token expiration " - "timestamp to the actual timestamp")); + if (!conversionResult) + { + ErrorString error( + QT_TR_NOOP("Internal error: failed to convert QVariant " + "with authentication token expiration " + "timestamp to the actual timestamp")); QNWARNING(error); Q_EMIT notifyError(error); return; } - if (checkIfTimestampIsAboutToExpireSoon(tokenExpirationTimestamp)) { - QNINFO(QStringLiteral("Authentication token stored in persistent " - "application settings is about to expire soon " - "enough, launching the OAuth procedure")); + if (checkIfTimestampIsAboutToExpireSoon(tokenExpirationTimestamp)) + { + QNINFO("Authentication token stored in persistent " + "application settings is about to expire soon " + "enough, launching the OAuth procedure"); launchOAuth(); return; } m_OAuthResult.m_expirationTime = tokenExpirationTimestamp; - QNTRACE(QStringLiteral("Restoring persistent note store url")); + QNTRACE("Restoring persistent note store url"); QVariant noteStoreUrlValue = appSettings.value(keyGroup + NOTE_STORE_URL_KEY); if (noteStoreUrlValue.isNull()) { @@ -1253,9 +1255,10 @@ m_OAuthResult.m_noteStoreUrl = noteStoreUrl; - QNDEBUG(QStringLiteral("Restoring persistent web api url prefix")); + QNDEBUG("Restoring persistent web api url prefix"); - QVariant webApiUrlPrefixValue = appSettings.value(keyGroup + WEB_API_URL_PREFIX_KEY); + QVariant webApiUrlPrefixValue = + appSettings.value(keyGroup + WEB_API_URL_PREFIX_KEY); if (webApiUrlPrefixValue.isNull()) { ErrorString error(QT_TR_NOOP("Failed to find the web API url prefix " "within persistent application settings")); @@ -1275,8 +1278,8 @@ m_OAuthResult.m_webApiUrlPrefix = webApiUrlPrefix; - QNDEBUG(QStringLiteral("Trying to restore the authentication token and " - "the shard id from the keychain")); + QNDEBUG("Trying to restore the authentication token and " + "the shard id from the keychain"); m_readingAuthToken = true; QString readAuthTokenService = QCoreApplication::applicationName() + @@ -1303,10 +1306,10 @@ void SynchronizationManagerPrivate::launchOAuth() { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::launchOAuth")); + QNDEBUG("SynchronizationManagerPrivate::launchOAuth"); if (m_authenticationInProgress) { - QNDEBUG(QStringLiteral("Authentication is already in progress")); + QNDEBUG("Authentication is already in progress"); return; } @@ -1316,7 +1319,7 @@ void SynchronizationManagerPrivate::launchSync() { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::launchSync")); + QNDEBUG("SynchronizationManagerPrivate::launchSync"); if (!m_onceReadLastSyncParams) { readLastSyncParameters(); @@ -1329,19 +1332,19 @@ m_pUserStore->setAuthenticationToken(m_OAuthResult.m_authToken); if (m_lastUpdateCount <= 0) { - QNDEBUG(QStringLiteral("The client has never synchronized with " - "the remote service, performing the full sync")); + QNDEBUG("The client has never synchronized with " + "the remote service, performing the full sync"); launchFullSync(); return; } - QNDEBUG(QStringLiteral("Performing incremental sync")); + QNDEBUG("Performing incremental sync"); launchIncrementalSync(); } void SynchronizationManagerPrivate::launchFullSync() { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::launchFullSync")); + QNDEBUG("SynchronizationManagerPrivate::launchFullSync"); m_somethingDownloaded = false; m_pRemoteToLocalSyncManager->start(); @@ -1349,8 +1352,8 @@ void SynchronizationManagerPrivate::launchIncrementalSync() { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::launchIncrementalSync: ") - << QStringLiteral("m_lastUpdateCount = ") << m_lastUpdateCount); + QNDEBUG("SynchronizationManagerPrivate::launchIncrementalSync: " + << "m_lastUpdateCount = " << m_lastUpdateCount); m_somethingDownloaded = false; m_pRemoteToLocalSyncManager->start(m_lastUpdateCount); @@ -1358,14 +1361,16 @@ void SynchronizationManagerPrivate::sendChanges() { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::sendChanges")); - m_pSendLocalChangesManager->start(m_lastUpdateCount, - m_cachedLinkedNotebookLastUpdateCountByGuid); + QNDEBUG("SynchronizationManagerPrivate::sendChanges"); + m_pSendLocalChangesManager->start( + m_lastUpdateCount, + m_cachedLinkedNotebookLastUpdateCountByGuid); } -void SynchronizationManagerPrivate::launchStoreOAuthResult(const AuthData & result) +void SynchronizationManagerPrivate::launchStoreOAuthResult( + const AuthData & result) { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::launchStoreOAuthResult")); + QNDEBUG("SynchronizationManagerPrivate::launchStoreOAuthResult"); m_writtenOAuthResult = result; @@ -1396,13 +1401,15 @@ void SynchronizationManagerPrivate::finalizeStoreOAuthResult() { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::finalizeStoreOAuthResult")); + QNDEBUG("SynchronizationManagerPrivate::finalizeStoreOAuthResult"); ApplicationSettings appSettings(m_pRemoteToLocalSyncManager->account(), SYNCHRONIZATION_PERSISTENCE_NAME); - QString keyGroup = QStringLiteral("Authentication/") + m_host + QStringLiteral("/") + - QString::number(m_writtenOAuthResult.m_userId) + QStringLiteral("/"); + QString keyGroup = QStringLiteral("Authentication/") + m_host + + QStringLiteral("/") + + QString::number(m_writtenOAuthResult.m_userId) + + QStringLiteral("/"); appSettings.setValue(keyGroup + NOTE_STORE_URL_KEY, m_writtenOAuthResult.m_noteStoreUrl); @@ -1411,13 +1418,12 @@ appSettings.setValue(keyGroup + WEB_API_URL_PREFIX_KEY, m_writtenOAuthResult.m_webApiUrlPrefix); - QNDEBUG(QStringLiteral("Successfully wrote the authentication result info ") - << QStringLiteral("to the application settings for host ") - << m_host << QStringLiteral(", user id ") - << m_writtenOAuthResult.m_userId << QStringLiteral(": ") - << QStringLiteral(": auth token expiration timestamp = ") + QNDEBUG("Successfully wrote the authentication result info " + << "to the application settings for host " << m_host << ", user id " + << m_writtenOAuthResult.m_userId + << ": auth token expiration timestamp = " << printableDateTimeFromTimestamp(m_writtenOAuthResult.m_expirationTime) - << QStringLiteral(", web API url prefix = ") + << ", web API url prefix = " << m_writtenOAuthResult.m_webApiUrlPrefix); finalizeAuthentication(); @@ -1425,8 +1431,8 @@ void SynchronizationManagerPrivate::finalizeAuthentication() { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::finalizeAuthentication: ") - << QStringLiteral("result = ") << m_OAuthResult); + QNDEBUG("SynchronizationManagerPrivate::finalizeAuthentication: " + << "result = " << m_OAuthResult); switch(m_authContext) { @@ -1446,9 +1452,11 @@ case AuthContext::CurrentUserRequest: { Account account = m_pRemoteToLocalSyncManager->account(); - QNDEBUG(QStringLiteral("Emitting the authenticationFinished signal: ") - << account); - Q_EMIT authenticationFinished(/* success = */ true, ErrorString(), account); + QNDEBUG("Emitting the authenticationFinished signal: " << account); + Q_EMIT authenticationFinished( + /* success = */ true, + ErrorString(), + account); m_writtenOAuthResult = AuthData(); m_writtenOAuthResult.m_userId = -1; @@ -1472,7 +1480,8 @@ void SynchronizationManagerPrivate::timerEvent(QTimerEvent * pTimerEvent) { - if (Q_UNLIKELY(!pTimerEvent)) { + if (Q_UNLIKELY(!pTimerEvent)) + { ErrorString errorDescription(QT_TR_NOOP("Qt error: detected null pointer " "to QTimerEvent")); QNWARNING(errorDescription); @@ -1483,20 +1492,21 @@ int timerId = pTimerEvent->timerId(); killTimer(timerId); - QNDEBUG(QStringLiteral("Timer event for timer id ") << timerId); + QNDEBUG("Timer event for timer id " << timerId); if (timerId == m_launchSyncPostponeTimerId) { - QNDEBUG(QStringLiteral("Re-launching the sync procedure due to " - "RATE_LIMIT_REACHED exception when trying to get " - "the sync state the last time")); + QNDEBUG("Re-launching the sync procedure due to " + "RATE_LIMIT_REACHED exception when trying to get " + "the sync state the last time"); launchSync(); return; } - if (timerId == m_authenticateToLinkedNotebooksPostponeTimerId) { + if (timerId == m_authenticateToLinkedNotebooksPostponeTimerId) + { m_authenticateToLinkedNotebooksPostponeTimerId = -1; - QNDEBUG(QStringLiteral("Re-attempting to authenticate to the remaining " - "linked (shared) notebooks")); + QNDEBUG("Re-attempting to authenticate to the remaining " + "linked (shared) notebooks"); onRequestAuthenticationTokensForLinkedNotebooks( m_linkedNotebookAuthDataPendingAuthentication); return; @@ -1505,7 +1515,7 @@ void SynchronizationManagerPrivate::clear() { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::clear")); + QNDEBUG("SynchronizationManagerPrivate::clear"); m_lastUpdateCount = -1; m_previousUpdateCount = -1; @@ -1568,12 +1578,12 @@ bool SynchronizationManagerPrivate::checkIfTimestampIsAboutToExpireSoon( const qevercloud::Timestamp timestamp) const { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::") - << QStringLiteral("checkIfTimestampIsAboutToExpireSoon: ") + QNDEBUG("SynchronizationManagerPrivate::" + << "checkIfTimestampIsAboutToExpireSoon: " << printableDateTimeFromTimestamp(timestamp)); qevercloud::Timestamp currentTimestamp = QDateTime::currentMSecsSinceEpoch(); - QNTRACE(QStringLiteral("Current datetime: ") + QNTRACE("Current datetime: " << printableDateTimeFromTimestamp(currentTimestamp)); if ((timestamp - currentTimestamp) < HALF_AN_HOUR_IN_MSEC) { @@ -1585,7 +1595,7 @@ void SynchronizationManagerPrivate::authenticateToLinkedNotebooks() { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::authenticateToLinkedNotebooks")); + QNDEBUG("SynchronizationManagerPrivate::authenticateToLinkedNotebooks"); if (Q_UNLIKELY(m_OAuthResult.m_userId < 0)) { ErrorString error(QT_TR_NOOP("Detected attempt to authenticate to linked " @@ -1598,9 +1608,9 @@ const int numLinkedNotebooks = m_linkedNotebookAuthDataPendingAuthentication.size(); if (numLinkedNotebooks == 0) { - QNDEBUG(QStringLiteral("No linked notebooks waiting for authentication, " - "sending the cached auth tokens, shard ids and " - "expiration times")); + QNDEBUG("No linked notebooks waiting for authentication, " + "sending the cached auth tokens, shard ids and " + "expiration times"); Q_EMIT sendAuthenticationTokensForLinkedNotebooks( m_cachedLinkedNotebookAuthTokensAndShardIdsByGuid, m_cachedLinkedNotebookAuthTokenExpirationTimeByGuid); @@ -1609,8 +1619,10 @@ ApplicationSettings appSettings(m_pRemoteToLocalSyncManager->account(), SYNCHRONIZATION_PERSISTENCE_NAME); - QString keyGroup = QStringLiteral("Authentication/") + m_host + QStringLiteral("/") + - QString::number(m_OAuthResult.m_userId) + QStringLiteral("/"); + QString keyGroup = QStringLiteral("Authentication/") + m_host + + QStringLiteral("/") + + QString::number(m_OAuthResult.m_userId) + + QStringLiteral("/"); QHash<QString,QPair<QString,QString> > authTokensAndShardIdsToCacheByGuid; QHash<QString,qevercloud::Timestamp> authTokenExpirationTimestampsToCacheByGuid; @@ -1631,11 +1643,11 @@ const QString & sharedNotebookGlobalId = authData.m_sharedNotebookGlobalId; const QString & uri = authData.m_uri; const QString & noteStoreUrl = authData.m_noteStoreUrl; - QNDEBUG(QStringLiteral("Processing linked notebook guid = ") << guid - << QStringLiteral(", shard id = ") << shardId - << QStringLiteral(", shared notebook global id = ") - << sharedNotebookGlobalId << QStringLiteral(", uri = ") << uri - << QStringLiteral(", note store URL = ") << noteStoreUrl); + QNDEBUG("Processing linked notebook guid = " << guid + << ", shard id = " << shardId + << ", shared notebook global id = " + << sharedNotebookGlobalId << ", uri = " << uri + << ", note store URL = " << noteStoreUrl); if (sharedNotebookGlobalId.isEmpty() && !uri.isEmpty()) { @@ -1655,7 +1667,8 @@ bool forceRemoteAuth = false; auto linkedNotebookAuthTokenIt = m_cachedLinkedNotebookAuthTokensAndShardIdsByGuid.find(guid); - if (linkedNotebookAuthTokenIt == m_cachedLinkedNotebookAuthTokensAndShardIdsByGuid.end()) + if (linkedNotebookAuthTokenIt == + m_cachedLinkedNotebookAuthTokensAndShardIdsByGuid.end()) { auto noAuthDataIt = m_linkedNotebookGuidsWithoutLocalAuthData.find(guid); if (noAuthDataIt != m_linkedNotebookGuidsWithoutLocalAuthData.end()) @@ -1665,10 +1678,10 @@ } else { - QNDEBUG(QStringLiteral("Haven't found the authentication token ") - << QStringLiteral("and shard id for linked notebook guid ") - << guid << QStringLiteral(" in the local cache, will try " - "to read them from the keychain")); + QNDEBUG("Haven't found the authentication token " + << "and shard id for linked notebook guid " << guid + << " in the local cache, will try to read them from " + << "the keychain"); Q_UNUSED(linkedNotebookGuidsPendingReadAuthTokenAndShardIdInKeychain.insert(guid)) @@ -1699,48 +1712,49 @@ guid, expirationTime); } else { - QNWARNING(QStringLiteral("Can't convert linked notebook's ") - << QStringLiteral("authentication token's expiration ") - << QStringLiteral("time from QVariant retrieved from ") - << QStringLiteral("app settings into timestamp: ") - << QStringLiteral("linked notebook guid = ") << guid - << QStringLiteral(", variant = ") << expirationTimeVariant); + QNWARNING("Can't convert linked notebook's " + << "authentication token's expiration " + << "time from QVariant retrieved from " + << "app settings into timestamp: " + << "linked notebook guid = " << guid + << ", variant = " << expirationTimeVariant); } } } if ( (linkedNotebookAuthTokenExpirationIt != m_cachedLinkedNotebookAuthTokenExpirationTimeByGuid.end()) && - !checkIfTimestampIsAboutToExpireSoon(linkedNotebookAuthTokenExpirationIt.value()) ) + !checkIfTimestampIsAboutToExpireSoon( + linkedNotebookAuthTokenExpirationIt.value()) ) { - QNDEBUG(QStringLiteral("Found authentication data for linked ") - << QStringLiteral("notebook guid ") << guid - << QStringLiteral(" + verified its expiration timestamp")); + QNDEBUG("Found authentication data for linked " + << "notebook guid " << guid + << " + verified its expiration timestamp"); it = m_linkedNotebookAuthDataPendingAuthentication.erase(it); continue; } } - QNDEBUG(QStringLiteral("Authentication data for linked notebook guid ") - << guid << QStringLiteral(" was either not found in local cache ") - << QStringLiteral("(and/or app settings / keychain) or has ") - << QStringLiteral("expired, need to receive that from remote ") - << QStringLiteral("Evernote service")); + QNDEBUG("Authentication data for linked notebook guid " + << guid << " was either not found in local cache " + << "(and/or app settings / keychain) or has " + << "expired, need to receive that from remote " + << "Evernote service"); if (m_authenticateToLinkedNotebooksPostponeTimerId >= 0) { - QNDEBUG(QStringLiteral("Authenticate to linked notebook postpone timer " - "is active, will wait to preserve the breach " - "of Evernote rate API limit")); + QNDEBUG("Authenticate to linked notebook postpone timer " + "is active, will wait to preserve the breach " + "of Evernote rate API limit"); ++it; continue; } if (m_authContext != AuthContext::Blank) { - QNDEBUG(QStringLiteral("Authentication context variable is not set ") - << QStringLiteral("to blank which means that authentication ") - << QStringLiteral("must be in progress: ") << m_authContext - << QStringLiteral("; won't attempt to call remote Evernote " - "API at this time")); + QNDEBUG("Authentication context variable is not set " + << "to blank which means that authentication " + << "must be in progress: " << m_authContext + << "; won't attempt to call remote Evernote " + << "API at this time"); ++it; continue; } @@ -1750,10 +1764,12 @@ qint32 rateLimitSeconds = 0; INoteStore * pNoteStore = noteStoreForLinkedNotebookGuid(guid); - if (Q_UNLIKELY(!pNoteStore)) { - ErrorString error(QT_TR_NOOP("Can't sync the linked notebook contents: " - "can't find or create the note store " - "for the linked notebook")); + if (Q_UNLIKELY(!pNoteStore)) + { + ErrorString error( + QT_TR_NOOP("Can't sync the linked notebook contents: " + "can't find or create the note store " + "for the linked notebook")); Q_EMIT notifyError(error); return; } @@ -1802,20 +1818,20 @@ } else if (errorCode != 0) { - QNWARNING(QStringLiteral("Failed to authenticate to shared notebook: ") - << errorDescription << QStringLiteral(" (error code = ") - << errorCode << QStringLiteral(")")); + QNWARNING("Failed to authenticate to shared notebook: " + << errorDescription << " (error code = " + << errorCode << ")"); Q_EMIT notifyError(errorDescription); return; } - QNDEBUG(QStringLiteral("Retrieved authentication: server-side result ") - << QStringLiteral("generation time (currentTime) = ") + QNDEBUG("Retrieved authentication: server-side result " + << "generation time (currentTime) = " << printableDateTimeFromTimestamp(authResult.currentTime) - << QStringLiteral(", expiration time for the authentication result ") - << QStringLiteral("(expiration): ") + << ", expiration time for the authentication result " + << "(expiration): " << printableDateTimeFromTimestamp(authResult.expiration) - << QStringLiteral(", user: ") + << ", user: " << (authResult.user.isSet() ? ToString(authResult.user.ref()) : QStringLiteral("<empty>"))); @@ -1839,8 +1855,8 @@ if (m_linkedNotebookAuthDataPendingAuthentication.isEmpty()) { - QNDEBUG(QStringLiteral("Retrieved authentication data for all requested " - "linked notebooks, sending the answer now")); + QNDEBUG("Retrieved authentication data for all requested " + "linked notebooks, sending the answer now"); Q_EMIT sendAuthenticationTokensForLinkedNotebooks( m_cachedLinkedNotebookAuthTokensAndShardIdsByGuid, @@ -1856,33 +1872,35 @@ const QString & guid = *it; // 1) Set up the job of reading the authentication token - auto readAuthTokenJobIt = m_readLinkedNotebookAuthTokenJobIdsWithLinkedNotebookGuids.left.find(guid); - if (readAuthTokenJobIt == m_readLinkedNotebookAuthTokenJobIdsWithLinkedNotebookGuids.left.end()) { - QUuid jobId = - m_pKeychainService->startReadPasswordJob(READ_LINKED_NOTEBOOK_AUTH_TOKEN_JOB, - keyPrefix + - LINKED_NOTEBOOK_AUTH_TOKEN_KEY_PART + - guid); + auto readAuthTokenJobIt = + m_readLinkedNotebookAuthTokenJobIdsWithLinkedNotebookGuids.left.find(guid); + if (readAuthTokenJobIt == + m_readLinkedNotebookAuthTokenJobIdsWithLinkedNotebookGuids.left.end()) + { + QUuid jobId = m_pKeychainService->startReadPasswordJob( + READ_LINKED_NOTEBOOK_AUTH_TOKEN_JOB, + keyPrefix + LINKED_NOTEBOOK_AUTH_TOKEN_KEY_PART + guid); m_readLinkedNotebookAuthTokenJobIdsWithLinkedNotebookGuids.insert( JobIdWithGuidBimap::value_type(guid, jobId)); } // 2) Set up the job reading the shard id - auto readShardIdJobIt = m_readLinkedNotebookShardIdJobIdsWithLinkedNotebookGuids.left.find(guid); - if (readShardIdJobIt == m_readLinkedNotebookShardIdJobIdsWithLinkedNotebookGuids.left.end()) { - QUuid jobId = - m_pKeychainService->startReadPasswordJob(READ_LINKED_NOTEBOOK_SHARD_ID_JOB, - keyPrefix + - LINKED_NOTEBOOK_SHARD_ID_KEY_PART + - guid); + auto readShardIdJobIt = + m_readLinkedNotebookShardIdJobIdsWithLinkedNotebookGuids.left.find(guid); + if (readShardIdJobIt == + m_readLinkedNotebookShardIdJobIdsWithLinkedNotebookGuids.left.end()) + { + QUuid jobId = m_pKeychainService->startReadPasswordJob( + READ_LINKED_NOTEBOOK_SHARD_ID_JOB, + keyPrefix + LINKED_NOTEBOOK_SHARD_ID_KEY_PART + guid); m_readLinkedNotebookShardIdJobIdsWithLinkedNotebookGuids.insert( JobIdWithGuidBimap::value_type(guid, jobId)); } } - QNDEBUG(QStringLiteral("Pending read auth tokens and shard ids from keychain for ") + QNDEBUG("Pending read auth tokens and shard ids from keychain for " << linkedNotebookGuidsPendingReadAuthTokenAndShardIdInKeychain.size() - << QStringLiteral(" linked notebooks")); + << " linked notebooks"); return; } @@ -1907,13 +1925,15 @@ const QString & shardId = it.value().second; // 1) Set up the job writing the auth token to the keychain - auto jobIt = m_writeLinkedNotebookAuthTokenJobIdsWithLinkedNotebookGuids.left.find(guid); // clazy:exclude=rule-of-two-soft - if (jobIt == m_writeLinkedNotebookAuthTokenJobIdsWithLinkedNotebookGuids.left.end()) + auto jobIt = + m_writeLinkedNotebookAuthTokenJobIdsWithLinkedNotebookGuids.left.find(guid); // clazy:exclude=rule-of-two-soft + if (jobIt == + m_writeLinkedNotebookAuthTokenJobIdsWithLinkedNotebookGuids.left.end()) { QString key = keyPrefix + LINKED_NOTEBOOK_AUTH_TOKEN_KEY_PART + guid; - QUuid jobId = - m_pKeychainService->startWritePasswordJob(WRITE_LINKED_NOTEBOOK_AUTH_TOKEN_JOB, - key, token); + QUuid jobId = m_pKeychainService->startWritePasswordJob( + WRITE_LINKED_NOTEBOOK_AUTH_TOKEN_JOB, + key, token); m_writeLinkedNotebookAuthTokenJobIdsWithLinkedNotebookGuids.insert( JobIdWithGuidBimap::value_type(guid, jobId)); } @@ -1922,13 +1942,15 @@ } // 2) Set up the job writing the shard id to the keychain - jobIt = m_writeLinkedNotebookShardIdJobIdsWithLinkedNotebookGuids.left.find(guid); // clazy:exclude=rule-of-two-soft - if (jobIt == m_writeLinkedNotebookShardIdJobIdsWithLinkedNotebookGuids.left.end()) + jobIt = // clazy:exclude=rule-of-two-soft + m_writeLinkedNotebookShardIdJobIdsWithLinkedNotebookGuids.left.find(guid); // clazy:exclude=rule-of-two-soft + if (jobIt == + m_writeLinkedNotebookShardIdJobIdsWithLinkedNotebookGuids.left.end()) { QString key = keyPrefix + LINKED_NOTEBOOK_SHARD_ID_KEY_PART + guid; - QUuid jobId = - m_pKeychainService->startWritePasswordJob(WRITE_LINKED_NOTEBOOK_SHARD_ID_JOB, - key, shardId); + QUuid jobId = m_pKeychainService->startWritePasswordJob( + WRITE_LINKED_NOTEBOOK_SHARD_ID_JOB, + key, shardId); m_writeLinkedNotebookShardIdJobIdsWithLinkedNotebookGuids.insert( JobIdWithGuidBimap::value_type(guid, jobId)); } @@ -1942,29 +1964,28 @@ const IKeychainService::ErrorCode::type errorCode, const ErrorString & errorDescription, const QString & password) { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::onReadAuthTokenFinished: ") - << QStringLiteral("error code = ") << errorCode - << QStringLiteral(", error description = ") << errorDescription); + QNDEBUG("SynchronizationManagerPrivate::onReadAuthTokenFinished: " + << "error code = " << errorCode << ", error description = " + << errorDescription); m_readingAuthToken = false; if (errorCode == IKeychainService::ErrorCode::EntryNotFound) { - QNWARNING(QStringLiteral("Unexpectedly missing OAuth token in the keychain: ") - << errorDescription << QStringLiteral("; fallback to explicit OAuth")); + QNWARNING("Unexpectedly missing OAuth token in the keychain: " + << errorDescription << "; fallback to explicit OAuth"); launchOAuth(); return; } if (errorCode != IKeychainService::ErrorCode::NoError) { - QNWARNING(QStringLiteral("Attempt to read the auth token returned with ") - << QStringLiteral("error: error code ") << errorCode - << QStringLiteral(", ") << errorDescription - << QStringLiteral(". Fallback to explicit OAuth")); + QNWARNING("Attempt to read the auth token returned with " + << "error: error code " << errorCode + << ", " << errorDescription << ". Fallback to explicit OAuth"); launchOAuth(); return; } - QNDEBUG(QStringLiteral("Successfully restored the authentication token")); + QNDEBUG("Successfully restored the authentication token"); m_OAuthResult.m_authToken = password; if (!m_readingShardId && !m_authenticationInProgress && !m_writingShardId) { @@ -1976,29 +1997,28 @@ const IKeychainService::ErrorCode::type errorCode, const ErrorString & errorDescription, const QString & password) { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::onReadShardIdFinished: ") - << QStringLiteral("error code = ") << errorCode - << QStringLiteral(", error description = ") << errorDescription); + QNDEBUG("SynchronizationManagerPrivate::onReadShardIdFinished: " + << "error code = " << errorCode + << ", error description = " << errorDescription); m_readingShardId = false; if (errorCode == IKeychainService::ErrorCode::EntryNotFound) { - QNWARNING(QStringLiteral("Unexpectedly missing OAuth shard id in the keychain: ") - << errorDescription << QStringLiteral("; fallback to explicit OAuth")); + QNWARNING("Unexpectedly missing OAuth shard id in the keychain: " + << errorDescription << "; fallback to explicit OAuth"); launchOAuth(); return; } if (errorCode != IKeychainService::ErrorCode::NoError) { - QNWARNING(QStringLiteral("Attempt to read the shard id returned with error: ") - << QStringLiteral("error code ") << errorCode - << QStringLiteral(", ") << errorDescription - << QStringLiteral(". Fallback to explicit OAuth")); + QNWARNING("Attempt to read the shard id returned with error: " + << "error code " << errorCode << ", " << errorDescription + << ". Fallback to explicit OAuth"); launchOAuth(); return; } - QNDEBUG(QStringLiteral("Successfully restored the shard id")); + QNDEBUG("Successfully restored the shard id"); m_OAuthResult.m_shardId = password; if (!m_readingAuthToken && !m_authenticationInProgress && !m_writingAuthToken) { @@ -2010,14 +2030,16 @@ const IKeychainService::ErrorCode::type errorCode, const ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::onWriteAuthTokenFinished: ") - << QStringLiteral("error code = ") << errorCode - << QStringLiteral(", error description = ") << errorDescription); + QNDEBUG("SynchronizationManagerPrivate::onWriteAuthTokenFinished: " + << "error code = " << errorCode + << ", error description = " << errorDescription); m_writingAuthToken = false; - if (errorCode != IKeychainService::ErrorCode::NoError) { - ErrorString error(QT_TR_NOOP("Failed to write the OAuth token to the keychain")); + if (errorCode != IKeychainService::ErrorCode::NoError) + { + ErrorString error( + QT_TR_NOOP("Failed to write the OAuth token to the keychain")); error.appendBase(errorDescription.base()); error.appendBase(errorDescription.additionalBases()); error.details() = errorDescription.details(); @@ -2026,7 +2048,7 @@ return; } - QNDEBUG(QStringLiteral("Successfully stored the authentication token in the keychain")); + QNDEBUG("Successfully stored the authentication token in the keychain"); if (!m_writingShardId && !m_authenticationInProgress && !m_readingShardId) { finalizeStoreOAuthResult(); @@ -2037,14 +2059,16 @@ const IKeychainService::ErrorCode::type errorCode, const ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::onWriteShardIdFinished: ") - << QStringLiteral("error code = ") << errorCode - << QStringLiteral(", error description = ") << errorDescription); + QNDEBUG("SynchronizationManagerPrivate::onWriteShardIdFinished: " + << "error code = " << errorCode << ", error description = " + << errorDescription); m_writingShardId = false; - if (errorCode != IKeychainService::ErrorCode::NoError) { - ErrorString error(QT_TR_NOOP("Failed to write the shard id to the keychain")); + if (errorCode != IKeychainService::ErrorCode::NoError) + { + ErrorString error( + QT_TR_NOOP("Failed to write the shard id to the keychain")); error.appendBase(errorDescription.base()); error.appendBase(errorDescription.additionalBases()); error.details() = errorDescription.details(); @@ -2053,7 +2077,7 @@ return; } - QNDEBUG(QStringLiteral("Successfully stored the shard id in the keychain")); + QNDEBUG("Successfully stored the shard id in the keychain"); if (!m_writingAuthToken && !m_authenticationInProgress && !m_readingAuthToken) { finalizeStoreOAuthResult(); @@ -2064,10 +2088,10 @@ const IKeychainService::ErrorCode::type errorCode, const ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::onDeleteAuthTokenFinished: ") - << QStringLiteral("user id = ") << m_lastRevokedAuthenticationUserId - << QStringLiteral(", error code = ") << errorCode - << QStringLiteral(", error description = ") << errorDescription); + QNDEBUG("SynchronizationManagerPrivate::onDeleteAuthTokenFinished: " + << "user id = " << m_lastRevokedAuthenticationUserId + << ", error code = " << errorCode + << ", error description = " << errorDescription); m_deletingAuthToken = false; @@ -2077,8 +2101,8 @@ m_deletingShardId = false; m_deleteShardIdJobId = QUuid(); - QNWARNING(QStringLiteral("Attempt to delete the auth token returned ") - << QStringLiteral("with error: ") << errorDescription); + QNWARNING("Attempt to delete the auth token returned " + << "with error: " << errorDescription); ErrorString error(QT_TR_NOOP("Failed to delete authentication token " "from the keychain")); error.appendBase(errorDescription.base()); @@ -2099,10 +2123,10 @@ const IKeychainService::ErrorCode::type errorCode, const ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::onDeleteShardIdFinished: ") - << QStringLiteral("user id = ") << m_lastRevokedAuthenticationUserId - << QStringLiteral(", error code = ") << errorCode - << QStringLiteral(", error description = ") << errorDescription); + QNDEBUG("SynchronizationManagerPrivate::onDeleteShardIdFinished: " + << "user id = " << m_lastRevokedAuthenticationUserId + << ", error code = " << errorCode + << ", error description = " << errorDescription); m_deletingShardId = false; @@ -2112,9 +2136,10 @@ m_deletingAuthToken = false; m_deleteAuthTokenJobId = QUuid(); - QNWARNING(QStringLiteral("Attempt to delete the shard id returned with error: ") + QNWARNING("Attempt to delete the shard id returned with error: " << errorDescription); - ErrorString error(QT_TR_NOOP("Failed to delete shard id from the keychain")); + ErrorString error( + QT_TR_NOOP("Failed to delete shard id from the keychain")); error.appendBase(errorDescription.base()); error.appendBase(errorDescription.additionalBases()); error.details() = errorDescription.details(); @@ -2131,7 +2156,7 @@ void SynchronizationManagerPrivate::tryUpdateLastSyncStatus() { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::tryUpdateLastSyncStatus")); + QNDEBUG("SynchronizationManagerPrivate::tryUpdateLastSyncStatus"); qint32 updateCount = -1; QHash<QString,qint32> updateCountsByLinkedNotebookGuid; @@ -2139,8 +2164,8 @@ updateCount, updateCountsByLinkedNotebookGuid); if ((updateCount < 0) && updateCountsByLinkedNotebookGuid.isEmpty()) { - QNDEBUG(QStringLiteral("Found no USNs for neither user's own account " - "nor linked notebooks")); + QNDEBUG("Found no USNs for neither user's own account " + "nor linked notebooks"); return; } @@ -2152,9 +2177,9 @@ { m_lastUpdateCount = updateCount; m_lastSyncTime = lastSyncTime; - QNDEBUG(QStringLiteral("Got updated sync state for user's own account: ") - << QStringLiteral("update count = ") << m_lastUpdateCount - << QStringLiteral(", last sync time = ") + QNDEBUG("Got updated sync state for user's own account: " + << "update count = " << m_lastUpdateCount + << ", last sync time = " << printableDateTimeFromTimestamp(m_lastSyncTime)); shouldUpdatePersistentSyncSettings = true; } @@ -2166,9 +2191,9 @@ { m_cachedLinkedNotebookLastUpdateCountByGuid[it.key()] = it.value(); m_cachedLinkedNotebookLastSyncTimeByGuid[it.key()] = lastSyncTime; - QNDEBUG(QStringLiteral("Got updated sync state for linked notebook with guid ") - << it.key() << QStringLiteral(", update count = ") << it.value() - << QStringLiteral(", last sync time = ") << lastSyncTime); + QNDEBUG("Got updated sync state for linked notebook with guid " + << it.key() << ", update count = " << it.value() + << ", last sync time = " << lastSyncTime); shouldUpdatePersistentSyncSettings = true; } } @@ -2180,23 +2205,24 @@ void SynchronizationManagerPrivate::updatePersistentSyncSettings() { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::updatePersistentSyncSettings")); + QNDEBUG("SynchronizationManagerPrivate::updatePersistentSyncSettings"); - m_pSyncStatePersistenceManager->persistSyncState(m_pRemoteToLocalSyncManager->account(), - m_lastUpdateCount, m_lastSyncTime, - m_cachedLinkedNotebookLastUpdateCountByGuid, - m_cachedLinkedNotebookLastSyncTimeByGuid); + m_pSyncStatePersistenceManager->persistSyncState( + m_pRemoteToLocalSyncManager->account(), + m_lastUpdateCount, m_lastSyncTime, + m_cachedLinkedNotebookLastUpdateCountByGuid, + m_cachedLinkedNotebookLastSyncTimeByGuid); } INoteStore * SynchronizationManagerPrivate::noteStoreForLinkedNotebook( const LinkedNotebook & linkedNotebook) { - QNTRACE(QStringLiteral("SynchronizationManagerPrivate::noteStoreForLinkedNotebook: ") + QNTRACE("SynchronizationManagerPrivate::noteStoreForLinkedNotebook: " << linkedNotebook); if (Q_UNLIKELY(!linkedNotebook.hasGuid())) { - QNTRACE(QStringLiteral("Linked notebook has no guid, can't find or create " - "note store for it")); + QNTRACE("Linked notebook has no guid, can't find or create " + "note store for it"); return Q_NULLPTR; } @@ -2206,8 +2232,8 @@ } if (linkedNotebook.hasNoteStoreUrl()) { - QNTRACE(QStringLiteral("Setting note store URL to the created and/or ") - << QStringLiteral("found note store: ") << linkedNotebook.noteStoreUrl()); + QNTRACE("Setting note store URL to the created and/or " + << "found note store: " << linkedNotebook.noteStoreUrl()); pNoteStore->setNoteStoreUrl(linkedNotebook.noteStoreUrl()); } @@ -2217,28 +2243,27 @@ INoteStore * SynchronizationManagerPrivate::noteStoreForLinkedNotebookGuid( const QString & guid) { - QNDEBUG(QStringLiteral("SynchronizationManagerPrivate::") - << QStringLiteral("noteStoreForLinkedNotebookGuid: guid = ") << guid); + QNDEBUG("SynchronizationManagerPrivate::" + << "noteStoreForLinkedNotebookGuid: guid = " << guid); if (Q_UNLIKELY(guid.isEmpty())) { - QNWARNING(QStringLiteral("Can't find or create the note store for empty " - "linked notebook guid")); + QNWARNING("Can't find or create the note store for empty " + "linked notebook guid"); return Q_NULLPTR; } auto it = m_noteStoresByLinkedNotebookGuids.find(guid); if (it != m_noteStoresByLinkedNotebookGuids.end()) { - QNDEBUG(QStringLiteral("Found existing note store for linked notebook guid ") - << guid); + QNDEBUG("Found existing note store for linked notebook guid " << guid); return it.value(); } - QNDEBUG(QStringLiteral("Found no existing note store corresponding to " - "linked notebook guid ") << guid); + QNDEBUG("Found no existing note store corresponding to " + << "linked notebook guid " << guid); if (m_authenticationInProgress) { - QNWARNING(QStringLiteral("Can't create the note store for a linked " - "notebook: the authentication is in progress")); + QNWARNING("Can't create the note store for a linked " + "notebook: the authentication is in progress"); return Q_NULLPTR; } @@ -2313,16 +2338,14 @@ QTextStream & SynchronizationManagerPrivate::AuthData::print(QTextStream & strm) const { - strm << QStringLiteral("AuthData: {\n") - << QStringLiteral(" user id = ") << m_userId << QStringLiteral(";\n") - << QStringLiteral(" auth token expiration time = ") - << printableDateTimeFromTimestamp(m_expirationTime) << QStringLiteral(";\n") - << QStringLiteral(" shard id = ") << m_shardId << QStringLiteral(";\n") - << QStringLiteral(" note store url = ") << m_noteStoreUrl - << QStringLiteral(";\n") - << QStringLiteral(" web API url prefix = ") << m_webApiUrlPrefix - << QStringLiteral(";\n") - << QStringLiteral("};\n"); + strm << "AuthData: {\n" + << " user id = " << m_userId << ";\n" + << " auth token expiration time = " + << printableDateTimeFromTimestamp(m_expirationTime) << ";\n" + << " shard id = " << m_shardId << ";\n" + << " note store url = " << m_noteStoreUrl << ";\n" + << " web API url prefix = " << m_webApiUrlPrefix << ";\n" + << "};\n"; return strm; } diff -Nru libquentier-0.5.0/src/synchronization/SynchronizationManager_p.h libquentier-0.5.0/src/synchronization/SynchronizationManager_p.h --- libquentier-0.5.0/src/synchronization/SynchronizationManager_p.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/SynchronizationManager_p.h 2019-07-11 10:46:53.000000000 +0000 @@ -44,11 +44,13 @@ { Q_OBJECT public: - SynchronizationManagerPrivate(const QString & host, - LocalStorageManagerAsync & localStorageManagerAsync, - IAuthenticationManager & authenticationManager, - SynchronizationManagerDependencyInjector * pInjector, - QObject * parent); + SynchronizationManagerPrivate( + const QString & host, + LocalStorageManagerAsync & localStorageManagerAsync, + IAuthenticationManager & authenticationManager, + SynchronizationManagerDependencyInjector * pInjector, + QObject * parent); + virtual ~SynchronizationManagerPrivate(); bool active() const; @@ -59,17 +61,21 @@ void notifyStop(); void notifyError(ErrorString errorDescription); void notifyRemoteToLocalSyncDone(bool somethingDownloaded); - void notifyFinish(Account account, bool somethingDownloaded, bool somethingSent); + void notifyFinish(Account account, bool somethingDownloaded, + bool somethingSent); // progress signals void syncChunksDownloadProgress(qint32 highestDownloadedUsn, qint32 highestServerUsn, qint32 lastPreviousUsn); void syncChunksDownloaded(); - void linkedNotebookSyncChunksDownloadProgress(qint32 highestDownloadedUsn, - qint32 highestServerUsn, - qint32 lastPreviousUsn, - LinkedNotebook linkedNotebook); + + void linkedNotebookSyncChunksDownloadProgress( + qint32 highestDownloadedUsn, + qint32 highestServerUsn, + qint32 lastPreviousUsn, + LinkedNotebook linkedNotebook); + void linkedNotebooksSyncChunksDownloaded(); void notesDownloadProgress(quint32 notesDownloaded, @@ -79,8 +85,10 @@ void resourcesDownloadProgress(quint32 resourcesDownloaded, quint32 totalResourcesToDownload); - void linkedNotebooksResourcesDownloadProgress(quint32 resourcesDownloaded, - quint32 totalResourcesToDownload); + + void linkedNotebooksResourcesDownloadProgress( + quint32 resourcesDownloaded, + quint32 totalResourcesToDownload); void preparedDirtyObjectsForSending(); void preparedLinkedNotebooksDirtyObjectsForSending(); @@ -118,8 +126,8 @@ void sendAuthenticationTokenAndShardId(QString authToken, QString shardId, qevercloud::Timestamp expirationTime); void sendAuthenticationTokensForLinkedNotebooks( - QHash<QString,QPair<QString,QString> > authenticationTokensAndShardIdsByLinkedNotebookGuids, - QHash<QString,qevercloud::Timestamp> authenticatonTokenExpirationTimesByLinkedNotebookGuids); + QHash<QString,QPair<QString,QString> > authTokensAndShardIdsByLinkedNotebookGuids, + QHash<QString,qevercloud::Timestamp> authTokenExpirationByLinkedNotebookGuids); void sendLastSyncParameters( qint32 lastUpdateCount, qevercloud::Timestamp lastSyncTime, @@ -135,15 +143,17 @@ typedef IKeychainService::ErrorCode ErrorCode; private Q_SLOTS: - void onOAuthResult(bool success, qevercloud::UserID userId, QString authToken, - qevercloud::Timestamp authTokenExpirationTime, QString shardId, - QString noteStoreUrl, QString webApiUrlPrefix, - ErrorString errorDescription); + void onOAuthResult(bool success, qevercloud::UserID userId, + QString authToken, + qevercloud::Timestamp authTokenExpirationTime, + QString shardId, QString noteStoreUrl, + QString webApiUrlPrefix, ErrorString errorDescription); void onWritePasswordJobFinished(QUuid jobId, ErrorCode::type errorCode, ErrorString errorDescription); void onReadPasswordJobFinished(QUuid jobId, ErrorCode::type errorCode, - ErrorString errorDescription, QString password); + ErrorString errorDescription, + QString password); void onDeletePasswordJobFinished(QUuid jobId, ErrorCode::type errorCode, ErrorString errorDescription); @@ -166,8 +176,10 @@ void onShouldRepeatIncrementalSync(); void onConflictDetectedDuringLocalChangesSending(); - void onLocalChangesSent(qint32 lastUpdateCount, - QHash<QString,qint32> lastUpdateCountByLinkedNotebookGuid); + void onLocalChangesSent( + qint32 lastUpdateCount, + QHash<QString,qint32> lastUpdateCountByLinkedNotebookGuid); + void onSendLocalChangesStopped(); void onSendLocalChangesFailure(ErrorString errorDescription); @@ -219,7 +231,10 @@ void clear(); bool validAuthentication() const; - bool checkIfTimestampIsAboutToExpireSoon(const qevercloud::Timestamp timestamp) const; + + bool checkIfTimestampIsAboutToExpireSoon( + const qevercloud::Timestamp timestamp) const; + void authenticateToLinkedNotebooks(); void onReadAuthTokenFinished(const IKeychainService::ErrorCode::type errorCode, diff -Nru libquentier-0.5.0/src/synchronization/SynchronizationShared.cpp libquentier-0.5.0/src/synchronization/SynchronizationShared.cpp --- libquentier-0.5.0/src/synchronization/SynchronizationShared.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/SynchronizationShared.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -28,11 +28,12 @@ m_noteStoreUrl() {} -LinkedNotebookAuthData::LinkedNotebookAuthData(const QString & guid, - const QString & shardId, - const QString & sharedNotebookGlobalId, - const QString & uri, - const QString & noteStoreUrl) : +LinkedNotebookAuthData::LinkedNotebookAuthData( + const QString & guid, + const QString & shardId, + const QString & sharedNotebookGlobalId, + const QString & uri, + const QString & noteStoreUrl) : m_guid(guid), m_shardId(shardId), m_sharedNotebookGlobalId(sharedNotebookGlobalId), @@ -42,14 +43,14 @@ QTextStream & LinkedNotebookAuthData::print(QTextStream & strm) const { - strm << QStringLiteral("LinkedNotebookAuthData: {\n") - << QStringLiteral(" guid = ") << m_guid << QStringLiteral("\n") - << QStringLiteral(" shard id = ") << m_shardId << QStringLiteral("\n") - << QStringLiteral(" shared notebook global id = ") - << m_sharedNotebookGlobalId << QStringLiteral("\n") - << QStringLiteral(" uri = ") << m_uri << QStringLiteral("\n") - << QStringLiteral(" note store url = ") << m_noteStoreUrl - << QStringLiteral("\n") << QStringLiteral("};\n"); + strm << "LinkedNotebookAuthData: {\n" + << " guid = " << m_guid << "\n" + << " shard id = " << m_shardId << "\n" + << " shared notebook global id = " + << m_sharedNotebookGlobalId << "\n" + << " uri = " << m_uri << "\n" + << " note store url = " << m_noteStoreUrl + << "\n" << "};\n"; return strm; } diff -Nru libquentier-0.5.0/src/synchronization/SynchronizationShared.h libquentier-0.5.0/src/synchronization/SynchronizationShared.h --- libquentier-0.5.0/src/synchronization/SynchronizationShared.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/SynchronizationShared.h 2019-07-11 10:46:53.000000000 +0000 @@ -37,33 +37,41 @@ #include <boost/multi_index/ordered_index.hpp> #endif -#define SYNCHRONIZATION_PERSISTENCE_NAME \ - QStringLiteral("SynchronizationPersistence") +#define SYNCHRONIZATION_PERSISTENCE_NAME \ + QStringLiteral("SynchronizationPersistence") \ +// SYNCHRONIZATION_PERSISTENCE_NAME #define HALF_AN_HOUR_IN_MSEC (1800000) #define EXPIRATION_TIMESTAMP_KEY QStringLiteral("ExpirationTimestamp") -#define LINKED_NOTEBOOK_EXPIRATION_TIMESTAMP_KEY_PREFIX \ - QStringLiteral("LinkedNotebookExpirationTimestamp_") - -#define LINKED_NOTEBOOK_AUTH_TOKEN_KEY_PART \ - QStringLiteral("_LinkedNotebookAuthToken_") - -#define LINKED_NOTEBOOK_SHARD_ID_KEY_PART \ - QStringLiteral("_LinkedNotebookShardId_") - -#define READ_LINKED_NOTEBOOK_AUTH_TOKEN_JOB \ - QStringLiteral("readLinkedNotebookAuthToken") - -#define READ_LINKED_NOTEBOOK_SHARD_ID_JOB \ - QStringLiteral("readLinkedNotebookShardId") - -#define WRITE_LINKED_NOTEBOOK_AUTH_TOKEN_JOB \ - QStringLiteral("writeLinkedNotebookAuthToken") - -#define WRITE_LINKED_NOTEBOOK_SHARD_ID_JOB \ - QStringLiteral("writeLinkedNotebookShardId") +#define LINKED_NOTEBOOK_EXPIRATION_TIMESTAMP_KEY_PREFIX \ + QStringLiteral("LinkedNotebookExpirationTimestamp_") \ +// LINKED_NOTEBOOK_EXPIRATION_TIMESTAMP_KEY_PREFIX + +#define LINKED_NOTEBOOK_AUTH_TOKEN_KEY_PART \ + QStringLiteral("_LinkedNotebookAuthToken_") \ +// LINKED_NOTEBOOK_AUTH_TOKEN_KEY_PART + +#define LINKED_NOTEBOOK_SHARD_ID_KEY_PART \ + QStringLiteral("_LinkedNotebookShardId_") \ +// LINKED_NOTEBOOK_SHARD_ID_KEY_PART + +#define READ_LINKED_NOTEBOOK_AUTH_TOKEN_JOB \ + QStringLiteral("readLinkedNotebookAuthToken") \ +// READ_LINKED_NOTEBOOK_AUTH_TOKEN_JOB + +#define READ_LINKED_NOTEBOOK_SHARD_ID_JOB \ + QStringLiteral("readLinkedNotebookShardId") \ +// READ_LINKED_NOTEBOOK_SHARD_ID_JOB + +#define WRITE_LINKED_NOTEBOOK_AUTH_TOKEN_JOB \ + QStringLiteral("writeLinkedNotebookAuthToken") \ +// WRITE_LINKED_NOTEBOOK_AUTH_TOKEN_JOB + +#define WRITE_LINKED_NOTEBOOK_SHARD_ID_JOB \ + QStringLiteral("writeLinkedNotebookShardId") \ +// WRITE_LINKED_NOTEBOOK_SHARD_ID_JOB #define NOTE_STORE_URL_KEY QStringLiteral("NoteStoreUrl") #define WEB_API_URL_PREFIX_KEY QStringLiteral("WebApiUrlPrefix") @@ -72,33 +80,37 @@ #define LAST_SYNC_UPDATE_COUNT_KEY QStringLiteral("last_sync_update_count") #define LAST_SYNC_TIME_KEY QStringLiteral("last_sync_time") -#define LAST_SYNC_LINKED_NOTEBOOKS_PARAMS \ - QStringLiteral("last_sync_linked_notebooks_params") +#define LAST_SYNC_LINKED_NOTEBOOKS_PARAMS \ + QStringLiteral("last_sync_linked_notebooks_params") \ +// LAST_SYNC_LINKED_NOTEBOOKS_PARAMS #define LINKED_NOTEBOOK_GUID_KEY QStringLiteral("linked_notebook_guid") -#define LINKED_NOTEBOOK_LAST_UPDATE_COUNT_KEY \ - QStringLiteral("linked_notebook_last_update_count") - -#define LINKED_NOTEBOOK_LAST_SYNC_TIME_KEY \ - QStringLiteral("linked_notebook_last_sync_time") +#define LINKED_NOTEBOOK_LAST_UPDATE_COUNT_KEY \ + QStringLiteral("linked_notebook_last_update_count") \ +// LINKED_NOTEBOOK_LAST_UPDATE_COUNT_KEY + +#define LINKED_NOTEBOOK_LAST_SYNC_TIME_KEY \ + QStringLiteral("linked_notebook_last_sync_time") \ +// LINKED_NOTEBOOK_LAST_SYNC_TIME_KEY #define AUTH_TOKEN_KEYCHAIN_KEY_PART QStringLiteral("_auth_token") #define SHARD_ID_KEYCHAIN_KEY_PART QStringLiteral("_shard_id") -#define APPEND_NOTE_DETAILS(errorDescription, note) \ - if (note.hasTitle()) \ - { \ - errorDescription.details() = note.title(); \ - } \ - else if (note.hasContent()) \ - { \ - QString previewText = note.plainText(); \ - if (!previewText.isEmpty()) { \ - previewText.truncate(30); \ - errorDescription.details() = previewText; \ - } \ - } +#define APPEND_NOTE_DETAILS(errorDescription, note) \ + if (note.hasTitle()) \ + { \ + errorDescription.details() = note.title(); \ + } \ + else if (note.hasContent()) \ + { \ + QString previewText = note.plainText(); \ + if (!previewText.isEmpty()) { \ + previewText.truncate(30); \ + errorDescription.details() = previewText; \ + } \ + } \ +// APPEND_NOTE_DETAILS namespace quentier { diff -Nru libquentier-0.5.0/src/synchronization/SyncStatePersistenceManager.cpp libquentier-0.5.0/src/synchronization/SyncStatePersistenceManager.cpp --- libquentier-0.5.0/src/synchronization/SyncStatePersistenceManager.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/SyncStatePersistenceManager.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -34,8 +34,8 @@ QHash<QString,qint32> & linkedNotebookUpdateCountsByLinkedNotebookGuid, QHash<QString,qevercloud::Timestamp> & linkedNotebookSyncTimesByLinkedNotebookGuid) { - QNDEBUG(QStringLiteral("SyncStatePersistenceManager::getPersistentSyncState: ") - << QStringLiteral("account = ") << account); + QNDEBUG("SyncStatePersistenceManager::getPersistentSyncState: " + << "account = " << account); userOwnDataUpdateCount = 0; userOwnDataSyncTime = 0; @@ -55,8 +55,8 @@ bool conversionResult = false; userOwnDataUpdateCount = lastUpdateCountVar.toInt(&conversionResult); if (!conversionResult) { - QNWARNING(QStringLiteral("Couldn't read last update count from " - "persistent application settings")); + QNWARNING("Couldn't read last update count from " + "persistent application settings"); userOwnDataUpdateCount = 0; } } @@ -67,8 +67,8 @@ bool conversionResult = false; userOwnDataSyncTime = lastSyncTimeVar.toLongLong(&conversionResult); if (!conversionResult) { - QNWARNING(QStringLiteral("Couldn't read last sync time from " - "persistent application settings")); + QNWARNING("Couldn't read last sync time from " + "persistent application settings"); userOwnDataSyncTime = 0; } } @@ -81,8 +81,8 @@ QString guid = appSettings.value(LINKED_NOTEBOOK_GUID_KEY).toString(); if (guid.isEmpty()) { - QNWARNING(QStringLiteral("Couldn't read linked notebook's guid " - "from persistent application settings")); + QNWARNING("Couldn't read linked notebook's guid " + "from persistent application settings"); continue; } @@ -91,20 +91,21 @@ bool conversionResult = false; qint32 lastUpdateCount = lastUpdateCountVar.toInt(&conversionResult); if (!conversionResult) { - QNWARNING(QStringLiteral("Couldn't read linked notebook's last " - "update count from persistent application " - "settings")); + QNWARNING("Couldn't read linked notebook's last " + "update count from persistent application " + "settings"); continue; } - QVariant lastSyncTimeVar = appSettings.value(LINKED_NOTEBOOK_LAST_SYNC_TIME_KEY); + QVariant lastSyncTimeVar = + appSettings.value(LINKED_NOTEBOOK_LAST_SYNC_TIME_KEY); conversionResult = false; qevercloud::Timestamp lastSyncTime = lastSyncTimeVar.toLongLong(&conversionResult); if (!conversionResult) { - QNWARNING(QStringLiteral("Couldn't read linked notebook's last " - "sync time from persistent application " - "settings")); + QNWARNING("Couldn't read linked notebook's last " + "sync time from persistent application " + "settings"); continue; } @@ -129,7 +130,8 @@ appSettings.setValue(keyGroup + LAST_SYNC_UPDATE_COUNT_KEY, userOwnDataUpdateCount); appSettings.setValue(keyGroup + LAST_SYNC_TIME_KEY, userOwnDataSyncTime); - int numLinkedNotebooksSyncParams = linkedNotebookUpdateCountsByLinkedNotebookGuid.size(); + int numLinkedNotebooksSyncParams = + linkedNotebookUpdateCountsByLinkedNotebookGuid.size(); appSettings.beginWriteArray(keyGroup + LAST_SYNC_LINKED_NOTEBOOKS_PARAMS, numLinkedNotebooksSyncParams); @@ -141,12 +143,12 @@ { const QString & guid = updateCountIt.key(); auto syncTimeIt = linkedNotebookSyncTimesByLinkedNotebookGuid.find(guid); - if (syncTimeIt == syncTimeEnd) { - QNWARNING(QStringLiteral("Detected inconsistent last sync parameters " - "for one of linked notebooks: last update " - "count is present while last sync time is " - "not, skipping writing the persistent " - "settings entry for this linked notebook")); + if (syncTimeIt == syncTimeEnd) + { + QNWARNING("Detected inconsistent last sync parameters for one of " + "linked notebooks: last update count is present while " + "last sync time is not, skipping writing the persistent " + "settings entry for this linked notebook"); continue; } @@ -154,10 +156,10 @@ appSettings.setValue(LINKED_NOTEBOOK_GUID_KEY, guid); appSettings.setValue(LINKED_NOTEBOOK_LAST_UPDATE_COUNT_KEY, updateCountIt.value()); appSettings.setValue(LINKED_NOTEBOOK_LAST_SYNC_TIME_KEY, syncTimeIt.value()); - QNTRACE(QStringLiteral("Persisted last sync parameters for a linked ") - << QStringLiteral("notebook: guid = ") << guid - << QStringLiteral(", update count = ") << updateCountIt.value() - << QStringLiteral(", sync time = ") + QNTRACE("Persisted last sync parameters for a linked " + << "notebook: guid = " << guid + << ", update count = " << updateCountIt.value() + << ", sync time = " << printableDateTimeFromTimestamp(syncTimeIt.value())); ++counter; @@ -165,8 +167,8 @@ appSettings.endArray(); - QNTRACE(QStringLiteral("Wrote ") << counter - << QStringLiteral(" last sync params entries for linked notebooks")); + QNTRACE("Wrote " << counter + << " last sync params entries for linked notebooks"); Q_EMIT notifyPersistentSyncStateUpdated(account, userOwnDataUpdateCount, userOwnDataSyncTime, diff -Nru libquentier-0.5.0/src/synchronization/TagSyncCache.cpp libquentier-0.5.0/src/synchronization/TagSyncCache.cpp --- libquentier-0.5.0/src/synchronization/TagSyncCache.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/TagSyncCache.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -19,23 +19,27 @@ #include "TagSyncCache.h" #include <quentier/logging/QuentierLogger.h> -#define __TCLOG_BASE(message, level) \ - if (m_linkedNotebookGuid.isEmpty()) { \ - __QNLOG_BASE(message, level); \ - } \ - else { \ - __QNLOG_BASE(QStringLiteral("[linked notebook ") << m_linkedNotebookGuid \ - << QStringLiteral("]: ") << message, level); \ - } - -#define TCTRACE(message) \ - __TCLOG_BASE(message, Trace) - -#define TCDEBUG(message) \ - __TCLOG_BASE(message, Debug) - -#define TCWARNING(message) \ - __TCLOG_BASE(message, Warn) +#define __TCLOG_BASE(message, level) \ + if (m_linkedNotebookGuid.isEmpty()) { \ + __QNLOG_BASE(message, level); \ + } \ + else { \ + __QNLOG_BASE("[linked notebook " << m_linkedNotebookGuid << "]: " \ + << message, level); \ + } \ +// __TCLOG_BASE + +#define TCTRACE(message) \ + __TCLOG_BASE(message, Trace) \ +// TCTRACE + +#define TCDEBUG(message) \ + __TCLOG_BASE(message, Debug) \ +// TCDEBUG + +#define TCWARNING(message) \ + __TCLOG_BASE(message, Warn) \ +// TCWARNING namespace quentier { @@ -56,7 +60,7 @@ void TagSyncCache::clear() { - TCDEBUG(QStringLiteral("TagSyncCache::clear")); + TCDEBUG("TagSyncCache::clear"); disconnectFromLocalStorage(); @@ -83,11 +87,11 @@ void TagSyncCache::fill() { - TCDEBUG(QStringLiteral("TagSyncCache::fill")); + TCDEBUG("TagSyncCache::fill"); if (m_connectedToLocalStorage) { - TCDEBUG(QStringLiteral("Already connected to the local storage, " - "no need to do anything")); + TCDEBUG("Already connected to the local storage, " + "no need to do anything"); return; } @@ -95,24 +99,23 @@ requestTagsList(); } -void TagSyncCache::onListTagsComplete(LocalStorageManager::ListObjectsOptions flag, - size_t limit, size_t offset, - LocalStorageManager::ListTagsOrder::type order, - LocalStorageManager::OrderDirection::type orderDirection, - QString linkedNotebookGuid, - QList<Tag> foundTags, QUuid requestId) +void TagSyncCache::onListTagsComplete( + LocalStorageManager::ListObjectsOptions flag, + size_t limit, size_t offset, + LocalStorageManager::ListTagsOrder::type order, + LocalStorageManager::OrderDirection::type orderDirection, + QString linkedNotebookGuid, + QList<Tag> foundTags, QUuid requestId) { if (requestId != m_listTagsRequestId) { return; } - TCDEBUG(QStringLiteral("TagSyncCache::onListTagsComplete: flag = ") - << flag << QStringLiteral(", limit = ") << limit - << QStringLiteral(", offset = ") << offset - << QStringLiteral(", order = ") << order - << QStringLiteral(", order direction = ") << orderDirection - << QStringLiteral(", linked notebook guid = ") << linkedNotebookGuid - << QStringLiteral(", request id = ") << requestId); + TCDEBUG("TagSyncCache::onListTagsComplete: flag = " + << flag << ", limit = " << limit << ", offset = " << offset + << ", order = " << order << ", order direction = " << orderDirection + << ", linked notebook guid = " << linkedNotebookGuid + << ", request id = " << requestId); for(auto it = foundTags.constBegin(), end = foundTags.constEnd(); it != end; ++it) @@ -124,8 +127,8 @@ if (foundTags.size() == static_cast<int>(limit)) { - TCTRACE(QStringLiteral("The number of found tags matches the limit, " - "requesting more tags from the local storage")); + TCTRACE("The number of found tags matches the limit, " + "requesting more tags from the local storage"); m_offset += limit; requestTagsList(); return; @@ -134,28 +137,26 @@ Q_EMIT filled(); } -void TagSyncCache::onListTagsFailed(LocalStorageManager::ListObjectsOptions flag, - size_t limit, size_t offset, - LocalStorageManager::ListTagsOrder::type order, - LocalStorageManager::OrderDirection::type orderDirection, - QString linkedNotebookGuid, - ErrorString errorDescription, - QUuid requestId) +void TagSyncCache::onListTagsFailed( + LocalStorageManager::ListObjectsOptions flag, + size_t limit, size_t offset, + LocalStorageManager::ListTagsOrder::type order, + LocalStorageManager::OrderDirection::type orderDirection, + QString linkedNotebookGuid, ErrorString errorDescription, + QUuid requestId) { if (requestId != m_listTagsRequestId) { return; } - TCDEBUG(QStringLiteral("TagSyncCache::onListTagsFailed: flag = ") - << flag << QStringLiteral(", limit = ") << limit - << QStringLiteral(", offset = ") << offset - << QStringLiteral(", order = ") << order - << QStringLiteral(", order direction = ") - << orderDirection << QStringLiteral(", linked notebook guid = ") - << linkedNotebookGuid << QStringLiteral(", error description = ") - << errorDescription << QStringLiteral(", request id = ") << requestId); + TCDEBUG("TagSyncCache::onListTagsFailed: flag = " << flag << ", limit = " + << limit << ", offset = " << offset << ", order = " << order + << ", order direction = " << orderDirection + << ", linked notebook guid = " + << linkedNotebookGuid << ", error description = " + << errorDescription << ", request id = " << requestId); - TCWARNING(QStringLiteral("Failed to cache the tag information required for the sync: ") + TCWARNING("Failed to cache the tag information required for the sync: " << errorDescription); m_tagNameByLocalUid.clear(); @@ -169,29 +170,28 @@ void TagSyncCache::onAddTagComplete(Tag tag, QUuid requestId) { - TCDEBUG(QStringLiteral("TagSyncCache::onAddTagComplete: request id = ") - << requestId << QStringLiteral(", tag: ") << tag); + TCDEBUG("TagSyncCache::onAddTagComplete: request id = " + << requestId << ", tag: " << tag); processTag(tag); } void TagSyncCache::onUpdateTagComplete(Tag tag, QUuid requestId) { - TCDEBUG(QStringLiteral("TagSyncCache::onUpdateTagComplete: request id = ") - << requestId << QStringLiteral(", tag: ") << tag); + TCDEBUG("TagSyncCache::onUpdateTagComplete: request id = " << requestId + << ", tag: " << tag); removeTag(tag.localUid()); processTag(tag); } -void TagSyncCache::onExpungeTagComplete(Tag tag, - QStringList expungedChildTagLocalUids, - QUuid requestId) +void TagSyncCache::onExpungeTagComplete( + Tag tag, QStringList expungedChildTagLocalUids, QUuid requestId) { - TCDEBUG(QStringLiteral("TagSyncCache::onExpungeTagComplete: request id = ") - << requestId << QStringLiteral(", expunged child tag local uids: ") + TCDEBUG("TagSyncCache::onExpungeTagComplete: request id = " + << requestId << ", expunged child tag local uids: " << expungedChildTagLocalUids.join(QStringLiteral(", ")) - << QStringLiteral(", tag: ") << tag); + << ", tag: " << tag); removeTag(tag.localUid()); @@ -204,10 +204,10 @@ void TagSyncCache::connectToLocalStorage() { - TCDEBUG(QStringLiteral("TagSyncCache::connectToLocalStorage")); + TCDEBUG("TagSyncCache::connectToLocalStorage"); if (m_connectedToLocalStorage) { - TCDEBUG(QStringLiteral("Already connected to the local storage")); + TCDEBUG("Already connected to the local storage"); return; } @@ -275,10 +275,10 @@ void TagSyncCache::disconnectFromLocalStorage() { - TCDEBUG(QStringLiteral("TagSyncCache::disconnectFromLocalStorage")); + TCDEBUG("TagSyncCache::disconnectFromLocalStorage"); if (!m_connectedToLocalStorage) { - TCDEBUG(QStringLiteral("Not connected to local storage at the moment")); + TCDEBUG("Not connected to local storage at the moment"); return; } @@ -345,12 +345,12 @@ void TagSyncCache::requestTagsList() { - TCDEBUG(QStringLiteral("TagSyncCache::requestTagsList")); + TCDEBUG("TagSyncCache::requestTagsList"); m_listTagsRequestId = QUuid::createUuid(); - TCTRACE(QStringLiteral("Emitting the request to list tags: request id = ") - << m_listTagsRequestId << QStringLiteral(", offset = ") << m_offset); + TCTRACE("Emitting the request to list tags: request id = " + << m_listTagsRequestId << ", offset = " << m_offset); Q_EMIT listTags(LocalStorageManager::ListAll, m_limit, m_offset, LocalStorageManager::ListTagsOrder::NoOrder, LocalStorageManager::OrderDirection::Ascending, @@ -359,11 +359,11 @@ void TagSyncCache::removeTag(const QString & tagLocalUid) { - TCDEBUG(QStringLiteral("TagSyncCache::removeTag: local uid = ") << tagLocalUid); + TCDEBUG("TagSyncCache::removeTag: local uid = " << tagLocalUid); auto localUidIt = m_tagNameByLocalUid.find(tagLocalUid); if (Q_UNLIKELY(localUidIt == m_tagNameByLocalUid.end())) { - TCDEBUG(QStringLiteral("The tag name was not found in the cache by local uid")); + TCDEBUG("The tag name was not found in the cache by local uid"); return; } @@ -372,7 +372,7 @@ auto guidIt = m_tagGuidByName.find(name); if (Q_UNLIKELY(guidIt == m_tagGuidByName.end())) { - TCDEBUG(QStringLiteral("The tag guid was not found in the cache by name")); + TCDEBUG("The tag guid was not found in the cache by name"); return; } @@ -386,7 +386,7 @@ auto nameIt = m_tagNameByGuid.find(guid); if (Q_UNLIKELY(nameIt == m_tagNameByGuid.end())) { - TCDEBUG(QStringLiteral("The tag name was not found in the cache by guid")); + TCDEBUG("The tag name was not found in the cache by guid"); return; } @@ -395,7 +395,7 @@ void TagSyncCache::processTag(const Tag & tag) { - TCDEBUG(QStringLiteral("TagSyncCache::processTag: ") << tag); + TCDEBUG("TagSyncCache::processTag: " << tag); if (tag.hasGuid()) { @@ -413,7 +413,7 @@ } if (!tag.hasName()) { - TCDEBUG(QStringLiteral("Skipping the tag without a name")); + TCDEBUG("Skipping the tag without a name"); return; } diff -Nru libquentier-0.5.0/src/synchronization/TagSyncCache.h libquentier-0.5.0/src/synchronization/TagSyncCache.h --- libquentier-0.5.0/src/synchronization/TagSyncCache.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/TagSyncCache.h 2019-07-11 10:46:53.000000000 +0000 @@ -37,7 +37,8 @@ void clear(); /** - * @return True if the cache is already filled with up-to-moment data, false otherwise + * @return True if the cache is already filled with up-to-moment data, + * false otherwise */ bool isFilled() const; @@ -68,25 +69,29 @@ public Q_SLOTS: /** - * Start collecting the information about tags; does nothing if the information - * is already collected or is being collected at the moment, otherwise initiates - * the sequence of actions required to collect the tag information + * Start collecting the information about tags; does nothing if the + * information is already collected or is being collected at the moment, + * otherwise initiates the sequence of actions required to collect the tag + * information */ void fill(); private Q_SLOTS: - void onListTagsComplete(LocalStorageManager::ListObjectsOptions flag, - size_t limit, size_t offset, - LocalStorageManager::ListTagsOrder::type order, - LocalStorageManager::OrderDirection::type orderDirection, - QString linkedNotebookGuid, QList<Tag> foundTags, - QUuid requestId); - void onListTagsFailed(LocalStorageManager::ListObjectsOptions flag, - size_t limit, size_t offset, - LocalStorageManager::ListTagsOrder::type order, - LocalStorageManager::OrderDirection::type orderDirection, - QString linkedNotebookGuid, ErrorString errorDescription, - QUuid requestId); + void onListTagsComplete( + LocalStorageManager::ListObjectsOptions flag, + size_t limit, size_t offset, + LocalStorageManager::ListTagsOrder::type order, + LocalStorageManager::OrderDirection::type orderDirection, + QString linkedNotebookGuid, QList<Tag> foundTags, + QUuid requestId); + + void onListTagsFailed( + LocalStorageManager::ListObjectsOptions flag, + size_t limit, size_t offset, + LocalStorageManager::ListTagsOrder::type order, + LocalStorageManager::OrderDirection::type orderDirection, + QString linkedNotebookGuid, ErrorString errorDescription, + QUuid requestId); void onAddTagComplete(Tag tag, QUuid requestId); void onUpdateTagComplete(Tag tag, QUuid requestId); diff -Nru libquentier-0.5.0/src/synchronization/TagSyncConflictResolver.cpp libquentier-0.5.0/src/synchronization/TagSyncConflictResolver.cpp --- libquentier-0.5.0/src/synchronization/TagSyncConflictResolver.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/TagSyncConflictResolver.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -46,10 +46,10 @@ void TagSyncConflictResolver::start() { - QNDEBUG(QStringLiteral("TagSyncConflictResolver::start")); + QNDEBUG("TagSyncConflictResolver::start"); if (m_started) { - QNDEBUG(QStringLiteral("Already started")); + QNDEBUG("Already started"); return; } @@ -59,7 +59,7 @@ ErrorString error(QT_TR_NOOP("Can't resolve the conflict between remote " "and local tags: the remote tag has no guid " "set")); - QNWARNING(error << QStringLiteral(": ") << m_remoteTag); + QNWARNING(error << ": " << m_remoteTag); Q_EMIT failure(m_remoteTag, error); return; } @@ -68,7 +68,7 @@ ErrorString error(QT_TR_NOOP("Can't resolve the conflict between remote " "and local tags: the remote tag has no guid " "set")); - QNWARNING(error << QStringLiteral(": ") << m_remoteTag); + QNWARNING(error << ": " << m_remoteTag); Q_EMIT failure(m_remoteTag, error); return; } @@ -78,7 +78,7 @@ ErrorString error(QT_TR_NOOP("Can't resolve the conflict between remote " "and local tags: the local conflicting tag " "has neither guid nor name set")); - QNWARNING(error << QStringLiteral(": ") << m_localConflict); + QNWARNING(error << ": " << m_localConflict); Q_EMIT failure(m_remoteTag, error); return; } @@ -102,12 +102,12 @@ return; } - QNDEBUG(QStringLiteral("TagSyncConflictResolver::onAddTagComplete: request id = ") - << requestId << QStringLiteral(", tag: ") << tag); + QNDEBUG("TagSyncConflictResolver::onAddTagComplete: request id = " + << requestId << ", tag: " << tag); if (m_state == State::PendingRemoteTagAdoptionInLocalStorage) { - QNDEBUG(QStringLiteral("Successfully added the remote tag to the local storage")); + QNDEBUG("Successfully added the remote tag to the local storage"); Q_EMIT finished(m_remoteTag); } else @@ -115,21 +115,21 @@ ErrorString error(QT_TR_NOOP("Internal error: wrong state on receiving " "the confirmation about the tag addition " "from the local storage")); - QNWARNING(error << QStringLiteral(", tag: ") << tag); + QNWARNING(error << ", tag: " << tag); Q_EMIT failure(m_remoteTag, error); } } -void TagSyncConflictResolver::onAddTagFailed(Tag tag, ErrorString errorDescription, - QUuid requestId) +void TagSyncConflictResolver::onAddTagFailed( + Tag tag, ErrorString errorDescription, QUuid requestId) { if (requestId != m_addTagRequestId) { return; } - QNDEBUG(QStringLiteral("TagSyncConflictResolver::onAddTagFailed: request id = ") - << requestId << QStringLiteral(", error description = ") - << errorDescription << QStringLiteral("; tag: ") << tag); + QNDEBUG("TagSyncConflictResolver::onAddTagFailed: request id = " + << requestId << ", error description = " + << errorDescription << "; tag: " << tag); Q_EMIT failure(m_remoteTag, errorDescription); } @@ -140,20 +140,20 @@ return; } - QNDEBUG(QStringLiteral("TagSyncConflictResolver::onUpdateTagComplete: request id = ") - << requestId << QStringLiteral(", tag: ") << tag); + QNDEBUG("TagSyncConflictResolver::onUpdateTagComplete: request id = " + << requestId << ", tag: " << tag); if (m_state == State::OverrideLocalChangesWithRemoteChanges) { - QNDEBUG(QStringLiteral("Successfully overridden the local changes with " - "remote changes")); + QNDEBUG("Successfully overridden the local changes with " + "remote changes"); Q_EMIT finished(m_remoteTag); return; } else if (m_state == State::PendingConflictingTagRenaming) { - QNDEBUG(QStringLiteral("Successfully renamed the local tag conflicting " - "by name with the remote tag")); + QNDEBUG("Successfully renamed the local tag conflicting " + "by name with the remote tag"); // Now need to find the duplicate of the remote tag by guid: // 1) if one exists, update it from the remote changes - notwithstanding @@ -176,8 +176,8 @@ auto it = nameByGuidHash.find(m_remoteTag.guid.ref()); if (it == nameByGuidHash.end()) { - QNDEBUG(QStringLiteral("Found no duplicate of the remote tag by guid, " - "adding new tag to the local storage")); + QNDEBUG("Found no duplicate of the remote tag by guid, " + "adding new tag to the local storage"); Tag tag(m_remoteTag); tag.setLinkedNotebookGuid(m_remoteTagLinkedNotebookGuid); @@ -185,15 +185,15 @@ tag.setLocal(false); m_addTagRequestId = QUuid::createUuid(); - QNTRACE(QStringLiteral("Emitting the request to add tag: request id = ") - << m_addTagRequestId << QStringLiteral(", tag: ") << tag); + QNTRACE("Emitting the request to add tag: request id = " + << m_addTagRequestId << ", tag: " << tag); Q_EMIT addTag(tag, m_addTagRequestId); } else { - QNDEBUG(QStringLiteral("The duplicate by guid exists in the local " - "storage, updating it with the state of " - "the remote tag")); + QNDEBUG("The duplicate by guid exists in the local " + "storage, updating it with the state of " + "the remote tag"); Tag tag(m_localConflict); tag.qevercloudTag() = m_remoteTag; @@ -202,16 +202,16 @@ tag.setLocal(false); m_updateTagRequestId = QUuid::createUuid(); - QNTRACE(QStringLiteral("Emitting the request to update tag: request id = ") - << m_updateTagRequestId << QStringLiteral(", tag: ") << tag - << QStringLiteral("\nLocal conflict: ") << m_localConflict); + QNTRACE("Emitting the request to update tag: request id = " + << m_updateTagRequestId << ", tag: " << tag + << "\nLocal conflict: " << m_localConflict); Q_EMIT updateTag(tag, m_updateTagRequestId); } } else if (m_state == State::PendingRemoteTagAdoptionInLocalStorage) { - QNDEBUG(QStringLiteral("Successfully finalized the sequence of actions " - "required for resolving the conflict of tags")); + QNDEBUG("Successfully finalized the sequence of actions " + "required for resolving the conflict of tags"); Q_EMIT finished(m_remoteTag); } else @@ -219,22 +219,21 @@ ErrorString error(QT_TR_NOOP("Internal error: wrong state on receiving " "the confirmation about the tag update " "from the local storage")); - QNWARNING(error << QStringLiteral(", tag: ") << tag); + QNWARNING(error << ", tag: " << tag); Q_EMIT failure(m_remoteTag, error); } } -void TagSyncConflictResolver::onUpdateTagFailed(Tag tag, - ErrorString errorDescription, - QUuid requestId) +void TagSyncConflictResolver::onUpdateTagFailed( + Tag tag, ErrorString errorDescription, QUuid requestId) { if (requestId != m_updateTagRequestId) { return; } - QNDEBUG(QStringLiteral("TagSyncConflictResolver::onUpdateTagFailed: request id = ") - << requestId << QStringLiteral(", error description = ") - << errorDescription << QStringLiteral("; tag: ") << tag); + QNDEBUG("TagSyncConflictResolver::onUpdateTagFailed: request id = " + << requestId << ", error description = " + << errorDescription << "; tag: " << tag); Q_EMIT failure(m_remoteTag, errorDescription); } @@ -245,8 +244,8 @@ return; } - QNDEBUG(QStringLiteral("TagSyncConflictResolver::onFindTagComplete: tag = ") - << tag << QStringLiteral("\nRequest id = ") << requestId); + QNDEBUG("TagSyncConflictResolver::onFindTagComplete: tag = " + << tag << "\nRequest id = " << requestId); m_findTagRequestId = QUuid(); @@ -254,16 +253,16 @@ processTagsConflictByName(tag); } -void TagSyncConflictResolver::onFindTagFailed(Tag tag, ErrorString errorDescription, - QUuid requestId) +void TagSyncConflictResolver::onFindTagFailed( + Tag tag, ErrorString errorDescription, QUuid requestId) { if (requestId != m_findTagRequestId) { return; } - QNDEBUG(QStringLiteral("TagSyncConflictResolver::onFindTagFailed: tag = ") - << tag << QStringLiteral("\nError description = ") << errorDescription - << QStringLiteral("; request id = ") << requestId); + QNDEBUG("TagSyncConflictResolver::onFindTagFailed: tag = " + << tag << "\nError description = " << errorDescription + << "; request id = " << requestId); m_findTagRequestId = QUuid(); @@ -274,10 +273,10 @@ void TagSyncConflictResolver::onCacheFilled() { - QNDEBUG(QStringLiteral("TagSyncConflictResolver::onCacheFilled")); + QNDEBUG("TagSyncConflictResolver::onCacheFilled"); if (!m_pendingCacheFilling) { - QNDEBUG(QStringLiteral("Not pending the cache filling")); + QNDEBUG("Not pending the cache filling"); return; } @@ -291,18 +290,17 @@ { ErrorString error(QT_TR_NOOP("Internal error: wrong state on receiving " "the tag info cache filling notification")); - QNWARNING(error << QStringLiteral(", state = ") << m_state); + QNWARNING(error << ", state = " << m_state); Q_EMIT failure(m_remoteTag, error); } } void TagSyncConflictResolver::onCacheFailed(ErrorString errorDescription) { - QNDEBUG(QStringLiteral("TagSyncConflictResolver::onCacheFailed: ") - << errorDescription); + QNDEBUG("TagSyncConflictResolver::onCacheFailed: " << errorDescription); if (!m_pendingCacheFilling) { - QNDEBUG(QStringLiteral("Not pending the cache filling")); + QNDEBUG("Not pending the cache filling"); return; } @@ -312,7 +310,7 @@ void TagSyncConflictResolver::connectToLocalStorage() { - QNDEBUG(QStringLiteral("TagSyncConflictResolver::connectToLocalStorage")); + QNDEBUG("TagSyncConflictResolver::connectToLocalStorage"); // Connect local signals to local storage manager async's slots QObject::connect(this, @@ -372,7 +370,7 @@ void TagSyncConflictResolver::processTagsConflictByGuid() { - QNDEBUG(QStringLiteral("TagSyncConflictResolver::processTagsConflictByGuid")); + QNDEBUG("TagSyncConflictResolver::processTagsConflictByGuid"); // Need to understand whether there's a duplicate by name in the local storage // for the new state of the remote tag @@ -382,11 +380,11 @@ const QHash<QString,QString> & guidByNameHash = m_cache.guidByNameHash(); auto it = guidByNameHash.find(m_remoteTag.name.ref().toLower()); if (it == guidByNameHash.end()) { - QNDEBUG(QStringLiteral("As deduced by the existing tag info cache, " - "there is no local tag with the same name " - "as the name from the new state of the remote " - "tag, can safely override the local changes " - "with the remote changes: ") << m_remoteTag); + QNDEBUG("As deduced by the existing tag info cache, " + << "there is no local tag with the same name " + << "as the name from the new state of the remote " + << "tag, can safely override the local changes " + << "with the remote changes: " << m_remoteTag); overrideLocalChangesWithRemoteChanges(); return; } @@ -398,27 +396,27 @@ dummyTag.unsetLocalUid(); dummyTag.setName(m_remoteTag.name.ref()); m_findTagRequestId = QUuid::createUuid(); - QNTRACE(QStringLiteral("Emitting the request to find tag by name: request id = ") - << m_findTagRequestId << QStringLiteral(", tag = ") << dummyTag); + QNTRACE("Emitting the request to find tag by name: request id = " + << m_findTagRequestId << ", tag = " << dummyTag); Q_EMIT findTag(dummyTag, m_findTagRequestId); } -void TagSyncConflictResolver::processTagsConflictByName(const Tag & localConflict) +void TagSyncConflictResolver::processTagsConflictByName( + const Tag & localConflict) { - QNDEBUG(QStringLiteral("TagSyncConflictResolver::processTagsConflictByName: " - "local conflict = ") << localConflict); + QNDEBUG("TagSyncConflictResolver::processTagsConflictByName: " + << "local conflict = " << localConflict); if (localConflict.hasGuid() && (localConflict.guid() == m_remoteTag.guid.ref())) { - QNDEBUG(QStringLiteral("The conflicting tags match by name and guid => " - "the changes from the remote " - "tag should just override the local changes")); + QNDEBUG("The conflicting tags match by name and guid => the changes " + "from the remote tag should just override the local changes"); overrideLocalChangesWithRemoteChanges(); return; } - QNDEBUG(QStringLiteral("The conflicting tags match by name but not by guid")); + QNDEBUG("The conflicting tags match by name but not by guid"); QString localConflictLinkedNotebookGuid; if (localConflict.hasLinkedNotebookGuid()) { @@ -427,11 +425,10 @@ if (localConflictLinkedNotebookGuid != m_remoteTagLinkedNotebookGuid) { - QNDEBUG(QStringLiteral("The tags conflicting by name don't have matching " - "linked notebook guids => they are either from " - "user's own account and a linked notebook or from " - "two different linked notebooks => can just add " - "the remote tag to the local storage")); + QNDEBUG("The tags conflicting by name don't have matching linked " + "notebook guids => they are either from user's own account and " + "a linked notebook or from two different linked notebooks => " + "can just add the remote tag to the local storage"); m_state = State::PendingRemoteTagAdoptionInLocalStorage; @@ -441,22 +438,21 @@ tag.setLocal(false); m_addTagRequestId = QUuid::createUuid(); - QNTRACE(QStringLiteral("Emitting the request to add tag: request id = ") - << m_addTagRequestId << QStringLiteral(", tag: ") << tag); + QNTRACE("Emitting the request to add tag: request id = " + << m_addTagRequestId << ", tag: " << tag); Q_EMIT addTag(tag, m_addTagRequestId); return; } - QNDEBUG(QStringLiteral("Both conflicting tags are either from user's own " - "account or from the same linked notebook => should " - "rename the local conflicting tag to \"free\" " - "the name it occupies")); + QNDEBUG("Both conflicting tags are either from user's own account or from " + "the same linked notebook => should rename the local conflicting " + "tag to \"free\" the name it occupies"); m_state = State::PendingConflictingTagRenaming; if (!m_cache.isFilled()) { - QNDEBUG(QStringLiteral("The cache of tag info has not been filled yet")); + QNDEBUG("The cache of tag info has not been filled yet"); QObject::connect(&m_cache, QNSIGNAL(TagSyncCache,filled), @@ -473,19 +469,19 @@ m_pendingCacheFilling = true; m_tagToBeRenamed = localConflict; - QNTRACE(QStringLiteral("Emitting the request to fill the tags cache")); + QNTRACE("Emitting the request to fill the tags cache"); Q_EMIT fillTagsCache(); return; } - QNDEBUG(QStringLiteral("The cache of notebook info has already been filled")); + QNDEBUG("The cache of notebook info has already been filled"); renameConflictingLocalTag(localConflict); } void TagSyncConflictResolver::overrideLocalChangesWithRemoteChanges() { - QNDEBUG(QStringLiteral("TagSyncConflictResolver::" - "overrideLocalChangesWithRemoteChanges")); + QNDEBUG("TagSyncConflictResolver::" + "overrideLocalChangesWithRemoteChanges"); m_state = State::OverrideLocalChangesWithRemoteChanges; @@ -501,15 +497,16 @@ tag.setParentLocalUid(QString()); m_updateTagRequestId = QUuid::createUuid(); - QNTRACE(QStringLiteral("Emitting the request to update tag: request id = ") - << m_updateTagRequestId << QStringLiteral(", tag: ") << tag); + QNTRACE("Emitting the request to update tag: request id = " + << m_updateTagRequestId << ", tag: " << tag); Q_EMIT updateTag(tag, m_updateTagRequestId); } -void TagSyncConflictResolver::renameConflictingLocalTag(const Tag & localConflict) +void TagSyncConflictResolver::renameConflictingLocalTag( + const Tag & localConflict) { - QNDEBUG(QStringLiteral("TagSyncConflictResolver::renameConflictingLocalTag: ") - << QStringLiteral("local conflict = ") << localConflict); + QNDEBUG("TagSyncConflictResolver::renameConflictingLocalTag: " + << "local conflict = " << localConflict); QString name = (localConflict.hasName() ? localConflict.name() @@ -536,8 +533,8 @@ tag.setDirty(true); m_updateTagRequestId = QUuid::createUuid(); - QNTRACE(QStringLiteral("Emitting the request to update tag: request id = ") - << m_updateTagRequestId << QStringLiteral(", tag: ") << tag); + QNTRACE("Emitting the request to update tag: request id = " + << m_updateTagRequestId << ", tag: " << tag); Q_EMIT updateTag(tag, m_updateTagRequestId); } diff -Nru libquentier-0.5.0/src/synchronization/TagSyncConflictResolver.h libquentier-0.5.0/src/synchronization/TagSyncConflictResolver.h --- libquentier-0.5.0/src/synchronization/TagSyncConflictResolver.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/TagSyncConflictResolver.h 2019-07-11 10:46:53.000000000 +0000 @@ -43,11 +43,12 @@ { Q_OBJECT public: - explicit TagSyncConflictResolver(const qevercloud::Tag & remoteTag, - const QString & remoteTagLinkedNotebookGuid, - const Tag & localConflict, TagSyncCache & cache, - LocalStorageManagerAsync & localStorageManagerAsync, - QObject * parent = Q_NULLPTR); + explicit TagSyncConflictResolver( + const qevercloud::Tag & remoteTag, + const QString & remoteTagLinkedNotebookGuid, + const Tag & localConflict, TagSyncCache & cache, + LocalStorageManagerAsync & localStorageManagerAsync, + QObject * parent = Q_NULLPTR); void start(); @@ -66,11 +67,14 @@ private Q_SLOTS: void onAddTagComplete(Tag tag, QUuid requestId); - void onAddTagFailed(Tag tag, ErrorString errorDescription, QUuid requestId); + void onAddTagFailed(Tag tag, ErrorString errorDescription, + QUuid requestId); void onUpdateTagComplete(Tag tag, QUuid requestId); - void onUpdateTagFailed(Tag tag, ErrorString errorDescription, QUuid requestId); + void onUpdateTagFailed(Tag tag, ErrorString errorDescription, + QUuid requestId); void onFindTagComplete(Tag tag, QUuid requestId); - void onFindTagFailed(Tag tag, ErrorString errorDescription, QUuid requestId); + void onFindTagFailed(Tag tag, ErrorString errorDescription, + QUuid requestId); void onCacheFilled(); void onCacheFailed(ErrorString errorDescription); diff -Nru libquentier-0.5.0/src/synchronization/UserStore.cpp libquentier-0.5.0/src/synchronization/UserStore.cpp --- libquentier-0.5.0/src/synchronization/UserStore.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/UserStore.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -36,8 +36,10 @@ new qevercloud::UserStore(host))); } -bool UserStore::checkVersion(const QString & clientName, qint16 edamVersionMajor, - qint16 edamVersionMinor, ErrorString & errorDescription) +bool UserStore::checkVersion(const QString & clientName, + qint16 edamVersionMajor, + qint16 edamVersionMinor, + ErrorString & errorDescription) { try { @@ -72,10 +74,11 @@ return qevercloud::EDAMErrorCode::UNKNOWN; } -qint32 UserStore::getAccountLimits(const qevercloud::ServiceLevel::type serviceLevel, - qevercloud::AccountLimits & limits, - ErrorString & errorDescription, - qint32 & rateLimitSeconds) +qint32 UserStore::getAccountLimits( + const qevercloud::ServiceLevel::type serviceLevel, + qevercloud::AccountLimits & limits, + ErrorString & errorDescription, + qint32 & rateLimitSeconds) { try { diff -Nru libquentier-0.5.0/src/synchronization/UserStore.h libquentier-0.5.0/src/synchronization/UserStore.h --- libquentier-0.5.0/src/synchronization/UserStore.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/synchronization/UserStore.h 2019-07-11 10:46:53.000000000 +0000 @@ -54,17 +54,21 @@ virtual qint32 getUser(User & user, ErrorString & errorDescription, qint32 & rateLimitSeconds) Q_DECL_OVERRIDE; - virtual qint32 getAccountLimits(const qevercloud::ServiceLevel::type serviceLevel, - qevercloud::AccountLimits & limits, - ErrorString & errorDescription, - qint32 & rateLimitSeconds) Q_DECL_OVERRIDE; + virtual qint32 getAccountLimits( + const qevercloud::ServiceLevel::type serviceLevel, + qevercloud::AccountLimits & limits, + ErrorString & errorDescription, + qint32 & rateLimitSeconds) Q_DECL_OVERRIDE; private: - qint32 processEdamUserException(const qevercloud::EDAMUserException & userException, - ErrorString & errorDescription) const; - qint32 processEdamSystemException(const qevercloud::EDAMSystemException & systemException, - ErrorString & errorDescription, - qint32 & rateLimitSeconds) const; + qint32 processEdamUserException( + const qevercloud::EDAMUserException & userException, + ErrorString & errorDescription) const; + + qint32 processEdamSystemException( + const qevercloud::EDAMSystemException & systemException, + ErrorString & errorDescription, + qint32 & rateLimitSeconds) const; private: UserStore(const UserStore & other) Q_DECL_EQ_DELETE; diff -Nru libquentier-0.5.0/src/tests/enml/EnexExportImportTests.cpp libquentier-0.5.0/src/tests/enml/EnexExportImportTests.cpp --- libquentier-0.5.0/src/tests/enml/EnexExportImportTests.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/tests/enml/EnexExportImportTests.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -565,59 +565,63 @@ const qevercloud::NoteAttributes & leftNoteAttributes = lhs.noteAttributes(); const qevercloud::NoteAttributes & rightNoteAttributes = rhs.noteAttributes(); -#define CHECK_NOTE_ATTRIBUTE_PRESENCE(attrName) \ - if (leftNoteAttributes.attrName.isSet() != \ - rightNoteAttributes.attrName.isSet()) \ - { \ - error = QStringLiteral("left: has " #attrName " = ") + \ - (leftNoteAttributes.attrName.isSet() \ - ? QStringLiteral("true") \ - : QStringLiteral("false")) + \ - QStringLiteral(", right: has " #attrName " = ") + \ - (rightNoteAttributes.attrName.isSet() \ - ? QStringLiteral("true") \ - : QStringLiteral("false")); \ - return false; \ - } - -#define CHECK_NOTE_DOUBLE_ATTRIBUTE(attrName) \ - CHECK_NOTE_ATTRIBUTE_PRESENCE(attrName) \ - if (leftNoteAttributes.attrName.isSet() && \ - (std::fabs(leftNoteAttributes.attrName.ref() - \ - rightNoteAttributes.attrName.ref()) > 1.0e-9)) \ - { \ - error = QStringLiteral("left: " #attrName " = ") + \ - QString::number(leftNoteAttributes.attrName.ref()) + \ - QStringLiteral(", right: " #attrName " = ") + \ - QString::number(rightNoteAttributes.attrName.ref()); \ - return false; \ - } - -#define CHECK_NOTE_STRING_ATTRIBUTE(attrName) \ - CHECK_NOTE_ATTRIBUTE_PRESENCE(attrName) \ - if (leftNoteAttributes.attrName.isSet() && \ - (leftNoteAttributes.attrName.ref() != \ - rightNoteAttributes.attrName.ref())) \ - { \ - error = QStringLiteral("left: " #attrName " = ") + \ - leftNoteAttributes.attrName.ref() + \ - QStringLiteral(", right: " #attrName " = ") + \ - rightNoteAttributes.attrName.ref(); \ - return false; \ - } - -#define CHECK_NOTE_INTEGER_ATTRIBUTE(attrName) \ - CHECK_NOTE_ATTRIBUTE_PRESENCE(attrName) \ - if (leftNoteAttributes.attrName.isSet() && \ - (leftNoteAttributes.attrName.ref() != \ - rightNoteAttributes.attrName.ref())) \ - { \ - error = QStringLiteral("left: " #attrName " = ") + \ - QString::number(leftNoteAttributes.attrName.ref()) + \ - QStringLiteral(", right: " #attrName " = ") + \ - QString::number(rightNoteAttributes.attrName.ref()); \ - return false; \ - } +#define CHECK_NOTE_ATTRIBUTE_PRESENCE(attrName) \ + if (leftNoteAttributes.attrName.isSet() != \ + rightNoteAttributes.attrName.isSet()) \ + { \ + error = QStringLiteral("left: has " #attrName " = ") + \ + (leftNoteAttributes.attrName.isSet() \ + ? QStringLiteral("true") \ + : QStringLiteral("false")) + \ + QStringLiteral(", right: has " #attrName " = ") + \ + (rightNoteAttributes.attrName.isSet() \ + ? QStringLiteral("true") \ + : QStringLiteral("false")); \ + return false; \ + } \ +// CHECK_NOTE_ATTRIBUTE_PRESENCE + +#define CHECK_NOTE_DOUBLE_ATTRIBUTE(attrName) \ + CHECK_NOTE_ATTRIBUTE_PRESENCE(attrName) \ + if (leftNoteAttributes.attrName.isSet() && \ + (std::fabs(leftNoteAttributes.attrName.ref() - \ + rightNoteAttributes.attrName.ref()) > 1.0e-9)) \ + { \ + error = QStringLiteral("left: " #attrName " = ") + \ + QString::number(leftNoteAttributes.attrName.ref()) + \ + QStringLiteral(", right: " #attrName " = ") + \ + QString::number(rightNoteAttributes.attrName.ref()); \ + return false; \ + } \ +// CHECK_NOTE_DOUBLE_ATTRIBUTE + +#define CHECK_NOTE_STRING_ATTRIBUTE(attrName) \ + CHECK_NOTE_ATTRIBUTE_PRESENCE(attrName) \ + if (leftNoteAttributes.attrName.isSet() && \ + (leftNoteAttributes.attrName.ref() != \ + rightNoteAttributes.attrName.ref())) \ + { \ + error = QStringLiteral("left: " #attrName " = ") + \ + leftNoteAttributes.attrName.ref() + \ + QStringLiteral(", right: " #attrName " = ") + \ + rightNoteAttributes.attrName.ref(); \ + return false; \ + } +// CHECK_NOTE_STRING_ATTRIBUTE + +#define CHECK_NOTE_INTEGER_ATTRIBUTE(attrName) \ + CHECK_NOTE_ATTRIBUTE_PRESENCE(attrName) \ + if (leftNoteAttributes.attrName.isSet() && \ + (leftNoteAttributes.attrName.ref() != \ + rightNoteAttributes.attrName.ref())) \ + { \ + error = QStringLiteral("left: " #attrName " = ") + \ + QString::number(leftNoteAttributes.attrName.ref()) + \ + QStringLiteral(", right: " #attrName " = ") + \ + QString::number(rightNoteAttributes.attrName.ref()); \ + return false; \ + } \ +// CHECK_NOTE_INTEGER_ATTRIBUTE CHECK_NOTE_DOUBLE_ATTRIBUTE(latitude) CHECK_NOTE_DOUBLE_ATTRIBUTE(longitude) @@ -847,72 +851,77 @@ const qevercloud::ResourceAttributes & rightResourceAttributes = rightResource.resourceAttributes(); -#define CHECK_RESOURCE_ATTRIBUTE_PRESENCE(attrName) \ - if (leftResourceAttributes.attrName.isSet() != \ - rightResourceAttributes.attrName.isSet()) \ - { \ - error = QStringLiteral("left resource: has " #attrName " = ") + \ - (leftResourceAttributes.attrName.isSet() \ - ? QStringLiteral("true") \ - : QStringLiteral("false")) + \ +#define CHECK_RESOURCE_ATTRIBUTE_PRESENCE(attrName) \ + if (leftResourceAttributes.attrName.isSet() != \ + rightResourceAttributes.attrName.isSet()) \ + { \ + error = QStringLiteral("left resource: has " #attrName " = ") + \ + (leftResourceAttributes.attrName.isSet() \ + ? QStringLiteral("true") \ + : QStringLiteral("false")) + \ QStringLiteral(", right resource: has " #attrName " = ") + \ - (rightResourceAttributes.attrName.isSet() \ - ? QStringLiteral("true") \ - : QStringLiteral("false")); \ - return false; \ - } - -#define CHECK_RESOURCE_DOUBLE_ATTRIBUTE(attrName) \ - CHECK_RESOURCE_ATTRIBUTE_PRESENCE(attrName) \ - if (leftResourceAttributes.attrName.isSet() && \ - (std::fabs(leftResourceAttributes.attrName.ref() - \ - rightResourceAttributes.attrName.ref()) > 1.0e-9)) \ - { \ - error = QStringLiteral("left resource: " #attrName " = ") + \ - QString::number(leftResourceAttributes.attrName.ref()) + \ - QStringLiteral(", right resource: " #attrName " = ") + \ - QString::number(rightResourceAttributes.attrName.ref()); \ - return false; \ - } - -#define CHECK_RESOURCE_STRING_ATTRIBUTE(attrName) \ - CHECK_RESOURCE_ATTRIBUTE_PRESENCE(attrName) \ - if (leftResourceAttributes.attrName.isSet() && \ - (leftResourceAttributes.attrName.ref() != \ - rightResourceAttributes.attrName.ref())) \ - { \ - error = QStringLiteral("left resource: " #attrName " = ") + \ - leftResourceAttributes.attrName.ref() + \ - QStringLiteral(", right resource: " #attrName " = ") + \ - rightResourceAttributes.attrName.ref(); \ - return false; \ - } - -#define CHECK_RESOURCE_INTEGER_ATTRIBUTE(attrName) \ - CHECK_RESOURCE_ATTRIBUTE_PRESENCE(attrName) \ - if (leftResourceAttributes.attrName.isSet() && \ - (leftResourceAttributes.attrName.ref() != \ - rightResourceAttributes.attrName.ref())) \ - { \ - error = QStringLiteral("left resource: " #attrName " = ") + \ - QString::number(leftResourceAttributes.attrName.ref()) + \ - QStringLiteral(", right resource: " #attrName " = ") + \ - QString::number(rightResourceAttributes.attrName.ref()); \ - return false; \ - } - -#define CHECK_RESOURCE_BOOLEAN_ATTRIBUTE(attrName) \ - CHECK_RESOURCE_ATTRIBUTE_PRESENCE(attrName) \ - if (leftResourceAttributes.attrName.isSet() && \ - (leftResourceAttributes.attrName.ref() != \ - rightResourceAttributes.attrName.ref())) \ - { \ - error = QStringLiteral("left resource: " #attrName " = ") + \ - QString::number(leftResourceAttributes.attrName.ref()) + \ - QStringLiteral(", right resource: " #attrName " = ") + \ - QString::number(rightResourceAttributes.attrName.ref()); \ - return false; \ - } + (rightResourceAttributes.attrName.isSet() \ + ? QStringLiteral("true") \ + : QStringLiteral("false")); \ + return false; \ + } \ +// CHECK_RESOURCE_ATTRIBUTE_PRESENCE + +#define CHECK_RESOURCE_DOUBLE_ATTRIBUTE(attrName) \ + CHECK_RESOURCE_ATTRIBUTE_PRESENCE(attrName) \ + if (leftResourceAttributes.attrName.isSet() && \ + (std::fabs(leftResourceAttributes.attrName.ref() - \ + rightResourceAttributes.attrName.ref()) > 1.0e-9)) \ + { \ + error = QStringLiteral("left resource: " #attrName " = ") + \ + QString::number(leftResourceAttributes.attrName.ref()) + \ + QStringLiteral(", right resource: " #attrName " = ") + \ + QString::number(rightResourceAttributes.attrName.ref()); \ + return false; \ + } \ +// CHECK_RESOURCE_DOUBLE_ATTRIBUTE + +#define CHECK_RESOURCE_STRING_ATTRIBUTE(attrName) \ + CHECK_RESOURCE_ATTRIBUTE_PRESENCE(attrName) \ + if (leftResourceAttributes.attrName.isSet() && \ + (leftResourceAttributes.attrName.ref() != \ + rightResourceAttributes.attrName.ref())) \ + { \ + error = QStringLiteral("left resource: " #attrName " = ") + \ + leftResourceAttributes.attrName.ref() + \ + QStringLiteral(", right resource: " #attrName " = ") + \ + rightResourceAttributes.attrName.ref(); \ + return false; \ + } \ +// CHECK_RESOURCE_STRING_ATTRIBUTE + +#define CHECK_RESOURCE_INTEGER_ATTRIBUTE(attrName) \ + CHECK_RESOURCE_ATTRIBUTE_PRESENCE(attrName) \ + if (leftResourceAttributes.attrName.isSet() && \ + (leftResourceAttributes.attrName.ref() != \ + rightResourceAttributes.attrName.ref())) \ + { \ + error = QStringLiteral("left resource: " #attrName " = ") + \ + QString::number(leftResourceAttributes.attrName.ref()) + \ + QStringLiteral(", right resource: " #attrName " = ") + \ + QString::number(rightResourceAttributes.attrName.ref()); \ + return false; \ + } +// CHECK_RESOURCE_INTEGER_ATTRIBUTE + +#define CHECK_RESOURCE_BOOLEAN_ATTRIBUTE(attrName) \ + CHECK_RESOURCE_ATTRIBUTE_PRESENCE(attrName) \ + if (leftResourceAttributes.attrName.isSet() && \ + (leftResourceAttributes.attrName.ref() != \ + rightResourceAttributes.attrName.ref())) \ + { \ + error = QStringLiteral("left resource: " #attrName " = ") + \ + QString::number(leftResourceAttributes.attrName.ref()) + \ + QStringLiteral(", right resource: " #attrName " = ") + \ + QString::number(rightResourceAttributes.attrName.ref()); \ + return false; \ + } \ +// CHECK_RESOURCE_BOOLEAN_ATTRIBUTE CHECK_RESOURCE_STRING_ATTRIBUTE(sourceURL) CHECK_RESOURCE_INTEGER_ATTRIBUTE(timestamp) diff -Nru libquentier-0.5.0/src/tests/enml/ENMLConverterTests.cpp libquentier-0.5.0/src/tests/enml/ENMLConverterTests.cpp --- libquentier-0.5.0/src/tests/enml/ENMLConverterTests.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/tests/enml/ENMLConverterTests.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -322,7 +322,7 @@ res = compareEnml(originalNoteContent, processedNoteContent, error); if (!res) { - QNWARNING(QStringLiteral("\n\nHTML: ") << html); + QNWARNING("\n\nHTML: " << html); return false; } @@ -338,17 +338,18 @@ QXmlStreamReader readerOriginal(originalSimplified); QXmlStreamReader readerProcessed(processedSimplified); -#define PRINT_WARNING(err) \ - QNWARNING(err << QStringLiteral("\n\nContext in the original ENML: <") \ - << readerOriginal.name() << QStringLiteral(">: ") \ - << readerOriginal.readElementText() \ - << QStringLiteral("\n\nContext in the processed ENML: <") \ - << readerProcessed.name() \ - << QStringLiteral(">: ") << readerProcessed.readElementText() \ - << QStringLiteral("\n\nFull simplified original ENML: ") \ - << originalSimplified \ - << QStringLiteral("\n\nFull simplified processed ENML: ") \ - << processedSimplified); +#define PRINT_WARNING(err) \ + QNWARNING(err << "\n\nContext in the original ENML: <" \ + << readerOriginal.name() << ">: " \ + << readerOriginal.readElementText() \ + << "\n\nContext in the processed ENML: <" \ + << readerProcessed.name() \ + << ">: " << readerProcessed.readElementText() \ + << "\n\nFull simplified original ENML: " \ + << originalSimplified \ + << "\n\nFull simplified processed ENML: " \ + << processedSimplified) \ +// PRINT_WARNING while(!readerOriginal.atEnd() && !readerProcessed.atEnd()) { @@ -415,56 +416,55 @@ "is at the start of the element while " "the reader of the processed ENML is not"); PRINT_WARNING(error - << QStringLiteral("\n\nchecking the state of " - "processed ENML reader: ") - << QStringLiteral("isStartDocument: ") + << "\n\nchecking the state of " + "processed ENML reader: isStartDocument: " << (readerProcessed.isStartDocument() - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", isDTD: ") + ? "true" + : "false") + << ", isDTD: " << (readerProcessed.isDTD() - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", isCDATA: ") + ? "true" + : "false") + << ", isCDATA: " << (readerProcessed.isCDATA() - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", isCharacters: ") + ? "true" + : "false") + << ", isCharacters: " << (readerProcessed.isCharacters() - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", isComment: ") + ? "true" + : "false") + << ", isComment: " << (readerProcessed.isComment() - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", isEndElement: ") + ? "true" + : "false") + << ", isEndElement: " << (readerProcessed.isEndElement() - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", isEndDocument: ") + ? "true" + : "false") + << ", isEndDocument: " << (readerProcessed.isEndDocument() - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", isEntityReference: ") + ? "true" + : "false") + << ", isEntityReference: " << (readerProcessed.isEntityReference() - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", isProcessingInstruction: ") + ? "true" + : "false") + << ", isProcessingInstruction: " << (readerProcessed.isProcessingInstruction() - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", isStandaloneDocument: ") + ? "true" + : "false") + << ", isStandaloneDocument: " << (readerProcessed.isStandaloneDocument() - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", isStartDocument: ") + ? "true" + : "false") + << ", isStartDocument: " << (readerProcessed.isStartDocument() - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", isWhitespace: ") + ? "true" + : "false") + << ", isWhitespace: " << (readerProcessed.isWhitespace() - ? QStringLiteral("true") - : QStringLiteral("false"))); + ? "true" + : "false")); return false; } @@ -548,28 +548,27 @@ "the original and the processed " "ENMLs do not match"); QNWARNING(error - << QStringLiteral(": the original attribute " - "was not found within " - "the processed attributes; ") - << QStringLiteral("original ENML: ") + << ": the original attribute was not found " + "within the processed attributes; " + "original ENML: " << originalSimplified - << QStringLiteral("\nProcessed ENML: ") + << "\nProcessed ENML: " << processedSimplified - << QStringLiteral(", index within attributes = ") + << ", index within attributes = " << i - << QStringLiteral("\nOriginal attribute: name = ") + << "\nOriginal attribute: name = " << originalAttribute.name() - << QStringLiteral(", namespace uri = ") + << ", namespace uri = " << originalAttribute.namespaceUri() - << QStringLiteral(", qualified name = ") + << ", qualified name = " << originalAttribute.qualifiedName() - << QStringLiteral(", is default = ") + << ", is default = " << (originalAttribute.isDefault() - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", value = ") + ? "true" + : "false") + << ", value = " << originalAttribute.value() - << QStringLiteral(", prefix = ") + << ", prefix = " << originalAttribute.prefix()); return false; } @@ -601,28 +600,27 @@ "the original and the processed " "ENMLs do not match"); QNWARNING(error - << QStringLiteral(": the original attribute " - "was not found within " - "the processed attributes; ") - << QStringLiteral("original ENML: ") + << ": the original attribute " + "was not found within " + "the processed attributes; " + "original ENML: " << originalSimplified - << QStringLiteral("\nProcessed ENML: ") + << "\nProcessed ENML: " << processedSimplified - << QStringLiteral(", index within attributes = ") - << i - << QStringLiteral("\nOriginal attribute: name = ") + << ", index within attributes = " << i + << "\nOriginal attribute: name = " << originalAttribute.name() - << QStringLiteral(", namespace uri = ") + << ", namespace uri = " << originalAttribute.namespaceUri() - << QStringLiteral(", qualified name = ") + << ", qualified name = " << originalAttribute.qualifiedName() - << QStringLiteral(", is default = ") + << ", is default = " << (originalAttribute.isDefault() - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", value = ") + ? "true" + : "false") + << ", value = " << originalAttribute.value() - << QStringLiteral(", prefix = ") + << ", prefix = " << originalAttribute.prefix()); return false; @@ -652,10 +650,8 @@ error = QStringLiteral("QXmlStreamReader of the original ENML " "points to characters while the reader " "of the processed ENML does not"); - QNWARNING(error << QStringLiteral("; original ENML: ") - << originalSimplified - << QStringLiteral("\nProcessed ENML: ") - << processedSimplified); + QNWARNING(error << "; original ENML: " << originalSimplified + << "\nProcessed ENML: " << processedSimplified); return false; } @@ -665,10 +661,8 @@ error = QStringLiteral("QXmlStreamReader of the original " "ENML points to CDATA while the reader " "of the processed ENML does not"); - QNWARNING(error << QStringLiteral("; original ENML: ") - << originalSimplified - << QStringLiteral("\nProcessed ENML: ") - << processedSimplified); + QNWARNING(error << "; original ENML: " << originalSimplified + << "\nProcessed ENML: " << processedSimplified); return false; } } @@ -681,14 +675,10 @@ error = QStringLiteral("The text extracted from the corresponding " "elements of both the original ENML " "and the processed ENML does not match"); - QNWARNING(error << QStringLiteral("; original ENML: ") - << originalSimplified - << QStringLiteral("\nProcessed ENML: ") - << processedSimplified - << QStringLiteral("\nOriginal element text: ") - << textOriginal - << QStringLiteral("\nProcessed element text: ") - << textProcessed); + QNWARNING(error << "; original ENML: " << originalSimplified + << "\nProcessed ENML: " << processedSimplified + << "\nOriginal element text: " << textOriginal + << "\nProcessed element text: " << textProcessed); return false; } } @@ -698,10 +688,8 @@ error = QStringLiteral("QXmlStreamReader of the original ENML is at " "the end of the document while the reader of " "the processed ENML is not"); - QNWARNING(error << QStringLiteral("; original ENML: ") - << originalSimplified - << QStringLiteral("\nProcessed ENML: ") - << processedSimplified); + QNWARNING(error << "; original ENML: " << originalSimplified + << "\nProcessed ENML: " << processedSimplified); return false; } } @@ -711,10 +699,8 @@ error = QStringLiteral("QXmlStreamReaders for the original ENML and " "the processed ENML have not both came to their " "ends after the checking loop"); - QNWARNING(error << QStringLiteral("; original ENML: ") - << originalSimplified - << QStringLiteral("\nProcessed ENML: ") - << processedSimplified); + QNWARNING(error << "; original ENML: " << originalSimplified + << "\nProcessed ENML: " << processedSimplified); return false; } @@ -891,7 +877,7 @@ res = compareEnml(noteContent, processedNoteContent, error); if (!res) { - QNWARNING(QStringLiteral("\n\nHTML: ") << html); + QNWARNING("\n\nHTML: " << html); return false; } @@ -954,7 +940,7 @@ res = compareEnml(noteContent, processedNoteContent, error); if (!res) { - QNWARNING(QStringLiteral("\n\nHTML: ") << html); + QNWARNING("\n\nHTML: " << html); return false; } diff -Nru libquentier-0.5.0/src/tests/enml/ENMLTester.cpp libquentier-0.5.0/src/tests/enml/ENMLTester.cpp --- libquentier-0.5.0/src/tests/enml/ENMLTester.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/tests/enml/ENMLTester.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -25,28 +25,29 @@ #include <QTextStream> #include <QtTest/QTest> -#define CATCH_EXCEPTION() \ - catch(const std::exception & exception) { \ - SysInfo sysInfo; \ - QFAIL(qPrintable(QStringLiteral("Caught exception: ") + \ - QString::fromUtf8(exception.what()) + \ - QStringLiteral(", backtrace: ") + \ - sysInfo.stackTrace())); \ - } +#define CATCH_EXCEPTION() \ + catch(const std::exception & exception) { \ + SysInfo sysInfo; \ + QFAIL(qPrintable(QStringLiteral("Caught exception: ") + \ + QString::fromUtf8(exception.what()) + \ + QStringLiteral(", backtrace: ") + \ + sysInfo.stackTrace())); \ + } \ +// CATCH_EXCEPTION #if QT_VERSION >= 0x050000 inline void nullMessageHandler(QtMsgType type, const QMessageLogContext &, const QString & message) { if (type != QtDebugMsg) { - QTextStream(stdout) << message << QStringLiteral("\n"); + QTextStream(stdout) << message << "\n"; } } #else inline void nullMessageHandler(QtMsgType type, const char * message) { if (type != QtDebugMsg) { - QTextStream(stdout) << message << QStringLiteral("\n"); + QTextStream(stdout) << message << "\n"; } } #endif diff -Nru libquentier-0.5.0/src/tests/local_storage/LinkedNotebookLocalStorageManagerAsyncTester.cpp libquentier-0.5.0/src/tests/local_storage/LinkedNotebookLocalStorageManagerAsyncTester.cpp --- libquentier-0.5.0/src/tests/local_storage/LinkedNotebookLocalStorageManagerAsyncTester.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/tests/local_storage/LinkedNotebookLocalStorageManagerAsyncTester.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -24,7 +24,8 @@ namespace quentier { namespace test { -LinkedNotebookLocalStorageManagerAsyncTester::LinkedNotebookLocalStorageManagerAsyncTester(QObject * parent) : +LinkedNotebookLocalStorageManagerAsyncTester::LinkedNotebookLocalStorageManagerAsyncTester( + QObject * parent) : QObject(parent), m_state(STATE_UNINITIALIZED), m_pLocalStorageManagerAsync(Q_NULLPTR), @@ -42,7 +43,8 @@ void LinkedNotebookLocalStorageManagerAsyncTester::onInitTestCase() { - QString username = QStringLiteral("LinkedNotebookLocalStorageManagerAsyncTester"); + QString username = + QStringLiteral("LinkedNotebookLocalStorageManagerAsyncTester"); qint32 userId = 1; LocalStorageManager::StartupOptions startupOptions( LocalStorageManager::StartupOption::ClearDatabase); @@ -81,13 +83,14 @@ QStringLiteral("Fake linked notebook note store url")); m_initialLinkedNotebook.setWebApiUrlPrefix( QStringLiteral("Fake linked notebook web api url prefix")); - m_initialLinkedNotebook.setStack(QStringLiteral("Fake linked notebook stack")); + m_initialLinkedNotebook.setStack( + QStringLiteral("Fake linked notebook stack")); m_initialLinkedNotebook.setBusinessId(1); ErrorString errorDescription; if (!m_initialLinkedNotebook.checkParameters(errorDescription)) { - QNWARNING(QStringLiteral("Found invalid LinkedNotebook: ") - << m_initialLinkedNotebook << QStringLiteral(", error: ") + QNWARNING("Found invalid LinkedNotebook: " + << m_initialLinkedNotebook << ", error: " << errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -104,13 +107,15 @@ ErrorString errorDescription; -#define HANDLE_WRONG_STATE() \ - else { \ - errorDescription.setBase("Internal error in "\ - "LinkedNotebookLocalStorageManagerAsyncTester: found wrong state"); \ - Q_EMIT failure(errorDescription.nonLocalizedString()); \ - return; \ - } +#define HANDLE_WRONG_STATE() \ + else { \ + errorDescription.setBase( \ + "Internal error in LinkedNotebookLocalStorageManagerAsyncTester: " \ + "found wrong state"); \ + Q_EMIT failure(errorDescription.nonLocalizedString()); \ + return; \ + } \ +// HANDLE_WRONG_STATE if (m_state == STATE_SENT_GET_COUNT_AFTER_UPDATE_REQUEST) { @@ -164,7 +169,7 @@ void LinkedNotebookLocalStorageManagerAsyncTester::onGetLinkedNotebookCountFailed( ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId); + QNWARNING(errorDescription << ", requestId = " << requestId); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -240,8 +245,8 @@ void LinkedNotebookLocalStorageManagerAsyncTester::onAddLinkedNotebookFailed( LinkedNotebook notebook, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", linked notebook: ") << notebook); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", linked notebook: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -273,8 +278,8 @@ void LinkedNotebookLocalStorageManagerAsyncTester::onUpdateLinkedNotebookFailed( LinkedNotebook notebook, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", linked notebook: ") << notebook); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", linked notebook: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -287,13 +292,14 @@ if (m_state == STATE_SENT_FIND_AFTER_ADD_REQUEST) { - if (notebook != m_initialLinkedNotebook) { + if (notebook != m_initialLinkedNotebook) + { errorDescription.setBase( "Added and found linked notebooks in local storage don't match"); QNWARNING(errorDescription - << QStringLiteral(": LinkedNotebook added to the local storage: ") + << ": LinkedNotebook added to the local storage: " << m_initialLinkedNotebook - << QStringLiteral("\nLinkedNotebook found in the local storage: ") + << "\nLinkedNotebook found in the local storage: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -316,13 +322,14 @@ } else if (m_state == STATE_SENT_FIND_AFTER_UPDATE_REQUEST) { - if (notebook != m_modifiedLinkedNotebook) { + if (notebook != m_modifiedLinkedNotebook) + { errorDescription.setBase("Updated and found linked notebooks " "don't match"); QNWARNING(errorDescription - << QStringLiteral(": LinkedNotebook updated in the local storage: ") + << ": LinkedNotebook updated in the local storage: " << m_modifiedLinkedNotebook - << QStringLiteral("\nLinkedNotebook found in the local storage: ") + << "\nLinkedNotebook found in the local storage: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -336,9 +343,9 @@ errorDescription.setBase("Error: found linked notebook which should " "have been expunged from the local storage"); QNWARNING(errorDescription - << QStringLiteral(": LinkedNotebook expunged from the local storage: ") + << ": LinkedNotebook expunged from the local storage: " << m_modifiedLinkedNotebook - << QStringLiteral("\nLinkedNotebook found in the local storage: ") + << "\nLinkedNotebook found in the local storage: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -355,8 +362,8 @@ return; } - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", linked notebook: ") << notebook); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", linked notebook: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -410,7 +417,7 @@ Q_UNUSED(order) Q_UNUSED(orderDirection) - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId); + QNWARNING(errorDescription << ", requestId = " << requestId); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -438,8 +445,8 @@ void LinkedNotebookLocalStorageManagerAsyncTester::onExpungeLinkedNotebookFailed( LinkedNotebook notebook, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", linked notebook: ") << notebook); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", linked notebook: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -451,7 +458,8 @@ QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync,initialized), this, - QNSLOT(LinkedNotebookLocalStorageManagerAsyncTester,initialize)); + QNSLOT(LinkedNotebookLocalStorageManagerAsyncTester, + initialize)); // Request --> slot connections QObject::connect(this, @@ -523,34 +531,40 @@ onAddLinkedNotebookFailed,LinkedNotebook, ErrorString,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, - QNSIGNAL(LocalStorageManagerAsync,updateLinkedNotebookComplete, + QNSIGNAL(LocalStorageManagerAsync, + updateLinkedNotebookComplete, LinkedNotebook,QUuid), this, QNSLOT(LinkedNotebookLocalStorageManagerAsyncTester, - onUpdateLinkedNotebookCompleted,LinkedNotebook,QUuid)); + onUpdateLinkedNotebookCompleted, + LinkedNotebook,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, - QNSIGNAL(LocalStorageManagerAsync,updateLinkedNotebookFailed, + QNSIGNAL(LocalStorageManagerAsync, + updateLinkedNotebookFailed, LinkedNotebook,ErrorString,QUuid), this, QNSLOT(LinkedNotebookLocalStorageManagerAsyncTester, onUpdateLinkedNotebookFailed,LinkedNotebook, ErrorString,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, - QNSIGNAL(LocalStorageManagerAsync,findLinkedNotebookComplete, + QNSIGNAL(LocalStorageManagerAsync, + findLinkedNotebookComplete, LinkedNotebook,QUuid), this, QNSLOT(LinkedNotebookLocalStorageManagerAsyncTester, - onFindLinkedNotebookCompleted,LinkedNotebook,QUuid)); + onFindLinkedNotebookCompleted, + LinkedNotebook,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, - QNSIGNAL(LocalStorageManagerAsync,findLinkedNotebookFailed, + QNSIGNAL(LocalStorageManagerAsync, + findLinkedNotebookFailed, LinkedNotebook,ErrorString,QUuid), this, QNSLOT(LinkedNotebookLocalStorageManagerAsyncTester, onFindLinkedNotebookFailed,LinkedNotebook, ErrorString,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, - QNSIGNAL(LocalStorageManagerAsync,listAllLinkedNotebooksComplete, - size_t,size_t, + QNSIGNAL(LocalStorageManagerAsync, + listAllLinkedNotebooksComplete,size_t,size_t, LocalStorageManager::ListLinkedNotebooksOrder::type, LocalStorageManager::OrderDirection::type, QList<LinkedNotebook>,QUuid), @@ -561,8 +575,8 @@ LocalStorageManager::OrderDirection::type, QList<LinkedNotebook>,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, - QNSIGNAL(LocalStorageManagerAsync,listAllLinkedNotebooksFailed, - size_t,size_t, + QNSIGNAL(LocalStorageManagerAsync, + listAllLinkedNotebooksFailed,size_t,size_t, LocalStorageManager::ListLinkedNotebooksOrder::type, LocalStorageManager::OrderDirection::type, ErrorString,QUuid), @@ -581,7 +595,8 @@ onExpungeLinkedNotebookCompleted, LinkedNotebook,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, - QNSIGNAL(LocalStorageManagerAsync,expungeLinkedNotebookFailed, + QNSIGNAL(LocalStorageManagerAsync, + expungeLinkedNotebookFailed, LinkedNotebook,ErrorString,QUuid), this, QNSLOT(LinkedNotebookLocalStorageManagerAsyncTester, diff -Nru libquentier-0.5.0/src/tests/local_storage/LocalStorageCacheAsyncTester.cpp libquentier-0.5.0/src/tests/local_storage/LocalStorageCacheAsyncTester.cpp --- libquentier-0.5.0/src/tests/local_storage/LocalStorageCacheAsyncTester.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/tests/local_storage/LocalStorageCacheAsyncTester.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -101,20 +101,21 @@ addNotebook(); } -void LocalStorageCacheAsyncTester::onAddNotebookCompleted(Notebook notebook, - QUuid requestId) +void LocalStorageCacheAsyncTester::onAddNotebookCompleted( + Notebook notebook, QUuid requestId) { Q_UNUSED(requestId) ErrorString errorDescription; -#define HANDLE_WRONG_STATE() \ - else { \ - errorDescription.setBase("Internal error in LocalStorageCacheAsyncTester: "\ - "found wrong state"); \ - QNWARNING(errorDescription << ": " << m_state); \ - Q_EMIT failure(errorDescription.nonLocalizedString()); \ - } +#define HANDLE_WRONG_STATE() \ + else { \ + errorDescription.setBase( \ + "Internal error in LocalStorageCacheAsyncTester: wrong state"); \ + QNWARNING(errorDescription << ": " << m_state); \ + Q_EMIT failure(errorDescription.nonLocalizedString()); \ + } \ +// HANDLE_WRONG_STATE if (m_state == STATE_SENT_NOTEBOOK_ADD_REQUEST) { @@ -122,8 +123,8 @@ errorDescription.setBase( "Internal error in LocalStorageCacheAsyncTester: notebook in " "onAddNotebookCompleted doesn't match the original notebook"); - QNWARNING(errorDescription << QStringLiteral("; original notebook: ") - << m_currentNotebook << QStringLiteral("\nFound notebook: ") + QNWARNING(errorDescription << "; original notebook: " + << m_currentNotebook << "\nFound notebook: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -140,14 +141,13 @@ if (m_addedNotebooksCount > MAX_NOTEBOOKS_TO_STORE) { - const Notebook * pNotebook = - m_pLocalStorageCacheManager->findNotebook(m_firstNotebook.localUid(), - LocalStorageCacheManager::LocalUid); + const Notebook * pNotebook = m_pLocalStorageCacheManager->findNotebook( + m_firstNotebook.localUid(), + LocalStorageCacheManager::LocalUid); if (pNotebook) { errorDescription.setBase("Found notebook which should not have " "been present in the local storage cache"); - QNWARNING(errorDescription << QStringLiteral(": ") - << pNotebook->toString()); + QNWARNING(errorDescription << ": " << pNotebook->toString()); Q_EMIT failure(errorDescription.nonLocalizedString()); } else { @@ -158,13 +158,14 @@ } else if (m_addedNotebooksCount > 1) { - const Notebook * pNotebook = - m_pLocalStorageCacheManager->findNotebook(m_firstNotebook.localUid(), - LocalStorageCacheManager::LocalUid); + const Notebook * pNotebook = m_pLocalStorageCacheManager->findNotebook( + m_firstNotebook.localUid(), + LocalStorageCacheManager::LocalUid); if (!pNotebook) { - errorDescription.setBase("Notebook which should have been present " - "in the local storage cache was not found there"); - QNWARNING(errorDescription << QStringLiteral(", first notebook: ") + errorDescription.setBase("Notebook which should have been " + "present in the local storage cache " + "was not found there"); + QNWARNING(errorDescription << ", first notebook: " << m_firstNotebook); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -176,17 +177,16 @@ HANDLE_WRONG_STATE() } -void LocalStorageCacheAsyncTester::onAddNotebookFailed(Notebook notebook, - ErrorString errorDescription, - QUuid requestId) +void LocalStorageCacheAsyncTester::onAddNotebookFailed( + Notebook notebook, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", notebook: ") << notebook); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", notebook: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); } -void LocalStorageCacheAsyncTester::onUpdateNotebookCompleted(Notebook notebook, - QUuid requestId) +void LocalStorageCacheAsyncTester::onUpdateNotebookCompleted( + Notebook notebook, QUuid requestId) { Q_UNUSED(requestId) @@ -198,27 +198,31 @@ errorDescription.setBase( "Internal error in LocalStorageCacheAsyncTester: notebook in " "onUpdateNotebookCompleted doesn't match the original notebook"); - QNWARNING(errorDescription << QStringLiteral("; original notebook: ") - << m_secondNotebook << QStringLiteral("\nFound notebook: ") + QNWARNING(errorDescription << "; original notebook: " + << m_secondNotebook << "\nFound notebook: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } - const Notebook * pNotebook = - m_pLocalStorageCacheManager->findNotebook(notebook.localUid(), - LocalStorageCacheManager::LocalUid); - if (!pNotebook) { - errorDescription.setBase("Updated notebook which should have been present " - "in the local storage cache was not found there"); - QNWARNING(errorDescription << QStringLiteral(", notebook: ") << notebook); + const Notebook * pNotebook = m_pLocalStorageCacheManager->findNotebook( + notebook.localUid(), + LocalStorageCacheManager::LocalUid); + if (!pNotebook) + { + errorDescription.setBase("Updated notebook which should have been " + "present in the local storage cache was " + "not found there"); + QNWARNING(errorDescription << ", notebook: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } - else if (*pNotebook != notebook) { - errorDescription.setBase("Updated notebook does not match the notebook " - "stored in the local storage cache"); - QNWARNING(errorDescription << QStringLiteral(", notebook: ") << notebook); + else if (*pNotebook != notebook) + { + errorDescription.setBase("Updated notebook does not match " + "the notebook stored in the local storage " + "cache"); + QNWARNING(errorDescription << ", notebook: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } @@ -229,12 +233,11 @@ HANDLE_WRONG_STATE() } -void LocalStorageCacheAsyncTester::onUpdateNotebookFailed(Notebook notebook, - ErrorString errorDescription, - QUuid requestId) +void LocalStorageCacheAsyncTester::onUpdateNotebookFailed( + Notebook notebook, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", notebook: ") << notebook); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", notebook: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -246,23 +249,26 @@ if (m_state == STATE_SENT_NOTE_ADD_REQUEST) { - if (m_currentNote != note) { + if (m_currentNote != note) + { errorDescription.setBase( "Internal error in LocalStorageCacheAsyncTester: " "note in onAddNoteCompleted doesn't match the original note"); - QNWARNING(errorDescription << QStringLiteral("; original note: ") - << m_currentNote << QStringLiteral("\nFound note: ") << note); + QNWARNING(errorDescription << "; original note: " + << m_currentNote << "\nFound note: " << note); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } - if (m_secondNotebook.localUid() != note.notebookLocalUid()) { - errorDescription.setBase("Internal error in LocalStorageCacheAsyncTester: " - "notebook in onAddNoteCompleted doesn't match " - "the original notebook"); - QNWARNING(errorDescription << QStringLiteral("; original notebook: ") + if (m_secondNotebook.localUid() != note.notebookLocalUid()) + { + errorDescription.setBase("Internal error in " + "LocalStorageCacheAsyncTester: " + "notebook in onAddNoteCompleted doesn't " + "match the original notebook"); + QNWARNING(errorDescription << "; original notebook: " << m_secondNotebook - << QStringLiteral("\nFound note's local notebook uid: ") + << "\nFound note's local notebook uid: " << note.notebookLocalUid()); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -279,17 +285,19 @@ if (m_addedNotesCount > MAX_NOTES_TO_STORE) { - const Note * pNote = - m_pLocalStorageCacheManager->findNote(m_firstNote.localUid(), - LocalStorageCacheManager::LocalUid); - if (pNote) { + const Note * pNote = m_pLocalStorageCacheManager->findNote( + m_firstNote.localUid(), + LocalStorageCacheManager::LocalUid); + if (pNote) + { errorDescription.setBase("Found note which should not have been " "present in the local storage cache: "); errorDescription.details() = pNote->toString(); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); } - else { + else + { updateNote(); } @@ -297,15 +305,15 @@ } else if (m_addedNotesCount > 1) { - const Note * pNote = - m_pLocalStorageCacheManager->findNote(m_firstNote.localUid(), - LocalStorageCacheManager::LocalUid); - if (!pNote) { + const Note * pNote = m_pLocalStorageCacheManager->findNote( + m_firstNote.localUid(), + LocalStorageCacheManager::LocalUid); + if (!pNote) + { errorDescription.setBase("Note which should have been present " "in the local storage cache was not " "found there"); - QNWARNING(errorDescription << QStringLiteral(", first note: ") - << m_firstNote); + QNWARNING(errorDescription << ", first note: " << m_firstNote); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } @@ -316,12 +324,11 @@ HANDLE_WRONG_STATE() } -void LocalStorageCacheAsyncTester::onAddNoteFailed(Note note, - ErrorString errorDescription, - QUuid requestId) +void LocalStorageCacheAsyncTester::onAddNoteFailed( + Note note, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", note: ") << note); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", note: " << note); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -335,43 +342,48 @@ if (m_state == STATE_SENT_NOTE_UPDATE_REQUEST) { - if (m_secondNote != note) { + if (m_secondNote != note) + { errorDescription.setBase( "Internal error in LocalStorageCacheAsyncTester: " "note in onUpdateNoteCompleted doesn't match the original note"); - QNWARNING(errorDescription << QStringLiteral("; original note: ") - << m_secondNote << QStringLiteral("\nFound note: ") << note); + QNWARNING(errorDescription << "; original note: " + << m_secondNote << "\nFound note: " << note); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } - if (m_secondNotebook.localUid() != note.notebookLocalUid()) { + if (m_secondNotebook.localUid() != note.notebookLocalUid()) + { errorDescription.setBase( "Internal error in LocalStorageCacheAsyncTester: " - "note's notebook local uid in onUpdateNoteCompleted doesn't match " - "the original notebook local uid"); - QNWARNING(errorDescription << QStringLiteral("; original notebook: ") + "note's notebook local uid in onUpdateNoteCompleted doesn't " + "match the original notebook local uid"); + QNWARNING(errorDescription << "; original notebook: " << m_secondNotebook - << QStringLiteral("\nUpdated note's notebook local uid: ") + << "\nUpdated note's notebook local uid: " << note.notebookLocalUid()); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } - const Note * pNote = - m_pLocalStorageCacheManager->findNote(note.localUid(), - LocalStorageCacheManager::LocalUid); - if (!pNote) { - errorDescription.setBase("Updated note which should have been present " - "in the local storage cache was not found there"); - QNWARNING(errorDescription << QStringLiteral(", note: ") << note); + const Note * pNote = m_pLocalStorageCacheManager->findNote( + note.localUid(), + LocalStorageCacheManager::LocalUid); + if (!pNote) + { + errorDescription.setBase("Updated note which should have been " + "present in the local storage cache was " + "not found there"); + QNWARNING(errorDescription << ", note: " << note); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } - else if (*pNote != note) { + else if (*pNote != note) + { errorDescription.setBase("Updated note does not match the note " "stored in the local storage cache"); - QNWARNING(errorDescription << QStringLiteral(", note: ") << note); + QNWARNING(errorDescription << ", note: " << note); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } @@ -388,8 +400,8 @@ { Q_UNUSED(options) - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", note: ") << note); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", note: " << note); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -401,12 +413,13 @@ if (m_state == STATE_SENT_TAG_ADD_REQUEST) { - if (m_currentTag != tag) { + if (m_currentTag != tag) + { errorDescription.setBase( "Internal error in LocalStorageCacheAsyncTester: " "tag in onAddTagCompleted doesn't match the original tag"); - QNWARNING(errorDescription << QStringLiteral("; original tag: ") - << m_currentTag << QStringLiteral("\nFound tag: ") << tag); + QNWARNING(errorDescription << "; original tag: " + << m_currentTag << "\nFound tag: " << tag); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } @@ -422,13 +435,13 @@ if (m_addedTagsCount > MAX_TAGS_TO_STORE) { - const Tag * pTag = - m_pLocalStorageCacheManager->findTag(m_firstTag.localUid(), - LocalStorageCacheManager::LocalUid); + const Tag * pTag = m_pLocalStorageCacheManager->findTag( + m_firstTag.localUid(), + LocalStorageCacheManager::LocalUid); if (pTag) { errorDescription.setBase("Found tag which should not have been " "present in the local storage cache"); - QNWARNING(errorDescription << QStringLiteral(": ") << *pTag); + QNWARNING(errorDescription << ": " << *pTag); Q_EMIT failure(errorDescription.nonLocalizedString()); } else { @@ -439,25 +452,26 @@ } else if (m_addedTagsCount > 1) { - const Tag * pTag = - m_pLocalStorageCacheManager->findTag(m_firstTag.localUid(), - LocalStorageCacheManager::LocalUid); - if (!pTag) { + const Tag * pTag = m_pLocalStorageCacheManager->findTag( + m_firstTag.localUid(), + LocalStorageCacheManager::LocalUid); + if (!pTag) + { errorDescription.setBase("Tag which should have been present " - "in the local storage cache was not found there"); - QNWARNING(errorDescription << QStringLiteral(", first tag: ") - << m_firstTag); + "in the local storage cache was not " + "found there"); + QNWARNING(errorDescription << ", first tag: " << m_firstTag); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } // Check that we can also find the tag by name in the cache pTag = m_pLocalStorageCacheManager->findTagByName(m_firstTag.name()); - if (!pTag) { - errorDescription.setBase("Tag present in the local storage cache " - "could not be found by tag name"); - QNWARNING(errorDescription << QStringLiteral(", first tag: ") - << m_firstTag); + if (!pTag) + { + errorDescription.setBase("Tag present in the local storage " + "cache could not be found by tag name"); + QNWARNING(errorDescription << ", first tag: " << m_firstTag); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } @@ -468,12 +482,11 @@ HANDLE_WRONG_STATE() } -void LocalStorageCacheAsyncTester::onAddTagFailed(Tag tag, - ErrorString errorDescription, - QUuid requestId) +void LocalStorageCacheAsyncTester::onAddTagFailed( + Tag tag, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", request id = ") << requestId - << QStringLiteral(", tag: ") << tag); + QNWARNING(errorDescription << ", request id = " << requestId + << ", tag: " << tag); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -485,30 +498,35 @@ if (m_state == STATE_SENT_TAG_UPDATE_REQUEST) { - if (m_secondTag != tag) { - errorDescription.setBase("Internal error in LocalStorageCacheAsyncTester: " - "tag in onUpdateTagCompleted doesn't match " + if (m_secondTag != tag) + { + errorDescription.setBase("Internal error in " + "LocalStorageCacheAsyncTester: tag in " + "onUpdateTagCompleted doesn't match " "the original tag"); - QNWARNING(errorDescription << QStringLiteral("; original tag: ") - << m_secondTag << QStringLiteral("\nFound tag: ") << tag); + QNWARNING(errorDescription << "; original tag: " + << m_secondTag << "\nFound tag: " << tag); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } - const Tag * pTag = - m_pLocalStorageCacheManager->findTag(tag.localUid(), - LocalStorageCacheManager::LocalUid); - if (!pTag) { - errorDescription.setBase("Updated tag which should have been present " - "in the local storage cache was not found there"); - QNWARNING(errorDescription << QStringLiteral(", tag: ") << tag); + const Tag * pTag = m_pLocalStorageCacheManager->findTag( + tag.localUid(), + LocalStorageCacheManager::LocalUid); + if (!pTag) + { + errorDescription.setBase("Updated tag which should have been " + "present in the local storage cache was " + "not found there"); + QNWARNING(errorDescription << ", tag: " << tag); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } - else if (*pTag != tag) { + else if (*pTag != tag) + { errorDescription.setBase("Updated tag does not match the tag " "stored in the local storage cache"); - QNWARNING(errorDescription << QStringLiteral(", tag: ") << tag); + QNWARNING(errorDescription << ", tag: " << tag); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } @@ -522,8 +540,8 @@ void LocalStorageCacheAsyncTester::onUpdateTagFailed( Tag tag, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", request id = ") << requestId - << QStringLiteral(", tag: ") << tag); + QNWARNING(errorDescription << ", request id = " << requestId + << ", tag: " << tag); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -536,15 +554,14 @@ if (m_state == STATE_SENT_LINKED_NOTEBOOK_ADD_REQUEST) { - if (m_currentLinkedNotebook != linkedNotebook) { + if (m_currentLinkedNotebook != linkedNotebook) + { errorDescription.setBase( "Internal error in LocalStorageCacheAsyncTester: linked notebook " "in onAddLinkedNotebookCompleted doesn't match the original " "linked notebook"); - QNWARNING(errorDescription - << QStringLiteral("; original linked notebook: ") - << m_currentLinkedNotebook - << QStringLiteral("\nFound linked notebook: ") + QNWARNING(errorDescription << "; original linked notebook: " + << m_currentLinkedNotebook << "\nFound linked notebook: " << linkedNotebook); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -562,14 +579,18 @@ if (m_addedLinkedNotebooksCount > MAX_LINKED_NOTEBOOKS_TO_STORE) { const LinkedNotebook * pLinkedNotebook = - m_pLocalStorageCacheManager->findLinkedNotebook(m_firstLinkedNotebook.guid()); - if (pLinkedNotebook) { - errorDescription.setBase("Found linked notebook which should not " - "have been present in the local storage cache"); - QNWARNING(errorDescription << QStringLiteral(": ") << *pLinkedNotebook); + m_pLocalStorageCacheManager->findLinkedNotebook( + m_firstLinkedNotebook.guid()); + if (pLinkedNotebook) + { + errorDescription.setBase("Found linked notebook which should " + "not have been present in the local " + "storage cache"); + QNWARNING(errorDescription << ": " << *pLinkedNotebook); Q_EMIT failure(errorDescription.nonLocalizedString()); } - else { + else + { updateLinkedNotebook(); } @@ -578,13 +599,14 @@ else if (m_addedLinkedNotebooksCount > 1) { const LinkedNotebook * pLinkedNotebook = - m_pLocalStorageCacheManager->findLinkedNotebook(m_firstLinkedNotebook.guid()); - if (!pLinkedNotebook) { + m_pLocalStorageCacheManager->findLinkedNotebook( + m_firstLinkedNotebook.guid()); + if (!pLinkedNotebook) + { errorDescription.setBase("Linked notebook which should have been " "present in the local storage cache was " "not found there"); - QNWARNING(errorDescription - << QStringLiteral(", first linked notebook: ") + QNWARNING(errorDescription << ", first linked notebook: " << m_firstLinkedNotebook); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -599,8 +621,8 @@ void LocalStorageCacheAsyncTester::onAddLinkedNotebookFailed( LinkedNotebook linkedNotebook, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", linked notebook: ") << linkedNotebook); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", linked notebook: " << linkedNotebook); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -613,15 +635,14 @@ if (m_state == STATE_SENT_LINKED_NOTEBOOK_UPDATE_REQUEST) { - if (m_secondLinkedNotebook != linkedNotebook) { + if (m_secondLinkedNotebook != linkedNotebook) + { errorDescription.setBase( "Internal error in LocalStorageCacheAsyncTester: linked notebook " "in onUpdateLinkedNotebookCompleted doesn't match the original " "linked notebook"); - QNWARNING(errorDescription - << QStringLiteral("; original linked notebook: ") - << m_secondLinkedNotebook - << QStringLiteral("\nFound linked notebook: ") + QNWARNING(errorDescription << "; original linked notebook: " + << m_secondLinkedNotebook << "\nFound linked notebook: " << linkedNotebook); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -629,26 +650,29 @@ const LinkedNotebook * pLinkedNotebook = m_pLocalStorageCacheManager->findLinkedNotebook(linkedNotebook.guid()); - if (!pLinkedNotebook) { + if (!pLinkedNotebook) + { errorDescription.setBase("Updated linked notebook which should have " "been present in the local storage cache " "was not found there"); - QNWARNING(errorDescription << QStringLiteral(", linked notebook: ") + QNWARNING(errorDescription << ", linked notebook: " << linkedNotebook); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } - else if (*pLinkedNotebook != linkedNotebook) { + else if (*pLinkedNotebook != linkedNotebook) + { errorDescription.setBase( - "Updated linked notebook does not match the linked notebook stored " - "in the local storage cache"); - QNWARNING(errorDescription << QStringLiteral(", linked notebook: ") + "Updated linked notebook does not match the linked notebook " + "stored in the local storage cache"); + QNWARNING(errorDescription << ", linked notebook: " << linkedNotebook); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } - // Ok, updated linked notebook was cached correctly, moving to testing saved searches + // Ok, updated linked notebook was cached correctly, moving to testing + // saved searches addSavedSearch(); } HANDLE_WRONG_STATE() @@ -657,13 +681,13 @@ void LocalStorageCacheAsyncTester::onUpdateLinkedNotebookFailed( LinkedNotebook linkedNotebook, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", linked notebook: ") << linkedNotebook); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", linked notebook: " << linkedNotebook); Q_EMIT failure(errorDescription.nonLocalizedString()); } -void LocalStorageCacheAsyncTester::onAddSavedSearchCompleted(SavedSearch search, - QUuid requestId) +void LocalStorageCacheAsyncTester::onAddSavedSearchCompleted( + SavedSearch search, QUuid requestId) { Q_UNUSED(requestId) @@ -671,13 +695,14 @@ if (m_state == STATE_SENT_SAVED_SEARCH_ADD_REQUEEST) { - if (m_currentSavedSearch != search) { + if (m_currentSavedSearch != search) + { errorDescription.setBase( "Internal error in LocalStorageCacheAsyncTester: saved search in " "onAddSavedSearchCompleted doesn't match the original saved search"); - QNWARNING(errorDescription << QStringLiteral("; original saved search: ") + QNWARNING(errorDescription << "; original saved search: " << m_currentSavedSearch - << QStringLiteral("\nFound saved search: ") << search); + << "\nFound saved search: " << search); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } @@ -694,15 +719,19 @@ if (m_addedSavedSearchesCount > MAX_SAVED_SEARCHES_TO_STORE) { const SavedSearch * pSavedSearch = - m_pLocalStorageCacheManager->findSavedSearch(m_firstSavedSearch.localUid(), - LocalStorageCacheManager::LocalUid); - if (pSavedSearch) { - errorDescription.setBase("Found saved search which should not have " - "been present in the local storage cache"); - QNWARNING(errorDescription << QStringLiteral(": ") << *pSavedSearch); + m_pLocalStorageCacheManager->findSavedSearch( + m_firstSavedSearch.localUid(), + LocalStorageCacheManager::LocalUid); + if (pSavedSearch) + { + errorDescription.setBase("Found saved search which should not " + "have been present in the local " + "storage cache"); + QNWARNING(errorDescription << ": " << *pSavedSearch); Q_EMIT failure(errorDescription.nonLocalizedString()); } - else { + else + { updateSavedSearch(); } @@ -711,12 +740,15 @@ else if (m_addedSavedSearchesCount > 1) { const SavedSearch * pSavedSearch = - m_pLocalStorageCacheManager->findSavedSearch(m_firstSavedSearch.localUid(), - LocalStorageCacheManager::LocalUid); - if (!pSavedSearch) { - errorDescription.setBase("Saved search which should have been present " - "in the local storage cache was not found there"); - QNWARNING(errorDescription << QStringLiteral(", first saved search: ") + m_pLocalStorageCacheManager->findSavedSearch( + m_firstSavedSearch.localUid(), + LocalStorageCacheManager::LocalUid); + if (!pSavedSearch) + { + errorDescription.setBase("Saved search which should have been " + "present in the local storage cache " + "was not found there"); + QNWARNING(errorDescription << ", first saved search: " << m_firstSavedSearch); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -731,13 +763,13 @@ void LocalStorageCacheAsyncTester::onAddSavedSearchFailed( SavedSearch search, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", saved search: ") << search); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", saved search: " << search); Q_EMIT failure(errorDescription.nonLocalizedString()); } -void LocalStorageCacheAsyncTester::onUpdateSavedSearchCompleted(SavedSearch search, - QUuid requestId) +void LocalStorageCacheAsyncTester::onUpdateSavedSearchCompleted( + SavedSearch search, QUuid requestId) { Q_UNUSED(requestId) @@ -745,36 +777,44 @@ if (m_state == STATE_SENT_SAVED_SEARCH_UPDATE_REQUEST) { - if (m_secondSavedSearch != search) { + if (m_secondSavedSearch != search) + { errorDescription.setBase( - "Internal error in LocalStorageCachesyncTester: saved search in " - "onUpdateSavedSearchCompleted doesn't match the original saved search"); - QNWARNING(errorDescription << QStringLiteral("; original saved search: ") - << m_secondSavedSearch - << QStringLiteral("\nFound saved search: ") << search); + "Internal error in LocalStorageCachesyncTester: saved search " + "in onUpdateSavedSearchCompleted doesn't match the original " + "saved search"); + QNWARNING(errorDescription << "; original saved search: " + << m_secondSavedSearch << "\nFound saved search: " + << search); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } const SavedSearch * pSavedSearch = - m_pLocalStorageCacheManager->findSavedSearch(search.localUid(), - LocalStorageCacheManager::LocalUid); - if (!pSavedSearch) { - errorDescription.setBase("Updated saved search which should have been present " - "in the local storage cache was not found there"); - QNWARNING(errorDescription << QStringLiteral(", saved search: ") << search); + m_pLocalStorageCacheManager->findSavedSearch( + search.localUid(), + LocalStorageCacheManager::LocalUid); + if (!pSavedSearch) + { + errorDescription.setBase("Updated saved search which should have " + "been present in the local storage cache " + "was not found there"); + QNWARNING(errorDescription << ", saved search: " << search); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } - else if (*pSavedSearch != search) { - errorDescription.setBase("Updated saved search does not match the saved " - "search in the local storage cache"); - QNWARNING(errorDescription << QStringLiteral(", saved search: ") << search); + else if (*pSavedSearch != search) + { + errorDescription.setBase("Updated saved search does not match " + "the saved search in the local storage " + "cache"); + QNWARNING(errorDescription << ", saved search: " << search); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } - // Ok, updated saved search was cached correctly, can finally return successfully + // Ok, updated saved search was cached correctly, can finally return + // successfully Q_EMIT success(); } HANDLE_WRONG_STATE() @@ -783,8 +823,8 @@ void LocalStorageCacheAsyncTester::onUpdateSavedSearchFailed( SavedSearch search, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", saved search: ") << search); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", saved search: " << search); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -836,17 +876,17 @@ QNSLOT(LocalStorageManagerAsync,onUpdateTagRequest, Tag,QUuid)); QObject::connect(this, - QNSIGNAL(LocalStorageCacheAsyncTester,addLinkedNotebookRequest, - LinkedNotebook,QUuid), + QNSIGNAL(LocalStorageCacheAsyncTester, + addLinkedNotebookRequest,LinkedNotebook,QUuid), m_pLocalStorageManagerAsync, QNSLOT(LocalStorageManagerAsync,onAddLinkedNotebookRequest, LinkedNotebook,QUuid)); QObject::connect(this, - QNSIGNAL(LocalStorageCacheAsyncTester,updateLinkedNotebookRequest, - LinkedNotebook,QUuid), + QNSIGNAL(LocalStorageCacheAsyncTester, + updateLinkedNotebookRequest,LinkedNotebook,QUuid), m_pLocalStorageManagerAsync, - QNSLOT(LocalStorageManagerAsync,onUpdateLinkedNotebookRequest, - LinkedNotebook,QUuid)); + QNSLOT(LocalStorageManagerAsync, + onUpdateLinkedNotebookRequest,LinkedNotebook,QUuid)); QObject::connect(this, QNSIGNAL(LocalStorageCacheAsyncTester,addSavedSearchRequest, SavedSearch,QUuid), @@ -854,8 +894,8 @@ QNSLOT(LocalStorageManagerAsync,onAddSavedSearchRequest, SavedSearch,QUuid)); QObject::connect(this, - QNSIGNAL(LocalStorageCacheAsyncTester,updateSavedSearchRequest, - SavedSearch,QUuid), + QNSIGNAL(LocalStorageCacheAsyncTester, + updateSavedSearchRequest,SavedSearch,QUuid), m_pLocalStorageManagerAsync, QNSLOT(LocalStorageManagerAsync,onUpdateSavedSearchRequest, SavedSearch,QUuid)); @@ -877,8 +917,8 @@ QNSIGNAL(LocalStorageManagerAsync,updateNotebookComplete, Notebook,QUuid), this, - QNSLOT(LocalStorageCacheAsyncTester,onUpdateNotebookCompleted, - Notebook,QUuid)); + QNSLOT(LocalStorageCacheAsyncTester, + onUpdateNotebookCompleted,Notebook,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync,updateNotebookFailed, Notebook,ErrorString,QUuid), @@ -886,9 +926,11 @@ QNSLOT(LocalStorageCacheAsyncTester,onUpdateNotebookFailed, Notebook,ErrorString,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, - QNSIGNAL(LocalStorageManagerAsync,addNoteComplete,Note,QUuid), + QNSIGNAL(LocalStorageManagerAsync,addNoteComplete, + Note,QUuid), this, - QNSLOT(LocalStorageCacheAsyncTester,onAddNoteCompleted,Note,QUuid)); + QNSLOT(LocalStorageCacheAsyncTester,onAddNoteCompleted, + Note,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync,addNoteFailed, Note,ErrorString,QUuid), @@ -937,31 +979,37 @@ QNSIGNAL(LocalStorageManagerAsync,addLinkedNotebookComplete, LinkedNotebook,QUuid), this, - QNSLOT(LocalStorageCacheAsyncTester,onAddLinkedNotebookCompleted, - LinkedNotebook,QUuid)); + QNSLOT(LocalStorageCacheAsyncTester, + onAddLinkedNotebookCompleted,LinkedNotebook,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync,addLinkedNotebookFailed, LinkedNotebook,ErrorString,QUuid), this, - QNSLOT(LocalStorageCacheAsyncTester,onAddLinkedNotebookFailed, + QNSLOT(LocalStorageCacheAsyncTester, + onAddLinkedNotebookFailed, LinkedNotebook,ErrorString,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, - QNSIGNAL(LocalStorageManagerAsync,updateLinkedNotebookComplete, + QNSIGNAL(LocalStorageManagerAsync, + updateLinkedNotebookComplete, LinkedNotebook,QUuid), this, - QNSLOT(LocalStorageCacheAsyncTester,onUpdateLinkedNotebookCompleted, + QNSLOT(LocalStorageCacheAsyncTester, + onUpdateLinkedNotebookCompleted, LinkedNotebook,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, - QNSIGNAL(LocalStorageManagerAsync,updateLinkedNotebookFailed, + QNSIGNAL(LocalStorageManagerAsync, + updateLinkedNotebookFailed, LinkedNotebook,ErrorString,QUuid), this, - QNSLOT(LocalStorageCacheAsyncTester,onUpdateLinkedNotebookFailed, + QNSLOT(LocalStorageCacheAsyncTester, + onUpdateLinkedNotebookFailed, LinkedNotebook,ErrorString,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync,addSavedSearchComplete, SavedSearch,QUuid), this, - QNSLOT(LocalStorageCacheAsyncTester,onAddSavedSearchCompleted, + QNSLOT(LocalStorageCacheAsyncTester, + onAddSavedSearchCompleted, SavedSearch,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync,addSavedSearchFailed, @@ -973,13 +1021,15 @@ QNSIGNAL(LocalStorageManagerAsync,updateSavedSearchComplete, SavedSearch,QUuid), this, - QNSLOT(LocalStorageCacheAsyncTester,onUpdateSavedSearchCompleted, + QNSLOT(LocalStorageCacheAsyncTester, + onUpdateSavedSearchCompleted, SavedSearch,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync,updateSavedSearchFailed, SavedSearch,ErrorString,QUuid), this, - QNSLOT(LocalStorageCacheAsyncTester,onUpdateSavedSearchFailed, + QNSLOT(LocalStorageCacheAsyncTester, + onUpdateSavedSearchFailed, SavedSearch,ErrorString,QUuid)); } @@ -1007,10 +1057,13 @@ m_currentNotebook.setUpdateSequenceNumber( static_cast<qint32>(m_addedNotebooksCount + 1)); m_currentNotebook.setName( - QStringLiteral("Fake notebook #") + QString::number(m_addedNotebooksCount + 1)); + QStringLiteral("Fake notebook #") + + QString::number(m_addedNotebooksCount + 1)); m_currentNotebook.setCreationTimestamp(QDateTime::currentMSecsSinceEpoch()); m_currentNotebook.setModificationTimestamp(QDateTime::currentMSecsSinceEpoch()); - m_currentNotebook.setDefaultNotebook((m_addedNotebooksCount == 0) ? true : false); + m_currentNotebook.setDefaultNotebook(m_addedNotebooksCount == 0 + ? true + : false); m_currentNotebook.setLastUsed(false); m_state = STATE_SENT_NOTEBOOK_ADD_REQUEST; @@ -1019,8 +1072,10 @@ void LocalStorageCacheAsyncTester::updateNotebook() { - m_secondNotebook.setUpdateSequenceNumber(m_secondNotebook.updateSequenceNumber() + 1); - m_secondNotebook.setName(m_secondNotebook.name() + QStringLiteral("_modified")); + m_secondNotebook.setUpdateSequenceNumber( + m_secondNotebook.updateSequenceNumber() + 1); + m_secondNotebook.setName( + m_secondNotebook.name() + QStringLiteral("_modified")); m_secondNotebook.setModificationTimestamp(QDateTime::currentMSecsSinceEpoch()); m_state = STATE_SENT_NOTEBOOK_UPDATE_REQUEST; @@ -1030,7 +1085,8 @@ void LocalStorageCacheAsyncTester::addNote() { m_currentNote = Note(); - m_currentNote.setUpdateSequenceNumber(static_cast<qint32>(m_addedNotesCount + 1)); + m_currentNote.setUpdateSequenceNumber( + static_cast<qint32>(m_addedNotesCount + 1)); m_currentNote.setTitle( QStringLiteral("Fake note #") + QString::number(m_addedNotesCount + 1)); m_currentNote.setCreationTimestamp(QDateTime::currentMSecsSinceEpoch()); @@ -1046,7 +1102,8 @@ void LocalStorageCacheAsyncTester::updateNote() { - m_secondNote.setUpdateSequenceNumber(m_secondNote.updateSequenceNumber() + 1); + m_secondNote.setUpdateSequenceNumber( + m_secondNote.updateSequenceNumber() + 1); m_secondNote.setTitle(m_secondNote.title() + QStringLiteral("_modified")); m_secondNote.setModificationTimestamp(QDateTime::currentMSecsSinceEpoch()); diff -Nru libquentier-0.5.0/src/tests/local_storage/LocalStorageManagerBasicTests.cpp libquentier-0.5.0/src/tests/local_storage/LocalStorageManagerBasicTests.cpp --- libquentier-0.5.0/src/tests/local_storage/LocalStorageManagerBasicTests.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/tests/local_storage/LocalStorageManagerBasicTests.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -70,11 +70,10 @@ VERIFY2( search == foundSearch, - QStringLiteral("Added and found saved searches in the local " - "storage don't match: saved search added to " - "the local storage: ") + "Added and found saved searches in the local storage don't match: " + << "saved search added to the local storage: " << search - << QStringLiteral("\nSaved search found in the local storage:" ) + << "\nSaved search found in the local storage:" << foundSearch); // ========= Check Find by name ============= @@ -86,11 +85,10 @@ VERIFY2( search == foundByNameSearch, - QStringLiteral("Added and found by name saved searches " - "in the local storage don't match: saved search added " - "to the local storage: ") + "Added and found by name saved searches in the local storage don't " + << "match: saved search added to the local storage: " << search - << QStringLiteral("\nSaved search found by name in the local storage: ") + << "\nSaved search found by name in the local storage: " << foundByNameSearch); // ========= Check Update + Find ============= @@ -113,10 +111,10 @@ modifiedSearch.setLocalUid(localUid); VERIFY2( modifiedSearch == foundSearch, - QStringLiteral("Updated and found saved searches in the local storage " - "don't match: saved search updated in the local storage: ") + "Updated and found saved searches in the local storage " + << "don't match: saved search updated in the local storage: " << modifiedSearch - << QStringLiteral("\nSavedSearch found in the local storage: ") + << "\nSavedSearch found in the local storage: " << foundSearch); // ========== Check savedSearchCount to return 1 ============ @@ -133,11 +131,11 @@ qPrintable(errorMessage.nonLocalizedString())); VERIFY2(!localStorageManager.findSavedSearch(foundSearch, errorMessage), - QStringLiteral("Error: found saved search which should have been " - "expunged from local storage: saved search expunged " - "from the local storage: ") + "Error: found saved search which should have been " + << "expunged from local storage: saved search expunged " + << "from the local storage: " << modifiedSearch - << QStringLiteral("\nSavedSearch found in the local storage: ") + << "\nSavedSearch found in the local storage: " << foundSearch); // ========== Check savedSearchCount to return 0 ============ @@ -174,8 +172,7 @@ ErrorString errorMessage; VERIFY2(linkedNotebook.checkParameters(errorMessage), - QStringLiteral("Found invalid LinkedNotebook: ") - << linkedNotebook << QStringLiteral(", error: ") + "Found invalid LinkedNotebook: " << linkedNotebook << ", error: " << errorMessage.nonLocalizedString()); // ========== Check Add + Find =========== @@ -189,10 +186,10 @@ qPrintable(errorMessage.nonLocalizedString())); VERIFY2(linkedNotebook == foundLinkedNotebook, - QStringLiteral("Added and found linked noteboks in the local storage " - "don't match: LinkedNotebook added to the local storage: ") + "Added and found linked noteboks in the local storage " + << "don't match: LinkedNotebook added to the local storage: " << linkedNotebook - << QStringLiteral("\nLinkedNotebook found in the local storage: ") + << "\nLinkedNotebook found in the local storage: " << foundLinkedNotebook); // =========== Check Update + Find =========== @@ -227,10 +224,10 @@ VERIFY2( modifiedLinkedNotebook == foundLinkedNotebook, - QStringLiteral("Updated and found linked notebooks in the local storage " - "don't match: LinkedNotebook updated in the local storage: ") + "Updated and found linked notebooks in the local storage " + << "don't match: LinkedNotebook updated in the local storage: " << modifiedLinkedNotebook - << QStringLiteral("\nLinkedNotebook found in the local storage: ") + << "\nLinkedNotebook found in the local storage: " << foundLinkedNotebook); // ========== Check linkedNotebookCount to return 1 ============ @@ -248,11 +245,11 @@ qPrintable(errorMessage.nonLocalizedString())); VERIFY2(!localStorageManager.findLinkedNotebook(foundLinkedNotebook, errorMessage), - QStringLiteral("Error: found linked notebook which should have been " - "expunged from local storage: LinkedNotebook expunged " - "from the local storage: ") + "Error: found linked notebook which should have been expunged from " + << "the local storage: LinkedNotebook expunged " + << "from the local storage: " << modifiedLinkedNotebook - << QStringLiteral("\nLinkedNotebook found in the local storage: ") + << "\nLinkedNotebook found in the local storage: " << foundLinkedNotebook); // ========== Check linkedNotebookCount to return 0 ============ @@ -315,9 +312,9 @@ qPrintable(errorMessage.nonLocalizedString())); VERIFY2(tag == foundTag, - QStringLiteral("Added and found tags in the local storage don't match: " - "tag added to the local storage: ") << tag - << QStringLiteral("\nTag found in the local storage: ") << foundTag); + "Added and found tags in the local storage don't match: " + << "tag added to the local storage: " << tag + << "\nTag found in the local storage: " << foundTag); // ========== Check Find by name ========== Tag foundByNameTag; @@ -331,14 +328,14 @@ qPrintable(errorMessage.nonLocalizedString())); VERIFY2(tag == foundByNameTag, - QStringLiteral("Tag found by name in the local storage doesn't match " - "the original tag: tag found by name: ") - << foundByNameTag << QStringLiteral("\nOriginal tag: ") << tag); + "Tag found by name in the local storage doesn't match " + << "the original tag: tag found by name: " + << foundByNameTag << "\nOriginal tag: " << tag); // ========== Check Update + Find ========== Tag modifiedTag(tag); modifiedTag.setUpdateSequenceNumber(tag.updateSequenceNumber() + 1); - modifiedTag.setLinkedNotebookGuid(QStringLiteral("")); + modifiedTag.setLinkedNotebookGuid(QLatin1String("")); modifiedTag.setName(tag.name() + QStringLiteral("_modified")); modifiedTag.setFavorited(true); modifiedTag.unsetLocalUid(); @@ -347,7 +344,7 @@ qPrintable(errorMessage.nonLocalizedString())); if (!modifiedTag.hasLinkedNotebookGuid()) { - foundTag.setLinkedNotebookGuid(QStringLiteral("")); + foundTag.setLinkedNotebookGuid(QLatin1String("")); } QVERIFY2(localStorageManager.findTag(foundTag, errorMessage), @@ -355,10 +352,10 @@ modifiedTag.setLocalUid(localTagGuid); VERIFY2(modifiedTag == foundTag, - QStringLiteral("Updated and found tags in the local storage don't match: ") - << QStringLiteral(": Tag updated in the local storage: ") + "Updated and found tags in the local storage don't match: " + << ": Tag updated in the local storage: " << modifiedTag - << QStringLiteral("\nTag found in the local storage: ") << foundTag); + << "\nTag found in the local storage: " << foundTag); // ========== tagCount to return 1 ============ int count = localStorageManager.tagCount(errorMessage); @@ -383,11 +380,11 @@ qPrintable(errorMessage.nonLocalizedString())); VERIFY2(newTag == foundNewTag, - QStringLiteral("Second added tag and its found copy " - "from the local storage don't match") - << QStringLiteral(": the second tag added to the local storage: ") + "Second added tag and its found copy " + << "from the local storage don't match" + << ": the second tag added to the local storage: " << newTag - << QStringLiteral("\nTag found in the local storage: ") + << "\nTag found in the local storage: " << foundNewTag); // ========== Check Expunge + Find (failure expected) ========== @@ -400,11 +397,11 @@ Q_UNUSED(expungedChildTagLocalUids) VERIFY2(!localStorageManager.findTag(foundTag, errorMessage), - QStringLiteral("Error: found tag which should have " - "been expunged from the local storage") - << QStringLiteral(": Tag expunged from the local storage: ") + "Error: found tag which should have " + << "been expunged from the local storage" + << ": Tag expunged from the local storage: " << modifiedTag - << QStringLiteral("\nTag found in the local storage: ") << foundTag); + << "\nTag found in the local storage: " << foundTag); } void TestResourceAddFindUpdateExpungeInLocalStorage() @@ -512,11 +509,11 @@ qPrintable(errorMessage.nonLocalizedString())); VERIFY2(resource == foundResource, - QStringLiteral("Added and found in the local storage " - "resources don't match") - << QStringLiteral(": Resource added to the local storage: ") + "Added and found in the local storage " + << "resources don't match" + << ": Resource added to the local storage: " << resource - << QStringLiteral("\nIResource found in the local storage: ") + << "\nIResource found in the local storage: " << foundResource); // ========== Check Update + Find ========== @@ -578,11 +575,10 @@ qPrintable(errorMessage.nonLocalizedString())); VERIFY2(modifiedResource == foundResource, - QStringLiteral("Updated and found in the local storage " - "resources don't match") - << QStringLiteral(": Resource updated in the local storage: ") + "Updated and found in the local storage resources don't match: " + << "Resource updated in the local storage: " << modifiedResource - << QStringLiteral("\nIResource found in the local storage: ") + << "\nIResource found in the local storage: " << foundResource); // ========== Check Find without resource binary data ========= @@ -597,11 +593,11 @@ modifiedResource.setAlternateDataBody(QByteArray()); VERIFY2(modifiedResource == foundResource, - QStringLiteral("Updated and found in the local storage " - "resources without binary data don't match") - << QStringLiteral(": Resource updated in the local storage: ") + "Updated and found in the local storage " + "resources without binary data don't match: " + << "Resource updated in the local storage: " << modifiedResource - << QStringLiteral("\nIResource found in the local storage: ") + << "\nIResource found in the local storage: " << foundResource); @@ -619,11 +615,11 @@ VERIFY2(!localStorageManager.findEnResource(foundResource, getResourceOptions, errorMessage), - QStringLiteral("Error: found Resource which should have " - "been expunged from the local storage") - << QStringLiteral(": Resource expunged from the local storage: ") + "Error: found Resource which should have " + << "been expunged from the local storage" + << ": Resource expunged from the local storage: " << modifiedResource - << QStringLiteral("\nIResource found in the local storage: ") + << "\nIResource found in the local storage: " << foundResource); // ========== enResourceCount to return 0 ============ @@ -816,9 +812,9 @@ } VERIFY2(note == foundNote, - QStringLiteral("Added and found notes in the local storage don't match") - << QStringLiteral(": Note added to the local storage: ") << note - << QStringLiteral("\nNote found in the local storage: ") << foundNote); + "Added and found notes in the local storage don't match" + << ": Note added to the local storage: " << note + << "\nNote found in the local storage: " << foundNote); // ========== Check Update + Find ========== Note modifiedNote(note); @@ -926,12 +922,12 @@ foundResource.setNoteLocalUid(QString()); VERIFY2(foundResource == newResource, - QStringLiteral("Something is wrong with the new resource " - "which should have been added to the local " - "storage along with the note update: it is " - "not equal to the original resource") - << QStringLiteral(": original resource: ") - << newResource << QStringLiteral("\nfound resource: ") + "Something is wrong with the new resource " + << "which should have been added to the local " + << "storage along with the note update: it is " + << "not equal to the original resource" + << ": original resource: " + << newResource << "\nfound resource: " << foundResource); QVERIFY2(localStorageManager.findNote(foundNote, getNoteOptions, errorMessage), @@ -947,11 +943,10 @@ } VERIFY2(modifiedNote == foundNote, - QStringLiteral("Updated and found in the local storage " - "notes don't match") - << QStringLiteral(": Note updated in the local storage: ") + "Updated and found in the local storage notes don't match" + << ": Note updated in the local storage: " << modifiedNote - << QStringLiteral("\nNote found in the local storage: ") + << "\nNote found in the local storage: " << foundNote); // Check that tags are not touched if update tags flag is not set on attempt @@ -994,28 +989,27 @@ * the modified note the two notes should become equal */ VERIFY2(modifiedNote != foundNote, - QStringLiteral("Detected unexpectedly equal notes: " - "locally modified notes which had its " - "tags list modified but not updated " - "in the local storage and the note found " - "in the local storage") - << QStringLiteral(": Note updated in the local storage ") - << QStringLiteral("(without tags lists): ") + "Detected unexpectedly equal notes: " + << "locally modified notes which had its " + << "tags list modified but not updated " + << "in the local storage and the note found " + << "in the local storage" + << ": Note updated in the local storage " + << "(without tags lists): " << modifiedNote - << QStringLiteral("\nNote found in the local storage: ") + << "\nNote found in the local storage: " << foundNote); modifiedNote.setTagGuids(tagGuidsBeforeUpdate); modifiedNote.setTagLocalUids(tagLocalUidsBeforeUpdate); VERIFY2(modifiedNote == foundNote, - QStringLiteral("Updated and found in the local storage " - "notes don't match") - << QStringLiteral(": Note updated in the local storage ") - << QStringLiteral("(without tags after which tags were ") - << QStringLiteral("manually restored): ") + "Updated and found in the local storage notes don't match" + << ": Note updated in the local storage " + << "(without tags after which tags were " + << "manually restored): " << modifiedNote - << QStringLiteral("\nNote found in the local storage: ") + << "\nNote found in the local storage: " << foundNote); /** @@ -1057,27 +1051,26 @@ * the modified note the two notes should become equal */ VERIFY2(modifiedNote != foundNote, - QStringLiteral("Detected unexpectedly equal notes: " - "locally modified notes which had its " - "resources list modified but not updated " - "in the local storage and the note found " - "in the local storage") - << QStringLiteral(": Note updated in the local storage ") - << QStringLiteral("(with resource removed): ") + "Detected unexpectedly equal notes: " + << "locally modified notes which had its " + << "resources list modified but not updated " + << "in the local storage and the note found " + << "in the local storage" + << ": Note updated in the local storage " + << "(with resource removed): " << modifiedNote - << QStringLiteral("\nNote found in the local storage: ") + << "\nNote found in the local storage: " << foundNote); modifiedNote.setResources(previousModifiedNoteResources); VERIFY2(modifiedNote == foundNote, - QStringLiteral("Updated and found in the local storage " - "notes don't match") - << QStringLiteral(": Note updated in the local storage ") - << QStringLiteral("(without resource metadata after which ") - << QStringLiteral("resources were manually restored): ") + "Updated and found in the local storage notes don't match" + << ": Note updated in the local storage " + << "(without resource metadata after which " + << "resources were manually restored): " << modifiedNote - << QStringLiteral("\nNote found in the local storage: ") + << "\nNote found in the local storage: " << foundNote); /** @@ -1116,27 +1109,26 @@ * the modified note the two notes should become equal */ VERIFY2(modifiedNote != foundNote, - QStringLiteral("Detected unexpectedly equal notes: " - "locally modified notes which had its " - "resources list modified but not updated " - "in the local storage and the note found " - "in the local storage") - << QStringLiteral(": Note updated in the local storage ") - << QStringLiteral("(with resource removed): ") + "Detected unexpectedly equal notes: " + << "locally modified notes which had its " + << "resources list modified but not updated " + << "in the local storage and the note found " + << "in the local storage" + << ": Note updated in the local storage " + << "(with resource removed): " << modifiedNote - << QStringLiteral("\nNote found in the local storage: ") + << "\nNote found in the local storage: " << foundNote); modifiedNote.setResources(previousModifiedNoteResources); VERIFY2(modifiedNote == foundNote, - QStringLiteral("Updated and found in the local storage " - "notes don't match") - << QStringLiteral(": Note updated in the local storage ") - << QStringLiteral("(without resource metadata after which ") - << QStringLiteral("resources were manually restored): ") + "Updated and found in the local storage notes don't match" + << ": Note updated in the local storage " + << "(without resource metadata after which " + << "resources were manually restored): " << modifiedNote - << QStringLiteral("\nNote found in the local storage: ") + << "\nNote found in the local storage: " << foundNote); // Check that resource binary data is not touched unless update resource @@ -1175,25 +1167,25 @@ * to the modified note the two notes should become equal */ VERIFY2(modifiedNote != foundNote, - QStringLiteral("Detected unexpectedly equal notes: " - "locally modified notes which had its " - "resource data body modified but not " - "updated in the local storage and " - "the note found in the local storage") - << QStringLiteral(": Note updated in the local storage (without ") - << QStringLiteral("resource data body): ") << modifiedNote - << QStringLiteral("\nNote found in the local storage: ") + "Detected unexpectedly equal notes: " + << "locally modified notes which had its " + << "resource data body modified but not " + << "updated in the local storage and " + << "the note found in the local storage" + << ": Note updated in the local storage (without " + << "resource data body): " << modifiedNote + << "\nNote found in the local storage: " << foundNote); modifiedNote.setResources(previousModifiedNoteResources); VERIFY2(modifiedNote == foundNote, - QStringLiteral("Updated and found in the local storage notes don't ") - << QStringLiteral("match: Note updated in the local storage ") - << QStringLiteral("(without resource binary data after which ") - << QStringLiteral("resources were manually restored): ") + "Updated and found in the local storage notes don't " + << "match: Note updated in the local storage " + << "(without resource binary data after which " + << "resources were manually restored): " << modifiedNote - << QStringLiteral("\nNote found in the local storage: ") + << "\nNote found in the local storage: " << foundNote); // Add one more note to test note counting methods @@ -1313,10 +1305,10 @@ qPrintable(errorMessage.nonLocalizedString())); VERIFY2(foundNote.hasActive() && !foundNote.active(), - QStringLiteral("Note which should have been marked " - "non-active is not marked so after " - "LocalStorageManager::FindNote") - << QStringLiteral(": Note found in the local storage: ") + "Note which should have been marked " + << "non-active is not marked so after " + << "LocalStorageManager::FindNote: " + << "Note found in the local storage: " << foundNote); // ========== noteCount to return 1 ============ @@ -1331,11 +1323,11 @@ qPrintable(errorMessage.nonLocalizedString())); VERIFY2(!localStorageManager.findNote(foundNote, getNoteOptions, errorMessage), - QStringLiteral("Error: found Note which should have " - "been expunged from the local storage") - << QStringLiteral(": Note expunged from the local storage: ") + "Error: found Note which should have " + << "been expunged from the local storage: " + << "Note expunged from the local storage: " << modifiedNote - << QStringLiteral("\nNote found in the local storage: ") + << "\nNote found in the local storage: " << foundNote); // ========== Try to find resource belonging to expunged note (failure expected) ========== @@ -1343,12 +1335,12 @@ foundResource.setGuid(newResource.guid()); VERIFY2(!localStorageManager.findEnResource(foundResource, getResourceOptions, errorMessage), - QStringLiteral("Error: found Resource which should " - "have been expunged from the local storage " - "along with Note owning it") - << QStringLiteral(": Note expunged from the local storage: ") + "Error: found Resource which should " + << "have been expunged from the local storage " + << "along with Note owning it: " + << "Note expunged from the local storage: " << modifiedNote - << QStringLiteral("\nResource found in the local storage: ") + << "\nResource found in the local storage: " << foundResource); } @@ -1500,11 +1492,10 @@ qPrintable(errorMessage.nonLocalizedString())); VERIFY2(notebook == foundNotebook, - QStringLiteral("Added and found notebooks in local " - "storage don't match") - << QStringLiteral(": Notebook added to LocalStorageManager: ") + "Added and found notebooks in local storage don't match: " + << "Notebook added to LocalStorageManager: " << notebook - << QStringLiteral("\nNotebook found in LocalStorageManager: ") + << "\nNotebook found in LocalStorageManager: " << foundNotebook); // ========== Check Find by name =========== @@ -1519,10 +1510,10 @@ qPrintable(errorMessage.nonLocalizedString())); VERIFY2(notebook == foundByNameNotebook, - QStringLiteral("Notebook found by name in local storage " - "doesn't match the original notebook") - << QStringLiteral(": Notebook found by name: ") - << foundByNameNotebook << QStringLiteral("\nOriginal notebook: ") + "Notebook found by name in local storage " + << "doesn't match the original notebook: " + << "Notebook found by name: " + << foundByNameNotebook << "\nOriginal notebook: " << notebook); if (notebook.hasLinkedNotebookGuid()) @@ -1538,11 +1529,11 @@ qPrintable(errorMessage.nonLocalizedString())); VERIFY2(notebook == foundByLinkedNotebookGuidNotebook, - QStringLiteral("Notebook found by linked notebook guid in " - "the local storage doesn't match the original " - "notebook: notebook found by linked notebook guid: ") + "Notebook found by linked notebook guid in " + "the local storage doesn't match the original " + "notebook: notebook found by linked notebook guid: " << foundByLinkedNotebookGuidNotebook - << QStringLiteral("\nOriginal notebook: ") << notebook); + << "\nOriginal notebook: " << notebook); } // ========== Check FindDefaultNotebook ========= @@ -1553,8 +1544,8 @@ // ========== Check FindLastUsedNotebook (failure expected) ========== Notebook lastUsedNotebook; VERIFY2(!localStorageManager.findLastUsedNotebook(lastUsedNotebook, errorMessage), - QStringLiteral("Found some last used notebook which shouldn't have " - "been found: ") << lastUsedNotebook); + "Found some last used notebook which shouldn't have been found: " + << lastUsedNotebook); // ========== Check FindDefaultOrLastUsedNotebook =========== Notebook defaultOrLastUsedNotebook; @@ -1563,17 +1554,17 @@ qPrintable(errorMessage.nonLocalizedString())); VERIFY2(defaultOrLastUsedNotebook == defaultNotebook, - QStringLiteral("Found defaultOrLastUsed notebook which " - "should be the same as default notebook " - "right now but it is not") - << QStringLiteral(". Default notebook: ") - << defaultNotebook << QStringLiteral(", defaultOrLastUsedNotebook: ") + "Found defaultOrLastUsed notebook which " + << "should be the same as default notebook " + << "right now but it is not. " + << "Default notebook: " + << defaultNotebook << ", defaultOrLastUsedNotebook: " << defaultOrLastUsedNotebook); // ========== Check Update + Find ========== Notebook modifiedNotebook(notebook); modifiedNotebook.setUpdateSequenceNumber(notebook.updateSequenceNumber() + 1); - modifiedNotebook.setLinkedNotebookGuid(QStringLiteral("")); + modifiedNotebook.setLinkedNotebookGuid(QLatin1String("")); modifiedNotebook.setName(notebook.name() + QStringLiteral("_modified")); modifiedNotebook.setDefaultNotebook(false); modifiedNotebook.setLastUsed(true); @@ -1606,17 +1597,17 @@ qPrintable(errorMessage.nonLocalizedString())); VERIFY2(modifiedNotebook == foundNotebook, - QStringLiteral("Updated and found notebooks in the local storage " - "don't match: notebook updated in the local storage: ") + "Updated and found notebooks in the local storage " + << "don't match: notebook updated in the local storage: " << modifiedNotebook - << QStringLiteral("\nNotebook found in the local storage: ") + << "\nNotebook found in the local storage: " << foundNotebook); // ========== Check FindDefaultNotebook (failure expected) ========= defaultNotebook = Notebook(); VERIFY2(!localStorageManager.findDefaultNotebook(defaultNotebook, errorMessage), - QStringLiteral("Found some default notebook which shouldn't have " - "been found: ") << defaultNotebook); + "Found some default notebook which shouldn't have been found: " + << defaultNotebook); // ========== Check FindLastUsedNotebook ========== lastUsedNotebook = Notebook(); @@ -1630,12 +1621,12 @@ qPrintable(errorMessage.nonLocalizedString())); VERIFY2(defaultOrLastUsedNotebook == lastUsedNotebook, - QStringLiteral("Found defaultOrLastUsed notebook which " - "should be the same as last used notebook " - "right now but it is not") - << QStringLiteral(". Last used notebook: ") + "Found defaultOrLastUsed notebook which " + << "should be the same as last used notebook " + << "right now but it is not. " + << "Last used notebook: " << lastUsedNotebook - << QStringLiteral(", defaultOrLastUsedNotebook: ") + << "\nDefaultOrLastUsedNotebook: " << defaultOrLastUsedNotebook); // ========== Check notebookCount to return 1 ============ @@ -1651,11 +1642,11 @@ qPrintable(errorMessage.nonLocalizedString())); VERIFY2(!localStorageManager.findNotebook(foundNotebook, errorMessage), - QStringLiteral("Error: found Notebook which should have " - "been expunged from the local storage") - << QStringLiteral(": Notebook expunged from the local storage: ") + "Error: found Notebook which should have " + << "been expunged from the local storage: " + << "Notebook expunged from the local storage: " << modifiedNotebook - << QStringLiteral("\nNotebook found in the local storage: ") + << "\nNotebook found in the local storage: " << foundNotebook); // ========== Check notebookCount to return 0 ============ @@ -1790,9 +1781,9 @@ qPrintable(errorMessage.nonLocalizedString())); VERIFY2(user == foundUser, - QStringLiteral("Added and found users in the local storage don't " - "match: user added to the local storage: ") - << user << QStringLiteral("\nIUser found in the local storage: ") + "Added and found users in the local storage don't " + << "match: user added to the local storage: " + << user << "\nIUser found in the local storage: " << foundUser); // ========== Check Update + Find ========== @@ -1848,11 +1839,10 @@ qPrintable(errorMessage.nonLocalizedString())); VERIFY2(modifiedUser == foundUser, - QStringLiteral("Updated and found users in the local " - "storage don't match") - << QStringLiteral(": User updated in the local storage: ") + "Updated and found users in the local storage don't match: " + << "User updated in the local storage: " << modifiedUser - << QStringLiteral("\nIUser found in the local storage: ") + << "\nIUser found in the local storage: " << foundUser); // ========== Check userCount to return 1 =========== @@ -1897,11 +1887,11 @@ foundUser.clear(); foundUser.setId(modifiedUser.id()); VERIFY2(!localStorageManager.findUser(foundUser, errorMessage), - QStringLiteral("Error: found User which should have " - "been expunged from the local storage") - << QStringLiteral(": User expunged from the local storage: ") + "Error: found User which should have " + "been expunged from the local storage: " + << "User expunged from the local storage: " << modifiedUser - << QStringLiteral("\nIUser found in the local storage: ") + << "\nIUser found in the local storage: " << foundUser); } @@ -1994,36 +1984,36 @@ qPrintable(errorMessage.nonLocalizedString())); VERIFY2(!foundUser.hasUserAttributes(), - QStringLiteral("Updated user found the in the local storage " - "still has user attributes while it " - "shouldn't have them after the update") - << QStringLiteral(": initial user: ") << user - << QStringLiteral("\nUpdated user: ") << updatedUser - << QStringLiteral("\nFound user: ") << foundUser); + "Updated user found the in the local storage " + << "still has user attributes while it " + << "shouldn't have them after the update" + << ": initial user: " << user + << "\nUpdated user: " << updatedUser + << "\nFound user: " << foundUser); VERIFY2(!foundUser.hasAccounting(), - QStringLiteral("Updated user found in the local storage " - "still has accounting while it shouldn't " - "have it after the update") - << QStringLiteral(": initial user: ") << user - << QStringLiteral("\nUpdated user: ") << updatedUser - << QStringLiteral("\nFound user: ") << foundUser); + "Updated user found in the local storage " + << "still has accounting while it shouldn't " + << "have it after the update" + << ": initial user: " << user + << "\nUpdated user: " << updatedUser + << "\nFound user: " << foundUser); VERIFY2(!foundUser.hasBusinessUserInfo(), - QStringLiteral("Updated user found in the local storage " - "still has business user info " - "while it shouldn't have it after the update") - << QStringLiteral(": initial user: ") << user - << QStringLiteral("\nUpdated user: ") << updatedUser - << QStringLiteral("\nFound user: ") << foundUser); + "Updated user found in the local storage " + << "still has business user info " + << "while it shouldn't have it after the update" + << ": initial user: " << user + << "\nUpdated user: " << updatedUser + << "\nFound user: " << foundUser); VERIFY2(!foundUser.hasAccountLimits(), - QStringLiteral("Updated user found in the local storage " - "still has account limits while it " - "shouldn't have them after the update") - << QStringLiteral(": initial user: ") << user - << QStringLiteral("\nUpdated user: ") << updatedUser - << QStringLiteral("\nFound user: ") << foundUser); + "Updated user found in the local storage " + << "still has account limits while it " + << "shouldn't have them after the update" + << ": initial user: " << user + << "\nUpdated user: " << updatedUser + << "\nFound user: " << foundUser); // ============ 6) Create Notebook with restrictions and shared notebooks ================== Notebook notebook; @@ -2122,20 +2112,20 @@ qPrintable(errorMessage.nonLocalizedString())); VERIFY2(!foundNotebook.hasSharedNotebooks(), - QStringLiteral("Updated notebook found in the local " - "storage has shared notebooks " - "while it shouldn't have them") - << QStringLiteral(", original notebook: ") << notebook - << QStringLiteral("\nUpdated notebook: ") << updatedNotebook - << QStringLiteral("\nFound notebook: ") << foundNotebook); + "Updated notebook found in the local " + << "storage has shared notebooks " + << "while it shouldn't have them" + << ", original notebook: " << notebook + << "\nUpdated notebook: " << updatedNotebook + << "\nFound notebook: " << foundNotebook); VERIFY2(!foundNotebook.hasRestrictions(), - QStringLiteral("Updated notebook found in the local " - "storage has restrictions " - "while it shouldn't have them") - << QStringLiteral(", original notebook: ") - << notebook << QStringLiteral("\nUpdated notebook: ") - << updatedNotebook << QStringLiteral("\nFound notebook: ") + "Updated notebook found in the local " + << "storage has restrictions " + << "while it shouldn't have them" + << ", original notebook: " + << notebook << "\nUpdated notebook: " + << updatedNotebook << "\nFound notebook: " << foundNotebook); // 9) ============== Create tag ================= @@ -2206,18 +2196,18 @@ qPrintable(errorMessage.nonLocalizedString())); VERIFY2(!foundNote.hasTagGuids(), - QStringLiteral("Updated note found in local storage " - "has tag guids while it shouldn't have them") - << QStringLiteral(", original note: ") << note - << QStringLiteral("\nUpdated note: ") << updatedNote - << QStringLiteral("\nFound note: ") << foundNote); + "Updated note found in local storage " + << "has tag guids while it shouldn't have them" + << ", original note: " << note + << "\nUpdated note: " << updatedNote + << "\nFound note: " << foundNote); VERIFY2(!foundNote.hasResources(), - QStringLiteral("Updated note found in local storage " - "has resources while it shouldn't have them") - << QStringLiteral(", original note: ") << note - << QStringLiteral("\nUpdated note: ") << updatedNote - << QStringLiteral("\nFound note: ") << foundNote); + "Updated note found in local storage " + << "has resources while it shouldn't have them" + << ", original note: " << note + << "\nUpdated note: " << updatedNote + << "\nFound note: " << foundNote); // 13) ==== Add resource attributes to the resource and add resource to note ===== auto & resourceAttributes = resource.resourceAttributes(); @@ -2245,9 +2235,9 @@ // 14) ===== Remove resource attributes from note's resource and update it again QList<Resource> resources = updatedNote.resources(); VERIFY2(!resources.empty(), - QStringLiteral("Note returned empty list of resources " - "while it should have contained at least " - "one entry, updated note: ") << updatedNote); + "Note returned empty list of resources " + << "while it should have contained at least " + << "one entry, updated note: " << updatedNote); Resource & updatedResource = resources[0]; qevercloud::ResourceAttributes & underlyngResourceAttributes = @@ -2266,15 +2256,15 @@ resources = foundNote.resources(); VERIFY2(!resources.empty(), - QStringLiteral("Note returned empty list of resources " - "while it should have contained " - "at least one entry, found note: ") << foundNote); + "Note returned empty list of resources " + << "while it should have contained " + << "at least one entry, found note: " << foundNote); Resource & foundResource = resources[0]; auto & foundResourceAttributes = foundResource.resourceAttributes(); VERIFY2(!foundResourceAttributes.applicationData.isSet(), - QStringLiteral("Resource from updated note has application " - "data while it shouldn't have it, found resource: ") + "Resource from updated note has application " + << "data while it shouldn't have it, found resource: " << foundResource); } @@ -2345,9 +2335,9 @@ qint32 accountHighUsn = localStorageManager.accountHighUsn(QString(), errorMessage); QVERIFY2(accountHighUsn >= 0, qPrintable(errorMessage.nonLocalizedString())); VERIFY2(accountHighUsn == thirdNotebook.updateSequenceNumber(), - QStringLiteral("Wrong value of account high USN, expected ") + "Wrong value of account high USN, expected " << QString::number(thirdNotebook.updateSequenceNumber()) - << QStringLiteral(", got ") + << ", got " << QString::number(accountHighUsn)); // 5) ========== Create some user's own tags with different USNs ========== @@ -2388,9 +2378,9 @@ QVERIFY2(accountHighUsn >= 0, qPrintable(errorMessage.nonLocalizedString())); VERIFY2(accountHighUsn == thirdTag.updateSequenceNumber(), - QStringLiteral("Wrong value of account high USN, expected ") + "Wrong value of account high USN, expected " << QString::number(thirdTag.updateSequenceNumber()) - << QStringLiteral(", got ") + << ", got " << QString::number(accountHighUsn)); // 7) ========== Create some user's own notes with different USNs ========== @@ -2427,9 +2417,9 @@ accountHighUsn = localStorageManager.accountHighUsn(QString(), errorMessage); QVERIFY2(accountHighUsn >= 0, qPrintable(errorMessage.nonLocalizedString())); VERIFY2(accountHighUsn == secondNote.updateSequenceNumber(), - QStringLiteral("Wrong value of account high USN, expected ") + "Wrong value of account high USN, expected " << QString::number(secondNote.updateSequenceNumber()) - << QStringLiteral(", got ") + << ", got " << QString::number(accountHighUsn)); // 9) ========== Create one more note, this time with a resource which USN @@ -2472,9 +2462,9 @@ accountHighUsn = localStorageManager.accountHighUsn(QString(), errorMessage); QVERIFY2(accountHighUsn >= 0, qPrintable(errorMessage.nonLocalizedString())); VERIFY2(accountHighUsn == thirdNoteResource.updateSequenceNumber(), - QStringLiteral("Wrong value of account high USN, expected ") + "Wrong value of account high USN, expected " << QString::number(thirdNoteResource.updateSequenceNumber()) - << QStringLiteral(", got ") + << ", got " << QString::number(accountHighUsn)); // 11) ==== Create some user's own saved sarches with different USNs ==== @@ -2516,9 +2506,9 @@ QVERIFY2(accountHighUsn >= 0, qPrintable(errorMessage.nonLocalizedString())); VERIFY2(accountHighUsn == thirdSearch.updateSequenceNumber(), - QStringLiteral("Wrong value of account high USN, expected ") + "Wrong value of account high USN, expected " << QString::number(thirdSearch.updateSequenceNumber()) - << QStringLiteral(", got ") + << ", got " << QString::number(accountHighUsn)); // 13) ========== Create a linked notebook ========== @@ -2542,9 +2532,9 @@ accountHighUsn = localStorageManager.accountHighUsn(QString(), errorMessage); QVERIFY2(accountHighUsn >= 0, qPrintable(errorMessage.nonLocalizedString())); VERIFY2(accountHighUsn == linkedNotebook.updateSequenceNumber(), - QStringLiteral("Wrong value of account high USN, expected ") + "Wrong value of account high USN, expected " << QString::number(linkedNotebook.updateSequenceNumber()) - << QStringLiteral(", got ") + << ", got " << QString::number(accountHighUsn)); // 15) ==== Add notebook and some tags and notes corresponding to the linked notebook ==== @@ -2644,9 +2634,9 @@ accountHighUsn = localStorageManager.accountHighUsn(QString(), errorMessage); QVERIFY2(accountHighUsn >= 0, qPrintable(errorMessage.nonLocalizedString())); VERIFY2(accountHighUsn == linkedNotebook.updateSequenceNumber(), - QStringLiteral("Wrong value of account high USN, expected ") + "Wrong value of account high USN, expected " << QString::number(linkedNotebook.updateSequenceNumber()) - << QStringLiteral(", got ") + << ", got " << QString::number(accountHighUsn)); // 17) ==== Verify the current value of the account high USN for the linked @@ -2657,9 +2647,9 @@ errorMessage); QVERIFY2(accountHighUsn >= 0, qPrintable(errorMessage.nonLocalizedString())); VERIFY2(accountHighUsn == secondNoteFromLinkedNotebookResource.updateSequenceNumber(), - QStringLiteral("Wrong value of account high USN, expected ") + "Wrong value of account high USN, expected " << QString::number(secondNoteFromLinkedNotebookResource.updateSequenceNumber()) - << QStringLiteral(", got ") + << ", got " << QString::number(accountHighUsn)); } diff -Nru libquentier-0.5.0/src/tests/local_storage/LocalStorageManagerListTests.cpp libquentier-0.5.0/src/tests/local_storage/LocalStorageManagerListTests.cpp --- libquentier-0.5.0/src/tests/local_storage/LocalStorageManagerListTests.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/tests/local_storage/LocalStorageManagerListTests.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -115,55 +115,56 @@ } } -#define CHECK_LIST_SAVED_SEARCHES_BY_FLAG(flag, flag_name, true_condition, false_condition) \ - errorMessage.clear(); \ +#define CHECK_LIST_SAVED_SEARCHES(flag, name, true_cond, false_cond) \ + errorMessage.clear(); \ foundSearches = localStorageManager.listSavedSearches(flag, errorMessage); \ - QVERIFY2(errorMessage.isEmpty(), qPrintable(errorMessage.nonLocalizedString())); \ - \ - for(int i = 0; i < nSearches; ++i) \ - { \ - const SavedSearch & search = searches.at(i); \ - bool res = foundSearches.contains(search); \ - if ((true_condition) && !res) { \ - QNWARNING(QStringLiteral("Not found saved search: ") << search); \ - QFAIL("One of " flag_name " SavedSearches was not found by " \ - "LocalStorageManager::ListSavedSearches"); \ - } \ - else if ((false_condition) && res) { \ - QNWARNING(QStringLiteral("Found irrelevant saved search: ") << search); \ - QFAIL("LocalStorageManager::ListSavedSearches with flag " flag_name \ - " returned incorrect saved search"); \ - } \ - } + QVERIFY2(errorMessage.isEmpty(), \ + qPrintable(errorMessage.nonLocalizedString())); \ + for(int i = 0; i < nSearches; ++i) \ + { \ + const SavedSearch & search = searches.at(i); \ + bool res = foundSearches.contains(search); \ + if ((true_cond) && !res) { \ + QNWARNING("Not found saved search: " << search); \ + QFAIL("One of " name " SavedSearches was not found by " \ + "LocalStorageManager::ListSavedSearches"); \ + } \ + else if ((false_cond) && res) { \ + QNWARNING("Found irrelevant saved search: " << search); \ + QFAIL("LocalStorageManager::ListSavedSearches with flag " name \ + " returned incorrect saved search"); \ + } \ + } \ +// CHECK_LIST_SAVED_SEARCHES // 2) Test method listing only dirty saved searches - CHECK_LIST_SAVED_SEARCHES_BY_FLAG(LocalStorageManager::ListDirty, "dirty", - i > 2, i <= 2); + CHECK_LIST_SAVED_SEARCHES(LocalStorageManager::ListDirty, "dirty", + i > 2, i <= 2); // 3) Test method listing only local saved searches - CHECK_LIST_SAVED_SEARCHES_BY_FLAG(LocalStorageManager::ListLocal, "local", - i < 3, i >= 3); + CHECK_LIST_SAVED_SEARCHES(LocalStorageManager::ListLocal, "local", + i < 3, i >= 3); // 4) Test method listing only saved searches without guid - CHECK_LIST_SAVED_SEARCHES_BY_FLAG(LocalStorageManager::ListElementsWithoutGuid, - "guidless", i <= 1, i > 1); + CHECK_LIST_SAVED_SEARCHES(LocalStorageManager::ListElementsWithoutGuid, + "guidless", i <= 1, i > 1); // 5) Test method listing only favorited saved searches - CHECK_LIST_SAVED_SEARCHES_BY_FLAG(LocalStorageManager::ListFavoritedElements, - "favorited", (i == 0) || (i == 4), - (i != 0) && (i != 4)); + CHECK_LIST_SAVED_SEARCHES(LocalStorageManager::ListFavoritedElements, + "favorited", (i == 0) || (i == 4), + (i != 0) && (i != 4)); // 6) Test method listing dirty favorited saved searches with guid - CHECK_LIST_SAVED_SEARCHES_BY_FLAG(LocalStorageManager::ListDirty | - LocalStorageManager::ListElementsWithGuid | - LocalStorageManager::ListFavoritedElements, - "dirty, favorited, having guid", - i == 4, i != 4); + CHECK_LIST_SAVED_SEARCHES(LocalStorageManager::ListDirty | + LocalStorageManager::ListElementsWithGuid | + LocalStorageManager::ListFavoritedElements, + "dirty, favorited, having guid", + i == 4, i != 4); // 7) Test method listing local favorited saved searches - CHECK_LIST_SAVED_SEARCHES_BY_FLAG(LocalStorageManager::ListLocal | - LocalStorageManager::ListFavoritedElements, - "local, favorited", i == 0, i != 0); + CHECK_LIST_SAVED_SEARCHES(LocalStorageManager::ListLocal | + LocalStorageManager::ListFavoritedElements, + "local, favorited", i == 0, i != 0); // 8) Test method listing saved searches with guid set also specifying // limit, offset and order @@ -309,13 +310,13 @@ const LinkedNotebook & linkedNotebook = linkedNotebooks.at(i); bool res = foundLinkedNotebooks.contains(linkedNotebook); if ((i > 2) && !res) { - QNWARNING(QStringLiteral("Not found linked notebook: ") + QNWARNING("Not found linked notebook: " << linkedNotebook); QFAIL("One of dirty linked notebooks was not found by " "LocalStorageManager::ListLinkedNotebooks"); } else if ((i <= 2) && res) { - QNWARNING(QStringLiteral("Found irrelevant linked notebook: ") + QNWARNING("Found irrelevant linked notebook: " << linkedNotebook); QFAIL("LocalStorageManager::ListLinkedNotebooks with flag " "ListDirty returned incorrect linked notebook"); @@ -402,54 +403,55 @@ } } -#define CHECK_LIST_TAGS_BY_FLAG(flag, flag_name, true_condition, false_condition) \ - errorMessage.clear(); \ - foundTags = localStorageManager.listTags(flag, errorMessage); \ - QVERIFY2(errorMessage.isEmpty(), qPrintable(errorMessage.nonLocalizedString())); \ - \ - for(int i = 0; i < nTags; ++i) \ - { \ - const Tag & tag = tags.at(i); \ - bool res = foundTags.contains(tag); \ - if ((true_condition) && !res) { \ - QNWARNING(QStringLiteral("Not found tag: ") << tag); \ - QFAIL("One of " flag_name " Tags was not found by " \ - "LocalStorageManager::ListTags"); \ - } \ - else if ((false_condition) && res) { \ - QNWARNING(QStringLiteral("Found irrelevant tag: ") << tag); \ - QFAIL("LocalStorageManager::ListTags with flag " flag_name \ - " returned incorrect tag"); \ - } \ - } +#define CHECK_LIST_TAGS(flag, name, true_cond, false_cond) \ + errorMessage.clear(); \ + foundTags = localStorageManager.listTags(flag, errorMessage); \ + QVERIFY2(errorMessage.isEmpty(), \ + qPrintable(errorMessage.nonLocalizedString())); \ + for(int i = 0; i < nTags; ++i) \ + { \ + const Tag & tag = tags.at(i); \ + bool res = foundTags.contains(tag); \ + if ((true_cond) && !res) { \ + QNWARNING("Not found tag: " << tag); \ + QFAIL("One of " name " Tags was not found by " \ + "LocalStorageManager::ListTags"); \ + } \ + else if ((false_cond) && res) { \ + QNWARNING("Found irrelevant tag: " << tag); \ + QFAIL("LocalStorageManager::ListTags with flag " name \ + " returned incorrect tag"); \ + } \ + } \ +// CHECK_LIST_TAGS // 2) Test method listing only dirty tags - CHECK_LIST_TAGS_BY_FLAG(LocalStorageManager::ListDirty, "dirty", i > 2, i <= 2); + CHECK_LIST_TAGS(LocalStorageManager::ListDirty, "dirty", i > 2, i <= 2); // 3) Test method listing only local tags - CHECK_LIST_TAGS_BY_FLAG(LocalStorageManager::ListLocal, "local", i < 3, i >= 3); + CHECK_LIST_TAGS(LocalStorageManager::ListLocal, "local", i < 3, i >= 3); // 4) Test method listing only tags without guid - CHECK_LIST_TAGS_BY_FLAG(LocalStorageManager::ListElementsWithoutGuid, - "guidless", i <= 1, i > 1); + CHECK_LIST_TAGS(LocalStorageManager::ListElementsWithoutGuid, + "guidless", i <= 1, i > 1); // 5) Test method listing only favorited tags - CHECK_LIST_TAGS_BY_FLAG(LocalStorageManager::ListFavoritedElements, - "favorited", (i == 0) || (i == 4), - (i != 0) && (i != 4)); + CHECK_LIST_TAGS(LocalStorageManager::ListFavoritedElements, + "favorited", (i == 0) || (i == 4), + (i != 0) && (i != 4)); // 6) Test method listing dirty favorited tags with guid - CHECK_LIST_TAGS_BY_FLAG(LocalStorageManager::ListDirty | - LocalStorageManager::ListElementsWithGuid | - LocalStorageManager::ListFavoritedElements, - "dirty, favorited, having guid", i == 4, i != 4); + CHECK_LIST_TAGS(LocalStorageManager::ListDirty | + LocalStorageManager::ListElementsWithGuid | + LocalStorageManager::ListFavoritedElements, + "dirty, favorited, having guid", i == 4, i != 4); // 7) Test method listing local favorited tags - CHECK_LIST_TAGS_BY_FLAG(LocalStorageManager::ListLocal | - LocalStorageManager::ListFavoritedElements, - "local, favorited", i == 0, i != 0); + CHECK_LIST_TAGS(LocalStorageManager::ListLocal | + LocalStorageManager::ListFavoritedElements, + "local, favorited", i == 0, i != 0); -#undef CHECK_LIST_TAGS_BY_FLAG +#undef CHECK_LIST_TAGS } void TestListTagsWithNoteLocalUids() @@ -554,9 +556,10 @@ note.setFavorited(false); } -#define APPEND_TAG_TO_NOTE(tagNum) \ - note.addTagLocalUid(tags[tagNum].localUid()); \ - noteLocalUidsByTagLocalUid[tags[tagNum].localUid()] << note.localUid() +#define APPEND_TAG_TO_NOTE(tagNum) \ + note.addTagLocalUid(tags[tagNum].localUid()); \ + noteLocalUidsByTagLocalUid[tags[tagNum].localUid()] << note.localUid() \ +// APPEND_TAG_TO_NOTE if (i == 0) { APPEND_TAG_TO_NOTE(1); @@ -589,108 +592,122 @@ QList<std::pair<Tag, QStringList> > foundTagsWithNoteLocalUids; -#define CHECK_LIST_TAGS_BY_FLAG(flag, flag_name, true_condition, false_condition) \ - errorMessage.clear(); \ - foundTagsWithNoteLocalUids = \ - localStorageManager.listTagsWithNoteLocalUids(flag, errorMessage); \ - QVERIFY2(errorMessage.isEmpty(), qPrintable(errorMessage.nonLocalizedString())); \ - \ - for(int i = 0; i < nTags; ++i) \ - { \ - const Tag & tag = tags.at(i); \ - int tagIndex = 0; \ - bool res = false; \ - for(int size = foundTagsWithNoteLocalUids.size(); tagIndex < size; ++tagIndex) { \ - if (foundTagsWithNoteLocalUids[tagIndex].first == tag) { \ - res = true; \ - break; \ - } \ - } \ - if ((true_condition) && !res) { \ - QNWARNING(QStringLiteral("Not found tag: ") << tag); \ - QFAIL("One of " flag_name " Tags was not found by "\ - "LocalStorageManager::ListTags"); \ - } \ - else if ((false_condition) && res) { \ - QNWARNING(QStringLiteral("Found irrelevant tag: ") << tag); \ - QFAIL("LocalStorageManager::ListTags with flag " flag_name \ - " returned incorrect tag"); \ - } \ - else if (res) { \ - auto noteIt = noteLocalUidsByTagLocalUid.find(tag.localUid()); \ - if (noteIt == noteLocalUidsByTagLocalUid.end() && \ - !foundTagsWithNoteLocalUids[tagIndex].second.isEmpty()) \ - { \ - QNWARNING(QStringLiteral("Found irrelevant list of note local "\ - "uids for a tag: ") \ - << foundTagsWithNoteLocalUids[tagIndex].second.join(QStringLiteral(", "))); \ - QFAIL("LocalStorageManager::ListTags with flag " flag_name \ - " returned redundant note local uids"); \ - } \ - else if (noteIt != noteLocalUidsByTagLocalUid.end()) \ - { \ - if (foundTagsWithNoteLocalUids[tagIndex].second.isEmpty()) \ - { \ - QNWARNING(QStringLiteral("Found empty list of note local "\ - "uids for a tag for which they "\ - "were expected: ") \ - << noteIt.value().join(QStringLiteral(", "))); \ - QFAIL("LocalStorageManager::ListTags with flag " flag_name \ - " did not return proper note local uids"); \ - } \ +#define CHECK_LIST_TAGS(flag, name, true_cond, false_cond) \ + errorMessage.clear(); \ + foundTagsWithNoteLocalUids = \ + localStorageManager.listTagsWithNoteLocalUids(flag, errorMessage); \ + QVERIFY2(errorMessage.isEmpty(), \ + qPrintable(errorMessage.nonLocalizedString())); \ + for(int i = 0; i < nTags; ++i) \ + { \ + const Tag & tag = tags.at(i); \ + int tagIndex = 0; \ + bool res = false; \ + for(int size = foundTagsWithNoteLocalUids.size(); \ + tagIndex < size; ++tagIndex) \ + { \ + if (foundTagsWithNoteLocalUids[tagIndex].first == tag) { \ + res = true; \ + break; \ + } \ + } \ + if ((true_cond) && !res) { \ + QNWARNING("Not found tag: " << tag); \ + QFAIL("One of " name " Tags was not found by " \ + "LocalStorageManager::ListTags"); \ + } \ + else if ((false_cond) && res) { \ + QNWARNING("Found irrelevant tag: " << tag); \ + QFAIL("LocalStorageManager::ListTags with flag " name \ + " returned incorrect tag"); \ + } \ + else if (res) { \ + auto noteIt = noteLocalUidsByTagLocalUid.find(tag.localUid()); \ + if (noteIt == noteLocalUidsByTagLocalUid.end() && \ + !foundTagsWithNoteLocalUids[tagIndex].second.isEmpty()) \ + { \ + QNWARNING("Found irrelevant list of note local " \ + "uids for a tag: " \ + << foundTagsWithNoteLocalUids[tagIndex].second \ + .join(QStringLiteral(", "))); \ + QFAIL("LocalStorageManager::ListTags with flag " name \ + " returned redundant note local uids"); \ + } \ + else if (noteIt != noteLocalUidsByTagLocalUid.end()) \ + { \ + if (foundTagsWithNoteLocalUids[tagIndex].second.isEmpty()) \ + { \ + QNWARNING("Found empty list of note local " \ + "uids for a tag for which they " \ + "were expected: " \ + << noteIt.value().join(QStringLiteral(", "))); \ + QFAIL("LocalStorageManager::ListTags with flag " name \ + " did not return proper note local uids"); \ + } \ else if (foundTagsWithNoteLocalUids[tagIndex].second.size() != \ - noteIt.value().size()) \ - { \ - QNWARNING(QStringLiteral("Found list of note local uids " \ - "for a tag with incorrect list size: ") \ - << foundTagsWithNoteLocalUids[tagIndex].second.join(QStringLiteral(", "))); \ - QFAIL("LocalStorageManager::ListTags with flag " flag_name \ + noteIt.value().size()) \ + { \ + QNWARNING("Found list of note local uids " \ + "for a tag with incorrect list size: " \ + << foundTagsWithNoteLocalUids[tagIndex].second \ + .join(QStringLiteral(", "))); \ + QFAIL("LocalStorageManager::ListTags with flag " name \ " did not return proper number of note local uids"); \ - } \ - else \ - { \ - for(int j = 0; j < foundTagsWithNoteLocalUids[tagIndex].second.size(); ++j) { \ - if (!noteIt.value().contains(foundTagsWithNoteLocalUids[tagIndex].second[j])) { \ - QNWARNING(QStringLiteral("Found incorrect list of " \ - "note local uids for a tag: ") \ - << foundTagsWithNoteLocalUids[tagIndex].second.join(QStringLiteral(", "))); \ - QFAIL("LocalStorageManager::ListTags with flag " flag_name \ - " did not return correct set of note local uids"); \ - } \ - } \ - } \ - } \ - } \ - } + } \ + else \ + { \ + for(int j = 0; \ + j < foundTagsWithNoteLocalUids[tagIndex].second.size();\ + ++j) \ + { \ + if (!noteIt.value().contains( \ + foundTagsWithNoteLocalUids[tagIndex] \ + .second[j])) \ + { \ + QNWARNING("Found incorrect list of " \ + "note local uids for a tag: " \ + << foundTagsWithNoteLocalUids[tagIndex] \ + .second.join(QStringLiteral(", "))); \ + QFAIL("LocalStorageManager::ListTags with flag " \ + name \ + " did not return correct set of note local " \ + "uids"); \ + } \ + } \ + } \ + } \ + } \ + } \ +// CHECK_LIST_TAGS // 1) Test method listing all tags with note local uids - CHECK_LIST_TAGS_BY_FLAG(LocalStorageManager::ListAll, "all", true, false); + CHECK_LIST_TAGS(LocalStorageManager::ListAll, "all", true, false); // 2) Test method listing only dirty tags - CHECK_LIST_TAGS_BY_FLAG(LocalStorageManager::ListDirty, "dirty", i > 2, i <= 2); + CHECK_LIST_TAGS(LocalStorageManager::ListDirty, "dirty", i > 2, i <= 2); // 3) Test method listing only local tags - CHECK_LIST_TAGS_BY_FLAG(LocalStorageManager::ListLocal, "local", i < 3, i >= 3); + CHECK_LIST_TAGS(LocalStorageManager::ListLocal, "local", i < 3, i >= 3); // 4) Test method listing only tags without guid - CHECK_LIST_TAGS_BY_FLAG(LocalStorageManager::ListElementsWithoutGuid, - "guidless", i <= 1, i > 1); + CHECK_LIST_TAGS(LocalStorageManager::ListElementsWithoutGuid, + "guidless", i <= 1, i > 1); // 5) Test method listing only favorited tags - CHECK_LIST_TAGS_BY_FLAG(LocalStorageManager::ListFavoritedElements, - "favorited", (i == 0) || (i == 4), (i != 0) && (i != 4)); + CHECK_LIST_TAGS(LocalStorageManager::ListFavoritedElements, + "favorited", (i == 0) || (i == 4), (i != 0) && (i != 4)); // 6) Test method listing dirty favorited tags with guid - CHECK_LIST_TAGS_BY_FLAG(LocalStorageManager::ListDirty | - LocalStorageManager::ListElementsWithGuid | - LocalStorageManager::ListFavoritedElements, - "dirty, favorited, having guid", i == 4, i != 4); + CHECK_LIST_TAGS(LocalStorageManager::ListDirty | + LocalStorageManager::ListElementsWithGuid | + LocalStorageManager::ListFavoritedElements, + "dirty, favorited, having guid", i == 4, i != 4); // 7) Test method listing local favorited tags - CHECK_LIST_TAGS_BY_FLAG(LocalStorageManager::ListLocal | - LocalStorageManager::ListFavoritedElements, - "local, favorited", i == 0, i != 0); -#undef CHECK_LIST_TAGS_BY_FLAG + CHECK_LIST_TAGS(LocalStorageManager::ListLocal | + LocalStorageManager::ListFavoritedElements, + "local, favorited", i == 0, i != 0); +#undef CHECK_LIST_TAGS } void TestListAllSharedNotebooks() @@ -1192,52 +1209,54 @@ } } -#define CHECK_LIST_NOTES_BY_FLAG(flag, flag_name, true_condition, false_condition) \ - errorMessage.clear(); \ - foundNotes = localStorageManager.listNotes(flag, getNoteOptions, errorMessage); \ - QVERIFY2(errorMessage.isEmpty(), qPrintable(errorMessage.nonLocalizedString())); \ - \ - for(int i = 0; i < numNotes; ++i) \ - { \ - const Note & note = notes[i]; \ - bool res = foundNotes.contains(note); \ - if ((true_condition) && !res) { \ - QNWARNING(QStringLiteral("Not found note: ") << note); \ - QFAIL("One of " flag_name " notes was not found by "\ - "LocalStorageManager::ListNotes"); \ - } \ - else if ((false_condition) && res) { \ - QNWARNING(QStringLiteral("Found irrelevant note: ") << note); \ - QFAIL("LocalStorageManager::ListNotes with flag " flag_name \ - " returned incorrect note"); \ - } \ - } +#define CHECK_LIST_NOTES(flag, name, true_cond, false_cond) \ + errorMessage.clear(); \ + foundNotes = \ + localStorageManager.listNotes(flag, getNoteOptions, errorMessage); \ + QVERIFY2(errorMessage.isEmpty(), \ + qPrintable(errorMessage.nonLocalizedString())); \ + for(int i = 0; i < numNotes; ++i) \ + { \ + const Note & note = notes[i]; \ + bool res = foundNotes.contains(note); \ + if ((true_cond) && !res) { \ + QNWARNING("Not found note: " << note); \ + QFAIL("One of " name " notes was not found by " \ + "LocalStorageManager::ListNotes"); \ + } \ + else if ((false_cond) && res) { \ + QNWARNING("Found irrelevant note: " << note); \ + QFAIL("LocalStorageManager::ListNotes with flag " name \ + " returned incorrect note"); \ + } \ + } \ +// CHECK_LIST_NOTES // 6) Test method listing only dirty notes - CHECK_LIST_NOTES_BY_FLAG(LocalStorageManager::ListDirty, "dirty", i > 2, i <= 2); + CHECK_LIST_NOTES(LocalStorageManager::ListDirty, "dirty", i > 2, i <= 2); // 7) Test method listing only local notes - CHECK_LIST_NOTES_BY_FLAG(LocalStorageManager::ListLocal, "local", i < 3, i >= 3); + CHECK_LIST_NOTES(LocalStorageManager::ListLocal, "local", i < 3, i >= 3); // 8) Test method listing only notes without guid - CHECK_LIST_NOTES_BY_FLAG(LocalStorageManager::ListElementsWithoutGuid, - "guidless", i <= 1, i > 1); + CHECK_LIST_NOTES(LocalStorageManager::ListElementsWithoutGuid, + "guidless", i <= 1, i > 1); // 9) Test method listing only favorited notes - CHECK_LIST_NOTES_BY_FLAG(LocalStorageManager::ListFavoritedElements, - "favorited", (i == 0) || (i == 4), - (i != 0) && (i != 4)); + CHECK_LIST_NOTES(LocalStorageManager::ListFavoritedElements, + "favorited", (i == 0) || (i == 4), + (i != 0) && (i != 4)); // 10) Test method listing dirty favorited notes with guid - CHECK_LIST_NOTES_BY_FLAG(LocalStorageManager::ListDirty | - LocalStorageManager::ListElementsWithGuid | - LocalStorageManager::ListFavoritedElements, - "dirty, favorited, having guid", i == 4, i != 4); + CHECK_LIST_NOTES(LocalStorageManager::ListDirty | + LocalStorageManager::ListElementsWithGuid | + LocalStorageManager::ListFavoritedElements, + "dirty, favorited, having guid", i == 4, i != 4); // 11) Test method listing local favorited notes - CHECK_LIST_NOTES_BY_FLAG(LocalStorageManager::ListLocal | - LocalStorageManager::ListFavoritedElements, - "local, favorited", i == 0, i != 0); + CHECK_LIST_NOTES(LocalStorageManager::ListLocal | + LocalStorageManager::ListFavoritedElements, + "local, favorited", i == 0, i != 0); // 12) Test method listing notes per notebook and tag local uids // using notebook local uids only as a filter @@ -1352,7 +1371,9 @@ "method listing notes by local uids: " "expected %1 notes, got %2") .arg(noteLocalUids.size(), foundNotes.size()))); - for(auto it = foundNotes.constBegin(), end = foundNotes.constEnd(); it != end; ++it) { + for(auto it = foundNotes.constBegin(), + end = foundNotes.constEnd(); it != end; ++it) + { QVERIFY2(noteLocalUids.contains(it->localUid()), "Detected note returned by method listing notes by local uids " "which local uid is not present within the original list of " @@ -1375,7 +1396,9 @@ "method listing notes by local uids: " "expected %1 notes, got %2") .arg(originalNoteLocalUidsSize, foundNotes.size()))); - for(auto it = foundNotes.constBegin(), end = foundNotes.constEnd(); it != end; ++it) { + for(auto it = foundNotes.constBegin(), + end = foundNotes.constEnd(); it != end; ++it) + { QVERIFY2(noteLocalUids.contains(it->localUid()), "Detected note returned by method listing notes by local uids " "which local uid is not present within the original list of " @@ -1518,52 +1541,53 @@ } } -#define CHECK_LIST_NOTEBOOKS_BY_FLAG(flag, flag_name, true_condition, false_condition) \ - errorMessage.clear(); \ - foundNotebooks = localStorageManager.listNotebooks(flag, errorMessage); \ - QVERIFY2(errorMessage.isEmpty(), qPrintable(errorMessage.nonLocalizedString())); \ - \ - for(int i = 0; i < numNotebooks; ++i) \ - { \ - const Notebook & notebook = notebooks.at(i); \ - bool res = foundNotebooks.contains(notebook); \ - if ((true_condition) && !res) { \ - QNWARNING(QStringLiteral("Not found notebook: ") << notebook); \ - QFAIL("One of " flag_name " notebooks was not found by "\ - "LocalStorageManager::ListNotebooks"); \ - } \ - else if ((false_condition) && res) { \ - QNWARNING(QStringLiteral("Found irrelevant notebook: ") << notebook); \ - QFAIL("LocalStorageManager::ListNotebooks with flag " flag_name \ - " returned incorrect notebook"); \ - } \ - } +#define CHECK_LIST_NOTEBOOKS(flag, name, true_cond, false_cond) \ + errorMessage.clear(); \ + foundNotebooks = localStorageManager.listNotebooks(flag, errorMessage); \ + QVERIFY2(errorMessage.isEmpty(), \ + qPrintable(errorMessage.nonLocalizedString())); \ + for(int i = 0; i < numNotebooks; ++i) \ + { \ + const Notebook & notebook = notebooks.at(i); \ + bool res = foundNotebooks.contains(notebook); \ + if ((true_cond) && !res) { \ + QNWARNING("Not found notebook: " << notebook); \ + QFAIL("One of " name " notebooks was not found by " \ + "LocalStorageManager::ListNotebooks"); \ + } \ + else if ((false_cond) && res) { \ + QNWARNING("Found irrelevant notebook: " << notebook); \ + QFAIL("LocalStorageManager::ListNotebooks with flag " name \ + " returned incorrect notebook"); \ + } \ + } \ +// CHECK_LIST_NOTEBOOKS // 2) Test method listing only dirty notebooks - CHECK_LIST_NOTEBOOKS_BY_FLAG(LocalStorageManager::ListDirty, "dirty", i > 2, i <= 2); + CHECK_LIST_NOTEBOOKS(LocalStorageManager::ListDirty, "dirty", i > 2, i <= 2); // 3) Test method listing only local notebooks - CHECK_LIST_NOTEBOOKS_BY_FLAG(LocalStorageManager::ListLocal, "local", i < 3, i >= 3); + CHECK_LIST_NOTEBOOKS(LocalStorageManager::ListLocal, "local", i < 3, i >= 3); // 4) Test method listing only notebooks without guid - CHECK_LIST_NOTEBOOKS_BY_FLAG(LocalStorageManager::ListElementsWithoutGuid, - "guidless", i <= 1, i > 1); + CHECK_LIST_NOTEBOOKS(LocalStorageManager::ListElementsWithoutGuid, + "guidless", i <= 1, i > 1); // 5) Test method listing only favorited notebooks - CHECK_LIST_NOTEBOOKS_BY_FLAG(LocalStorageManager::ListFavoritedElements, - "favorited", (i == 0) || (i == 4), - (i != 0) && (i != 4)); + CHECK_LIST_NOTEBOOKS(LocalStorageManager::ListFavoritedElements, + "favorited", (i == 0) || (i == 4), + (i != 0) && (i != 4)); // 6) Test method listing dirty favorited notebooks with guid - CHECK_LIST_NOTEBOOKS_BY_FLAG(LocalStorageManager::ListDirty | - LocalStorageManager::ListElementsWithGuid | - LocalStorageManager::ListFavoritedElements, - "dirty, favorited, having guid", i == 4, i != 4); + CHECK_LIST_NOTEBOOKS(LocalStorageManager::ListDirty | + LocalStorageManager::ListElementsWithGuid | + LocalStorageManager::ListFavoritedElements, + "dirty, favorited, having guid", i == 4, i != 4); // 7) Test method listing local favorited notebooks - CHECK_LIST_NOTEBOOKS_BY_FLAG(LocalStorageManager::ListLocal | - LocalStorageManager::ListFavoritedElements, - "local, favorited", i == 0, i != 0); + CHECK_LIST_NOTEBOOKS(LocalStorageManager::ListLocal | + LocalStorageManager::ListFavoritedElements, + "local, favorited", i == 0, i != 0); } void TestExpungeNotelessTagsFromLinkedNotebooks() diff -Nru libquentier-0.5.0/src/tests/local_storage/NotebookLocalStorageManagerAsyncTester.cpp libquentier-0.5.0/src/tests/local_storage/NotebookLocalStorageManagerAsyncTester.cpp --- libquentier-0.5.0/src/tests/local_storage/NotebookLocalStorageManagerAsyncTester.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/tests/local_storage/NotebookLocalStorageManagerAsyncTester.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -24,7 +24,8 @@ namespace quentier { namespace test { -NotebookLocalStorageManagerAsyncTester::NotebookLocalStorageManagerAsyncTester(QObject *parent) : +NotebookLocalStorageManagerAsyncTester::NotebookLocalStorageManagerAsyncTester( + QObject *parent) : QObject(parent), m_state(STATE_UNINITIALIZED), m_pLocalStorageManagerAsync(Q_NULLPTR), @@ -69,7 +70,8 @@ void NotebookLocalStorageManagerAsyncTester::initialize() { m_initialNotebook.clear(); - m_initialNotebook.setGuid(QStringLiteral("00000000-0000-0000-c000-000000000047")); + m_initialNotebook.setGuid( + QStringLiteral("00000000-0000-0000-c000-000000000047")); m_initialNotebook.setUpdateSequenceNumber(1); m_initialNotebook.setName(QStringLiteral("Fake notebook name")); m_initialNotebook.setCreationTimestamp(1); @@ -105,8 +107,8 @@ ErrorString errorDescription; if (!m_initialNotebook.checkParameters(errorDescription)) { - QNWARNING(QStringLiteral("Found invalid notebook: ") << m_initialNotebook - << QStringLiteral(", error: ") << errorDescription); + QNWARNING("Found invalid notebook: " << m_initialNotebook + << ", error: " << errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } @@ -122,20 +124,21 @@ ErrorString errorDescription; -#define HANDLE_WRONG_STATE() \ - else { \ - errorDescription.setBase("Internal error in "\ - "NotebookLocalStorageManagerAsyncTester: "\ - "found wrong state"); \ - QNWARNING(errorDescription << QStringLiteral(": ") << m_state); \ - Q_EMIT failure(errorDescription.nonLocalizedString()); \ - } +#define HANDLE_WRONG_STATE() \ + else { \ + errorDescription.setBase("Internal error in " \ + "NotebookLocalStorageManagerAsyncTester: " \ + "found wrong state"); \ + QNWARNING(errorDescription << ": " << m_state); \ + Q_EMIT failure(errorDescription.nonLocalizedString()); \ + } \ +// HANDLE_WRONG_STATE if (m_state == STATE_SENT_GET_COUNT_AFTER_UPDATE_REQUEST) { if (count != 1) { - errorDescription.setBase("GetNotebookCount returned result different " - "from the expected one (1)"); + errorDescription.setBase("GetNotebookCount returned result " + "different from the expected one (1)"); errorDescription.details() = QString::number(count); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); @@ -157,14 +160,16 @@ } Notebook extraNotebook; - extraNotebook.setGuid(QStringLiteral("00000000-0000-0000-c000-000000000001")); + extraNotebook.setGuid( + QStringLiteral("00000000-0000-0000-c000-000000000001")); extraNotebook.setUpdateSequenceNumber(1); extraNotebook.setName(QStringLiteral("Fake extra notebook one")); extraNotebook.setCreationTimestamp(1); extraNotebook.setModificationTimestamp(1); extraNotebook.setDefaultNotebook(true); extraNotebook.setLastUsed(false); - extraNotebook.setPublishingUri(QStringLiteral("Fake publishing uri one")); + extraNotebook.setPublishingUri( + QStringLiteral("Fake publishing uri one")); extraNotebook.setPublishingOrder(1); extraNotebook.setPublishingAscending(true); extraNotebook.setPublishingPublicDescription( @@ -179,11 +184,14 @@ sharedNotebookOne.setId(1); sharedNotebookOne.setUserId(4); sharedNotebookOne.setNotebookGuid(extraNotebook.guid()); - sharedNotebookOne.setEmail(QStringLiteral("Fake shared notebook email one")); + sharedNotebookOne.setEmail( + QStringLiteral("Fake shared notebook email one")); sharedNotebookOne.setCreationTimestamp(1); sharedNotebookOne.setModificationTimestamp(1); - sharedNotebookOne.setGlobalId(QStringLiteral("Fake shared notebook global id one")); - sharedNotebookOne.setUsername(QStringLiteral("Fake shared notebook username one")); + sharedNotebookOne.setGlobalId( + QStringLiteral("Fake shared notebook global id one")); + sharedNotebookOne.setUsername( + QStringLiteral("Fake shared notebook username one")); sharedNotebookOne.setPrivilegeLevel(1); sharedNotebookOne.setReminderNotifyEmail(true); sharedNotebookOne.setReminderNotifyApp(false); @@ -194,11 +202,14 @@ sharedNotebookTwo.setId(2); sharedNotebookTwo.setUserId(4); sharedNotebookTwo.setNotebookGuid(extraNotebook.guid()); - sharedNotebookTwo.setEmail(QStringLiteral("Fake shared notebook email two")); + sharedNotebookTwo.setEmail( + QStringLiteral("Fake shared notebook email two")); sharedNotebookTwo.setCreationTimestamp(1); sharedNotebookTwo.setModificationTimestamp(1); - sharedNotebookTwo.setGlobalId(QStringLiteral("Fake shared notebook global id two")); - sharedNotebookTwo.setUsername(QStringLiteral("Fake shared notebook username two")); + sharedNotebookTwo.setGlobalId( + QStringLiteral("Fake shared notebook global id two")); + sharedNotebookTwo.setUsername( + QStringLiteral("Fake shared notebook username two")); sharedNotebookTwo.setPrivilegeLevel(1); sharedNotebookTwo.setReminderNotifyEmail(false); sharedNotebookTwo.setReminderNotifyApp(true); @@ -220,12 +231,12 @@ void NotebookLocalStorageManagerAsyncTester::onGetNotebookCountFailed( ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId); + QNWARNING(errorDescription << ", requestId = " << requestId); Q_EMIT failure(errorDescription.nonLocalizedString()); } -void NotebookLocalStorageManagerAsyncTester::onAddNotebookCompleted(Notebook notebook, - QUuid requestId) +void NotebookLocalStorageManagerAsyncTester::onAddNotebookCompleted( + Notebook notebook, QUuid requestId) { Q_UNUSED(requestId) @@ -236,10 +247,10 @@ if (m_initialNotebook != notebook) { errorDescription.setBase("Internal error in " "NotebookLocalStorageManagerAsyncTester: " - "notebook in onAddNotebookCompleted doesn't " - "match the original Notebook"); - QNWARNING(errorDescription << QStringLiteral("; original notebook: ") - << m_initialNotebook << QStringLiteral("\nFound notebook: ") + "notebook in onAddNotebookCompleted " + "doesn't match the original Notebook"); + QNWARNING(errorDescription << "; original notebook: " + << m_initialNotebook << "\nFound notebook: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -256,14 +267,16 @@ m_initialNotebooks << notebook; Notebook extraNotebook; - extraNotebook.setGuid(QStringLiteral("00000000-0000-0000-c000-000000000002")); + extraNotebook.setGuid( + QStringLiteral("00000000-0000-0000-c000-000000000002")); extraNotebook.setUpdateSequenceNumber(2); extraNotebook.setName(QStringLiteral("Fake extra notebook two")); extraNotebook.setCreationTimestamp(2); extraNotebook.setModificationTimestamp(2); extraNotebook.setDefaultNotebook(false); extraNotebook.setLastUsed(true); - extraNotebook.setPublishingUri(QStringLiteral("Fake publishing uri two")); + extraNotebook.setPublishingUri( + QStringLiteral("Fake publishing uri two")); extraNotebook.setPublishingOrder(1); extraNotebook.setPublishingAscending(false); extraNotebook.setPublishingPublicDescription( @@ -278,11 +291,14 @@ sharedNotebook.setId(3); sharedNotebook.setUserId(4); sharedNotebook.setNotebookGuid(extraNotebook.guid()); - sharedNotebook.setEmail(QStringLiteral("Fake shared notebook email three")); + sharedNotebook.setEmail( + QStringLiteral("Fake shared notebook email three")); sharedNotebook.setCreationTimestamp(2); sharedNotebook.setModificationTimestamp(2); - sharedNotebook.setGlobalId(QStringLiteral("Fake shared notebook global id three")); - sharedNotebook.setUsername(QStringLiteral("Fake shared notebook username three")); + sharedNotebook.setGlobalId( + QStringLiteral("Fake shared notebook global id three")); + sharedNotebook.setUsername( + QStringLiteral("Fake shared notebook username three")); sharedNotebook.setPrivilegeLevel(1); sharedNotebook.setReminderNotifyEmail(true); sharedNotebook.setReminderNotifyApp(false); @@ -311,17 +327,16 @@ HANDLE_WRONG_STATE(); } -void NotebookLocalStorageManagerAsyncTester::onAddNotebookFailed(Notebook notebook, - ErrorString errorDescription, - QUuid requestId) +void NotebookLocalStorageManagerAsyncTester::onAddNotebookFailed( + Notebook notebook, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", Notebook: ") << notebook); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", Notebook: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); } -void NotebookLocalStorageManagerAsyncTester::onUpdateNotebookCompleted(Notebook notebook, - QUuid requestId) +void NotebookLocalStorageManagerAsyncTester::onUpdateNotebookCompleted( + Notebook notebook, QUuid requestId) { Q_UNUSED(requestId) @@ -332,9 +347,10 @@ if (m_modifiedNotebook != notebook) { errorDescription.setBase("Internal error in " "NotebookLocalStorageManagerAsyncTester: " - "notebook pointer in onUpdateNotebookCompleted " - "slot doesn't match the pointer to " - "the original modified Notebook"); + "notebook pointer in " + "onUpdateNotebookCompleted slot doesn't " + "match the pointer to the original " + "modified Notebook"); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -346,17 +362,16 @@ HANDLE_WRONG_STATE(); } -void NotebookLocalStorageManagerAsyncTester::onUpdateNotebookFailed(Notebook notebook, - ErrorString errorDescription, - QUuid requestId) +void NotebookLocalStorageManagerAsyncTester::onUpdateNotebookFailed( + Notebook notebook, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", Notebook: ") << notebook); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", Notebook: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); } -void NotebookLocalStorageManagerAsyncTester::onFindNotebookCompleted(Notebook notebook, - QUuid requestId) +void NotebookLocalStorageManagerAsyncTester::onFindNotebookCompleted( + Notebook notebook, QUuid requestId) { Q_UNUSED(requestId) @@ -369,8 +384,8 @@ "NotebookLocalStorageManagerAsyncTester: " "notebook in onFindNotebookCompleted slot " "doesn't match the original Notebook"); - QNWARNING(errorDescription << QStringLiteral("; original notebook: ") - << m_initialNotebook << QStringLiteral("\nFound notebook: ") + QNWARNING(errorDescription << "; original notebook: " + << m_initialNotebook << "\nFound notebook: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -390,9 +405,9 @@ errorDescription.setBase("Added and found by name notebooks " "in the local storage don't match"); QNWARNING(errorDescription - << QStringLiteral(": Notebook added to the local storage: ") + << ": Notebook added to the local storage: " << m_initialNotebook - << QStringLiteral("\nNotebook found in the local storage: ") + << "\nNotebook found in the local storage: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -405,11 +420,13 @@ } else if (m_state == STATE_SENT_FIND_AFTER_UPDATE_REQUEST) { - if (m_modifiedNotebook != notebook) { + if (m_modifiedNotebook != notebook) + { errorDescription.setBase("Internal error in " "NotebookLocalStorageManagerAsyncTester: " - "notebook pointer in onFindNotebookCompleted " - "slot doesn't match the pointer to the original " + "notebook pointer in " + "onFindNotebookCompleted slot doesn't " + "match the pointer to the original " "modified Notebook"); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); @@ -427,9 +444,9 @@ errorDescription.setBase("Error: found notebook which should have been " "expunged from the local storage"); QNWARNING(errorDescription - << QStringLiteral(": Notebook expunged from the local storage: ") + << ": Notebook expunged from the local storage: " << m_modifiedNotebook - << QStringLiteral("\nNotebook found in the local storage: ") + << "\nNotebook found in the local storage: " << m_foundNotebook); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -437,9 +454,8 @@ HANDLE_WRONG_STATE(); } -void NotebookLocalStorageManagerAsyncTester::onFindNotebookFailed(Notebook notebook, - ErrorString errorDescription, - QUuid requestId) +void NotebookLocalStorageManagerAsyncTester::onFindNotebookFailed( + Notebook notebook, ErrorString errorDescription, QUuid requestId) { if (m_state == STATE_SENT_FIND_AFTER_EXPUNGE_REQUEST) { m_state = STATE_SENT_GET_COUNT_AFTER_EXPUNGE_REQUEST; @@ -447,13 +463,13 @@ return; } - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", Notebook: ") << notebook); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", Notebook: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); } -void NotebookLocalStorageManagerAsyncTester::onFindDefaultNotebookCompleted(Notebook notebook, - QUuid requestId) +void NotebookLocalStorageManagerAsyncTester::onFindDefaultNotebookCompleted( + Notebook notebook, QUuid requestId) { Q_UNUSED(requestId) @@ -489,7 +505,7 @@ errorDescription.setBase("Error: found default notebook which should not " "have been in the local storage"); QNWARNING(errorDescription - << QStringLiteral(": Notebook found in the local storage: ") + << ": Notebook found in the local storage: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -497,9 +513,8 @@ HANDLE_WRONG_STATE(); } -void NotebookLocalStorageManagerAsyncTester::onFindDefaultNotebookFailed(Notebook notebook, - ErrorString errorDescription, - QUuid requestId) +void NotebookLocalStorageManagerAsyncTester::onFindDefaultNotebookFailed( + Notebook notebook, ErrorString errorDescription, QUuid requestId) { if (m_state == STATE_SENT_FIND_DEFAULT_NOTEBOOK_AFTER_UPDATE) { m_state = STATE_SENT_FIND_LAST_USED_NOTEBOOK_AFTER_UPDATE; @@ -507,13 +522,13 @@ return; } - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", Notebook: ") << notebook); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", Notebook: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); } -void NotebookLocalStorageManagerAsyncTester::onFindLastUsedNotebookCompleted(Notebook notebook, - QUuid requestId) +void NotebookLocalStorageManagerAsyncTester::onFindLastUsedNotebookCompleted( + Notebook notebook, QUuid requestId) { Q_UNUSED(requestId) @@ -521,7 +536,8 @@ if (m_state == STATE_SENT_FIND_LAST_USED_NOTEBOOK_AFTER_UPDATE) { - if (m_foundNotebook != notebook) { + if (m_foundNotebook != notebook) + { errorDescription.setBase("Internal error in " "NotebookLocalStorageManagerAsyncTester: " "notebook pointer in " @@ -542,14 +558,15 @@ } m_state = STATE_SENT_FIND_DEFAULT_OR_LAST_USED_NOTEBOOK_AFTER_UPDATE; - Q_EMIT findDefaultOrLastUsedNotebookRequest(m_foundNotebook, QUuid::createUuid()); + Q_EMIT findDefaultOrLastUsedNotebookRequest(m_foundNotebook, + QUuid::createUuid()); } else if (m_state == STATE_SENT_FIND_LAST_USED_NOTEBOOK_AFTER_ADD) { errorDescription.setBase("Error: found last used notebook which should " "not have been in the local storage"); QNWARNING(errorDescription - << QStringLiteral(": Notebook found in the local storage: ") + << ": Notebook found in the local storage: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -557,9 +574,8 @@ HANDLE_WRONG_STATE(); } -void NotebookLocalStorageManagerAsyncTester::onFindLastUsedNotebookFailed(Notebook notebook, - ErrorString errorDescription, - QUuid requestId) +void NotebookLocalStorageManagerAsyncTester::onFindLastUsedNotebookFailed( + Notebook notebook, ErrorString errorDescription, QUuid requestId) { if (m_state == STATE_SENT_FIND_LAST_USED_NOTEBOOK_AFTER_ADD) { @@ -570,13 +586,13 @@ return; } - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", Notebook: ") << notebook); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", Notebook: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); } -void NotebookLocalStorageManagerAsyncTester::onFindDefaultOrLastUsedNotebookCompleted(Notebook notebook, - QUuid requestId) +void NotebookLocalStorageManagerAsyncTester::onFindDefaultOrLastUsedNotebookCompleted( + Notebook notebook, QUuid requestId) { Q_UNUSED(requestId) @@ -585,13 +601,14 @@ if ( (m_state == STATE_SENT_FIND_DEFAULT_OR_LAST_USED_NOTEBOOK_AFTER_ADD) || (m_state == STATE_SENT_FIND_DEFAULT_OR_LAST_USED_NOTEBOOK_AFTER_UPDATE) ) { - if (m_foundNotebook != notebook) { + if (m_foundNotebook != notebook) + { errorDescription.setBase("Internal error in " "NotebookLocalStorageManagerAsyncTester: " "notebook pointer in " "onFindDefaultOrLastUsedNotebookCompleted " - "slot doesn't match the pointer to the original " - "Notebook"); + "slot doesn't match the pointer to " + "the original Notebook"); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -653,8 +670,8 @@ void NotebookLocalStorageManagerAsyncTester::onFindDefaultOrLastUsedNotebookFailed( Notebook notebook, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", Notebook: ") << notebook); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", Notebook: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -684,10 +701,9 @@ foreach(const Notebook & notebook, m_initialNotebooks) { if (!notebooks.contains(notebook)) { ErrorString errorDescription( - QStringLiteral("One of initial notebooks is not found within " - "the listed notebooks")); - QNWARNING(errorDescription - << QStringLiteral(", notebook which was not found: ") + "One of initial notebooks is not found within " + "the listed notebooks"); + QNWARNING(errorDescription << ", notebook which was not found: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -711,7 +727,7 @@ Q_UNUSED(orderDirection) Q_UNUSED(linkedNotebookGuid) - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId); + QNWARNING(errorDescription << ", requestId = " << requestId); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -738,7 +754,7 @@ errorDescription.setBase("One of initial shared notebooks is not " "found within listed shared notebooks"); QNWARNING(errorDescription - << QStringLiteral(", shared notebook which was not found: ") + << ", shared notebook which was not found: " << sharedNotebook); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -754,7 +770,7 @@ void NotebookLocalStorageManagerAsyncTester::onListAllSharedNotebooksFailed( ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId); + QNWARNING(errorDescription << ", requestId = " << requestId); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -769,7 +785,7 @@ { errorDescription.setBase("Sizes of listed and reference shared notebooks " "don't match"); - QNWARNING(errorDescription << QStringLiteral(", notebook guid = ") + QNWARNING(errorDescription << ", notebook guid = " << notebookGuid); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -781,13 +797,10 @@ const SharedNotebook & sharedNotebook = *it; if (!sharedNotebooks.contains(sharedNotebook)) { - errorDescription.setBase("One of initial shared notebooks is not found " - "within the listed shared notebooks"); - QNWARNING(errorDescription - << QStringLiteral(", shared notebook which was not found: ") - << sharedNotebook - << QStringLiteral(", notebook guid = ") - << notebookGuid); + errorDescription.setBase("One of initial shared notebooks is not " + "found within the listed shared notebooks"); + QNWARNING(errorDescription << ", shared notebook which was not found: " + << sharedNotebook << ", notebook guid = " << notebookGuid); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } @@ -799,13 +812,13 @@ void NotebookLocalStorageManagerAsyncTester::onListSharedNotebooksPerNotebookGuidFailed( QString notebookGuid, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", notebook guid = ") << notebookGuid); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", notebook guid = " << notebookGuid); Q_EMIT failure(errorDescription.nonLocalizedString()); } -void NotebookLocalStorageManagerAsyncTester::onExpungeNotebookCompleted(Notebook notebook, - QUuid requestId) +void NotebookLocalStorageManagerAsyncTester::onExpungeNotebookCompleted( + Notebook notebook, QUuid requestId) { Q_UNUSED(requestId) @@ -813,7 +826,8 @@ if (m_modifiedNotebook != notebook) { - errorDescription.setBase("Internal error in NotebookLocalStorageManagerAsyncTester: " + errorDescription.setBase("Internal error in " + "NotebookLocalStorageManagerAsyncTester: " "notebook pointer in onExpungeNotebookCompleted " "slot doesn't match the pointer to the original " "expunged Notebook"); @@ -826,12 +840,11 @@ Q_EMIT findNotebookRequest(m_foundNotebook, QUuid::createUuid()); } -void NotebookLocalStorageManagerAsyncTester::onExpungeNotebookFailed(Notebook notebook, - ErrorString errorDescription, - QUuid requestId) +void NotebookLocalStorageManagerAsyncTester::onExpungeNotebookFailed( + Notebook notebook, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", Notebook: ") << notebook); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", Notebook: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -874,20 +887,22 @@ QNSIGNAL(NotebookLocalStorageManagerAsyncTester, findDefaultNotebookRequest,Notebook,QUuid), m_pLocalStorageManagerAsync, - QNSLOT(LocalStorageManagerAsync,onFindDefaultNotebookRequest, - Notebook,QUuid)); + QNSLOT(LocalStorageManagerAsync, + onFindDefaultNotebookRequest,Notebook,QUuid)); QObject::connect(this, QNSIGNAL(NotebookLocalStorageManagerAsyncTester, findLastUsedNotebookRequest,Notebook,QUuid), m_pLocalStorageManagerAsync, - QNSLOT(LocalStorageManagerAsync,onFindLastUsedNotebookRequest, - Notebook,QUuid)); + QNSLOT(LocalStorageManagerAsync, + onFindLastUsedNotebookRequest,Notebook,QUuid)); QObject::connect(this, QNSIGNAL(NotebookLocalStorageManagerAsyncTester, - findDefaultOrLastUsedNotebookRequest,Notebook,QUuid), + findDefaultOrLastUsedNotebookRequest, + Notebook,QUuid), m_pLocalStorageManagerAsync, QNSLOT(LocalStorageManagerAsync, - onFindDefaultOrLastUsedNotebookRequest,Notebook,QUuid)); + onFindDefaultOrLastUsedNotebookRequest, + Notebook,QUuid)); QObject::connect(this, QNSIGNAL(NotebookLocalStorageManagerAsyncTester, listAllNotebooksRequest,size_t,size_t, @@ -896,8 +911,10 @@ QString,QUuid), m_pLocalStorageManagerAsync, QNSLOT(LocalStorageManagerAsync,onListAllNotebooksRequest, - size_t,size_t,LocalStorageManager::ListNotebooksOrder::type, - LocalStorageManager::OrderDirection::type,QString,QUuid)); + size_t,size_t, + LocalStorageManager::ListNotebooksOrder::type, + LocalStorageManager::OrderDirection::type, + QString,QUuid)); QObject::connect(this, QNSIGNAL(NotebookLocalStorageManagerAsyncTester, listAllSharedNotebooksRequest,QUuid), @@ -906,10 +923,12 @@ onListAllSharedNotebooksRequest,QUuid)); QObject::connect(this, QNSIGNAL(NotebookLocalStorageManagerAsyncTester, - listSharedNotebooksPerNotebookRequest,QString,QUuid), + listSharedNotebooksPerNotebookRequest, + QString,QUuid), m_pLocalStorageManagerAsync, QNSLOT(LocalStorageManagerAsync, - onListSharedNotebooksPerNotebookGuidRequest,QString,QUuid)); + onListSharedNotebooksPerNotebookGuidRequest, + QString,QUuid)); QObject::connect(this, QNSIGNAL(NotebookLocalStorageManagerAsyncTester, expungeNotebookRequest,Notebook,QUuid), @@ -967,17 +986,19 @@ QNSLOT(NotebookLocalStorageManagerAsyncTester, onFindNotebookFailed,Notebook,ErrorString,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, - QNSIGNAL(LocalStorageManagerAsync,findDefaultNotebookComplete, - Notebook,QUuid), + QNSIGNAL(LocalStorageManagerAsync, + findDefaultNotebookComplete,Notebook,QUuid), this, QNSLOT(NotebookLocalStorageManagerAsyncTester, onFindDefaultNotebookCompleted,Notebook,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, - QNSIGNAL(LocalStorageManagerAsync,findDefaultNotebookFailed, + QNSIGNAL(LocalStorageManagerAsync, + findDefaultNotebookFailed, Notebook,ErrorString,QUuid), this, QNSLOT(NotebookLocalStorageManagerAsyncTester, - onFindDefaultNotebookFailed,Notebook,ErrorString,QUuid)); + onFindDefaultNotebookFailed, + Notebook,ErrorString,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync, findLastUsedNotebookComplete,Notebook,QUuid), @@ -985,17 +1006,21 @@ QNSLOT(NotebookLocalStorageManagerAsyncTester, onFindLastUsedNotebookCompleted,Notebook,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, - QNSIGNAL(LocalStorageManagerAsync,findLastUsedNotebookFailed, + QNSIGNAL(LocalStorageManagerAsync, + findLastUsedNotebookFailed, Notebook,ErrorString,QUuid), this, QNSLOT(NotebookLocalStorageManagerAsyncTester, - onFindLastUsedNotebookFailed,Notebook,ErrorString,QUuid)); + onFindLastUsedNotebookFailed, + Notebook,ErrorString,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync, - findDefaultOrLastUsedNotebookComplete,Notebook,QUuid), + findDefaultOrLastUsedNotebookComplete, + Notebook,QUuid), this, QNSLOT(NotebookLocalStorageManagerAsyncTester, - onFindDefaultOrLastUsedNotebookCompleted,Notebook,QUuid)); + onFindDefaultOrLastUsedNotebookCompleted, + Notebook,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync, findDefaultOrLastUsedNotebookFailed,Notebook, @@ -1006,7 +1031,8 @@ Notebook,ErrorString,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync,listAllNotebooksComplete, - size_t,size_t,LocalStorageManager::ListNotebooksOrder::type, + size_t,size_t, + LocalStorageManager::ListNotebooksOrder::type, LocalStorageManager::OrderDirection::type, QString,QList<Notebook>,QUuid), this, @@ -1017,7 +1043,8 @@ QString,QList<Notebook>,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync,listAllNotebooksFailed, - size_t,size_t,LocalStorageManager::ListNotebooksOrder::type, + size_t,size_t, + LocalStorageManager::ListNotebooksOrder::type, LocalStorageManager::OrderDirection::type, QString,ErrorString,QUuid), this, @@ -1027,7 +1054,8 @@ LocalStorageManager::OrderDirection::type, QString,ErrorString,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, - QNSIGNAL(LocalStorageManagerAsync,listAllSharedNotebooksComplete, + QNSIGNAL(LocalStorageManagerAsync, + listAllSharedNotebooksComplete, QList<SharedNotebook>,QUuid), this, QNSLOT(NotebookLocalStorageManagerAsyncTester, diff -Nru libquentier-0.5.0/src/tests/local_storage/NoteLocalStorageManagerAsyncTester.cpp libquentier-0.5.0/src/tests/local_storage/NoteLocalStorageManagerAsyncTester.cpp --- libquentier-0.5.0/src/tests/local_storage/NoteLocalStorageManagerAsyncTester.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/tests/local_storage/NoteLocalStorageManagerAsyncTester.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -25,7 +25,8 @@ namespace quentier { namespace test { -NoteLocalStorageManagerAsyncTester::NoteLocalStorageManagerAsyncTester(QObject * parent) : +NoteLocalStorageManagerAsyncTester::NoteLocalStorageManagerAsyncTester( + QObject * parent) : QObject(parent), m_state(STATE_UNINITIALIZED), m_pLocalStorageManagerAsync(Q_NULLPTR), @@ -92,8 +93,8 @@ ErrorString errorDescription; if (!m_notebook.checkParameters(errorDescription)) { - QNWARNING(QStringLiteral("Found invalid notebook: ") << m_notebook - << QStringLiteral(", error: ") << errorDescription); + QNWARNING("Found invalid notebook: " << m_notebook + << ", error: " << errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } @@ -102,37 +103,42 @@ Q_EMIT addNotebookRequest(m_notebook, QUuid::createUuid()); } -void NoteLocalStorageManagerAsyncTester::onAddNotebookCompleted(Notebook notebook, - QUuid requestId) +void NoteLocalStorageManagerAsyncTester::onAddNotebookCompleted( + Notebook notebook, QUuid requestId) { Q_UNUSED(requestId) ErrorString errorDescription; -#define HANDLE_WRONG_STATE() \ - else { \ - errorDescription.setBase("Internal error in NoteLocalStorageManagerAsyncTester: "\ - "found wrong state"); \ - QNWARNING(errorDescription << ": " << m_state); \ - Q_EMIT failure(errorDescription.nonLocalizedString()); \ - } +#define HANDLE_WRONG_STATE() \ + else { \ + errorDescription.setBase("Internal error in " \ + "NoteLocalStorageManagerAsyncTester: " \ + "found wrong state"); \ + QNWARNING(errorDescription << ": " << m_state); \ + Q_EMIT failure(errorDescription.nonLocalizedString()); \ + } \ +// HANDLE_WRONG_STATE if (m_state == STATE_SENT_ADD_NOTEBOOK_REQUEST) { if (m_notebook != notebook) { - errorDescription.setBase("Internal error in NoteLocalStorageManagerAsyncTester: " - "notebook in onAddNotebookCompleted slot doesn't match " - "the original Notebook"); + errorDescription.setBase("Internal error in " + "NoteLocalStorageManagerAsyncTester: " + "notebook in onAddNotebookCompleted slot " + "doesn't match the original Notebook"); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } m_initialNote.clear(); - m_initialNote.setGuid(QStringLiteral("00000000-0000-0000-c000-000000000048")); + m_initialNote.setGuid( + QStringLiteral("00000000-0000-0000-c000-000000000048")); m_initialNote.setUpdateSequenceNumber(1); m_initialNote.setTitle(QStringLiteral("Fake note")); - m_initialNote.setContent(QStringLiteral("<en-note><h1>Hello, world</h1></en-note>")); + m_initialNote.setContent( + QStringLiteral("<en-note><h1>Hello, world</h1></en-note>")); m_initialNote.setCreationTimestamp(1); m_initialNote.setModificationTimestamp(1); m_initialNote.setNotebookGuid(m_notebook.guid()); @@ -145,10 +151,12 @@ else if (m_state == STATE_SENT_ADD_EXTRA_NOTEBOOK_REQUEST) { Note extraNote; - extraNote.setGuid(QStringLiteral("00000000-0000-0000-c000-000000000006")); + extraNote.setGuid( + QStringLiteral("00000000-0000-0000-c000-000000000006")); extraNote.setUpdateSequenceNumber(6); extraNote.setActive(true); - extraNote.setContent(QStringLiteral("<en-note><h1>Hello, world 3</h1></en-note>")); + extraNote.setContent( + QStringLiteral("<en-note><h1>Hello, world 3</h1></en-note>")); extraNote.setCreationTimestamp(3); extraNote.setModificationTimestamp(3); extraNote.setNotebookGuid(m_extraNotebook.guid()); @@ -161,12 +169,11 @@ HANDLE_WRONG_STATE(); } -void NoteLocalStorageManagerAsyncTester::onAddNotebookFailed(Notebook notebook, - ErrorString errorDescription, - QUuid requestId) +void NoteLocalStorageManagerAsyncTester::onAddNotebookFailed( + Notebook notebook, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", Notebook: ") << notebook); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", Notebook: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -209,10 +216,12 @@ } Note extraNote; - extraNote.setGuid(QStringLiteral("00000000-0000-0000-c000-000000000001")); + extraNote.setGuid( + QStringLiteral("00000000-0000-0000-c000-000000000001")); extraNote.setUpdateSequenceNumber(1); extraNote.setActive(true); - extraNote.setContent(QStringLiteral("<en-note><h1>Hello, world 1</h1></en-note>")); + extraNote.setContent( + QStringLiteral("<en-note><h1>Hello, world 1</h1></en-note>")); extraNote.setCreationTimestamp(1); extraNote.setModificationTimestamp(1); extraNote.setNotebookGuid(m_notebook.guid()); @@ -220,7 +229,8 @@ extraNote.setTitle(QStringLiteral("Fake note title one")); Resource resource; - resource.setGuid(QStringLiteral("00000000-0000-0000-c000-000000000002")); + resource.setGuid( + QStringLiteral("00000000-0000-0000-c000-000000000002")); resource.setUpdateSequenceNumber(2); resource.setNoteGuid(extraNote.guid()); resource.setDataBody(QByteArray("Fake resource data body")); @@ -233,7 +243,8 @@ extraNote.addResource(resource); Resource resource2; - resource2.setGuid(QStringLiteral("00000000-0000-0000-c000-000000000009")); + resource2.setGuid( + QStringLiteral("00000000-0000-0000-c000-000000000009")); resource2.setUpdateSequenceNumber(3); resource2.setNoteGuid(extraNote.guid()); resource2.setDataBody(QByteArray("Fake resource data body")); @@ -249,7 +260,8 @@ noteAttributes.altitude = 20.0; noteAttributes.latitude = 10.0; noteAttributes.longitude = 30.0; - noteAttributes.author = QStringLiteral("NoteLocalStorageManagerAsyncTester"); + noteAttributes.author = + QStringLiteral("NoteLocalStorageManagerAsyncTester"); noteAttributes.lastEditedBy = QStringLiteral("Same as author"); noteAttributes.placeName = QStringLiteral("Testing hall"); noteAttributes.sourceApplication = QStringLiteral("tester"); @@ -265,11 +277,12 @@ QUuid requestId) { Q_UNUSED(options) - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId); + QNWARNING(errorDescription << ", requestId = " << requestId); Q_EMIT failure(errorDescription.nonLocalizedString()); } -void NoteLocalStorageManagerAsyncTester::onAddNoteCompleted(Note note, QUuid requestId) +void NoteLocalStorageManagerAsyncTester::onAddNoteCompleted( + Note note, QUuid requestId) { Q_UNUSED(requestId) @@ -278,9 +291,10 @@ if (m_state == STATE_SENT_ADD_REQUEST) { if (m_initialNote != note) { - errorDescription.setBase("Internal error in NoteLocalStorageManagerAsyncTester: " - "note in onAddNoteCompleted slot doesn't match " - "the original Note"); + errorDescription.setBase("Internal error in " + "NoteLocalStorageManagerAsyncTester: " + "note in onAddNoteCompleted slot doesn't " + "match the original Note"); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -300,10 +314,12 @@ m_initialNotes << note; Note extraNote; - extraNote.setGuid(QStringLiteral("00000000-0000-0000-c000-000000000004")); + extraNote.setGuid( + QStringLiteral("00000000-0000-0000-c000-000000000004")); extraNote.setUpdateSequenceNumber(4); extraNote.setActive(true); - extraNote.setContent(QStringLiteral("<en-note><h1>Hello, world 2</h1></en-note>")); + extraNote.setContent( + QStringLiteral("<en-note><h1>Hello, world 2</h1></en-note>")); extraNote.setCreationTimestamp(2); extraNote.setModificationTimestamp(2); extraNote.setNotebookGuid(m_notebook.guid()); @@ -318,7 +334,8 @@ m_initialNotes << note; m_extraNotebook.clear(); - m_extraNotebook.setGuid(QStringLiteral("00000000-0000-0000-c000-000000000005")); + m_extraNotebook.setGuid( + QStringLiteral("00000000-0000-0000-c000-000000000005")); m_extraNotebook.setUpdateSequenceNumber(1); m_extraNotebook.setName(QStringLiteral("Fake notebook name two")); m_extraNotebook.setCreationTimestamp(1); @@ -334,7 +351,8 @@ m_initialNotes << note; m_state = STATE_SENT_LIST_NOTES_PER_NOTEBOOK_ONE_REQUEST; - LocalStorageManager::ListObjectsOptions flag = LocalStorageManager::ListAll; + LocalStorageManager::ListObjectsOptions flag = + LocalStorageManager::ListAll; size_t limit = 0, offset = 0; LocalStorageManager::ListNotesOrder::type order = LocalStorageManager::ListNotesOrder::NoOrder; @@ -350,12 +368,11 @@ HANDLE_WRONG_STATE(); } -void NoteLocalStorageManagerAsyncTester::onAddNoteFailed(Note note, - ErrorString errorDescription, - QUuid requestId) +void NoteLocalStorageManagerAsyncTester::onAddNoteFailed( + Note note, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", note: ") << note); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", note: " << note); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -370,9 +387,10 @@ if (m_state == STATE_SENT_UPDATE_REQUEST) { if (m_modifiedNote != note) { - errorDescription.setBase("Internal error in NoteLocalStorageManagerAsyncTester: " - "note in onUpdateNoteCompleted slot doesn't match " - "the original updated Note"); + errorDescription.setBase("Internal error in " + "NoteLocalStorageManagerAsyncTester: " + "note in onUpdateNoteCompleted slot " + "doesn't match the original updated Note"); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -389,7 +407,8 @@ ErrorString errorDescription; if (m_modifiedNote != note) { - errorDescription.setBase("Internal error in NoteLocalStorageManagerAsyncTester: " + errorDescription.setBase("Internal error in " + "NoteLocalStorageManagerAsyncTester: " "note in onUpdateNoteCompleted slot after " "the deletion update doesn't match " "the original deleted Note"); @@ -411,8 +430,8 @@ { Q_UNUSED(options) - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", note: ") << note); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", note: " << note); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -427,20 +446,22 @@ if (m_state == STATE_SENT_FIND_AFTER_ADD_REQUEST) { if (m_initialNote != note) { - errorDescription.setBase("Internal error in NoteLocalStorageManagerAsyncTester: " + errorDescription.setBase("Internal error in " + "NoteLocalStorageManagerAsyncTester: " "note in onFindNoteCompleted slot doesn't " "match the original Note"); - QNWARNING(errorDescription << QStringLiteral("; original note: ") - << m_initialNote << QStringLiteral("\nFound note: ") - << note); + QNWARNING(errorDescription << "; original note: " + << m_initialNote << "\nFound note: " << note); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } // Ok, found note is good, updating it now m_modifiedNote = m_initialNote; - m_modifiedNote.setUpdateSequenceNumber(m_initialNote.updateSequenceNumber() + 1); - m_modifiedNote.setTitle(m_initialNote.title() + QStringLiteral("_modified")); + m_modifiedNote.setUpdateSequenceNumber( + m_initialNote.updateSequenceNumber() + 1); + m_modifiedNote.setTitle( + m_initialNote.title() + QStringLiteral("_modified")); m_state = STATE_SENT_UPDATE_REQUEST; LocalStorageManager::UpdateNoteOptions options( @@ -452,9 +473,10 @@ else if (m_state == STATE_SENT_FIND_AFTER_UPDATE_REQUEST) { if (m_modifiedNote != note) { - errorDescription.setBase("Internal error in NoteLocalStorageManagerAsyncTester: " - "not in onFindNoteCompleted slot doesn't match " - "the original modified Note"); + errorDescription.setBase("Internal error in " + "NoteLocalStorageManagerAsyncTester: " + "not in onFindNoteCompleted slot doesn't " + "match the original modified Note"); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -472,9 +494,9 @@ errorDescription.setBase("Found note which should have been expunged " "from the local storage"); QNWARNING(errorDescription - << QStringLiteral(": Note expunged from LocalStorageManager: ") + << ": Note expunged from LocalStorageManager: " << m_modifiedNote - << QStringLiteral("\nNote found in LocalStorageManager: ") + << "\nNote found in LocalStorageManager: " << m_foundNote); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -494,16 +516,16 @@ return; } - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", note: ") << note - << QStringLiteral("\nWith resource metadata = ") + QNWARNING(errorDescription << ", requestId = " << requestId + << ", note: " << note + << "\nWith resource metadata = " << ((options & LocalStorageManager::GetNoteOption::WithResourceMetadata) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with resource binary data = ") + ? "true" + : "false") + << ", with resource binary data = " << ((options & LocalStorageManager::GetNoteOption::WithResourceBinaryData) - ? QStringLiteral("true") - : QStringLiteral("false"))); + ? "true" + : "false")); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -535,14 +557,15 @@ if (!m_initialNotes.contains(note)) { errorDescription.setBase("One of found notes was not found " "within initial notes"); - QNWARNING(errorDescription << QStringLiteral(", unfound note: ") + QNWARNING(errorDescription << ", unfound note: " << note); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } if (note.notebookGuid() != m_notebook.guid()) { - errorDescription.setBase("One of found notes has invalid notebook guid"); + errorDescription.setBase("One of found notes has invalid " + "notebook guid"); errorDescription.details() = QStringLiteral("expected "); errorDescription.details() += m_notebook.guid(); errorDescription.details() += QStringLiteral(", found: "); @@ -568,8 +591,9 @@ } if (note.notebookGuid() != m_extraNotebook.guid()) { - errorDescription.setBase("One of found notes has invalid notebook guid"); - errorDescription.details() = QStringLiteral("expected "); + errorDescription.setBase("One of found notes has invalid " + "notebook guid"); + errorDescription.details() = QStringLiteral("expected"); errorDescription.details() += m_extraNotebook.guid(); errorDescription.details() += QStringLiteral(", found: "); errorDescription.details() += note.notebookGuid(); @@ -598,30 +622,31 @@ Q_UNUSED(order) Q_UNUSED(orderDirection) - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", notebook: ") << notebook - << QStringLiteral(", with resource metadata = ") + QNWARNING(errorDescription << ", requestId = " << requestId + << ", notebook: " << notebook + << ", with resource metadata = " << ((options & LocalStorageManager::GetNoteOption::WithResourceMetadata) - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", with resource binary data = ") + ? "true" + : "false") + << ", with resource binary data = " << ((options & LocalStorageManager::GetNoteOption::WithResourceBinaryData) - ? QStringLiteral("true") - : QStringLiteral("false"))); + ? "true" + : "false")); Q_EMIT failure(errorDescription.nonLocalizedString()); } -void NoteLocalStorageManagerAsyncTester::onExpungeNoteCompleted(Note note, - QUuid requestId) +void NoteLocalStorageManagerAsyncTester::onExpungeNoteCompleted( + Note note, QUuid requestId) { Q_UNUSED(requestId) ErrorString errorDescription; if (m_modifiedNote != note) { - errorDescription.setBase("Internal error in NoteLocalStorageManagerAsyncTester: " - "note in onExpungeNoteCompleted slot doesn't match " - "the original expunged Note"); + errorDescription.setBase("Internal error in " + "NoteLocalStorageManagerAsyncTester: " + "note in onExpungeNoteCompleted slot doesn't " + "match the original expunged Note"); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -637,8 +662,8 @@ void NoteLocalStorageManagerAsyncTester::onExpungeNoteFailed( Note note, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", note: ") << note); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", note: " << note); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -654,8 +679,8 @@ // Request --> slot connections QObject::connect(this, - QNSIGNAL(NoteLocalStorageManagerAsyncTester,addNotebookRequest, - Notebook,QUuid), + QNSIGNAL(NoteLocalStorageManagerAsyncTester, + addNotebookRequest,Notebook,QUuid), m_pLocalStorageManagerAsync, QNSLOT(LocalStorageManagerAsync,onAddNotebookRequest, Notebook,QUuid)); @@ -670,9 +695,11 @@ QNSIGNAL(NoteLocalStorageManagerAsyncTester,addNoteRequest, Note,QUuid), m_pLocalStorageManagerAsync, - QNSLOT(LocalStorageManagerAsync,onAddNoteRequest,Note,QUuid)); + QNSLOT(LocalStorageManagerAsync, + onAddNoteRequest,Note,QUuid)); QObject::connect(this, - QNSIGNAL(NoteLocalStorageManagerAsyncTester,updateNoteRequest, + QNSIGNAL(NoteLocalStorageManagerAsyncTester, + updateNoteRequest, Note,LocalStorageManager::UpdateNoteOptions,QUuid), m_pLocalStorageManagerAsync, QNSLOT(LocalStorageManagerAsync,onUpdateNoteRequest, @@ -691,14 +718,15 @@ size_t,LocalStorageManager::ListNotesOrder::type, LocalStorageManager::OrderDirection::type,QUuid), m_pLocalStorageManagerAsync, - QNSLOT(LocalStorageManagerAsync,onListNotesPerNotebookRequest, + QNSLOT(LocalStorageManagerAsync, + onListNotesPerNotebookRequest, Notebook,LocalStorageManager::GetNoteOptions, - LocalStorageManager::ListObjectsOptions, - size_t,size_t,LocalStorageManager::ListNotesOrder::type, + LocalStorageManager::ListObjectsOptions,size_t, + size_t,LocalStorageManager::ListNotesOrder::type, LocalStorageManager::OrderDirection::type,QUuid)); QObject::connect(this, - QNSIGNAL(NoteLocalStorageManagerAsyncTester,expungeNoteRequest, - Note,QUuid), + QNSIGNAL(NoteLocalStorageManagerAsyncTester, + expungeNoteRequest,Note,QUuid), m_pLocalStorageManagerAsync, QNSLOT(LocalStorageManagerAsync,onExpungeNoteRequest, Note,QUuid)); @@ -708,32 +736,36 @@ QNSIGNAL(LocalStorageManagerAsync,addNotebookComplete, Notebook,QUuid), this, - QNSLOT(NoteLocalStorageManagerAsyncTester,onAddNotebookCompleted, - Notebook,QUuid)); + QNSLOT(NoteLocalStorageManagerAsyncTester, + onAddNotebookCompleted,Notebook,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync,addNotebookFailed, Notebook,ErrorString,QUuid), this, - QNSLOT(NoteLocalStorageManagerAsyncTester,onAddNotebookFailed, - Notebook,ErrorString,QUuid)); + QNSLOT(NoteLocalStorageManagerAsyncTester, + onAddNotebookFailed,Notebook,ErrorString,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync,getNoteCountComplete, int,LocalStorageManager::NoteCountOptions,QUuid), this, - QNSLOT(NoteLocalStorageManagerAsyncTester,onGetNoteCountCompleted, + QNSLOT(NoteLocalStorageManagerAsyncTester, + onGetNoteCountCompleted, int,LocalStorageManager::NoteCountOptions,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync,getNoteCountFailed, ErrorString,LocalStorageManager::NoteCountOptions, QUuid), this, - QNSLOT(NoteLocalStorageManagerAsyncTester,onGetNoteCountFailed, - ErrorString,LocalStorageManager::NoteCountOptions,QUuid)); + QNSLOT(NoteLocalStorageManagerAsyncTester, + onGetNoteCountFailed, + ErrorString,LocalStorageManager::NoteCountOptions, + QUuid)); QObject::connect(m_pLocalStorageManagerAsync, - QNSIGNAL(LocalStorageManagerAsync,addNoteComplete,Note,QUuid), + QNSIGNAL(LocalStorageManagerAsync, + addNoteComplete,Note,QUuid), this, - QNSLOT(NoteLocalStorageManagerAsyncTester,onAddNoteCompleted, - Note,QUuid)); + QNSLOT(NoteLocalStorageManagerAsyncTester, + onAddNoteCompleted,Note,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync,addNoteFailed, Note,ErrorString,QUuid), @@ -744,14 +776,16 @@ QNSIGNAL(LocalStorageManagerAsync,updateNoteComplete, Note,LocalStorageManager::UpdateNoteOptions,QUuid), this, - QNSLOT(NoteLocalStorageManagerAsyncTester,onUpdateNoteCompleted, + QNSLOT(NoteLocalStorageManagerAsyncTester, + onUpdateNoteCompleted, Note,LocalStorageManager::UpdateNoteOptions,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync,updateNoteFailed, Note,LocalStorageManager::UpdateNoteOptions, ErrorString,QUuid), this, - QNSLOT(NoteLocalStorageManagerAsyncTester,onUpdateNoteFailed, + QNSLOT(NoteLocalStorageManagerAsyncTester, + onUpdateNoteFailed, Note,LocalStorageManager::UpdateNoteOptions, ErrorString,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, @@ -770,7 +804,8 @@ Note,LocalStorageManager::GetNoteOptions, ErrorString,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, - QNSIGNAL(LocalStorageManagerAsync,listNotesPerNotebookComplete, + QNSIGNAL(LocalStorageManagerAsync, + listNotesPerNotebookComplete, Notebook,LocalStorageManager::GetNoteOptions, LocalStorageManager::ListObjectsOptions,size_t, size_t,LocalStorageManager::ListNotesOrder::type, @@ -785,7 +820,8 @@ LocalStorageManager::OrderDirection::type, QList<Note>,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, - QNSIGNAL(LocalStorageManagerAsync,listNotesPerNotebookFailed, + QNSIGNAL(LocalStorageManagerAsync, + listNotesPerNotebookFailed, Notebook,LocalStorageManager::GetNoteOptions, LocalStorageManager::ListObjectsOptions,size_t, size_t,LocalStorageManager::ListNotesOrder::type, @@ -809,8 +845,8 @@ QNSIGNAL(LocalStorageManagerAsync,expungeNoteFailed, Note,ErrorString,QUuid), this, - QNSLOT(NoteLocalStorageManagerAsyncTester,onExpungeNoteFailed, - Note,ErrorString,QUuid)); + QNSLOT(NoteLocalStorageManagerAsyncTester, + onExpungeNoteFailed,Note,ErrorString,QUuid)); } void NoteLocalStorageManagerAsyncTester::clear() diff -Nru libquentier-0.5.0/src/tests/local_storage/NoteNotebookAndTagListTrackingAsyncTester.cpp libquentier-0.5.0/src/tests/local_storage/NoteNotebookAndTagListTrackingAsyncTester.cpp --- libquentier-0.5.0/src/tests/local_storage/NoteNotebookAndTagListTrackingAsyncTester.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/tests/local_storage/NoteNotebookAndTagListTrackingAsyncTester.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -23,7 +23,8 @@ namespace quentier { namespace test { -NoteNotebookAndTagListTrackingAsyncTester::NoteNotebookAndTagListTrackingAsyncTester(QObject * parent) : +NoteNotebookAndTagListTrackingAsyncTester::NoteNotebookAndTagListTrackingAsyncTester( + QObject * parent) : QObject(parent), m_state(STATE_UNINITIALIZED), m_pLocalStorageManagerAsync(Q_NULLPTR), @@ -111,17 +112,17 @@ } } -void NoteNotebookAndTagListTrackingAsyncTester::onAddNotebookComplete(Notebook notebook, - QUuid requestId) +void NoteNotebookAndTagListTrackingAsyncTester::onAddNotebookComplete( + Notebook notebook, QUuid requestId) { Q_UNUSED(notebook) Q_UNUSED(requestId) if (Q_UNLIKELY(m_state != STATE_PENDING_NOTEBOOKS_AND_TAGS_CREATION)) { - ErrorString errorDescription(QStringLiteral("Internal error: unexpected " - "add notebook complete event")); - QNWARNING(errorDescription << QStringLiteral(", state = ") << m_state); + ErrorString errorDescription("Internal error: unexpected " + "add notebook complete event"); + QNWARNING(errorDescription << ", state = " << m_state); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } @@ -138,28 +139,27 @@ } } -void NoteNotebookAndTagListTrackingAsyncTester::onAddNotebookFailed(Notebook notebook, - ErrorString errorDescription, - QUuid requestId) +void NoteNotebookAndTagListTrackingAsyncTester::onAddNotebookFailed( + Notebook notebook, ErrorString errorDescription, QUuid requestId) { - QNWARNING(QStringLiteral("NoteNotebookAndTagListTrackingAsyncTester::onAddNotebookFailed: ") - << errorDescription << QStringLiteral(", notebook: ") << notebook); + QNWARNING("NoteNotebookAndTagListTrackingAsyncTester::onAddNotebookFailed: " + << errorDescription << ", notebook: " << notebook); Q_UNUSED(requestId) Q_EMIT failure(errorDescription.nonLocalizedString()); } -void NoteNotebookAndTagListTrackingAsyncTester::onAddTagComplete(Tag tag, - QUuid requestId) +void NoteNotebookAndTagListTrackingAsyncTester::onAddTagComplete( + Tag tag, QUuid requestId) { Q_UNUSED(tag) Q_UNUSED(requestId) if (Q_UNLIKELY(m_state != STATE_PENDING_NOTEBOOKS_AND_TAGS_CREATION)) { - ErrorString errorDescription(QStringLiteral("Internal error: unexpected " - "add tag complete event")); - QNWARNING(errorDescription << QStringLiteral(", state = ") << m_state); + ErrorString errorDescription("Internal error: unexpected " + "add tag complete event"); + QNWARNING(errorDescription << ", state = " << m_state); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } @@ -177,27 +177,26 @@ } } -void NoteNotebookAndTagListTrackingAsyncTester::onAddTagFailed(Tag tag, - ErrorString errorDescription, - QUuid requestId) +void NoteNotebookAndTagListTrackingAsyncTester::onAddTagFailed( + Tag tag, ErrorString errorDescription, QUuid requestId) { - QNWARNING(QStringLiteral("NoteNotebookAndTagListTrackingAsyncTester::onAddTagFailed: ") - << errorDescription << QStringLiteral(", tag: ") << tag); + QNWARNING("NoteNotebookAndTagListTrackingAsyncTester::onAddTagFailed: " + << errorDescription << ", tag: " << tag); Q_UNUSED(requestId) Q_EMIT failure(errorDescription.nonLocalizedString()); } -void NoteNotebookAndTagListTrackingAsyncTester::onAddNoteComplete(Note note, - QUuid requestId) +void NoteNotebookAndTagListTrackingAsyncTester::onAddNoteComplete( + Note note, QUuid requestId) { Q_UNUSED(requestId) if (Q_UNLIKELY(m_state != STATE_PENDING_NOTE_CREATION)) { - ErrorString errorDescription(QStringLiteral("Internal error: unexpected " - "add note complete event")); - QNWARNING(errorDescription << QStringLiteral(", state = ") << m_state); + ErrorString errorDescription("Internal error: unexpected " + "add note complete event"); + QNWARNING(errorDescription << ", state = " << m_state); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } @@ -214,12 +213,11 @@ Q_EMIT updateNote(modifiedNote, options, QUuid::createUuid()); } -void NoteNotebookAndTagListTrackingAsyncTester::onAddNoteFailed(Note note, - ErrorString errorDescription, - QUuid requestId) +void NoteNotebookAndTagListTrackingAsyncTester::onAddNoteFailed( + Note note, ErrorString errorDescription, QUuid requestId) { - QNWARNING(QStringLiteral("NoteNotebookAndTagListTrackingAsyncTester::onAddNoteFailed: ") - << errorDescription << QStringLiteral(", note: ") << note); + QNWARNING("NoteNotebookAndTagListTrackingAsyncTester::onAddNoteFailed: " + << errorDescription << ", note: " << note); Q_UNUSED(requestId) Q_EMIT failure(errorDescription.nonLocalizedString()); @@ -236,8 +234,8 @@ if (Q_UNLIKELY(m_receivedNoteMovedToAnotherNotebookSignal)) { ErrorString errorDescription( - QStringLiteral("Detected note moved to another notebook signal " - "when note's notebook was not changed")); + "Detected note moved to another notebook signal " + "when note's notebook was not changed"); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -246,8 +244,8 @@ if (Q_UNLIKELY(m_receivedNoteTagsListChangedSignal)) { ErrorString errorDescription( - QStringLiteral("Detected note tags list updated signal when " - "note's tags were not changed")); + "Detected note tags list updated signal when " + "note's tags were not changed"); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -261,8 +259,8 @@ if (Q_UNLIKELY(m_receivedNoteTagsListChangedSignal)) { ErrorString errorDescription( - QStringLiteral("Detected note tags list updated signal when " - "note's tags were not changed")); + "Detected note tags list updated signal when " + "note's tags were not changed"); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -280,8 +278,8 @@ if (Q_UNLIKELY(m_receivedNoteMovedToAnotherNotebookSignal)) { ErrorString errorDescription( - QStringLiteral("Detected note moved to another notebook signal " - "when note's notebook was not changed")); + "Detected note moved to another notebook signal " + "when note's notebook was not changed"); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -308,8 +306,8 @@ else { ErrorString errorDescription( - QStringLiteral("Internal error: unexpected update note complete event")); - QNWARNING(errorDescription << QStringLiteral(", state = ") << m_state); + "Internal error: unexpected update note complete event"); + QNWARNING(errorDescription << ", state = " << m_state); Q_EMIT failure(errorDescription.nonLocalizedString()); } } @@ -318,8 +316,8 @@ Note note, LocalStorageManager::UpdateNoteOptions options, ErrorString errorDescription, QUuid requestId) { - QNWARNING(QStringLiteral("NoteNotebookAndTagListTrackingAsyncTester::onUpdateNoteFailed: ") - << errorDescription << QStringLiteral(", note: ") << note); + QNWARNING("NoteNotebookAndTagListTrackingAsyncTester::onUpdateNoteFailed: " + << errorDescription << ", note: " << note); Q_UNUSED(options) Q_UNUSED(requestId) @@ -333,9 +331,9 @@ ++m_noteMovedToAnotherNotebookSlotInvocationCount; if (Q_UNLIKELY(m_noteMovedToAnotherNotebookSlotInvocationCount > 2)) { - ErrorString errorDescription(QStringLiteral("Too many note moved to " - "another notebook signals " - "received")); + ErrorString errorDescription("Too many note moved to " + "another notebook signals " + "received"); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -345,10 +343,10 @@ { if (Q_UNLIKELY(m_note.localUid() != noteLocalUid)) { - ErrorString errorDescription(QStringLiteral("Internal error: unexpected " - "note local uid in note " - "moved to another notebook " - "signal")); + ErrorString errorDescription("Internal error: unexpected " + "note local uid in note " + "moved to another notebook " + "signal"); errorDescription.details() = noteLocalUid; errorDescription.details() += QStringLiteral("; expected ") + m_note.localUid(); @@ -359,10 +357,10 @@ if (Q_UNLIKELY(m_firstNotebook.localUid() != previousNotebookLocalUid)) { - ErrorString errorDescription(QStringLiteral("Internal error: unexpected " - "previous notebook local " - "uid in note moved to " - "another notebook signal")); + ErrorString errorDescription("Internal error: unexpected " + "previous notebook local " + "uid in note moved to " + "another notebook signal"); errorDescription.details() = previousNotebookLocalUid; errorDescription.details() += QStringLiteral("; expected ") + m_firstNotebook.localUid(); @@ -373,10 +371,10 @@ if (Q_UNLIKELY(m_secondNotebook.localUid() != newNotebookLocalUid)) { - ErrorString errorDescription(QStringLiteral("Internal error: unexpected " - "new notebook local uid " - "in note moved to another " - "notebook signal")); + ErrorString errorDescription("Internal error: unexpected " + "new notebook local uid " + "in note moved to another " + "notebook signal"); errorDescription.details() = newNotebookLocalUid; errorDescription.details() += QStringLiteral("; expected ") + m_secondNotebook.localUid(); @@ -387,9 +385,9 @@ if (Q_UNLIKELY(m_receivedNoteTagsListChangedSignal)) { - ErrorString errorDescription(QStringLiteral("Detected note tags list " - "updated signal when note's " - "tags were not changed")); + ErrorString errorDescription("Detected note tags list " + "updated signal when note's " + "tags were not changed"); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -404,10 +402,10 @@ { if (Q_UNLIKELY(m_note.localUid() != noteLocalUid)) { - ErrorString errorDescription(QStringLiteral("Internal error: unexpected " - "note local uid in note " - "moved to another notebook " - "signal")); + ErrorString errorDescription("Internal error: unexpected " + "note local uid in note " + "moved to another notebook " + "signal"); errorDescription.details() = noteLocalUid; errorDescription.details() += QStringLiteral("; expected ") + m_note.localUid(); @@ -418,10 +416,10 @@ if (Q_UNLIKELY(m_secondNotebook.localUid() != previousNotebookLocalUid)) { - ErrorString errorDescription(QStringLiteral("Internal error: unexpected " - "previous notebook local " - "uid in note moved to " - "another notebook signal")); + ErrorString errorDescription("Internal error: unexpected " + "previous notebook local " + "uid in note moved to " + "another notebook signal"); errorDescription.details() = previousNotebookLocalUid; errorDescription.details() += QStringLiteral("; expected ") + m_secondNotebook.localUid(); @@ -432,10 +430,10 @@ if (Q_UNLIKELY(m_firstNotebook.localUid() != newNotebookLocalUid)) { - ErrorString errorDescription(QStringLiteral("Internal error: " - "unexpected new notebook " - "local uid in note moved " - "to another notebook signal")); + ErrorString errorDescription("Internal error: " + "unexpected new notebook " + "local uid in note moved " + "to another notebook signal"); errorDescription.details() = newNotebookLocalUid; errorDescription.details() += QStringLiteral("; expected ") + m_firstNotebook.localUid(); @@ -446,16 +444,18 @@ m_receivedNoteTagsListChangedSignal = true; - if (m_receivedUpdateNoteCompleteSignal && m_receivedNoteTagsListChangedSignal) { + if (m_receivedUpdateNoteCompleteSignal && + m_receivedNoteTagsListChangedSignal) + { Q_EMIT success(); } } else { - ErrorString errorDescription(QStringLiteral("Internal error: unexpected " - "note moved to another notebook " - "event")); - QNWARNING(errorDescription << QStringLiteral(", state = ") << m_state); + ErrorString errorDescription("Internal error: unexpected " + "note moved to another notebook " + "event"); + QNWARNING(errorDescription << ", state = " << m_state); Q_EMIT failure(errorDescription.nonLocalizedString()); } } @@ -467,8 +467,8 @@ ++m_noteTagsListChangedSlotInvocationCount; if (Q_UNLIKELY(m_noteTagsListChangedSlotInvocationCount > 2)) { - ErrorString errorDescription(QStringLiteral("Too many note tags list " - "changed signals received")); + ErrorString errorDescription("Too many note tags list " + "changed signals received"); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -478,9 +478,9 @@ { if (Q_UNLIKELY(m_note.localUid() != noteLocalUid)) { - ErrorString errorDescription(QStringLiteral("Internal error: unexpected " - "note local uid in note " - "tags list updated signal")); + ErrorString errorDescription("Internal error: unexpected " + "note local uid in note " + "tags list updated signal"); errorDescription.details() = noteLocalUid; errorDescription.details() += QStringLiteral("; expected ") + m_note.localUid(); @@ -491,10 +491,10 @@ if (Q_UNLIKELY(!checkTagsListEqual(m_firstNoteTagsSet, previousTagLocalUids))) { - ErrorString errorDescription(QStringLiteral("Internal error: unexpected " - "set of previous tag local " - "uids in note tags list " - "updated signal")); + ErrorString errorDescription("Internal error: unexpected " + "set of previous tag local " + "uids in note tags list " + "updated signal"); errorDescription.details() = previousTagLocalUids.join(QStringLiteral(",")); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); @@ -503,10 +503,10 @@ if (Q_UNLIKELY(!checkTagsListEqual(m_secondNoteTagsSet, newTagLocalUids))) { - ErrorString errorDescription(QStringLiteral("Internal error: unexpected " - "set of new tag local uids " - "in note tags list updated " - "signal")); + ErrorString errorDescription("Internal error: unexpected " + "set of new tag local uids " + "in note tags list updated " + "signal"); errorDescription.details() = newTagLocalUids.join(QStringLiteral(",")); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); @@ -515,10 +515,10 @@ if (Q_UNLIKELY(m_receivedNoteMovedToAnotherNotebookSignal)) { - ErrorString errorDescription(QStringLiteral("Detected note moved to " - "another notebook signal " - "when note's notebook was " - "not changed")); + ErrorString errorDescription("Detected note moved to " + "another notebook signal " + "when note's notebook was " + "not changed"); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -533,9 +533,9 @@ { if (Q_UNLIKELY(m_note.localUid() != noteLocalUid)) { - ErrorString errorDescription(QStringLiteral("Internal error: unexpected " - "note local uid in note tags " - "list updated signal")); + ErrorString errorDescription("Internal error: unexpected " + "note local uid in note tags " + "list updated signal"); errorDescription.details() = noteLocalUid; errorDescription.details() += QStringLiteral("; expected ") + m_note.localUid(); @@ -546,10 +546,10 @@ if (Q_UNLIKELY(!checkTagsListEqual(m_secondNoteTagsSet, previousTagLocalUids))) { - ErrorString errorDescription(QStringLiteral("Internal error: unexpected " - "set of previous tag local " - "uids in note tags list " - "updated signal")); + ErrorString errorDescription("Internal error: unexpected " + "set of previous tag local " + "uids in note tags list " + "updated signal"); errorDescription.details() = previousTagLocalUids.join(QStringLiteral(",")); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); @@ -558,10 +558,10 @@ if (Q_UNLIKELY(!checkTagsListEqual(m_firstNoteTagsSet, newTagLocalUids))) { - ErrorString errorDescription(QStringLiteral("Internal error: unexpected " - "set of new tag local uids " - "in note tags list updated " - "signal")); + ErrorString errorDescription("Internal error: unexpected " + "set of new tag local uids " + "in note tags list updated " + "signal"); errorDescription.details() = newTagLocalUids.join(QStringLiteral(",")); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); @@ -578,9 +578,9 @@ } else { - ErrorString errorDescription(QStringLiteral("Internal error: unexpected " - "note tags list update event")); - QNWARNING(errorDescription << QStringLiteral(", state = ") << m_state); + ErrorString errorDescription("Internal error: unexpected " + "note tags list update event"); + QNWARNING(errorDescription << ", state = " << m_state); Q_EMIT failure(errorDescription.nonLocalizedString()); } } diff -Nru libquentier-0.5.0/src/tests/local_storage/NoteSearchQueryParsingTest.cpp libquentier-0.5.0/src/tests/local_storage/NoteSearchQueryParsingTest.cpp --- libquentier-0.5.0/src/tests/local_storage/NoteSearchQueryParsingTest.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/tests/local_storage/NoteSearchQueryParsingTest.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -401,21 +401,22 @@ queryString += QStringLiteral("-encryption: "); } -#define ADD_LIST_TO_QUERY_STRING(keyword, list, type, ...) \ - for(int i = 0, size = list.size(); i < size; ++i) { \ - const type & item = list[i]; \ - queryString += QStringLiteral(#keyword ":"); \ - QString itemStr = __VA_ARGS__(item); \ - bool itemContainsSpace = itemStr.contains(QStringLiteral(" ")); \ - if (itemContainsSpace) { \ - queryString += QStringLiteral("\""); \ - } \ - queryString += itemStr; \ - if (itemContainsSpace) { \ - queryString += QStringLiteral("\""); \ - } \ - queryString += QStringLiteral(" "); \ - } \ +#define ADD_LIST_TO_QUERY_STRING(keyword, list, type, ...) \ + for(int i = 0, size = list.size(); i < size; ++i) { \ + const type & item = list[i]; \ + queryString += QStringLiteral(#keyword ":"); \ + QString itemStr = __VA_ARGS__(item); \ + bool itemContainsSpace = itemStr.contains(QStringLiteral(" ")); \ + if (itemContainsSpace) { \ + queryString += QStringLiteral("\""); \ + } \ + queryString += itemStr; \ + if (itemContainsSpace) { \ + queryString += QStringLiteral("\""); \ + } \ + queryString += QStringLiteral(" "); \ + } \ +// ADD_LIST_TO_QUERY_STRING ADD_LIST_TO_QUERY_STRING(tag, tagNames, QString); ADD_LIST_TO_QUERY_STRING(-tag, negatedTagNames, QString); @@ -866,24 +867,27 @@ } } -#define CHECK_LIST(list, accessor, ...) \ - auto noteSearchQueryList##list = noteSearchQuery.accessor(); \ - if (noteSearchQueryList##list != list) { \ - error = QStringLiteral("NoteSearchQuery: " #list " doesn't match the one "\ - "from the original list; original " #list ": "); \ - for(int i = 0, size = list.size(); i < size; ++i) { \ - const auto & item = list[i]; \ - error += __VA_ARGS__(item); \ - error += QStringLiteral("; "); \ - } \ - error += QStringLiteral("; \nNoteSearchQuery's list: "); \ - for(int i = 0, size = noteSearchQueryList##list.size(); i < size; ++i) { \ - const auto & item = noteSearchQueryList##list[i]; \ - error += __VA_ARGS__(item); \ - error += QStringLiteral("; "); \ - } \ - return false; \ - } +#define CHECK_LIST(list, accessor, ...) \ + auto noteSearchQueryList##list = noteSearchQuery.accessor(); \ + if (noteSearchQueryList##list != list) { \ + error = QStringLiteral("NoteSearchQuery: " #list " doesn't match the one " \ + "from the original list; original " #list ": "); \ + for(int i = 0, size = list.size(); i < size; ++i) { \ + const auto & item = list[i]; \ + error += __VA_ARGS__(item); \ + error += QStringLiteral("; "); \ + } \ + error += QStringLiteral("; \nNoteSearchQuery's list: "); \ + for(int i = 0, size = noteSearchQueryList##list.size(); \ + i < size; ++i) \ + { \ + const auto & item = noteSearchQueryList##list[i]; \ + error += __VA_ARGS__(item); \ + error += QStringLiteral("; "); \ + } \ + return false; \ + } \ +// CHECK_LIST CHECK_LIST(tagNames, tagNames); CHECK_LIST(negatedTagNames, negatedTagNames); @@ -914,31 +918,35 @@ #undef CHECK_LIST -#define CHECK_DATETIME_LIST(list, accessor) \ - auto noteSearchQuery##list = noteSearchQuery.accessor(); \ - int size##list = noteSearchQuery##list.size() ; \ - for(int i = 0; i < size##list; ++i) \ - { \ - const auto & item = noteSearchQuery##list[i]; \ - const auto & strItem = list.at(i); \ - \ - if (!timestampForDateTimeString.contains(strItem)) { \ - error = QStringLiteral("Internal error in test: unknown datetime argument "); \ - error += strItem; \ - return false; \ - } \ - \ - if (item != timestampForDateTimeString[strItem]) { \ - error = QStringLiteral("Timestamp from NoteSearchQuery is different "\ - "from precalculated one for string item \""); \ - error += strItem; \ - error += QStringLiteral("\": precalculated timestamp = "); \ - error += QString::number(timestampForDateTimeString[strItem]); \ - error += QStringLiteral(", timestamp from NoteSearchQuery: "); \ - error += QString::number(item); \ - return false; \ - } \ - } +#define CHECK_DATETIME_LIST(list, accessor) \ + auto noteSearchQuery##list = noteSearchQuery.accessor(); \ + int size##list = noteSearchQuery##list.size() ; \ + for(int i = 0; i < size##list; ++i) \ + { \ + const auto & item = noteSearchQuery##list[i]; \ + const auto & strItem = list.at(i); \ + \ + if (!timestampForDateTimeString.contains(strItem)) { \ + error = QStringLiteral("Internal error in test: " \ + "unknown datetime argument "); \ + error += strItem; \ + return false; \ + } \ + \ + if (item != timestampForDateTimeString[strItem]) \ + { \ + error = QStringLiteral("Timestamp from NoteSearchQuery is " \ + "different from precalculated one for " \ + "string item \""); \ + error += strItem; \ + error += QStringLiteral("\": precalculated timestamp = "); \ + error += QString::number(timestampForDateTimeString[strItem]); \ + error += QStringLiteral(", timestamp from NoteSearchQuery: "); \ + error += QString::number(item); \ + return false; \ + } \ + } \ +// CHECK_DATETIME_LIST CHECK_DATETIME_LIST(created, creationTimestamps); CHECK_DATETIME_LIST(negatedCreated, negatedCreationTimestamps); @@ -976,7 +984,8 @@ return false; } - const QStringList & contentSearchTermsFromQuery = noteSearchQuery.contentSearchTerms(); + const QStringList & contentSearchTermsFromQuery = + noteSearchQuery.contentSearchTerms(); const int numContentSearchTermsFromQuery = contentSearchTermsFromQuery.size(); QRegExp asteriskFilter(QStringLiteral("[*]")); @@ -1003,11 +1012,11 @@ error = QStringLiteral("Internal error: the number of content search " "terms doesn't match the expected one after " "parsing the note search query"); - QNWARNING(error << QStringLiteral("; original content search terms: ") + QNWARNING(error << "; original content search terms: " << contentSearchTerms.join(QStringLiteral("; ")) - << QStringLiteral("; filtered content search terms: ") + << "; filtered content search terms: " << filteredContentSearchTerms.join(QStringLiteral("; ")) - << QStringLiteral("; processed search query terms: ") + << "; processed search query terms: " << contentSearchTermsFromQuery.join(QStringLiteral("; "))); return false; } @@ -1021,9 +1030,9 @@ "content search terms after parsing the note " "search query"); QNWARNING(error - << QStringLiteral("; filtered original content search terms: ") + << "; filtered original content search terms: " << filteredContentSearchTerms.join(QStringLiteral("; ")) - << QStringLiteral("; parsed content search terms: ") + << "; parsed content search terms: " << contentSearchTermsFromQuery.join(QStringLiteral("; "))); return false; } @@ -1036,19 +1045,22 @@ QStringList filteredNegatedContentSearchTerms; filteredNegatedContentSearchTerms.reserve(numNegatedContentSearchTermsFromQuery); - for(int i = 0, numOriginalNegatedContentSearchTerms = negatedContentSearchTerms.size(); + for(int i = 0, + numOriginalNegatedContentSearchTerms = negatedContentSearchTerms.size(); i < numOriginalNegatedContentSearchTerms; ++i) { QString filteredNegatedSearchTerm = negatedContentSearchTerms[i]; // Don't accept search terms consisting only of asterisks - QString filteredNegatedSearchTermWithoutAsterisks = filteredNegatedSearchTerm; + QString filteredNegatedSearchTermWithoutAsterisks = + filteredNegatedSearchTerm; filteredNegatedSearchTermWithoutAsterisks.remove(asteriskFilter); if (filteredNegatedSearchTermWithoutAsterisks.isEmpty()) { continue; } - filteredNegatedContentSearchTerms << filteredNegatedSearchTerm.simplified().toLower(); + filteredNegatedContentSearchTerms + << filteredNegatedSearchTerm.simplified().toLower(); } if (numNegatedContentSearchTermsFromQuery != filteredNegatedContentSearchTerms.size()) @@ -1057,27 +1069,30 @@ "search terms doesn't match the expected one " "after parsing the note search query"); QNWARNING(error - << QStringLiteral("; original negated content search terms: ") + << "; original negated content search terms: " << negatedContentSearchTerms.join(QStringLiteral(" ")) - << QStringLiteral("; filtered negated content search terms: ") + << "; filtered negated content search terms: " << filteredNegatedContentSearchTerms.join(QStringLiteral(" ")) - << QStringLiteral("; processed negated search query terms: ") + << "; processed negated search query terms: " << negatedContentSearchTermsFromQuery.join(QStringLiteral(" "))); return false; } for(int i = 0; i < numNegatedContentSearchTermsFromQuery; ++i) { - const QString & negatedContentSearchTermFromQuery = negatedContentSearchTermsFromQuery[i]; - int index = filteredNegatedContentSearchTerms.indexOf(negatedContentSearchTermFromQuery); - if (index < 0) { + const QString & negatedContentSearchTermFromQuery = + negatedContentSearchTermsFromQuery[i]; + int index = filteredNegatedContentSearchTerms.indexOf( + negatedContentSearchTermFromQuery); + if (index < 0) + { error = QStringLiteral("Internal error: can't find one of original " "negated content search terms after parsing " "the note search query"); QNWARNING(error - << QStringLiteral("; filtered original negated content search terms: ") + << "; filtered original negated content search terms: " << filteredNegatedContentSearchTerms.join(QStringLiteral(" ")) - << QStringLiteral("; parsed negated content search terms: ") + << "; parsed negated content search terms: " << negatedContentSearchTermsFromQuery.join(QStringLiteral(" "))); return false; } diff -Nru libquentier-0.5.0/src/tests/local_storage/ResourceLocalStorageManagerAsyncTester.cpp libquentier-0.5.0/src/tests/local_storage/ResourceLocalStorageManagerAsyncTester.cpp --- libquentier-0.5.0/src/tests/local_storage/ResourceLocalStorageManagerAsyncTester.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/tests/local_storage/ResourceLocalStorageManagerAsyncTester.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -24,7 +24,8 @@ namespace quentier { namespace test { -ResourceLocalStorageManagerAsyncTester::ResourceLocalStorageManagerAsyncTester(QObject * parent) : +ResourceLocalStorageManagerAsyncTester::ResourceLocalStorageManagerAsyncTester( + QObject * parent) : QObject(parent), m_state(STATE_UNINITIALIZED), m_pLocalStorageManagerAsync(Q_NULLPTR), @@ -89,8 +90,8 @@ ErrorString errorDescription; if (!m_notebook.checkParameters(errorDescription)) { - QNWARNING(QStringLiteral("Found invalid notebook: ") << m_notebook - << QStringLiteral(", error: ") << errorDescription); + QNWARNING("Found invalid notebook: " << m_notebook + << ", error: " << errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } @@ -99,22 +100,23 @@ Q_EMIT addNotebookRequest(m_notebook, QUuid::createUuid()); } -void ResourceLocalStorageManagerAsyncTester::onAddNotebookCompleted(Notebook notebook, - QUuid requestId) +void ResourceLocalStorageManagerAsyncTester::onAddNotebookCompleted( + Notebook notebook, QUuid requestId) { Q_UNUSED(requestId) ErrorString errorDescription; -#define HANDLE_WRONG_STATE() \ - else \ - { \ - errorDescription.setBase("Internal error in "\ - "ResourceLocalStorageManagerAsyncTester: "\ - "found wrong state"); \ - QNWARNING(errorDescription << ": " << m_state); \ - Q_EMIT failure(errorDescription.nonLocalizedString()); \ - } +#define HANDLE_WRONG_STATE() \ + else \ + { \ + errorDescription.setBase("Internal error in " \ + "ResourceLocalStorageManagerAsyncTester: " \ + "found wrong state"); \ + QNWARNING(errorDescription << ": " << m_state); \ + Q_EMIT failure(errorDescription.nonLocalizedString()); \ + } \ +// HANDLE_WRONG_STATE if (m_state == STATE_SENT_ADD_NOTEBOOK_REQUEST) { @@ -149,13 +151,13 @@ void ResourceLocalStorageManagerAsyncTester::onAddNotebookFailed( Notebook notebook, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", Notebook: ") << notebook); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", Notebook: " << notebook); Q_EMIT failure(errorDescription.nonLocalizedString()); } -void ResourceLocalStorageManagerAsyncTester::onAddNoteCompleted(Note note, - QUuid requestId) +void ResourceLocalStorageManagerAsyncTester::onAddNoteCompleted( + Note note, QUuid requestId) { Q_UNUSED(requestId) @@ -255,8 +257,8 @@ void ResourceLocalStorageManagerAsyncTester::onAddNoteFailed( Note note, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", Note: ") << note); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", Note: " << note); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -300,12 +302,12 @@ void ResourceLocalStorageManagerAsyncTester::onGetResourceCountFailed( ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId); + QNWARNING(errorDescription << ", requestId = " << requestId); Q_EMIT failure(errorDescription.nonLocalizedString()); } -void ResourceLocalStorageManagerAsyncTester::onAddResourceCompleted(Resource resource, - QUuid requestId) +void ResourceLocalStorageManagerAsyncTester::onAddResourceCompleted( + Resource resource, QUuid requestId) { Q_UNUSED(requestId) @@ -334,17 +336,16 @@ HANDLE_WRONG_STATE(); } -void ResourceLocalStorageManagerAsyncTester::onAddResourceFailed(Resource resource, - ErrorString errorDescription, - QUuid requestId) +void ResourceLocalStorageManagerAsyncTester::onAddResourceFailed( + Resource resource, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", Resource: ") << resource); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", Resource: " << resource); Q_EMIT failure(errorDescription.nonLocalizedString()); } -void ResourceLocalStorageManagerAsyncTester::onUpdateResourceCompleted(Resource resource, - QUuid requestId) +void ResourceLocalStorageManagerAsyncTester::onUpdateResourceCompleted( + Resource resource, QUuid requestId) { Q_UNUSED(requestId) @@ -373,12 +374,11 @@ HANDLE_WRONG_STATE(); } -void ResourceLocalStorageManagerAsyncTester::onUpdateResourceFailed(Resource resource, - ErrorString errorDescription, - QUuid requestId) +void ResourceLocalStorageManagerAsyncTester::onUpdateResourceFailed( + Resource resource, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", Resource: ") << resource); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", Resource: " << resource); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -399,9 +399,9 @@ errorDescription.setBase("Added and found resources in the local " "storage don't match"); QNWARNING(errorDescription - << QStringLiteral(": Resource added to the local storage: ") + << ": Resource added to the local storage: " << m_initialResource - << QStringLiteral("\nResource found in the local storage: ") + << "\nResource found in the local storage: " << resource); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -434,9 +434,9 @@ errorDescription.setBase("Updated and found resources in the local " "storage don't match"); QNWARNING(errorDescription - << QStringLiteral(": Resource updated in the local storage: ") + << ": Resource updated in the local storage: " << m_modifiedResource - << QStringLiteral("\nResource found in the local storage: ") + << "\nResource found in the local storage: " << resource); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -450,9 +450,9 @@ errorDescription.setBase("Found resource which should have been expunged " "from the local storage"); QNWARNING(errorDescription - << QStringLiteral(": Resource expunged from the local storage: ") + << ": Resource expunged from the local storage: " << m_modifiedResource - << QStringLiteral("\nResource fond in the local storage: ") + << "\nResource fond in the local storage: " << resource); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -470,26 +470,28 @@ return; } - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", Resource: ") << resource - << QStringLiteral(", withBinaryData = ") + QNWARNING(errorDescription << ", requestId = " << requestId + << ", Resource: " << resource + << ", withBinaryData = " << ((options & LocalStorageManager::GetResourceOption::WithBinaryData) - ? QStringLiteral("true") - : QStringLiteral("false"))); + ? "true" + : "false")); Q_EMIT failure(errorDescription.nonLocalizedString()); } -void ResourceLocalStorageManagerAsyncTester::onExpungeResourceCompleted(Resource resource, - QUuid requestId) +void ResourceLocalStorageManagerAsyncTester::onExpungeResourceCompleted( + Resource resource, QUuid requestId) { Q_UNUSED(requestId) ErrorString errorDescription; - if (m_modifiedResource != resource) { - errorDescription.setBase("Internal error in ResourceLocalStorageManagerAsyncTester: " - "resource in onExpungeResourceCompleted slot doesn't match " - "the original expunged Resource"); + if (m_modifiedResource != resource) + { + errorDescription.setBase("Internal error in " + "ResourceLocalStorageManagerAsyncTester: " + "resource in onExpungeResourceCompleted slot " + "doesn't match the original expunged Resource"); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -501,12 +503,11 @@ Q_EMIT findResourceRequest(m_foundResource, options, QUuid::createUuid()); } -void ResourceLocalStorageManagerAsyncTester::onExpungeResourceFailed(Resource resource, - ErrorString errorDescription, - QUuid requestId) +void ResourceLocalStorageManagerAsyncTester::onExpungeResourceFailed( + Resource resource, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", Resource: ") << resource); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", Resource: " << resource); Q_EMIT failure(errorDescription.nonLocalizedString()); } diff -Nru libquentier-0.5.0/src/tests/local_storage/SavedSearchLocalStorageManagerAsyncTester.cpp libquentier-0.5.0/src/tests/local_storage/SavedSearchLocalStorageManagerAsyncTester.cpp --- libquentier-0.5.0/src/tests/local_storage/SavedSearchLocalStorageManagerAsyncTester.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/tests/local_storage/SavedSearchLocalStorageManagerAsyncTester.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -24,7 +24,8 @@ namespace quentier { namespace test { -SavedSearchLocalStorageManagerAsyncTester::SavedSearchLocalStorageManagerAsyncTester(QObject * parent) : +SavedSearchLocalStorageManagerAsyncTester::SavedSearchLocalStorageManagerAsyncTester( + QObject * parent) : QObject(parent), m_state(STATE_UNINITIALIZED), m_pLocalStorageManagerAsync(Q_NULLPTR), @@ -67,7 +68,8 @@ void SavedSearchLocalStorageManagerAsyncTester::initialize() { m_initialSavedSearch = SavedSearch(); - m_initialSavedSearch.setGuid(QStringLiteral("00000000-0000-0000-c000-000000000046")); + m_initialSavedSearch.setGuid( + QStringLiteral("00000000-0000-0000-c000-000000000046")); m_initialSavedSearch.setUpdateSequenceNumber(1); m_initialSavedSearch.setName(QStringLiteral("Fake saved search name")); m_initialSavedSearch.setQuery(QStringLiteral("Fake saved search query")); @@ -78,8 +80,8 @@ ErrorString errorDescription; if (!m_initialSavedSearch.checkParameters(errorDescription)) { - QNWARNING(QStringLiteral("Found invalid SavedSearch: ") - << m_initialSavedSearch << QStringLiteral(", error: ") + QNWARNING("Found invalid SavedSearch: " + << m_initialSavedSearch << ", error: " << errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -96,15 +98,16 @@ ErrorString errorDescription; -#define HANDLE_WRONG_STATE() \ - else \ - { \ - errorDescription.setBase("Internal error in "\ - "SavedSearchLocalStorageManagerAsyncTester: "\ - "found wrong state"); \ - Q_EMIT failure(errorDescription.nonLocalizedString()); \ - return; \ - } +#define HANDLE_WRONG_STATE() \ + else \ + { \ + errorDescription.setBase("Internal error in " \ + "SavedSearchLocalStorageManagerAsyncTester: " \ + "found wrong state"); \ + Q_EMIT failure(errorDescription.nonLocalizedString()); \ + return; \ + } \ +// HANDLE_WRONG_STATE if (m_state == STATE_SENT_GET_COUNT_AFTER_UPDATE_REQUEST) { @@ -118,7 +121,8 @@ } m_state = STATE_SENT_EXPUNGE_REQUEST; - Q_EMIT expungeSavedSearchRequest(m_modifiedSavedSearch, QUuid::createUuid()); + Q_EMIT expungeSavedSearchRequest(m_modifiedSavedSearch, + QUuid::createUuid()); } else if (m_state == STATE_SENT_GET_COUNT_AFTER_EXPUNGE_REQUEST) { @@ -131,10 +135,12 @@ } SavedSearch extraSavedSearch; - extraSavedSearch.setGuid(QStringLiteral("00000000-0000-0000-c000-000000000001")); + extraSavedSearch.setGuid( + QStringLiteral("00000000-0000-0000-c000-000000000001")); extraSavedSearch.setUpdateSequenceNumber(1); extraSavedSearch.setName(QStringLiteral("Extra SavedSearch")); - extraSavedSearch.setQuery(QStringLiteral("Fake extra saved search query")); + extraSavedSearch.setQuery( + QStringLiteral("Fake extra saved search query")); extraSavedSearch.setQueryFormat(1); extraSavedSearch.setIncludeAccount(true); extraSavedSearch.setIncludeBusinessLinkedNotebooks(true); @@ -149,7 +155,7 @@ void SavedSearchLocalStorageManagerAsyncTester::onGetSavedSearchCountFailed( ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId); + QNWARNING(errorDescription << ", requestId = " << requestId); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -184,10 +190,12 @@ m_initialSavedSearches << search; SavedSearch extraSavedSearch; - extraSavedSearch.setGuid(QStringLiteral("00000000-0000-0000-c000-000000000002")); + extraSavedSearch.setGuid( + QStringLiteral("00000000-0000-0000-c000-000000000002")); extraSavedSearch.setUpdateSequenceNumber(2); extraSavedSearch.setName(QStringLiteral("Extra SavedSearch two")); - extraSavedSearch.setQuery(QStringLiteral("Fake extra saved search query two")); + extraSavedSearch.setQuery( + QStringLiteral("Fake extra saved search query two")); extraSavedSearch.setQueryFormat(1); extraSavedSearch.setIncludeAccount(true); extraSavedSearch.setIncludeBusinessLinkedNotebooks(false); @@ -215,8 +223,8 @@ void SavedSearchLocalStorageManagerAsyncTester::onAddSavedSearchFailed( SavedSearch search, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", saved search: ") << search); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", saved search: " << search); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -233,8 +241,9 @@ { errorDescription.setBase("Internal error in " "SavedSearchLocalStorageManagerAsyncTester: " - "search in onUpdateSavedSearchCompleted slot " - "doesn't match the original modified SavedSearch"); + "search in onUpdateSavedSearchCompleted " + "slot doesn't match the original modified " + "SavedSearch"); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -252,8 +261,8 @@ void SavedSearchLocalStorageManagerAsyncTester::onUpdateSavedSearchFailed( SavedSearch search, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", saved search: ") << search); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", saved search: " << search); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -268,12 +277,12 @@ { if (search != m_initialSavedSearch) { - errorDescription.setBase("Added and found saved searches in the local " - "storage don't match"); + errorDescription.setBase("Added and found saved searches in " + "the local storage don't match"); QNWARNING(errorDescription - << QStringLiteral(": SavedSearch added to the local storage: ") + << ": SavedSearch added to the local storage: " << m_initialSavedSearch - << QStringLiteral("\nSavedSearch found in the local storage: ") + << "\nSavedSearch found in the local storage: " << search); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -293,9 +302,9 @@ errorDescription.setBase("Added and found by name saved searches " "in the local storage don't match"); QNWARNING(errorDescription - << QStringLiteral(": SavedSearch added to the local storage: ") + << ": SavedSearch added to the local storage: " << m_initialSavedSearch - << QStringLiteral("\nSavedSearch found by name in the local storage: ") + << "\nSavedSearch found by name in the local storage: " << search); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -311,7 +320,8 @@ m_initialSavedSearch.query() + QStringLiteral("_modified")); m_state = STATE_SENT_UPDATE_REQUEST; - Q_EMIT updateSavedSearchRequest(m_modifiedSavedSearch, QUuid::createUuid()); + Q_EMIT updateSavedSearchRequest(m_modifiedSavedSearch, + QUuid::createUuid()); } else if (m_state == STATE_SENT_FIND_AFTER_UPDATE_REQUEST) { @@ -319,9 +329,9 @@ errorDescription.setBase("Updated and found saved searches " "in the local storage don't match"); QNWARNING(errorDescription - << QStringLiteral(": SavedSearch updated in the local storage: ") + << ": SavedSearch updated in the local storage: " << m_modifiedSavedSearch - << QStringLiteral("\nSavedSearch found in the local storage: ") + << "\nSavedSearch found in the local storage: " << search); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -335,9 +345,9 @@ errorDescription.setBase("Error: found saved search which should have " "been expunged from the local storage"); QNWARNING(errorDescription - << QStringLiteral(": SavedSearch expunged from the local storage: ") + << ": SavedSearch expunged from the local storage: " << m_modifiedSavedSearch - << QStringLiteral("\nSavedSearch found in the local storage: ") + << "\nSavedSearch found in the local storage: " << search); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -354,8 +364,8 @@ return; } - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", saved search: ") << search); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", saved search: " << search); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -377,8 +387,9 @@ ErrorString errorDescription; if (numInitialSearches != numFoundSearches) { - errorDescription.setBase("Number of found saved searches does not correspond " - "to the number of original added saved searches"); + errorDescription.setBase("Number of found saved searches does not " + "correspond to the number of original added " + "saved searches"); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -410,7 +421,7 @@ Q_UNUSED(order) Q_UNUSED(orderDirection) - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId); + QNWARNING(errorDescription << ", requestId = " << requestId); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -424,8 +435,9 @@ errorDescription.setBase("Internal error in " "SavedSearchLocalStorageManagerAsyncTester: " "search in onExpungeSavedSearchCompleted slot " - "doesn't match the original expunged SavedSearch"); - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId); + "doesn't match the original expunged " + "SavedSearch"); + QNWARNING(errorDescription << ", requestId = " << requestId); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } @@ -440,8 +452,8 @@ void SavedSearchLocalStorageManagerAsyncTester::onExpungeSavedSearchFailed( SavedSearch search, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", saved search: ") << search); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", saved search: " << search); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -453,15 +465,16 @@ QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync,initialized), this, - QNSLOT(SavedSearchLocalStorageManagerAsyncTester,initialize)); + QNSLOT(SavedSearchLocalStorageManagerAsyncTester, + initialize)); // Request --> slot connections QObject::connect(this, QNSIGNAL(SavedSearchLocalStorageManagerAsyncTester, getSavedSearchCountRequest,QUuid), m_pLocalStorageManagerAsync, - QNSLOT(LocalStorageManagerAsync,onGetSavedSearchCountRequest, - QUuid)); + QNSLOT(LocalStorageManagerAsync, + onGetSavedSearchCountRequest,QUuid)); QObject::connect(this, QNSIGNAL(SavedSearchLocalStorageManagerAsyncTester, addSavedSearchRequest,SavedSearch,QUuid), @@ -486,16 +499,16 @@ LocalStorageManager::ListSavedSearchesOrder::type, LocalStorageManager::OrderDirection::type,QUuid), m_pLocalStorageManagerAsync, - QNSLOT(LocalStorageManagerAsync,onListAllSavedSearchesRequest, - size_t,size_t, + QNSLOT(LocalStorageManagerAsync, + onListAllSavedSearchesRequest,size_t,size_t, LocalStorageManager::ListSavedSearchesOrder::type, LocalStorageManager::OrderDirection::type,QUuid)); QObject::connect(this, QNSIGNAL(SavedSearchLocalStorageManagerAsyncTester, expungeSavedSearchRequest,SavedSearch,QUuid), m_pLocalStorageManagerAsync, - QNSLOT(LocalStorageManagerAsync,onExpungeSavedSearchRequest, - SavedSearch,QUuid)); + QNSLOT(LocalStorageManagerAsync, + onExpungeSavedSearchRequest,SavedSearch,QUuid)); // Slot <-- result connections QObject::connect(m_pLocalStorageManagerAsync, @@ -505,8 +518,8 @@ QNSLOT(SavedSearchLocalStorageManagerAsyncTester, onGetSavedSearchCountCompleted,int,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, - QNSIGNAL(LocalStorageManagerAsync,getSavedSearchCountFailed, - ErrorString,QUuid), + QNSIGNAL(LocalStorageManagerAsync, + getSavedSearchCountFailed,ErrorString,QUuid), this, QNSLOT(SavedSearchLocalStorageManagerAsyncTester, onGetSavedSearchCountFailed,ErrorString,QUuid)); @@ -521,10 +534,11 @@ SavedSearch,ErrorString,QUuid), this, QNSLOT(SavedSearchLocalStorageManagerAsyncTester, - onAddSavedSearchFailed,SavedSearch,ErrorString,QUuid)); + onAddSavedSearchFailed,SavedSearch, + ErrorString,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, - QNSIGNAL(LocalStorageManagerAsync,updateSavedSearchComplete, - SavedSearch,QUuid), + QNSIGNAL(LocalStorageManagerAsync, + updateSavedSearchComplete,SavedSearch,QUuid), this, QNSLOT(SavedSearchLocalStorageManagerAsyncTester, onUpdateSavedSearchCompleted,SavedSearch,QUuid)); @@ -533,7 +547,8 @@ SavedSearch,ErrorString,QUuid), this, QNSLOT(SavedSearchLocalStorageManagerAsyncTester, - onUpdateSavedSearchFailed,SavedSearch,ErrorString,QUuid)); + onUpdateSavedSearchFailed,SavedSearch, + ErrorString,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync,findSavedSearchComplete, SavedSearch,QUuid), @@ -545,10 +560,11 @@ SavedSearch,ErrorString,QUuid), this, QNSLOT(SavedSearchLocalStorageManagerAsyncTester, - onFindSavedSearchFailed,SavedSearch,ErrorString,QUuid)); + onFindSavedSearchFailed,SavedSearch, + ErrorString,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, - QNSIGNAL(LocalStorageManagerAsync,listAllSavedSearchesComplete, - size_t,size_t, + QNSIGNAL(LocalStorageManagerAsync, + listAllSavedSearchesComplete,size_t,size_t, LocalStorageManager::ListSavedSearchesOrder::type, LocalStorageManager::OrderDirection::type, QList<SavedSearch>,QUuid), @@ -559,8 +575,8 @@ LocalStorageManager::OrderDirection::type, QList<SavedSearch>,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, - QNSIGNAL(LocalStorageManagerAsync,listAllSavedSearchesFailed, - size_t,size_t, + QNSIGNAL(LocalStorageManagerAsync, + listAllSavedSearchesFailed,size_t,size_t, LocalStorageManager::ListSavedSearchesOrder::type, LocalStorageManager::OrderDirection::type, ErrorString,QUuid), @@ -571,8 +587,8 @@ LocalStorageManager::OrderDirection::type, ErrorString,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, - QNSIGNAL(LocalStorageManagerAsync,expungeSavedSearchComplete, - SavedSearch,QUuid), + QNSIGNAL(LocalStorageManagerAsync, + expungeSavedSearchComplete,SavedSearch,QUuid), this, QNSLOT(SavedSearchLocalStorageManagerAsyncTester, onExpungeSavedSearchCompleted,SavedSearch,QUuid)); diff -Nru libquentier-0.5.0/src/tests/local_storage/TagLocalStorageManagerAsyncTester.cpp libquentier-0.5.0/src/tests/local_storage/TagLocalStorageManagerAsyncTester.cpp --- libquentier-0.5.0/src/tests/local_storage/TagLocalStorageManagerAsyncTester.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/tests/local_storage/TagLocalStorageManagerAsyncTester.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -24,7 +24,8 @@ namespace quentier { namespace test { -TagLocalStorageManagerAsyncTester::TagLocalStorageManagerAsyncTester(QObject * parent) : +TagLocalStorageManagerAsyncTester::TagLocalStorageManagerAsyncTester( + QObject * parent) : QObject(parent), m_state(STATE_UNINITIALIZED), m_pLocalStorageManagerAsync(Q_NULLPTR), @@ -73,8 +74,8 @@ ErrorString errorDescription; if (!m_initialTag.checkParameters(errorDescription)) { - QNWARNING(QStringLiteral("Found invalid Tag: ") << m_initialTag - << QStringLiteral(", error: ") << errorDescription); + QNWARNING("Found invalid Tag: " << m_initialTag + << ", error: " << errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } @@ -83,22 +84,23 @@ Q_EMIT addTagRequest(m_initialTag, QUuid::createUuid()); } -void TagLocalStorageManagerAsyncTester::onGetTagCountCompleted(int count, - QUuid requestId) +void TagLocalStorageManagerAsyncTester::onGetTagCountCompleted( + int count, QUuid requestId) { Q_UNUSED(requestId) ErrorString errorDescription; -#define HANDLE_WRONG_STATE() \ - else \ - { \ - errorDescription.setBase("Internal error in "\ - "TagLocalStorageManagerAsyncTester: "\ - "found wrong state"); \ - Q_EMIT failure(errorDescription.nonLocalizedString()); \ - return; \ - } +#define HANDLE_WRONG_STATE() \ + else \ + { \ + errorDescription.setBase("Internal error in " \ + "TagLocalStorageManagerAsyncTester: " \ + "found wrong state"); \ + Q_EMIT failure(errorDescription.nonLocalizedString()); \ + return; \ + } \ +// HANDLE_WRONG_STATE if (m_state == STATE_SENT_GET_COUNT_AFTER_UPDATE_REQUEST) { @@ -139,10 +141,10 @@ HANDLE_WRONG_STATE(); } -void TagLocalStorageManagerAsyncTester::onGetTagCountFailed(ErrorString errorDescription, - QUuid requestId) +void TagLocalStorageManagerAsyncTester::onGetTagCountFailed( + ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId); + QNWARNING(errorDescription << ", requestId = " << requestId); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -201,17 +203,16 @@ HANDLE_WRONG_STATE(); } -void TagLocalStorageManagerAsyncTester::onAddTagFailed(Tag tag, - ErrorString errorDescription, - QUuid requestId) +void TagLocalStorageManagerAsyncTester::onAddTagFailed( + Tag tag, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", request id = ") << requestId - << QStringLiteral(", tag: ") << tag); + QNWARNING(errorDescription << ", request id = " << requestId + << ", tag: " << tag); Q_EMIT failure(errorDescription.nonLocalizedString()); } -void TagLocalStorageManagerAsyncTester::onUpdateTagCompleted(Tag tag, - QUuid requestId) +void TagLocalStorageManagerAsyncTester::onUpdateTagCompleted( + Tag tag, QUuid requestId) { Q_UNUSED(requestId) @@ -219,10 +220,12 @@ if (m_state == STATE_SENT_UPDATE_REQUEST) { - if (m_modifiedTag != tag) { - errorDescription.setBase("Internal error in TagLocalStorageManagerAsyncTester: " - "tag in onUpdateTagCompleted slot doesn't match " - "the original modified Tag"); + if (m_modifiedTag != tag) + { + errorDescription.setBase("Internal error in " + "TagLocalStorageManagerAsyncTester: " + "tag in onUpdateTagCompleted slot doesn't " + "match the original modified Tag"); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -234,12 +237,11 @@ HANDLE_WRONG_STATE(); } -void TagLocalStorageManagerAsyncTester::onUpdateTagFailed(Tag tag, - ErrorString errorDescription, - QUuid requestId) +void TagLocalStorageManagerAsyncTester::onUpdateTagFailed( + Tag tag, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", tag: ") << tag); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", tag: " << tag); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -255,10 +257,8 @@ { errorDescription.setBase("Added and found tags in the local storage " "don't match"); - QNWARNING(errorDescription - << QStringLiteral(": Tag added to the local storage: ") - << m_initialTag - << QStringLiteral("\nTag found in the local storage: ") + QNWARNING(errorDescription << ": Tag added to the local storage: " + << m_initialTag << "\nTag found in the local storage: " << m_foundTag); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -278,10 +278,8 @@ { errorDescription.setBase("Added and found by name tags in the local " "storage don't match"); - QNWARNING(errorDescription - << QStringLiteral(": Tag added to the local storage: ") - << m_initialTag - << QStringLiteral("\nTag found in the local storage: ") + QNWARNING(errorDescription << ": Tag added to the local storage: " + << m_initialTag << "\nTag found in the local storage: " << m_foundTag); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -289,7 +287,8 @@ // Ok, found tag is good, updating it now m_modifiedTag = m_initialTag; - m_modifiedTag.setUpdateSequenceNumber(m_initialTag.updateSequenceNumber() + 1); + m_modifiedTag.setUpdateSequenceNumber( + m_initialTag.updateSequenceNumber() + 1); m_modifiedTag.setName(m_initialTag.name() + QStringLiteral("_modified")); m_state = STATE_SENT_UPDATE_REQUEST; @@ -301,10 +300,8 @@ { errorDescription.setBase("Updated and found tags in the local " "storage don't match"); - QNWARNING(errorDescription - << QStringLiteral(": Tag updated in the local storage: ") - << m_modifiedTag - << QStringLiteral("\nTag found in the local storage: ") + QNWARNING(errorDescription << ": Tag updated in the local storage: " + << m_modifiedTag << "\nTag found in the local storage: " << m_foundTag); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -317,10 +314,8 @@ { errorDescription.setBase("Found tag which should have been expunged " "from the local storage"); - QNWARNING(errorDescription - << QStringLiteral(": Tag expunged from the local storage: ") - << m_modifiedTag - << QStringLiteral("\nTag found in the local storage: ") + QNWARNING(errorDescription << ": Tag expunged from the local storage: " + << m_modifiedTag << "\nTag found in the local storage: " << m_foundTag); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -328,9 +323,8 @@ HANDLE_WRONG_STATE(); } -void TagLocalStorageManagerAsyncTester::onFindTagFailed(Tag tag, - ErrorString errorDescription, - QUuid requestId) +void TagLocalStorageManagerAsyncTester::onFindTagFailed( + Tag tag, ErrorString errorDescription, QUuid requestId) { if (m_state == STATE_SENT_FIND_AFTER_EXPUNGE_REQUEST) { m_state = STATE_SENT_GET_COUNT_AFTER_EXPUNGE_REQUEST; @@ -338,8 +332,8 @@ return; } - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", tag: ") << tag); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", tag: " << tag); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -362,8 +356,9 @@ ErrorString errorDescription; if (numInitialTags != numFoundTags) { - errorDescription.setBase("Error: number of found tags does not correspond " - "to the number of original added tags"); + errorDescription.setBase("Error: number of found tags does not " + "correspond to the number of original added " + "tags"); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -372,7 +367,8 @@ foreach(const Tag & tag, m_initialTags) { if (!tags.contains(tag)) { - errorDescription.setBase("One of initial tags was not found within found tags"); + errorDescription.setBase("One of initial tags was not found within " + "found tags"); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -394,23 +390,24 @@ Q_UNUSED(orderDirection) Q_UNUSED(linkedNotebookGuid) - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId); + QNWARNING(errorDescription << ", requestId = " << requestId); Q_EMIT failure(errorDescription.nonLocalizedString()); } -void TagLocalStorageManagerAsyncTester::onExpungeTagCompleted(Tag tag, - QStringList expungedChildTagLocalUids, - QUuid requestId) +void TagLocalStorageManagerAsyncTester::onExpungeTagCompleted( + Tag tag, QStringList expungedChildTagLocalUids, QUuid requestId) { Q_UNUSED(requestId) Q_UNUSED(expungedChildTagLocalUids) ErrorString errorDescription; - if (m_modifiedTag != tag) { - errorDescription.setBase("Internal error in TagLocalStorageManagerAsyncTester: " - "tag in onExpungeTagCompleted slot doesn't match " - "the original expunged Tag"); + if (m_modifiedTag != tag) + { + errorDescription.setBase("Internal error in " + "TagLocalStorageManagerAsyncTester: " + "tag in onExpungeTagCompleted slot doesn't " + "match the original expunged Tag"); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; @@ -420,12 +417,11 @@ Q_EMIT findTagRequest(m_foundTag, QUuid::createUuid()); } -void TagLocalStorageManagerAsyncTester::onExpungeTagFailed(Tag tag, - ErrorString errorDescription, - QUuid requestId) +void TagLocalStorageManagerAsyncTester::onExpungeTagFailed( + Tag tag, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", tag: ") << tag); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", tag: " << tag); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -441,54 +437,61 @@ // Request --> slot connections QObject::connect(this, - QNSIGNAL(TagLocalStorageManagerAsyncTester,getTagCountRequest, - QUuid), + QNSIGNAL(TagLocalStorageManagerAsyncTester, + getTagCountRequest,QUuid), m_pLocalStorageManagerAsync, - QNSLOT(LocalStorageManagerAsync,onGetTagCountRequest,QUuid)); + QNSLOT(LocalStorageManagerAsync, + onGetTagCountRequest,QUuid)); QObject::connect(this, QNSIGNAL(TagLocalStorageManagerAsyncTester,addTagRequest, Tag,QUuid), m_pLocalStorageManagerAsync, - QNSLOT(LocalStorageManagerAsync,onAddTagRequest,Tag,QUuid)); + QNSLOT(LocalStorageManagerAsync, + onAddTagRequest,Tag,QUuid)); QObject::connect(this, - QNSIGNAL(TagLocalStorageManagerAsyncTester,updateTagRequest, - Tag,QUuid), + QNSIGNAL(TagLocalStorageManagerAsyncTester, + updateTagRequest,Tag,QUuid), m_pLocalStorageManagerAsync, - QNSLOT(LocalStorageManagerAsync,onUpdateTagRequest,Tag,QUuid)); + QNSLOT(LocalStorageManagerAsync, + onUpdateTagRequest,Tag,QUuid)); QObject::connect(this, QNSIGNAL(TagLocalStorageManagerAsyncTester,findTagRequest, Tag,QUuid), m_pLocalStorageManagerAsync, QNSLOT(LocalStorageManagerAsync,onFindTagRequest,Tag,QUuid)); QObject::connect(this, - QNSIGNAL(TagLocalStorageManagerAsyncTester,listAllTagsRequest, + QNSIGNAL(TagLocalStorageManagerAsyncTester, + listAllTagsRequest, size_t,size_t, LocalStorageManager::ListTagsOrder::type, LocalStorageManager::OrderDirection::type, QString,QUuid), m_pLocalStorageManagerAsync, QNSLOT(LocalStorageManagerAsync,onListAllTagsRequest, - size_t,size_t,LocalStorageManager::ListTagsOrder::type, - LocalStorageManager::OrderDirection::type,QString,QUuid)); + size_t,size_t, + LocalStorageManager::ListTagsOrder::type, + LocalStorageManager::OrderDirection::type, + QString,QUuid)); QObject::connect(this, - QNSIGNAL(TagLocalStorageManagerAsyncTester,expungeTagRequest, - Tag,QUuid), + QNSIGNAL(TagLocalStorageManagerAsyncTester, + expungeTagRequest,Tag,QUuid), m_pLocalStorageManagerAsync, - QNSLOT(LocalStorageManagerAsync,onExpungeTagRequest,Tag,QUuid)); + QNSLOT(LocalStorageManagerAsync,onExpungeTagRequest, + Tag,QUuid)); // Slot <-- result connections QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync,getTagCountComplete, int,QUuid), this, - QNSLOT(TagLocalStorageManagerAsyncTester,onGetTagCountCompleted, - int,QUuid)); + QNSLOT(TagLocalStorageManagerAsyncTester, + onGetTagCountCompleted,int,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync,getTagCountFailed, ErrorString,QUuid), this, - QNSLOT(TagLocalStorageManagerAsyncTester,onGetTagCountFailed, - ErrorString,QUuid)); + QNSLOT(TagLocalStorageManagerAsyncTester, + onGetTagCountFailed,ErrorString,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync,addTagComplete,Tag,QUuid), this, @@ -501,10 +504,11 @@ QNSLOT(TagLocalStorageManagerAsyncTester,onAddTagFailed, Tag,ErrorString,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, - QNSIGNAL(LocalStorageManagerAsync,updateTagComplete,Tag,QUuid), + QNSIGNAL(LocalStorageManagerAsync,updateTagComplete, + Tag,QUuid), this, - QNSLOT(TagLocalStorageManagerAsyncTester,onUpdateTagCompleted, - Tag,QUuid)); + QNSLOT(TagLocalStorageManagerAsyncTester, + onUpdateTagCompleted,Tag,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync,updateTagFailed, Tag,ErrorString,QUuid), @@ -524,35 +528,43 @@ Tag,ErrorString,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync,listAllTagsComplete, - size_t,size_t,LocalStorageManager::ListTagsOrder::type, + size_t,size_t, + LocalStorageManager::ListTagsOrder::type, LocalStorageManager::OrderDirection::type,QString, QList<Tag>,QUuid), this, - QNSLOT(TagLocalStorageManagerAsyncTester,onListAllTagsCompleted, - size_t,size_t,LocalStorageManager::ListTagsOrder::type, + QNSLOT(TagLocalStorageManagerAsyncTester, + onListAllTagsCompleted, + size_t,size_t, + LocalStorageManager::ListTagsOrder::type, LocalStorageManager::OrderDirection::type,QString, QList<Tag>,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync,listAllTagsFailed, - size_t,size_t,LocalStorageManager::ListTagsOrder::type, + size_t,size_t, + LocalStorageManager::ListTagsOrder::type, LocalStorageManager::OrderDirection::type, QString,ErrorString,QUuid), this, - QNSLOT(TagLocalStorageManagerAsyncTester,onListAllTagsFailed, - size_t,size_t,LocalStorageManager::ListTagsOrder::type, + QNSLOT(TagLocalStorageManagerAsyncTester, + onListAllTagsFailed, + size_t,size_t, + LocalStorageManager::ListTagsOrder::type, LocalStorageManager::OrderDirection::type, QString,ErrorString,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync,expungeTagComplete, Tag,QStringList,QUuid), this, - QNSLOT(TagLocalStorageManagerAsyncTester,onExpungeTagCompleted, + QNSLOT(TagLocalStorageManagerAsyncTester, + onExpungeTagCompleted, Tag,QStringList,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync,expungeTagFailed, Tag,ErrorString,QUuid), this, - QNSLOT(TagLocalStorageManagerAsyncTester,onExpungeTagFailed, + QNSLOT(TagLocalStorageManagerAsyncTester, + onExpungeTagFailed, Tag,ErrorString,QUuid)); } diff -Nru libquentier-0.5.0/src/tests/local_storage/UserLocalStorageManagerAsyncTester.cpp libquentier-0.5.0/src/tests/local_storage/UserLocalStorageManagerAsyncTester.cpp --- libquentier-0.5.0/src/tests/local_storage/UserLocalStorageManagerAsyncTester.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/tests/local_storage/UserLocalStorageManagerAsyncTester.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -24,7 +24,8 @@ namespace quentier { namespace test { -UserLocalStorageManagerAsyncTester::UserLocalStorageManagerAsyncTester(QObject * parent) : +UserLocalStorageManagerAsyncTester::UserLocalStorageManagerAsyncTester( + QObject * parent) : QObject(parent), m_state(STATE_UNINITIALIZED), m_pLocalStorageManagerAsync(Q_NULLPTR), @@ -77,8 +78,8 @@ ErrorString errorDescription; if (!m_initialUser.checkParameters(errorDescription)) { - QNWARNING(QStringLiteral("Found invalid user: ") << m_initialUser - << QStringLiteral(", error: ") << errorDescription); + QNWARNING("Found invalid user: " << m_initialUser + << ", error: " << errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } @@ -87,20 +88,22 @@ Q_EMIT addUserRequest(m_initialUser, QUuid::createUuid()); } -void UserLocalStorageManagerAsyncTester::onGetUserCountCompleted(int count, - QUuid requestId) +void UserLocalStorageManagerAsyncTester::onGetUserCountCompleted( + int count, QUuid requestId) { Q_UNUSED(requestId) ErrorString errorDescription; -#define HANDLE_WRONG_STATE() \ - else \ - { \ - errorDescription.setBase("Internal error in UserLocalStorageManagerAsyncTester: "\ - "found wrong state"); \ - Q_EMIT failure(errorDescription.nonLocalizedString()); \ - } +#define HANDLE_WRONG_STATE() \ + else \ + { \ + errorDescription.setBase("Internal error in " \ + "UserLocalStorageManagerAsyncTester: " \ + "found wrong state"); \ + Q_EMIT failure(errorDescription.nonLocalizedString()); \ + } \ +// HANDLE_WRONG_STATE if (m_state == STATE_SENT_GET_COUNT_AFTER_UPDATE_REQUEST) { @@ -134,14 +137,15 @@ HANDLE_WRONG_STATE(); } -void UserLocalStorageManagerAsyncTester::onGetUserCountFailed(ErrorString errorDescription, - QUuid requestId) +void UserLocalStorageManagerAsyncTester::onGetUserCountFailed( + ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId); + QNWARNING(errorDescription << ", requestId = " << requestId); Q_EMIT failure(errorDescription.nonLocalizedString()); } -void UserLocalStorageManagerAsyncTester::onAddUserCompleted(User user, QUuid requestId) +void UserLocalStorageManagerAsyncTester::onAddUserCompleted( + User user, QUuid requestId) { Q_UNUSED(requestId) @@ -169,17 +173,16 @@ HANDLE_WRONG_STATE(); } -void UserLocalStorageManagerAsyncTester::onAddUserFailed(User user, - ErrorString errorDescription, - QUuid requestId) +void UserLocalStorageManagerAsyncTester::onAddUserFailed( + User user, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", user: ") << user); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", user: " << user); Q_EMIT failure(errorDescription.nonLocalizedString()); } -void UserLocalStorageManagerAsyncTester::onUpdateUserCompleted(User user, - QUuid requestId) +void UserLocalStorageManagerAsyncTester::onUpdateUserCompleted( + User user, QUuid requestId) { Q_UNUSED(requestId) @@ -204,17 +207,16 @@ HANDLE_WRONG_STATE(); } -void UserLocalStorageManagerAsyncTester::onUpdateUserFailed(User user, - ErrorString errorDescription, - QUuid requestId) +void UserLocalStorageManagerAsyncTester::onUpdateUserFailed( + User user, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", user: ") << user); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", user: " << user); Q_EMIT failure(errorDescription.nonLocalizedString()); } -void UserLocalStorageManagerAsyncTester::onFindUserCompleted(User user, - QUuid requestId) +void UserLocalStorageManagerAsyncTester::onFindUserCompleted( + User user, QUuid requestId) { Q_UNUSED(requestId) @@ -224,21 +226,21 @@ { if (user != m_initialUser) { - errorDescription.setBase("Added and found users in the local storage " - "don't match"); - QNWARNING(errorDescription - << QStringLiteral(": User added to the local storage: ") + errorDescription.setBase("Added and found users in " + "the local storage don't match"); + QNWARNING(errorDescription << ": User added to the local storage: " << m_initialUser - << QStringLiteral("\nUserWrapper found in the local storage: ") - << user); + << "\nUserWrapper found in the local storage: " << user); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } // Ok, found user is good, updating it now m_modifiedUser = m_initialUser; - m_modifiedUser.setUsername(m_initialUser.username() + QStringLiteral("_modified")); - m_modifiedUser.setName(m_initialUser.name() + QStringLiteral("_modified")); + m_modifiedUser.setUsername( + m_initialUser.username() + QStringLiteral("_modified")); + m_modifiedUser.setName( + m_initialUser.name() + QStringLiteral("_modified")); m_state = STATE_SENT_UPDATE_REQUEST; Q_EMIT updateUserRequest(m_modifiedUser, QUuid::createUuid()); @@ -249,11 +251,9 @@ { errorDescription.setBase("Updated and found users in the local " "storage don't match"); - QNWARNING(errorDescription - << QStringLiteral(": User updated in the local storage: ") + QNWARNING(errorDescription << ": User updated in the local storage: " << m_modifiedUser - << QStringLiteral("\nUserWrapper found in the local storage: ") - << user); + << "\nUserWrapper found in the local storage: " << user); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } @@ -265,20 +265,17 @@ { errorDescription.setBase("Error: found user which should have been " "expunged from local storage"); - QNWARNING(errorDescription - << QStringLiteral(": User expunged from the local storage: ") + QNWARNING(errorDescription << ": User expunged from the local storage: " << m_modifiedUser - << QStringLiteral("\nUserWrapper found in the local storage: ") - << user); + << "\nUserWrapper found in the local storage: " << user); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } HANDLE_WRONG_STATE(); } -void UserLocalStorageManagerAsyncTester::onFindUserFailed(User user, - ErrorString errorDescription, - QUuid requestId) +void UserLocalStorageManagerAsyncTester::onFindUserFailed( + User user, ErrorString errorDescription, QUuid requestId) { if (m_state == STATE_SENT_FIND_AFTER_EXPUNGE_REQUEST) { m_state = STATE_SENT_GET_COUNT_AFTER_EXPUNGE_REQUEST; @@ -286,13 +283,13 @@ return; } - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", user: ") << user); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", user: " << user); Q_EMIT failure(errorDescription.nonLocalizedString()); } -void UserLocalStorageManagerAsyncTester::onDeleteUserCompleted(User user, - QUuid requestId) +void UserLocalStorageManagerAsyncTester::onDeleteUserCompleted( + User user, QUuid requestId) { Q_UNUSED(requestId) @@ -300,11 +297,12 @@ if (m_modifiedUser != user) { - errorDescription.setBase("Internal error in UserLocalStorageManagerAsyncTester: " - "user in onDeleteUserCompleted slot doesn't match " - "the original deleted User"); - QNWARNING(errorDescription << QStringLiteral("; original deleted user: ") - << m_modifiedUser << QStringLiteral(", user: ") << user); + errorDescription.setBase("Internal error in " + "UserLocalStorageManagerAsyncTester: " + "user in onDeleteUserCompleted slot doesn't " + "match the original deleted User"); + QNWARNING(errorDescription << "; original deleted user: " + << m_modifiedUser << ", user: " << user); Q_EMIT failure(errorDescription.nonLocalizedString()); return; } @@ -314,26 +312,26 @@ Q_EMIT expungeUserRequest(m_modifiedUser, QUuid::createUuid()); } -void UserLocalStorageManagerAsyncTester::onDeleteUserFailed(User user, - ErrorString errorDescription, - QUuid requestId) +void UserLocalStorageManagerAsyncTester::onDeleteUserFailed( + User user, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", user: ") << user); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", user: " << user); Q_EMIT failure(errorDescription.nonLocalizedString()); } -void UserLocalStorageManagerAsyncTester::onExpungeUserCompleted(User user, - QUuid requestId) +void UserLocalStorageManagerAsyncTester::onExpungeUserCompleted( + User user, QUuid requestId) { Q_UNUSED(requestId) ErrorString errorDescription; if (m_modifiedUser != user) { - errorDescription.setBase("Internal error in UserLocalStorageManagerAsyncTester: " - "user in onExpungeUserCompleted slot doesn't match " - "the original expunged User"); + errorDescription.setBase("Internal error in " + "UserLocalStorageManagerAsyncTester: " + "user in onExpungeUserCompleted slot doesn't " + "match the original expunged User"); QNWARNING(errorDescription); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -342,12 +340,11 @@ Q_EMIT findUserRequest(m_foundUser, QUuid::createUuid()); } -void UserLocalStorageManagerAsyncTester::onExpungeUserFailed(User user, - ErrorString errorDescription, - QUuid requestId) +void UserLocalStorageManagerAsyncTester::onExpungeUserFailed( + User user, ErrorString errorDescription, QUuid requestId) { - QNWARNING(errorDescription << QStringLiteral(", requestId = ") << requestId - << QStringLiteral(", user: ") << user); + QNWARNING(errorDescription << ", requestId = " << requestId + << ", user: " << user); Q_EMIT failure(errorDescription.nonLocalizedString()); } @@ -366,32 +363,38 @@ QNSIGNAL(UserLocalStorageManagerAsyncTester, getUserCountRequest,QUuid), m_pLocalStorageManagerAsync, - QNSLOT(LocalStorageManagerAsync,onGetUserCountRequest,QUuid)); + QNSLOT(LocalStorageManagerAsync, + onGetUserCountRequest,QUuid)); QObject::connect(this, QNSIGNAL(UserLocalStorageManagerAsyncTester, addUserRequest,User,QUuid), m_pLocalStorageManagerAsync, - QNSLOT(LocalStorageManagerAsync,onAddUserRequest,User,QUuid)); + QNSLOT(LocalStorageManagerAsync,onAddUserRequest, + User,QUuid)); QObject::connect(this, QNSIGNAL(UserLocalStorageManagerAsyncTester, updateUserRequest,User,QUuid), m_pLocalStorageManagerAsync, - QNSLOT(LocalStorageManagerAsync,onUpdateUserRequest,User,QUuid)); + QNSLOT(LocalStorageManagerAsync,onUpdateUserRequest, + User,QUuid)); QObject::connect(this, QNSIGNAL(UserLocalStorageManagerAsyncTester, findUserRequest,User,QUuid), m_pLocalStorageManagerAsync, - QNSLOT(LocalStorageManagerAsync,onFindUserRequest,User,QUuid)); + QNSLOT(LocalStorageManagerAsync,onFindUserRequest, + User,QUuid)); QObject::connect(this, QNSIGNAL(UserLocalStorageManagerAsyncTester, deleteUserRequest,User,QUuid), m_pLocalStorageManagerAsync, - QNSLOT(LocalStorageManagerAsync,onDeleteUserRequest,User,QUuid)); + QNSLOT(LocalStorageManagerAsync,onDeleteUserRequest, + User,QUuid)); QObject::connect(this, QNSIGNAL(UserLocalStorageManagerAsyncTester, expungeUserRequest,User,QUuid), m_pLocalStorageManagerAsync, - QNSLOT(LocalStorageManagerAsync,onExpungeUserRequest,User,QUuid)); + QNSLOT(LocalStorageManagerAsync,onExpungeUserRequest, + User,QUuid)); // Slot <-- result connections QObject::connect(m_pLocalStorageManagerAsync, @@ -404,13 +407,14 @@ QNSIGNAL(LocalStorageManagerAsync,getUserCountFailed, ErrorString,QUuid), this, - QNSLOT(UserLocalStorageManagerAsyncTester,onGetUserCountFailed, - ErrorString,QUuid)); + QNSLOT(UserLocalStorageManagerAsyncTester, + onGetUserCountFailed,ErrorString,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, - QNSIGNAL(LocalStorageManagerAsync,addUserComplete,User,QUuid), + QNSIGNAL(LocalStorageManagerAsync,addUserComplete, + User,QUuid), this, - QNSLOT(UserLocalStorageManagerAsyncTester,onAddUserCompleted, - User,QUuid)); + QNSLOT(UserLocalStorageManagerAsyncTester, + onAddUserCompleted,User,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync,addUserFailed, User,ErrorString,QUuid), @@ -427,10 +431,11 @@ QNSIGNAL(LocalStorageManagerAsync,updateUserFailed, User,ErrorString,QUuid), this, - QNSLOT(UserLocalStorageManagerAsyncTester,onUpdateUserFailed, - User,ErrorString,QUuid)); + QNSLOT(UserLocalStorageManagerAsyncTester, + onUpdateUserFailed,User,ErrorString,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, - QNSIGNAL(LocalStorageManagerAsync,findUserComplete,User,QUuid), + QNSIGNAL(LocalStorageManagerAsync,findUserComplete, + User,QUuid), this, QNSLOT(UserLocalStorageManagerAsyncTester, onFindUserCompleted,User,QUuid)); @@ -438,30 +443,32 @@ QNSIGNAL(LocalStorageManagerAsync,findUserFailed, User,ErrorString,QUuid), this, - QNSLOT(UserLocalStorageManagerAsyncTester,onFindUserFailed,User, - ErrorString,QUuid)); + QNSLOT(UserLocalStorageManagerAsyncTester,onFindUserFailed, + User,ErrorString,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, - QNSIGNAL(LocalStorageManagerAsync,deleteUserComplete,User,QUuid), + QNSIGNAL(LocalStorageManagerAsync,deleteUserComplete, + User,QUuid), this, - QNSLOT(UserLocalStorageManagerAsyncTester,onDeleteUserCompleted, - User,QUuid)); + QNSLOT(UserLocalStorageManagerAsyncTester, + onDeleteUserCompleted,User,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync,deleteUserFailed, User,ErrorString,QUuid), this, - QNSLOT(UserLocalStorageManagerAsyncTester,onDeleteUserFailed, - User,ErrorString,QUuid)); + QNSLOT(UserLocalStorageManagerAsyncTester, + onDeleteUserFailed,User,ErrorString,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, - QNSIGNAL(LocalStorageManagerAsync,expungeUserComplete,User,QUuid), + QNSIGNAL(LocalStorageManagerAsync,expungeUserComplete, + User,QUuid), this, - QNSLOT(UserLocalStorageManagerAsyncTester,onExpungeUserCompleted, - User,QUuid)); + QNSLOT(UserLocalStorageManagerAsyncTester, + onExpungeUserCompleted,User,QUuid)); QObject::connect(m_pLocalStorageManagerAsync, QNSIGNAL(LocalStorageManagerAsync,expungeUserFailed, User,ErrorString,QUuid), this, - QNSLOT(UserLocalStorageManagerAsyncTester,onExpungeUserFailed, - User,ErrorString,QUuid)); + QNSLOT(UserLocalStorageManagerAsyncTester, + onExpungeUserFailed,User,ErrorString,QUuid)); } void UserLocalStorageManagerAsyncTester::clear() diff -Nru libquentier-0.5.0/src/tests/synchronization/FakeNoteStore.cpp libquentier-0.5.0/src/tests/synchronization/FakeNoteStore.cpp --- libquentier-0.5.0/src/tests/synchronization/FakeNoteStore.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/tests/synchronization/FakeNoteStore.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -92,15 +92,16 @@ return result; } -bool FakeNoteStore::setSavedSearch(SavedSearch & search, ErrorString & errorDescription) +bool FakeNoteStore::setSavedSearch( + SavedSearch & search, ErrorString & errorDescription) { if (!search.hasGuid()) { - errorDescription.setBase(QStringLiteral("Can't set saved search without guid")); + errorDescription.setBase("Can't set saved search without guid"); return false; } if (!search.hasName()) { - errorDescription.setBase(QStringLiteral("Can't set saved search without name")); + errorDescription.setBase("Can't set saved search without name"); return false; } @@ -215,15 +216,15 @@ bool FakeNoteStore::setTag(Tag & tag, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("FakeNoteStore::setTag: tag = ") << tag); + QNDEBUG("FakeNoteStore::setTag: tag = " << tag); if (!tag.hasGuid()) { - errorDescription.setBase(QStringLiteral("Can't set tag without guid")); + errorDescription.setBase("Can't set tag without guid"); return false; } if (!tag.hasName()) { - errorDescription.setBase(QStringLiteral("Can't set tag without name")); + errorDescription.setBase("Can't set tag without name"); return false; } @@ -235,9 +236,9 @@ m_data->m_linkedNotebooks.get<LinkedNotebookByGuid>(); auto it = index.find(linkedNotebookGuid); if (it == index.end()) { - errorDescription.setBase(QStringLiteral("Can't set tag with linked " - "notebook guid corresponding " - "to no existing linked notebook")); + errorDescription.setBase("Can't set tag with linked " + "notebook guid corresponding " + "to no existing linked notebook"); return false; } } @@ -289,7 +290,7 @@ Q_UNUSED(tagGuidIndex.replace(tagIt, tag)) } - QNDEBUG(QStringLiteral("Tag with complemented fields: ") << tag); + QNDEBUG("Tag with complemented fields: " << tag); return true; } @@ -335,8 +336,8 @@ { tagIt = index.find(guid); if (Q_UNLIKELY(tagIt == index.end())) { - QNWARNING(QStringLiteral("Tag to be removed is not not found after ") - << QStringLiteral("the removal of its child tags: guid = ") + QNWARNING("Tag to be removed is not not found after " + << "the removal of its child tags: guid = " << guid); return false; } @@ -406,12 +407,12 @@ bool FakeNoteStore::setNotebook(Notebook & notebook, ErrorString & errorDescription) { if (!notebook.hasGuid()) { - errorDescription.setBase(QStringLiteral("Can't set notebook without guid")); + errorDescription.setBase("Can't set notebook without guid"); return false; } if (!notebook.hasName()) { - errorDescription.setBase(QStringLiteral("Can't set notebook without name")); + errorDescription.setBase("Can't set notebook without name"); return false; } @@ -423,10 +424,10 @@ m_data->m_linkedNotebooks.get<LinkedNotebookByGuid>(); auto it = index.find(linkedNotebookGuid); if (it == index.end()) { - errorDescription.setBase(QStringLiteral("Can't set notebook with " - "linked notebook guid " - "corresponding to no existing " - "linked notebook")); + errorDescription.setBase("Can't set notebook with " + "linked notebook guid " + "corresponding to no existing " + "linked notebook"); return false; } } @@ -577,12 +578,12 @@ bool FakeNoteStore::setNote(Note & note, ErrorString & errorDescription) { if (!note.hasGuid()) { - errorDescription.setBase(QStringLiteral("Can't set note without guid")); + errorDescription.setBase("Can't set note without guid"); return false; } if (!note.hasNotebookGuid()) { - errorDescription.setBase(QStringLiteral("Can't set note without notebook guid")); + errorDescription.setBase("Can't set note without notebook guid"); return false; } @@ -590,8 +591,8 @@ m_data->m_notebooks.get<NotebookByGuid>(); auto notebookIt = notebookGuidIndex.find(note.notebookGuid()); if (notebookIt == notebookGuidIndex.end()) { - errorDescription.setBase(QStringLiteral("Can't set note: no notebook " - "was found for it by guid")); + errorDescription.setBase("Can't set note: no notebook " + "was found for it by guid"); return false; } @@ -761,20 +762,20 @@ bool FakeNoteStore::setResource(Resource & resource, ErrorString & errorDescription) { if (!resource.hasGuid()) { - errorDescription.setBase(QStringLiteral("Can't set resource without guid")); + errorDescription.setBase("Can't set resource without guid"); return false; } if (!resource.hasNoteGuid()) { - errorDescription.setBase(QStringLiteral("Can't set resource without note guid")); + errorDescription.setBase("Can't set resource without note guid"); return false; } NoteDataByGuid & noteGuidIndex = m_data->m_notes.get<NoteByGuid>(); auto noteIt = noteGuidIndex.find(resource.noteGuid()); if (noteIt == noteGuidIndex.end()) { - errorDescription.setBase(QStringLiteral("Can't set resource: no note " - "was found for it by guid")); + errorDescription.setBase("Can't set resource: no note " + "was found for it by guid"); return false; } @@ -782,9 +783,9 @@ m_data->m_notebooks.get<NotebookByGuid>(); auto notebookIt = notebookGuidIndex.find(noteIt->notebookGuid()); if (notebookIt == notebookGuidIndex.end()) { - errorDescription.setBase(QStringLiteral("Can't set resource: no notebook " - "was found for resource's note " - "by notebook guid")); + errorDescription.setBase("Can't set resource: no notebook " + "was found for resource's note " + "by notebook guid"); return false; } @@ -857,8 +858,7 @@ Q_UNUSED(noteGuidIndex.replace(noteIt, note)) } else { - QNWARNING(QStringLiteral("Found no note corresponding to the removed resource: ") - << *it); + QNWARNING("Found no note corresponding to the removed resource: " << *it); } Q_UNUSED(index.erase(it)) @@ -885,20 +885,18 @@ ErrorString & errorDescription) { if (!linkedNotebook.hasGuid()) { - errorDescription.setBase(QStringLiteral("Can't set linked notebook " - "without guid")); + errorDescription.setBase("Can't set linked notebook without guid"); return false; } if (!linkedNotebook.hasUsername()) { - errorDescription.setBase(QStringLiteral("Can't set linked notebook " - "without username")); + errorDescription.setBase("Can't set linked notebook without username"); return false; } if (!linkedNotebook.hasShardId() && !linkedNotebook.hasUri()) { - errorDescription.setBase(QStringLiteral("Can't set linked notebook without " - "either shard id or uri")); + errorDescription.setBase("Can't set linked notebook without " + "either shard id or uri"); return false; } @@ -1079,11 +1077,11 @@ return Q_NULLPTR; } -void FakeNoteStore::setLinkedNotebookSyncState(const QString & linkedNotebookOwner, - const qevercloud::SyncState & syncState) +void FakeNoteStore::setLinkedNotebookSyncState( + const QString & linkedNotebookOwner, const qevercloud::SyncState & syncState) { - QNDEBUG(QStringLiteral("FakeNoteStore::setLinkedNotebookSyncState: linked notebook owner: ") - << linkedNotebookOwner << QStringLiteral(", sync state: ") << syncState); + QNDEBUG("FakeNoteStore::setLinkedNotebookSyncState: linked notebook owner: " + << linkedNotebookOwner << ", sync state: " << syncState); m_data->m_linkedNotebookSyncStates[linkedNotebookOwner] = syncState; } @@ -1105,7 +1103,7 @@ void FakeNoteStore::setAuthToken(const QString & authToken) { - QNDEBUG(QStringLiteral("FakeNoteStore::setAuthToken: ") << authToken); + QNDEBUG("FakeNoteStore::setAuthToken: " << authToken); m_data->m_authenticationToken = authToken; } @@ -1119,11 +1117,11 @@ return QString(); } -void FakeNoteStore::setLinkedNotebookAuthToken(const QString & linkedNotebookOwner, - const QString & linkedNotebookAuthToken) +void FakeNoteStore::setLinkedNotebookAuthToken( + const QString & linkedNotebookOwner, const QString & linkedNotebookAuthToken) { - QNDEBUG(QStringLiteral("FakeNoteStore::setLinkedNotebookAuthToken: owner = ") - << linkedNotebookOwner << QStringLiteral(", token = ") + QNDEBUG("FakeNoteStore::setLinkedNotebookAuthToken: owner = " + << linkedNotebookOwner << ", token = " << linkedNotebookAuthToken); m_data->m_linkedNotebookAuthTokens[linkedNotebookOwner] = linkedNotebookAuthToken; } @@ -1141,7 +1139,7 @@ qint32 FakeNoteStore::currentMaxUsn(const QString & linkedNotebookGuid) const { - QNDEBUG(QStringLiteral("FakeNoteStore::currentMaxUsn: linked notebook guid = ") + QNDEBUG("FakeNoteStore::currentMaxUsn: linked notebook guid = " << linkedNotebookGuid); qint32 maxUsn = 0; @@ -1152,11 +1150,11 @@ { auto lastSavedSearchIt = savedSearchUsnIndex.end(); --lastSavedSearchIt; - QNTRACE(QStringLiteral("Examing saved search ") << *lastSavedSearchIt); + QNTRACE("Examing saved search " << *lastSavedSearchIt); if (lastSavedSearchIt->updateSequenceNumber() > maxUsn) { maxUsn = lastSavedSearchIt->updateSequenceNumber(); - QNTRACE(QStringLiteral("Updated max USN to ") << maxUsn - << QStringLiteral(" from saved search: ") << *lastSavedSearchIt); + QNTRACE("Updated max USN to " << maxUsn + << " from saved search: " << *lastSavedSearchIt); } } @@ -1168,7 +1166,7 @@ for(size_t tagCounter = 0, numTags = tagUsnIndex.size(); tagCounter < numTags; ++tagCounter, --tagIt) { - QNTRACE(QStringLiteral("Examing tag: ") << *tagIt); + QNTRACE("Examing tag: " << *tagIt); bool matchesByLinkedNotebook = ( ( !linkedNotebookGuid.isEmpty() && @@ -1178,20 +1176,20 @@ (linkedNotebookGuid.isEmpty() && !tagIt->hasLinkedNotebookGuid()) ); if (!matchesByLinkedNotebook) { - QNTRACE(QStringLiteral("Skipping tag ") << *tagIt - << QStringLiteral("\nAs it doesn't match by linked notebook")); + QNTRACE("Skipping tag " << *tagIt + << "\nAs it doesn't match by linked notebook"); continue; } if (tagIt->updateSequenceNumber() > maxUsn) { maxUsn = tagIt->updateSequenceNumber(); - QNTRACE(QStringLiteral("Updated max USN to ") << maxUsn - << QStringLiteral(" from tag: ") << *tagIt); + QNTRACE("Updated max USN to " << maxUsn + << " from tag: " << *tagIt); } else { - QNTRACE(QStringLiteral("Skipping tag ") << *tagIt - << QStringLiteral("\nAs its USN is no greater than ") - << QStringLiteral("max USN ") << maxUsn); + QNTRACE("Skipping tag " << *tagIt + << "\nAs its USN is no greater than " + << "max USN " << maxUsn); } } } @@ -1205,7 +1203,7 @@ for(size_t notebookCounter = 0, numNotebooks = notebookUsnIndex.size(); notebookCounter < numNotebooks; ++notebookCounter, --notebookIt) { - QNTRACE(QStringLiteral("Examing notebook: ") << *notebookIt); + QNTRACE("Examing notebook: " << *notebookIt); bool matchesByLinkedNotebook = ( ( !linkedNotebookGuid.isEmpty() && @@ -1215,20 +1213,19 @@ (linkedNotebookGuid.isEmpty() && !notebookIt->hasLinkedNotebookGuid()) ); if (!matchesByLinkedNotebook) { - QNTRACE(QStringLiteral("Skipping notebook ") << *notebookIt - << QStringLiteral("\nAs it doesn't match by linked notebook")); + QNTRACE("Skipping notebook " << *notebookIt + << "\nAs it doesn't match by linked notebook"); continue; } if (notebookIt->updateSequenceNumber() > maxUsn) { maxUsn = notebookIt->updateSequenceNumber(); - QNTRACE(QStringLiteral("Updated max USN to ") << maxUsn - << QStringLiteral(" from notebook: ") << *notebookIt); + QNTRACE("Updated max USN to " << maxUsn + << " from notebook: " << *notebookIt); } else { - QNTRACE(QStringLiteral("Skipping notebook ") << *notebookIt - << QStringLiteral("\nAs its USN is no greater than max USN ") - << maxUsn); + QNTRACE("Skipping notebook " << *notebookIt + << "\nAs its USN is no greater than max USN " << maxUsn); } } } @@ -1244,7 +1241,7 @@ for(size_t noteCounter = 0, numNotes = noteUsnIndex.size(); noteCounter < numNotes; ++noteCounter, --noteIt) { - QNTRACE(QStringLiteral("Examing note: ") << *noteIt); + QNTRACE("Examing note: " << *noteIt); bool matchesByLinkedNotebook = false; @@ -1261,19 +1258,19 @@ } if (!matchesByLinkedNotebook) { - QNTRACE(QStringLiteral("Skipping note ") << *noteIt - << QStringLiteral("\nAs it doesn't match by linked notebook")); + QNTRACE("Skipping note " << *noteIt + << "\nAs it doesn't match by linked notebook"); continue; } if (noteIt->updateSequenceNumber() > maxUsn) { maxUsn = noteIt->updateSequenceNumber(); - QNTRACE(QStringLiteral("Updated max USN to ") << maxUsn - << QStringLiteral(" from note: ") << *noteIt); + QNTRACE("Updated max USN to " << maxUsn + << " from note: " << *noteIt); } else { - QNTRACE(QStringLiteral("Skipping note ") << *noteIt - << QStringLiteral("\nAs its USN is no greater than max USN ") + QNTRACE("Skipping note " << *noteIt + << "\nAs its USN is no greater than max USN " << maxUsn); } } @@ -1294,7 +1291,7 @@ for(size_t resourceCounter = 0, numResources = resourceUsnIndex.size(); resourceCounter < numResources; ++resourceCounter, --resourceIt) { - QNTRACE(QStringLiteral("Examing resource: ") << *resourceIt); + QNTRACE("Examing resource: " << *resourceIt); bool matchesByLinkedNotebook = false; auto noteIt = noteGuidIndex.find(resourceIt->noteGuid()); @@ -1314,19 +1311,19 @@ } if (!matchesByLinkedNotebook) { - QNTRACE(QStringLiteral("Skipping resource ") << *resourceIt - << QStringLiteral("\nAs it doesn't match by linked notebook")); + QNTRACE("Skipping resource " << *resourceIt + << "\nAs it doesn't match by linked notebook"); continue; } if (resourceIt->updateSequenceNumber() > maxUsn) { maxUsn = resourceIt->updateSequenceNumber(); - QNTRACE(QStringLiteral("Updated max USN to ") << maxUsn - << QStringLiteral(" from resource: ") << *resourceIt); + QNTRACE("Updated max USN to " << maxUsn + << " from resource: " << *resourceIt); } else { - QNTRACE(QStringLiteral("Skipping resource ") << *resourceIt - << QStringLiteral("\nAs its USN is no greater than max USN ") + QNTRACE("Skipping resource " << *resourceIt + << "\nAs its USN is no greater than max USN " << maxUsn); } } @@ -1338,15 +1335,14 @@ { auto lastLinkedNotebookIt = linkedNotebookUsnIndex.end(); --lastLinkedNotebookIt; - QNTRACE(QStringLiteral("Examing linked notebook ") << *lastLinkedNotebookIt); + QNTRACE("Examing linked notebook " << *lastLinkedNotebookIt); if (lastLinkedNotebookIt->updateSequenceNumber() > maxUsn) { maxUsn = lastLinkedNotebookIt->updateSequenceNumber(); - QNTRACE(QStringLiteral("Updated max USN from linked notebook to ") - << maxUsn); + QNTRACE("Updated max USN from linked notebook to " << maxUsn); } } - QNDEBUG(QStringLiteral("Overall max USN = ") << maxUsn); + QNDEBUG("Overall max USN = " << maxUsn); return maxUsn; } @@ -1378,9 +1374,9 @@ qint32 FakeNoteStore::smallestUsnOfNotCompletelySentDataItemBeforeRateLimitBreach( const QString & linkedNotebookGuid) const { - QNDEBUG(QStringLiteral("FakeNoteStore::") - << QStringLiteral("smallestUsnOfNotCompletelySentDataItemBeforeRateLimitBreach: ") - << QStringLiteral("linked notebook guid = ") << linkedNotebookGuid); + QNDEBUG("FakeNoteStore::" + << "smallestUsnOfNotCompletelySentDataItemBeforeRateLimitBreach: " + << "linked notebook guid = " << linkedNotebookGuid); auto git = m_data->m_guidsOfCompleteSentItemsByLinkedNotebookGuid.end(); if (!linkedNotebookGuid.isEmpty()) @@ -1406,20 +1402,19 @@ end = savedSearchUsnIndex.end(); it != end; ++it) { const SavedSearch & savedSearch = *it; - QNTRACE(QStringLiteral("Processing saved search: ") << savedSearch); + QNTRACE("Processing saved search: " << savedSearch); auto guidIt = guidsOfCompleteSentItems.m_savedSearchGuids.find(savedSearch.guid()); if (guidIt == guidsOfCompleteSentItems.m_savedSearchGuids.end()) { - QNTRACE(QStringLiteral("Encountered first notebook not within " - "the list of sent items")); + QNTRACE("Encountered first notebook not within " + "the list of sent items"); if ((smallestUsn < 0) || (smallestUsn > savedSearch.updateSequenceNumber())) { smallestUsn = savedSearch.updateSequenceNumber(); - QNTRACE(QStringLiteral("Updated smallest USN to ") - << smallestUsn); + QNTRACE("Updated smallest USN to " << smallestUsn); } break; @@ -1434,31 +1429,31 @@ { const Notebook & notebook = *it; if (linkedNotebookGuid.isEmpty() == notebook.hasLinkedNotebookGuid()) { - QNTRACE(QStringLiteral("Skipping notebook not matching by linked ") - << QStringLiteral("notebook criteria: ") << notebook); + QNTRACE("Skipping notebook not matching by linked " + << "notebook criteria: " << notebook); continue; } if (notebook.hasLinkedNotebookGuid() && (notebook.linkedNotebookGuid() != linkedNotebookGuid)) { - QNTRACE(QStringLiteral("Skipping notebook not matching by linked ") - << QStringLiteral("notebook criteria: ") << notebook); + QNTRACE("Skipping notebook not matching by linked " + << "notebook criteria: " << notebook); continue; } - QNTRACE(QStringLiteral("Processing notebook: ") << notebook); + QNTRACE("Processing notebook: " << notebook); auto guidIt = guidsOfCompleteSentItems.m_notebookGuids.find(notebook.guid()); if (guidIt == guidsOfCompleteSentItems.m_notebookGuids.end()) { - QNTRACE(QStringLiteral("Encountered first notebook not within " - "the list of sent items")); + QNTRACE("Encountered first notebook not within " + "the list of sent items"); if ((smallestUsn < 0) || (smallestUsn > notebook.updateSequenceNumber())) { smallestUsn = notebook.updateSequenceNumber(); - QNTRACE(QStringLiteral("Updated smallest USN to ") << smallestUsn); + QNTRACE("Updated smallest USN to " << smallestUsn); } break; @@ -1470,29 +1465,28 @@ { const Tag & tag = *it; if (linkedNotebookGuid.isEmpty() == tag.hasLinkedNotebookGuid()) { - QNTRACE(QStringLiteral("Skipping tag not matching by linked notebook ") - << QStringLiteral("criteria: ") << tag); + QNTRACE("Skipping tag not matching by linked notebook " + << "criteria: " << tag); continue; } if (tag.hasLinkedNotebookGuid() && (tag.linkedNotebookGuid() != linkedNotebookGuid)) { - QNTRACE(QStringLiteral("Skipping tag not matching by linked notebook ") - << QStringLiteral("criteria: ") << tag); + QNTRACE("Skipping tag not matching by linked notebook " + << "criteria: " << tag); continue; } - QNTRACE(QStringLiteral("Processing tag: ") << tag); + QNTRACE("Processing tag: " << tag); auto guidIt = guidsOfCompleteSentItems.m_tagGuids.find(tag.guid()); if (guidIt == guidsOfCompleteSentItems.m_tagGuids.end()) { - QNTRACE(QStringLiteral("Encountered first tag not within the list of " - "sent items")); + QNTRACE("Encountered first tag not within the list of sent items"); if ((smallestUsn < 0) || (smallestUsn > tag.updateSequenceNumber())) { smallestUsn = tag.updateSequenceNumber(); - QNTRACE(QStringLiteral("Updated smallest USN to ") << smallestUsn); + QNTRACE("Updated smallest USN to " << smallestUsn); } break; @@ -1507,21 +1501,20 @@ end = linkedNotebookUsnIndex.end(); it != end; ++it) { const LinkedNotebook & linkedNotebook = *it; - QNTRACE(QStringLiteral("Processing linked notebook: ") << linkedNotebook); + QNTRACE("Processing linked notebook: " << linkedNotebook); auto guidIt = guidsOfCompleteSentItems.m_linkedNotebookGuids.find(linkedNotebook.guid()); if (guidIt == guidsOfCompleteSentItems.m_linkedNotebookGuids.end()) { - QNTRACE(QStringLiteral("Encountered first linked notebook not " - "within the list of sent items")); + QNTRACE("Encountered first linked notebook not " + "within the list of sent items"); if ((smallestUsn < 0) || (smallestUsn > linkedNotebook.updateSequenceNumber())) { smallestUsn = linkedNotebook.updateSequenceNumber(); - QNTRACE(QStringLiteral("Updated smallest USN to ") - << smallestUsn); + QNTRACE("Updated smallest USN to " << smallestUsn); } break; @@ -1537,41 +1530,40 @@ const Note & note = *it; auto notebookIt = notebookGuidIndex.find(note.notebookGuid()); if (Q_UNLIKELY(notebookIt == notebookGuidIndex.end())) { - QNWARNING(QStringLiteral("Skipping note for which no notebook was found: ") - << note); + QNWARNING("Skipping note for which no notebook was found: " << note); continue; } const Notebook & notebook = *notebookIt; if (linkedNotebookGuid.isEmpty() == notebook.hasLinkedNotebookGuid()) { - QNTRACE(QStringLiteral("Skipping note as its notebook doesn't match ") - << QStringLiteral("by linked notebook criteria: ") << note - << QStringLiteral("\nNotebook: ") << notebook); + QNTRACE("Skipping note as its notebook doesn't match " + << "by linked notebook criteria: " << note + << "\nNotebook: " << notebook); continue; } if (notebook.hasLinkedNotebookGuid() && (notebook.linkedNotebookGuid() != linkedNotebookGuid)) { - QNTRACE(QStringLiteral("Skipping note as its notebook doesn't match ") - << QStringLiteral("by linked notebook criteria: ") << note - << QStringLiteral("\nNotebook: ") << notebook); + QNTRACE("Skipping note as its notebook doesn't match " + << "by linked notebook criteria: " << note + << "\nNotebook: " << notebook); continue; } - QNTRACE(QStringLiteral("Processing note: ") << note); + QNTRACE("Processing note: " << note); auto guidIt = guidsOfCompleteSentItems.m_noteGuids.find(note.guid()); if (guidIt == guidsOfCompleteSentItems.m_noteGuids.end()) { - QNTRACE(QStringLiteral("Encountered first note not within the list " - "of sent items")); + QNTRACE("Encountered first note not within the list " + "of sent items"); if ((smallestUsn < 0) || (smallestUsn > note.updateSequenceNumber())) { smallestUsn = note.updateSequenceNumber(); - QNTRACE(QStringLiteral("Updated smallest USN to ") << smallestUsn); + QNTRACE("Updated smallest USN to " << smallestUsn); } break; @@ -1587,7 +1579,7 @@ const Resource & resource = *it; auto noteIt = noteGuidIndex.find(resource.noteGuid()); if (Q_UNLIKELY(noteIt == noteGuidIndex.end())) { - QNWARNING(QStringLiteral("Skipping resource for which no note was found: ") + QNWARNING("Skipping resource for which no note was found: " << resource); continue; } @@ -1595,53 +1587,53 @@ const Note & note = *noteIt; auto notebookIt = notebookGuidIndex.find(note.notebookGuid()); if (Q_UNLIKELY(notebookIt == notebookGuidIndex.end())) { - QNWARNING(QStringLiteral("Skipping resource for which note ") - << QStringLiteral("no notebook was found: ") << note); + QNWARNING("Skipping resource for which note " + << "no notebook was found: " << note); continue; } const Notebook & notebook = *notebookIt; if (linkedNotebookGuid.isEmpty() == notebook.hasLinkedNotebookGuid()) { - QNTRACE(QStringLiteral("Skipping resource as its note's notebook ") - << QStringLiteral("doesn't match by linked notebook criteria: ") - << resource << QStringLiteral("\nNote: ") << note - << QStringLiteral("\nNotebook: ") << notebook); + QNTRACE("Skipping resource as its note's notebook " + << "doesn't match by linked notebook criteria: " + << resource << "\nNote: " << note + << "\nNotebook: " << notebook); continue; } if (notebook.hasLinkedNotebookGuid() && (notebook.linkedNotebookGuid() != linkedNotebookGuid)) { - QNTRACE(QStringLiteral("Skipping resource as its note's notebook ") - << QStringLiteral("doesn't match by linked notebook criteria: ") - << resource << QStringLiteral("\nNote: ") << note - << QStringLiteral("\nNotebook: ") << notebook); + QNTRACE("Skipping resource as its note's notebook " + << "doesn't match by linked notebook criteria: " + << resource << "\nNote: " << note + << "\nNotebook: " << notebook); continue; } - QNTRACE(QStringLiteral("Processing resource: ") << resource); + QNTRACE("Processing resource: " << resource); auto guidIt = guidsOfCompleteSentItems.m_resourceGuids.find(resource.guid()); if (guidIt == guidsOfCompleteSentItems.m_resourceGuids.end()) { - QNTRACE(QStringLiteral("Encountered first resource not within " - "the list of sent items")); + QNTRACE("Encountered first resource not within " + "the list of sent items"); if ((smallestUsn < 0) || (smallestUsn > resource.updateSequenceNumber())) { smallestUsn = resource.updateSequenceNumber(); - QNTRACE(QStringLiteral("Updated smallest USN to ") << smallestUsn); + QNTRACE("Updated smallest USN to " << smallestUsn); } break; } } - QNDEBUG(QStringLiteral("Smallest USN of not completely sent data item is ") - << smallestUsn << QStringLiteral(" (linked notebook guid = ") - << linkedNotebookGuid << QStringLiteral(")")); + QNDEBUG("Smallest USN of not completely sent data item is " + << smallestUsn << " (linked notebook guid = " + << linkedNotebookGuid << ")"); return smallestUsn; } @@ -1701,7 +1693,7 @@ } if (m_data->m_notebooks.size() + 1 > m_data->m_maxNumNotebooks) { - errorDescription.setBase(QStringLiteral("Already at max number of notebooks")); + errorDescription.setBase("Already at max number of notebooks"); return qevercloud::EDAMErrorCode::LIMIT_REACHED; } @@ -1722,15 +1714,15 @@ else if (!linkedNotebookAuthToken.isEmpty() && (linkedNotebookAuthToken != m_data->m_authenticationToken)) { - errorDescription.setBase(QStringLiteral("Notebook doesn't belong to " - "a linked notebook but linked " - "notebook auth token is not empty")); + errorDescription.setBase("Notebook doesn't belong to " + "a linked notebook but linked " + "notebook auth token is not empty"); return qevercloud::EDAMErrorCode::INVALID_AUTH; } if (!linkedNotebookAuthToken.isEmpty() && notebook.isDefaultNotebook()) { - errorDescription.setBase(QStringLiteral("Linked notebook cannot be set " - "as default notebook")); + errorDescription.setBase("Linked notebook cannot be set " + "as default notebook"); return qevercloud::EDAMErrorCode::PERMISSION_DENIED; } @@ -1738,8 +1730,8 @@ m_data->m_notebooks.get<NotebookByNameUpper>(); auto nameIt = nameIndex.find(notebook.name().toUpper()); if (nameIt != nameIndex.end()) { - errorDescription.setBase(QStringLiteral("Notebook with the specified " - "name already exists")); + errorDescription.setBase("Notebook with the specified " + "name already exists"); return qevercloud::EDAMErrorCode::DATA_CONFLICT; } @@ -1781,7 +1773,7 @@ } if (!notebook.hasGuid()) { - errorDescription.setBase(QStringLiteral("Notebook guid is not set")); + errorDescription.setBase("Notebook guid is not set"); return qevercloud::EDAMErrorCode::UNKNOWN; } @@ -1802,29 +1794,29 @@ else if (!linkedNotebookAuthToken.isEmpty() && (linkedNotebookAuthToken != m_data->m_authenticationToken)) { - errorDescription.setBase(QStringLiteral("Notebook doesn't belong to " - "a linked notebook but linked " - "notebook auth token is not empty")); + errorDescription.setBase("Notebook doesn't belong to " + "a linked notebook but linked " + "notebook auth token is not empty"); return qevercloud::EDAMErrorCode::INVALID_AUTH; } if (!linkedNotebookAuthToken.isEmpty() && notebook.isDefaultNotebook()) { - errorDescription.setBase(QStringLiteral("Linked notebook cannot be set " - "as default notebook")); + errorDescription.setBase("Linked notebook cannot be set " + "as default notebook"); return qevercloud::EDAMErrorCode::PERMISSION_DENIED; } NotebookDataByGuid & index = m_data->m_notebooks.get<NotebookByGuid>(); auto it = index.find(notebook.guid()); if (it == index.end()) { - errorDescription.setBase(QStringLiteral("Notebook with the specified " - "guid doesn't exist")); + errorDescription.setBase("Notebook with the specified " + "guid doesn't exist"); return qevercloud::EDAMErrorCode::DATA_CONFLICT; } const Notebook & originalNotebook = *it; if (!originalNotebook.canUpdateNotebook()) { - errorDescription.setBase(QStringLiteral("No permission to update the notebook")); + errorDescription.setBase("No permission to update the notebook"); return qevercloud::EDAMErrorCode::PERMISSION_DENIED; } @@ -1834,8 +1826,8 @@ m_data->m_notebooks.get<NotebookByNameUpper>(); auto nameIt = nameIndex.find(notebook.name().toUpper()); if (nameIt != nameIndex.end()) { - errorDescription.setBase(QStringLiteral("Notebook with the specified " - "name already exists")); + errorDescription.setBase("Notebook with the specified " + "name already exists"); return qevercloud::EDAMErrorCode::DATA_CONFLICT; } } @@ -1875,7 +1867,7 @@ } if (m_data->m_notes.size() + 1 > m_data->m_maxNumNotes) { - errorDescription.setBase(QStringLiteral("Already at max number of notes")); + errorDescription.setBase("Already at max number of notes"); return qevercloud::EDAMErrorCode::LIMIT_REACHED; } @@ -1887,7 +1879,7 @@ const Notebook * pNotebook = findNotebook(note.notebookGuid()); if (Q_UNLIKELY(!pNotebook)) { - errorDescription.setBase(QStringLiteral("No notebook was found for note")); + errorDescription.setBase("No notebook was found for note"); return qevercloud::EDAMErrorCode::DATA_CONFLICT; } @@ -1903,9 +1895,9 @@ else if (!linkedNotebookAuthToken.isEmpty() && (linkedNotebookAuthToken != m_data->m_authenticationToken)) { - errorDescription.setBase(QStringLiteral("Note's notebook doesn't belong " - "to a linked notebook but linked " - "notebook auth token is not empty")); + errorDescription.setBase("Note's notebook doesn't belong " + "to a linked notebook but linked " + "notebook auth token is not empty"); return qevercloud::EDAMErrorCode::INVALID_AUTH; } @@ -1961,7 +1953,7 @@ // Restore the original resources with guids and USNs back to the input-output note note.setResources(originalResources); - QNTRACE(QStringLiteral("Note after FakeNoteStore::createNote: ") << note); + QNTRACE("Note after FakeNoteStore::createNote: " << note); } return 0; @@ -1983,7 +1975,7 @@ } if (!note.hasGuid()) { - errorDescription.setBase(QStringLiteral("Note.guid")); + errorDescription.setBase("Note.guid"); return qevercloud::EDAMErrorCode::UNKNOWN; } @@ -1996,14 +1988,14 @@ NoteDataByGuid & index = m_data->m_notes.get<NoteByGuid>(); auto it = index.find(note.guid()); if (it == index.end()) { - errorDescription.setBase(QStringLiteral("Note with the specified guid " - "doesn't exist")); + errorDescription.setBase("Note with the specified guid " + "doesn't exist"); return qevercloud::EDAMErrorCode::DATA_CONFLICT; } const Notebook * pNotebook = findNotebook(note.notebookGuid()); if (Q_UNLIKELY(!pNotebook)) { - errorDescription.setBase(QStringLiteral("No notebook was found for note")); + errorDescription.setBase("No notebook was found for note"); return qevercloud::EDAMErrorCode::DATA_CONFLICT; } @@ -2019,9 +2011,9 @@ else if (!linkedNotebookAuthToken.isEmpty() && (linkedNotebookAuthToken != m_data->m_authenticationToken)) { - errorDescription.setBase(QStringLiteral("Note's notebook doesn't belong " - "to a linked notebook but linked " - "notebook auth token is not empty")); + errorDescription.setBase("Note's notebook doesn't belong " + "to a linked notebook but linked " + "notebook auth token is not empty"); return qevercloud::EDAMErrorCode::INVALID_AUTH; } @@ -2078,7 +2070,7 @@ // Restore the original resources with guids and USNs back to the input-output note note.setResources(originalResources); - QNTRACE(QStringLiteral("Note after FakeNoteStore::updateNote: ") << note); + QNTRACE("Note after FakeNoteStore::updateNote: " << note); } return 0; @@ -2100,7 +2092,7 @@ } if (m_data->m_tags.size() + 1 > m_data->m_maxNumTags) { - errorDescription.setBase(QStringLiteral("Already at max number of tags")); + errorDescription.setBase("Already at max number of tags"); return qevercloud::EDAMErrorCode::LIMIT_REACHED; } @@ -2120,16 +2112,16 @@ else if (!linkedNotebookAuthToken.isEmpty() && (linkedNotebookAuthToken != m_data->m_authenticationToken)) { - errorDescription.setBase(QStringLiteral("Tag doesn't belong to a linked " - "notebook but linked notebook " - "auth token is not empty")); + errorDescription.setBase("Tag doesn't belong to a linked " + "notebook but linked notebook " + "auth token is not empty"); return qevercloud::EDAMErrorCode::INVALID_AUTH; } TagDataByNameUpper & nameIndex = m_data->m_tags.get<TagByNameUpper>(); auto it = nameIndex.find(tag.name().toUpper()); if (it != nameIndex.end()) { - errorDescription.setBase(QStringLiteral("Tag name is already in use")); + errorDescription.setBase("Tag name is already in use"); return qevercloud::EDAMErrorCode::DATA_CONFLICT; } @@ -2171,7 +2163,7 @@ } if (!tag.hasGuid()) { - errorDescription.setBase(QStringLiteral("Tag guid is not set")); + errorDescription.setBase("Tag guid is not set"); return qevercloud::EDAMErrorCode::UNKNOWN; } @@ -2191,17 +2183,16 @@ else if (!linkedNotebookAuthToken.isEmpty() && (linkedNotebookAuthToken != m_data->m_authenticationToken)) { - errorDescription.setBase(QStringLiteral("Tag doesn't belong to a linked " - "notebook but linked notebook " - "auth token is not empty")); + errorDescription.setBase("Tag doesn't belong to a linked " + "notebook but linked notebook " + "auth token is not empty"); return qevercloud::EDAMErrorCode::INVALID_AUTH; } TagDataByGuid & index = m_data->m_tags.get<TagByGuid>(); auto it = index.find(tag.guid()); if (it == index.end()) { - errorDescription.setBase(QStringLiteral("Tag with the specified guid " - "doesn't exist")); + errorDescription.setBase("Tag with the specified guid doesn't exist"); return qevercloud::EDAMErrorCode::DATA_CONFLICT; } @@ -2211,8 +2202,8 @@ TagDataByNameUpper & nameIndex = m_data->m_tags.get<TagByNameUpper>(); auto nameIt = nameIndex.find(tag.name().toUpper()); if (nameIt != nameIndex.end()) { - errorDescription.setBase(QStringLiteral("Tag with the specified name " - "already exists")); + errorDescription.setBase("Tag with the specified name " + "already exists"); return qevercloud::EDAMErrorCode::DATA_CONFLICT; } } @@ -2252,8 +2243,7 @@ } if (m_data->m_savedSearches.size() + 1 > m_data->m_maxNumSavedSearches) { - errorDescription.setBase(QStringLiteral("Already at max number of " - "saved searches")); + errorDescription.setBase("Already at max number of saved searches"); return qevercloud::EDAMErrorCode::LIMIT_REACHED; } @@ -2266,7 +2256,7 @@ m_data->m_savedSearches.get<SavedSearchByNameUpper>(); auto it = nameIndex.find(savedSearch.name().toUpper()); if (it != nameIndex.end()) { - errorDescription.setBase(QStringLiteral("Saved search name is already in use")); + errorDescription.setBase("Saved search name is already in use"); return qevercloud::EDAMErrorCode::DATA_CONFLICT; } @@ -2301,7 +2291,7 @@ } if (!savedSearch.hasGuid()) { - errorDescription.setBase(QStringLiteral("Saved search guid is not set")); + errorDescription.setBase("Saved search guid is not set"); return qevercloud::EDAMErrorCode::UNKNOWN; } @@ -2313,8 +2303,8 @@ SavedSearchDataByGuid & index = m_data->m_savedSearches.get<SavedSearchByGuid>(); auto it = index.find(savedSearch.guid()); if (it == index.end()) { - errorDescription.setBase(QStringLiteral("Saved search with the specified " - "guid doesn't exist")); + errorDescription.setBase("Saved search with the specified " + "guid doesn't exist"); return qevercloud::EDAMErrorCode::DATA_CONFLICT; } @@ -2325,8 +2315,8 @@ m_data->m_savedSearches.get<SavedSearchByNameUpper>(); auto nameIt = nameIndex.find(savedSearch.name().toUpper()); if (nameIt != nameIndex.end()) { - errorDescription.setBase(QStringLiteral("Saved search with the specified " - "name already exists")); + errorDescription.setBase("Saved search with the specified " + "name already exists"); return qevercloud::EDAMErrorCode::DATA_CONFLICT; } } @@ -2370,9 +2360,9 @@ ErrorString & errorDescription, qint32 & rateLimitSeconds) { - QNDEBUG(QStringLiteral("FakeNoteStore::getSyncChunk: after USN = ") << afterUSN - << QStringLiteral(", max entries = ") << maxEntries - << QStringLiteral(", filter = ") << filter); + QNDEBUG("FakeNoteStore::getSyncChunk: after USN = " << afterUSN + << ", max entries = " << maxEntries + << ", filter = " << filter); if (m_data->m_whenToTriggerAPIRateLimitExceeding == WhenToTriggerAPIRateLimitsExceeding::OnGetUserOwnSyncChunkAttempt) @@ -2406,7 +2396,7 @@ } if (m_pQecNoteStore->authenticationToken() != authToken) { - errorDescription.setBase(QStringLiteral("Wrong authentication token")); + errorDescription.setBase("Wrong authentication token"); return qevercloud::EDAMErrorCode::PERMISSION_DENIED; } @@ -2418,12 +2408,12 @@ auto it = m_data->m_linkedNotebookSyncStates.find(linkedNotebook.username.ref()); if (it == m_data->m_linkedNotebookSyncStates.end()) { - QNWARNING(QStringLiteral("Failed to find linked notebook sync state for ") - << QStringLiteral("linked notebook: ") << linkedNotebook - << QStringLiteral("\nLinked notebook sync states: ") + QNWARNING("Failed to find linked notebook sync state for " + << "linked notebook: " << linkedNotebook + << "\nLinked notebook sync states: " << m_data->m_linkedNotebookSyncStates); - errorDescription.setBase(QStringLiteral("Found no sync state for the given " - "linked notebook owner")); + errorDescription.setBase("Found no sync state for the given " + "linked notebook owner"); return qevercloud::EDAMErrorCode::UNKNOWN; } @@ -2438,13 +2428,13 @@ qevercloud::SyncChunk & syncChunk, ErrorString & errorDescription, qint32 & rateLimitSeconds) { - QNDEBUG(QStringLiteral("FakeNoteStore::getLinkedNotebookSyncChunk: linked ") - << QStringLiteral("notebook = ") << linkedNotebook - << QStringLiteral("\nAfter USN = ") << afterUSN - << QStringLiteral(", max entries = ") << maxEntries - << QStringLiteral(", linked notebook auth token = ") - << linkedNotebookAuthToken << QStringLiteral(", full sync only = ") - << (fullSyncOnly ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("FakeNoteStore::getLinkedNotebookSyncChunk: linked " + << "notebook = " << linkedNotebook + << "\nAfter USN = " << afterUSN + << ", max entries = " << maxEntries + << ", linked notebook auth token = " + << linkedNotebookAuthToken << ", full sync only = " + << (fullSyncOnly ? "true" : "false")); if (m_data->m_whenToTriggerAPIRateLimitExceeding == WhenToTriggerAPIRateLimitsExceeding::OnGetLinkedNotebookSyncChunkAttempt) @@ -2468,13 +2458,13 @@ m_data->m_linkedNotebooks.get<LinkedNotebookByUsername>(); auto linkedNotebookIt = linkedNotebookUsernameIndex.find(linkedNotebook.username.ref()); if (linkedNotebookIt == linkedNotebookUsernameIndex.end()) { - errorDescription.setBase(QStringLiteral("Found no existing linked notebook " - "by username")); + errorDescription.setBase("Found no existing linked notebook " + "by username"); return qevercloud::EDAMErrorCode::UNKNOWN; } if (linkedNotebookAuthToken != m_data->m_authenticationToken) { - errorDescription.setBase(QStringLiteral("Wrong authentication token")); + errorDescription.setBase("Wrong authentication token"); return qevercloud::EDAMErrorCode::PERMISSION_DENIED; } @@ -2531,14 +2521,14 @@ } if (!note.hasGuid()) { - errorDescription.setBase(QStringLiteral("Note has no guid")); + errorDescription.setBase("Note has no guid"); return qevercloud::EDAMErrorCode::UNKNOWN; } const NoteDataByGuid & noteGuidIndex = m_data->m_notes.get<NoteByGuid>(); auto noteIt = noteGuidIndex.find(note.guid()); if (noteIt == noteGuidIndex.end()) { - errorDescription.setBase(QStringLiteral("Note was not found")); + errorDescription.setBase("Note was not found"); return qevercloud::EDAMErrorCode::UNKNOWN; } @@ -2546,7 +2536,7 @@ const Notebook * pNotebook = findNotebook(note.notebookGuid()); if (Q_UNLIKELY(!pNotebook)) { - errorDescription.setBase(QStringLiteral("No notebook was found for note")); + errorDescription.setBase("No notebook was found for note"); return qevercloud::EDAMErrorCode::DATA_CONFLICT; } @@ -2604,9 +2594,11 @@ if (note.hasResources()) { QList<Resource> resources = note.resources(); - for(auto it = resources.constBegin(), end = resources.constEnd(); it != end; ++it) { + for(auto it = resources.constBegin(), + end = resources.constEnd(); it != end; ++it) + { Q_UNUSED(guidsOfCompleteSentItems.m_resourceGuids.insert(it->guid())) - QNTRACE(QStringLiteral("Marked resource as processed: ") << *it); + QNTRACE("Marked resource as processed: " << *it); } } } @@ -2627,7 +2619,7 @@ ErrorString & errorDescription) { if (Q_UNLIKELY(noteGuid.isEmpty())) { - errorDescription.setBase(QStringLiteral("Note guid is empty")); + errorDescription.setBase("Note guid is empty"); return false; } @@ -2646,8 +2638,8 @@ m_data->m_getNoteAsyncRequests.enqueue(request); int timerId = startTimer(0); - QNDEBUG(QStringLiteral("Started timer to postpone the get note result, ") - << QStringLiteral("timer id = ") << timerId); + QNDEBUG("Started timer to postpone the get note result, " + << "timer id = " << timerId); Q_UNUSED(m_data->m_getNoteAsyncDelayTimerIds.insert(timerId)) return true; @@ -2690,7 +2682,7 @@ } if (!resource.hasGuid()) { - errorDescription.setBase(QStringLiteral("Resource has no guid")); + errorDescription.setBase("Resource has no guid"); return qevercloud::EDAMErrorCode::UNKNOWN; } @@ -2698,12 +2690,12 @@ m_data->m_resources.get<ResourceByGuid>(); auto resourceIt = resourceGuidIndex.find(resource.guid()); if (resourceIt == resourceGuidIndex.end()) { - errorDescription.setBase(QStringLiteral("Resource was not found")); + errorDescription.setBase("Resource was not found"); return qevercloud::EDAMErrorCode::UNKNOWN; } if (Q_UNLIKELY(!resourceIt->hasNoteGuid())) { - errorDescription.setBase(QStringLiteral("Found resource has no note guid")); + errorDescription.setBase("Found resource has no note guid"); return qevercloud::EDAMErrorCode::INTERNAL_ERROR; } @@ -2711,13 +2703,12 @@ const NoteDataByGuid & noteGuidIndex = m_data->m_notes.get<NoteByGuid>(); auto noteIt = noteGuidIndex.find(noteGuid); if (Q_UNLIKELY(noteIt == noteGuidIndex.end())) { - errorDescription.setBase(QStringLiteral("Found no note containing " - "the resource")); + errorDescription.setBase("Found no note containing the resource"); return qevercloud::EDAMErrorCode::INTERNAL_ERROR; } if (Q_UNLIKELY(!noteIt->hasNotebookGuid())) { - errorDescription.setBase(QStringLiteral("Found note has no notebook guid")); + errorDescription.setBase("Found note has no notebook guid"); return qevercloud::EDAMErrorCode::INTERNAL_ERROR; } @@ -2726,8 +2717,8 @@ m_data->m_notebooks.get<NotebookByGuid>(); auto notebookIt = notebookGuidIndex.find(notebookGuid); if (Q_UNLIKELY(notebookIt == notebookGuidIndex.end())) { - errorDescription.setBase(QStringLiteral("Found no notebook containing " - "the note with the resource")); + errorDescription.setBase("Found no notebook containing " + "the note with the resource"); return qevercloud::EDAMErrorCode::INTERNAL_ERROR; } @@ -2766,7 +2757,7 @@ ? m_data->m_guidsOfCompleteSentItemsByLinkedNotebookGuid[notebookIt->linkedNotebookGuid()] : m_data->m_guidsOfUserOwnCompleteSentItems); Q_UNUSED(guidsOfCompleteSentItems.m_resourceGuids.insert(resource.guid())) - QNTRACE(QStringLiteral("Marked resource as processed: ") << resource); + QNTRACE("Marked resource as processed: " << resource); } return 0; @@ -2781,7 +2772,7 @@ ErrorString & errorDescription) { if (Q_UNLIKELY(resourceGuid.isEmpty())) { - errorDescription.setBase(QStringLiteral("Resource guid is empty")); + errorDescription.setBase("Resource guid is empty"); return false; } @@ -2796,8 +2787,8 @@ m_data->m_getResourceAsyncRequests.enqueue(request); int timerId = startTimer(0); - QNDEBUG(QStringLiteral("Started timer to postpone the get resource result, ") - << QStringLiteral("timer id = ") << timerId); + QNDEBUG("Started timer to postpone the get resource result, " + << "timer id = " << timerId); Q_UNUSED(m_data->m_getResourceAsyncDelayTimerIds.insert(timerId)) return true; @@ -2831,8 +2822,7 @@ auto authTokenIt = m_data->m_linkedNotebookAuthTokens.find(linkedNotebook.username()); if (authTokenIt == m_data->m_linkedNotebookAuthTokens.end()) { - errorDescription.setBase(QStringLiteral("No valid authentication token " - "was provided")); + errorDescription.setBase("No valid authentication token was provided"); return qevercloud::EDAMErrorCode::INVALID_AUTH; } @@ -2853,8 +2843,7 @@ auto noteIt = m_data->m_getNoteAsyncDelayTimerIds.find(pEvent->timerId()); if (noteIt != m_data->m_getNoteAsyncDelayTimerIds.end()) { - QNDEBUG(QStringLiteral("getNoteAsync delay timer event, timer id = ") - << pEvent->timerId()); + QNDEBUG("getNoteAsync delay timer event, timer id = " << pEvent->timerId()); Q_UNUSED(m_data->m_getNoteAsyncDelayTimerIds.erase(noteIt)) killTimer(pEvent->timerId()); @@ -2875,8 +2864,7 @@ { const Notebook * pNotebook = findNotebook(note.notebookGuid()); if (Q_UNLIKELY(!pNotebook)) { - errorDescription.setBase(QStringLiteral("No notebook was " - "found for note")); + errorDescription.setBase("No notebook was found for note"); res = qevercloud::EDAMErrorCode::DATA_CONFLICT; } else if (pNotebook->hasLinkedNotebookGuid()) @@ -2888,11 +2876,11 @@ else if (!request.m_authToken.isEmpty() && (request.m_authToken != m_data->m_authenticationToken)) { - errorDescription.setBase(QStringLiteral("Note's notebook doesn't " - "belong to a linked " - "notebook but linked " - "notebook auth token " - "is not empty")); + errorDescription.setBase("Note's notebook doesn't " + "belong to a linked " + "notebook but linked " + "notebook auth token " + "is not empty"); res = qevercloud::EDAMErrorCode::INVALID_AUTH; } } @@ -2911,7 +2899,7 @@ auto resourceIt = m_data->m_getResourceAsyncDelayTimerIds.find(pEvent->timerId()); if (resourceIt != m_data->m_getResourceAsyncDelayTimerIds.end()) { - QNDEBUG(QStringLiteral("getResourceAsync delay timer event, timer id = ") + QNDEBUG("getResourceAsync delay timer event, timer id = " << pEvent->timerId()); Q_UNUSED(m_data->m_getResourceAsyncDelayTimerIds.erase(resourceIt)) @@ -2950,24 +2938,24 @@ ErrorString & errorDescription) const { if (!notebook.hasName()) { - errorDescription.setBase(QStringLiteral("Notebook name is not set")); + errorDescription.setBase("Notebook name is not set"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } const QString & notebookName = notebook.name(); if (notebookName.size() < qevercloud::EDAM_NOTEBOOK_NAME_LEN_MIN) { - errorDescription.setBase(QStringLiteral("Notebook name length is too small")); + errorDescription.setBase("Notebook name length is too small"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } if (notebookName.size() > qevercloud::EDAM_NOTEBOOK_NAME_LEN_MAX) { - errorDescription.setBase(QStringLiteral("Notebook name length is too large")); + errorDescription.setBase("Notebook name length is too large"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } if (notebookName != notebookName.trimmed()) { - errorDescription.setBase(QStringLiteral("Notebook name cannot begin or " - "end with whitespace")); + errorDescription.setBase("Notebook name cannot begin or " + "end with whitespace"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } @@ -2981,20 +2969,20 @@ const QString & notebookStack = notebook.stack(); if (notebookStack.size() < qevercloud::EDAM_NOTEBOOK_STACK_LEN_MIN) { - errorDescription.setBase(QStringLiteral("Notebook stack's length " - "is too small")); + errorDescription.setBase("Notebook stack's length " + "is too small"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } if (notebookStack.size() > qevercloud::EDAM_NOTEBOOK_STACK_LEN_MAX) { - errorDescription.setBase(QStringLiteral("Notebook stack's length " - "is too large")); + errorDescription.setBase("Notebook stack's length " + "is too large"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } if (notebookStack != notebookStack.trimmed()) { - errorDescription.setBase(QStringLiteral("Notebook stack should not " - "begin or end with whitespace")); + errorDescription.setBase("Notebook stack should not " + "begin or end with whitespace"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } @@ -3010,14 +2998,14 @@ const QString & publishingUri = notebook.publishingUri(); if (publishingUri.size() < qevercloud::EDAM_PUBLISHING_URI_LEN_MIN) { - errorDescription.setBase(QStringLiteral("Notebook publishing uri " - "length is too small")); + errorDescription.setBase("Notebook publishing uri " + "length is too small"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } if (publishingUri.size() > qevercloud::EDAM_PUBLISHING_URI_LEN_MAX) { - errorDescription.setBase(QStringLiteral("Notebook publising uri " - "length is too large")); + errorDescription.setBase("Notebook publising uri " + "length is too large"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } @@ -3026,16 +3014,16 @@ it != end; ++it) { if (publishingUri == *it) { - errorDescription.setBase(QStringLiteral("Prohibited publishing " - "URI value is set")); + errorDescription.setBase("Prohibited publishing " + "URI value is set"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } } QRegExp publishingUriRegExp(qevercloud::EDAM_PUBLISHING_URI_REGEX); if (!publishingUriRegExp.exactMatch(publishingUri)) { - errorDescription.setBase(QStringLiteral("Publishing URI doesn't match " - "the mandatory regex")); + errorDescription.setBase("Publishing URI doesn't match " + "the mandatory regex"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } } @@ -3045,21 +3033,21 @@ const QString & description = notebook.publishingPublicDescription(); if (description.size() < qevercloud::EDAM_PUBLISHING_DESCRIPTION_LEN_MIN) { - errorDescription.setBase(QStringLiteral("Publishing description length " - "is too small")); + errorDescription.setBase("Publishing description length " + "is too small"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } if (description.size() > qevercloud::EDAM_PUBLISHING_DESCRIPTION_LEN_MAX) { - errorDescription.setBase(QStringLiteral("Publishing description length " - "is too large")); + errorDescription.setBase("Publishing description length " + "is too large"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } QRegExp publishingDescriptionRegExp(qevercloud::EDAM_PUBLISHING_DESCRIPTION_REGEX); if (!publishingDescriptionRegExp.exactMatch(description)) { - errorDescription.setBase(QStringLiteral("Notebook description doesn't " - "match the mandatory regex")); + errorDescription.setBase("Notebook description doesn't " + "match the mandatory regex"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } } @@ -3072,7 +3060,7 @@ ErrorString & errorDescription) const { if (!note.hasNotebookGuid()) { - errorDescription.setBase(QStringLiteral("Note has no notebook guid set")); + errorDescription.setBase("Note has no notebook guid set"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } @@ -3080,7 +3068,7 @@ m_data->m_notebooks.get<NotebookByGuid>(); auto notebookIt = notebookIndex.find(note.notebookGuid()); if (notebookIt == notebookIndex.end()) { - errorDescription.setBase(QStringLiteral("Note.notebookGuid")); + errorDescription.setBase("Note.notebookGuid"); return qevercloud::EDAMErrorCode::UNKNOWN; } @@ -3088,16 +3076,16 @@ if (purpose == CheckNoteFieldsPurpose::CreateNote) { if (!notebook.canCreateNotes()) { - errorDescription.setBase(QStringLiteral("No permission to create " - "notes within this notebook")); + errorDescription.setBase("No permission to create " + "notes within this notebook"); return qevercloud::EDAMErrorCode::PERMISSION_DENIED; } } else if (purpose == CheckNoteFieldsPurpose::UpdateNote) { if (!notebook.canUpdateNotes()) { - errorDescription.setBase(QStringLiteral("No permission to update notes " - "within this notebook")); + errorDescription.setBase("No permission to update notes " + "within this notebook"); return qevercloud::EDAMErrorCode::PERMISSION_DENIED; } } @@ -3107,12 +3095,12 @@ const QString & title = note.title(); if (title.size() < qevercloud::EDAM_NOTE_TITLE_LEN_MIN) { - errorDescription.setBase(QStringLiteral("Note title length is too small")); + errorDescription.setBase("Note title length is too small"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } if (title.size() > qevercloud::EDAM_NOTE_TITLE_LEN_MAX) { - errorDescription.setBase(QStringLiteral("Note title length is too large")); + errorDescription.setBase("Note title length is too large"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } @@ -3127,12 +3115,12 @@ const QString & content = note.content(); if (content.size() < qevercloud::EDAM_NOTE_CONTENT_LEN_MIN) { - errorDescription.setBase(QStringLiteral("Note content length is too small")); + errorDescription.setBase("Note content length is too small"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } if (content.size() > qevercloud::EDAM_NOTE_CONTENT_LEN_MAX) { - errorDescription.setBase(QStringLiteral("Note content length is too large")); + errorDescription.setBase("Note content length is too large"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } } @@ -3155,21 +3143,28 @@ { const qevercloud::NoteAttributes & attributes = note.noteAttributes(); -#define CHECK_STRING_ATTRIBUTE(attr) \ - if (attributes.attr.isSet()) \ - { \ - if (attributes.attr.ref().size() < qevercloud::EDAM_ATTRIBUTE_LEN_MIN) { \ - errorDescription.setBase(QStringLiteral("Attribute length is too small: ") + \ - QString::fromUtf8( #attr )); \ - return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; \ - } \ - \ - if (attributes.attr.ref().size() < qevercloud::EDAM_ATTRIBUTE_LEN_MAX) { \ - errorDescription.setBase(QStringLiteral("Attribute length is too large: ") + \ - QString::fromUtf8( #attr )); \ - return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; \ - } \ - } +#define CHECK_STRING_ATTRIBUTE(attr) \ + if (attributes.attr.isSet()) \ + { \ + if (attributes.attr.ref().size() < \ + qevercloud::EDAM_ATTRIBUTE_LEN_MIN) \ + { \ + errorDescription.setBase( \ + QStringLiteral("Attribute length is too small: ") + \ + QString::fromUtf8( #attr )); \ + return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; \ + } \ + \ + if (attributes.attr.ref().size() < \ + qevercloud::EDAM_ATTRIBUTE_LEN_MAX) \ + { \ + errorDescription.setBase( \ + QStringLiteral("Attribute length is too large: ") + \ + QString::fromUtf8( #attr )); \ + return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; \ + } \ + } \ +// CHECK_STRING_ATTRIBUTE CHECK_STRING_ATTRIBUTE(author) CHECK_STRING_ATTRIBUTE(source) @@ -3199,22 +3194,21 @@ const QString & mime = resource.mime(); if (mime.size() < qevercloud::EDAM_MIME_LEN_MIN) { - errorDescription.setBase(QStringLiteral("Note's resource mime type " - "length is too small")); + errorDescription.setBase("Note's resource mime type " + "length is too small"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } if (mime.size() > qevercloud::EDAM_MIME_LEN_MAX) { - errorDescription.setBase(QStringLiteral("Note's resource mime type " - "length is too large")); + errorDescription.setBase("Note's resource mime type " + "length is too large"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } QRegExp mimeRegExp(qevercloud::EDAM_MIME_REGEX); if (!mimeRegExp.exactMatch(mime)) { - errorDescription.setBase(QStringLiteral("Note's resource mime type " - "doesn't match the mandatory " - "regex")); + errorDescription.setBase("Note's resource mime type doesn't match " + "the mandatory regex"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } } @@ -3241,21 +3235,22 @@ return 0; } -qint32 FakeNoteStore::checkTagFields(const Tag & tag, ErrorString & errorDescription) const +qint32 FakeNoteStore::checkTagFields( + const Tag & tag, ErrorString & errorDescription) const { if (!tag.hasName()) { - errorDescription.setBase(QStringLiteral("Tag name is not set")); + errorDescription.setBase("Tag name is not set"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } const QString & tagName = tag.name(); if (tagName.size() < qevercloud::EDAM_TAG_NAME_LEN_MIN) { - errorDescription.setBase(QStringLiteral("Tag name length is too small")); + errorDescription.setBase("Tag name length is too small"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } if (tagName.size() > qevercloud::EDAM_TAG_NAME_LEN_MAX) { - errorDescription.setBase(QStringLiteral("Tag name length is too large")); + errorDescription.setBase("Tag name length is too large"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } @@ -3265,8 +3260,8 @@ // doesn't match the text which should actually match if (tagName != tagName.trimmed()) { - errorDescription.setBase(QStringLiteral("Tag name shouldn't start or " - "end with whitespace")); + errorDescription.setBase("Tag name shouldn't start or " + "end with whitespace"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } @@ -3275,7 +3270,7 @@ const TagDataByGuid & index = m_data->m_tags.get<TagByGuid>(); auto it = index.find(tag.parentGuid()); if (it == index.end()) { - errorDescription.setBase(QStringLiteral("Parent tag doesn't exist")); + errorDescription.setBase("Parent tag doesn't exist"); return qevercloud::EDAMErrorCode::UNKNOWN; } } @@ -3283,27 +3278,27 @@ return 0; } -qint32 FakeNoteStore::checkSavedSearchFields(const SavedSearch & savedSearch, - ErrorString & errorDescription) const +qint32 FakeNoteStore::checkSavedSearchFields( + const SavedSearch & savedSearch, ErrorString & errorDescription) const { if (!savedSearch.hasName()) { - errorDescription.setBase(QStringLiteral("Saved search name is not set")); + errorDescription.setBase("Saved search name is not set"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } if (!savedSearch.hasQuery()) { - errorDescription.setBase(QStringLiteral("Saved search query is not set")); + errorDescription.setBase("Saved search query is not set"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } const QString & savedSearchName = savedSearch.name(); if (savedSearchName.size() < qevercloud::EDAM_SAVED_SEARCH_NAME_LEN_MIN) { - errorDescription.setBase(QStringLiteral("Saved search name length is too small")); + errorDescription.setBase("Saved search name length is too small"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } if (savedSearchName.size() > qevercloud::EDAM_SAVED_SEARCH_NAME_LEN_MAX) { - errorDescription.setBase(QStringLiteral("Saved search name length is too large")); + errorDescription.setBase("Saved search name length is too large"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } @@ -3313,21 +3308,19 @@ // and hence doesn't match the text which should actually match if (savedSearchName != savedSearchName.trimmed()) { - errorDescription.setBase(QStringLiteral("Saved search name shouldn't " - "start or end with whitespace")); + errorDescription.setBase("Saved search name shouldn't " + "start or end with whitespace"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } const QString & savedSearchQuery = savedSearch.query(); if (savedSearchQuery.size() < qevercloud::EDAM_SEARCH_QUERY_LEN_MIN) { - errorDescription.setBase(QStringLiteral("Saved search query length " - "is too small")); + errorDescription.setBase("Saved search query length is too small"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } if (savedSearchQuery.size() > qevercloud::EDAM_SEARCH_QUERY_LEN_MAX) { - errorDescription.setBase(QStringLiteral("Saved search query length " - "is too large")); + errorDescription.setBase("Saved search query length is too large"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } @@ -3344,13 +3337,13 @@ ErrorString & errorDescription) const { if (!linkedNotebook.username.isSet()) { - errorDescription.setBase(QStringLiteral("Linked notebook owner is not set")); + errorDescription.setBase("Linked notebook owner is not set"); return qevercloud::EDAMErrorCode::DATA_REQUIRED; } if (!linkedNotebook.shardId.isSet() && !linkedNotebook.uri.isSet()) { - errorDescription.setBase(QStringLiteral("Neither linked notebook's shard " - "id nor uri is set")); + errorDescription.setBase("Neither linked notebook's shard " + "id nor uri is set"); return qevercloud::EDAMErrorCode::DATA_REQUIRED; } @@ -3358,8 +3351,8 @@ m_data->m_linkedNotebooks.get<LinkedNotebookByUsername>(); auto linkedNotebookIt = usernameIndex.find(linkedNotebook.username.ref()); if (linkedNotebookIt == usernameIndex.end()) { - errorDescription.setBase(QStringLiteral("Found no linked notebook " - "corresponding to the owner")); + errorDescription.setBase("Found no linked notebook " + "corresponding to the owner"); return qevercloud::EDAMErrorCode::UNKNOWN; } @@ -3367,28 +3360,28 @@ if (linkedNotebook.shardId.isSet()) { if (!existingLinkedNotebook.hasShardId()) { - errorDescription.setBase(QStringLiteral("Linked notebook belonging " - "to this owner has no shard id")); + errorDescription.setBase("Linked notebook belonging " + "to this owner has no shard id"); return qevercloud::EDAMErrorCode::SHARD_UNAVAILABLE; } if (existingLinkedNotebook.shardId() != linkedNotebook.shardId.ref()) { - errorDescription.setBase(QStringLiteral("Linked notebook belonging to " - "this owner has another shard id")); + errorDescription.setBase("Linked notebook belonging to " + "this owner has another shard id"); return qevercloud::EDAMErrorCode::SHARD_UNAVAILABLE; } } else if (linkedNotebook.uri.isSet()) { if (!existingLinkedNotebook.hasUri()) { - errorDescription.setBase(QStringLiteral("Linked notebook belonging to " - "this owner has no uri")); + errorDescription.setBase("Linked notebook belonging to " + "this owner has no uri"); return qevercloud::EDAMErrorCode::SHARD_UNAVAILABLE; } if (existingLinkedNotebook.uri() != linkedNotebook.uri.ref()) { - errorDescription.setBase(QStringLiteral("Linked notebook belonging to " - "this owner has another uri")); + errorDescription.setBase("Linked notebook belonging to " + "this owner has another uri"); return qevercloud::EDAMErrorCode::SHARD_UNAVAILABLE; } } @@ -3429,23 +3422,22 @@ const QString & value = it.value(); if (value.size() < qevercloud::EDAM_APPLICATIONDATA_VALUE_LEN_MIN) { - errorDescription.setBase(QStringLiteral("Resource app data value ") + - QStringLiteral("length is too small: ") + - value); + errorDescription.setBase( + QStringLiteral("Resource app data value ") + + QStringLiteral("length is too small: ") + value); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } if (value.size() > qevercloud::EDAM_APPLICATIONDATA_VALUE_LEN_MAX) { - errorDescription.setBase(QStringLiteral("Resource app data value ") + - QStringLiteral("length is too large: ") + - value); + errorDescription.setBase( + QStringLiteral("Resource app data value ") + + QStringLiteral("length is too large: ") + value); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } if (!valueRegExp.exactMatch(value)) { - errorDescription.setBase(QStringLiteral("Resource app data value " - "doesn't match the mandatory " - "regex")); + errorDescription.setBase("Resource app data value doesn't " + "match the mandatory regex"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } } @@ -3459,20 +3451,22 @@ ErrorString & errorDescription) const { if (key.size() < qevercloud::EDAM_APPLICATIONDATA_NAME_LEN_MIN) { - errorDescription.setBase(QStringLiteral("Resource app data key length ") + - QStringLiteral("is too small: ") + key); + errorDescription.setBase( + QStringLiteral("Resource app data key length ") + + QStringLiteral("is too small: ") + key); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } if (key.size() > qevercloud::EDAM_APPLICATIONDATA_NAME_LEN_MAX) { - errorDescription.setBase(QStringLiteral("Resource app data key length ") + - QStringLiteral("is too large: ") + key); + errorDescription.setBase( + QStringLiteral("Resource app data key length ") + + QStringLiteral("is too large: ") + key); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } if (!keyRegExp.exactMatch(key)) { - errorDescription.setBase(QStringLiteral("Resource app data key doesn't ") + - QStringLiteral("match the mandatory regex")); + errorDescription.setBase("Resource app data key doesn't " + "match the mandatory regex"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } @@ -3487,18 +3481,18 @@ const QString & username = linkedNotebook.username(); auto authTokenIt = m_data->m_linkedNotebookAuthTokens.find(username); if (authTokenIt == m_data->m_linkedNotebookAuthTokens.end()) { - errorDescription.setBase(QStringLiteral("Found no auth token for the given " - "linked notebook")); + errorDescription.setBase("Found no auth token for the given " + "linked notebook"); return qevercloud::EDAMErrorCode::PERMISSION_DENIED; } const QString & expectedLinkedNotebookAuthToken = authTokenIt.value(); if (linkedNotebookAuthToken != expectedLinkedNotebookAuthToken) { - errorDescription.setBase(QStringLiteral("Wrong linked notebook auth token")); - QNWARNING(errorDescription << QStringLiteral(", expected: ") + errorDescription.setBase("Wrong linked notebook auth token"); + QNWARNING(errorDescription << ", expected: " << expectedLinkedNotebookAuthToken - << QStringLiteral(", got: ") << linkedNotebookAuthToken - << QStringLiteral(", linked notebook: ") << linkedNotebook); + << ", got: " << linkedNotebookAuthToken + << ", linked notebook: " << linkedNotebook); return qevercloud::EDAMErrorCode::PERMISSION_DENIED; } @@ -3514,22 +3508,21 @@ m_data->m_notebooks.get<NotebookByGuid>(); auto notebookIt = notebookGuidIndex.find(notebookGuid); if (notebookIt == notebookGuidIndex.end()) { - errorDescription.setBase(QStringLiteral("No notebook with specified " - "guid was found")); + errorDescription.setBase("No notebook with specified guid was found"); return qevercloud::EDAMErrorCode::PERMISSION_DENIED; } const Notebook & notebook = *notebookIt; if (!notebook.hasLinkedNotebookGuid()) { - errorDescription.setBase(QStringLiteral("Notebook doesn't belong to " - "a linked notebook")); + errorDescription.setBase("Notebook doesn't belong to " + "a linked notebook"); return qevercloud::EDAMErrorCode::PERMISSION_DENIED; } if (linkedNotebookAuthToken.isEmpty()) { - errorDescription.setBase(QStringLiteral("Notebook belongs to a linked " - "notebook but linked notebook " - "auth token is empty")); + errorDescription.setBase("Notebook belongs to a linked " + "notebook but linked notebook " + "auth token is empty"); return qevercloud::EDAMErrorCode::PERMISSION_DENIED; } @@ -3538,8 +3531,8 @@ m_data->m_linkedNotebooks.get<LinkedNotebookByGuid>(); auto linkedNotebookIt = linkedNotebookGuidIndex.find(linkedNotebookGuid); if (linkedNotebookIt == linkedNotebookGuidIndex.end()) { - errorDescription.setBase(QStringLiteral("Found no linked notebook " - "corresponding to the notebook")); + errorDescription.setBase("Found no linked notebook " + "corresponding to the notebook"); return qevercloud::EDAMErrorCode::PERMISSION_DENIED; } @@ -3554,20 +3547,18 @@ ErrorString & errorDescription) const { if (!linkedNotebookAuthToken.isEmpty() && !tag.hasLinkedNotebookGuid()) { - errorDescription.setBase(QStringLiteral("Excess linked notebook auth token")); + errorDescription.setBase("Excess linked notebook auth token"); return qevercloud::EDAMErrorCode::PERMISSION_DENIED; } if (!tag.hasLinkedNotebookGuid()) { - errorDescription.setBase(QStringLiteral("Tag doesn't belong to " - "a linked notebook")); + errorDescription.setBase("Tag doesn't belong to a linked notebook"); return qevercloud::EDAMErrorCode::PERMISSION_DENIED; } if (linkedNotebookAuthToken.isEmpty()) { - errorDescription.setBase(QStringLiteral("Tag belongs to a linked notebook " - "but linked notebook auth token " - "is empty")); + errorDescription.setBase("Tag belongs to a linked notebook " + "but linked notebook auth token is empty"); return qevercloud::EDAMErrorCode::PERMISSION_DENIED; } @@ -3575,12 +3566,13 @@ m_data->m_linkedNotebooks.get<LinkedNotebookByGuid>(); auto it = linkedNotebookGuidIndex.find(tag.linkedNotebookGuid()); if (it == linkedNotebookGuidIndex.end()) { - errorDescription.setBase(QStringLiteral("Tag belongs to a linked notebook " - "but it was not found by guid")); + errorDescription.setBase("Tag belongs to a linked notebook " + "but it was not found by guid"); return qevercloud::EDAMErrorCode::PERMISSION_DENIED; } - return checkLinkedNotebookAuthToken(*it, linkedNotebookAuthToken, errorDescription); + return checkLinkedNotebookAuthToken(*it, linkedNotebookAuthToken, + errorDescription); } QString FakeNoteStore::nextName(const QString & name) const @@ -3603,21 +3595,19 @@ return result; } -qint32 FakeNoteStore::getSyncChunkImpl(const qint32 afterUSN, - const qint32 maxEntries, - const bool fullSyncOnly, - const QString & linkedNotebookGuid, - const qevercloud::SyncChunkFilter & filter, - qevercloud::SyncChunk & syncChunk, - ErrorString & errorDescription) +qint32 FakeNoteStore::getSyncChunkImpl( + const qint32 afterUSN, const qint32 maxEntries, + const bool fullSyncOnly, const QString & linkedNotebookGuid, + const qevercloud::SyncChunkFilter & filter, + qevercloud::SyncChunk & syncChunk, ErrorString & errorDescription) { if (afterUSN < 0) { - errorDescription.setBase(QStringLiteral("After USN is negative")); + errorDescription.setBase("After USN is negative"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } if (maxEntries < 1) { - errorDescription.setBase(QStringLiteral("Max entries is less than 1")); + errorDescription.setBase("Max entries is less than 1"); return qevercloud::EDAMErrorCode::BAD_DATA_FORMAT; } @@ -3627,8 +3617,8 @@ if (filter.notebookGuids.isSet() && !filter.notebookGuids.ref().isEmpty() && filter.includeExpunged.isSet() && filter.includeExpunged.ref()) { - errorDescription.setBase(QStringLiteral("Can't set notebook guids along " - "with include expunged")); + errorDescription.setBase("Can't set notebook guids along " + "with include expunged"); return qevercloud::EDAMErrorCode::DATA_CONFLICT; } @@ -3644,7 +3634,7 @@ m_data->m_linkedNotebooks.get<LinkedNotebookByUSN>(); syncChunk.updateCount = currentMaxUsn(linkedNotebookGuid); - QNDEBUG(QStringLiteral("Sync chunk update count = ") << syncChunk.updateCount); + QNDEBUG("Sync chunk update count = " << syncChunk.updateCount); GuidsOfCompleteSentItems & guidsOfCompleteSentItems = (linkedNotebookGuid.isEmpty() @@ -3716,30 +3706,30 @@ if (savedSearchIt != savedSearchUsnIndex.end()) { const SavedSearch & nextSearch = *savedSearchIt; - QNDEBUG(QStringLiteral("Checking saved search for the possibility ") - << QStringLiteral("to include it into the sync chunk: ") + QNDEBUG("Checking saved search for the possibility " + << "to include it into the sync chunk: " << nextSearch.qevercloudSavedSearch()); qint32 usn = nextSearch.updateSequenceNumber(); if (usn < lastItemUsn) { lastItemUsn = usn; nextItemType = NextItemType::SavedSearch; - QNDEBUG(QStringLiteral("Will include saved search into the sync chunk")); + QNDEBUG("Will include saved search into the sync chunk"); } } if ((nextItemType == NextItemType::None) && (tagIt != tagUsnIndex.end())) { const Tag & nextTag = *tagIt; - QNDEBUG(QStringLiteral("Checking tag for the possibility to include ") - << QStringLiteral("it into the sync chunk: ") + QNDEBUG("Checking tag for the possibility to include " + << "it into the sync chunk: " << nextTag.qevercloudTag()); qint32 usn = nextTag.updateSequenceNumber(); if (usn < lastItemUsn) { lastItemUsn = usn; nextItemType = NextItemType::Tag; - QNDEBUG(QStringLiteral("Will include tag into the sync chunk")); + QNDEBUG("Will include tag into the sync chunk"); } } @@ -3747,30 +3737,30 @@ (notebookIt != notebookUsnIndex.end())) { const Notebook & nextNotebook = *notebookIt; - QNDEBUG(QStringLiteral("Checking notebook for the possibility to ") - << QStringLiteral("include it into the sync chunk: ") + QNDEBUG("Checking notebook for the possibility to " + << "include it into the sync chunk: " << nextNotebook.qevercloudNotebook()); qint32 usn = nextNotebook.updateSequenceNumber(); if (usn < lastItemUsn) { lastItemUsn = usn; nextItemType = NextItemType::Notebook; - QNDEBUG(QStringLiteral("Will include notebook into the sync chunk")); + QNDEBUG("Will include notebook into the sync chunk"); } } if ((nextItemType == NextItemType::None) && (noteIt != noteUsnIndex.end())) { const Note & nextNote = *noteIt; - QNDEBUG(QStringLiteral("Checking note for the possibility to include ") - << QStringLiteral("it into the sync chunk: ") + QNDEBUG("Checking note for the possibility to include " + << "it into the sync chunk: " << nextNote.qevercloudNote()); qint32 usn = nextNote.updateSequenceNumber(); if (usn < lastItemUsn) { lastItemUsn = usn; nextItemType = NextItemType::Note; - QNDEBUG(QStringLiteral("Will include note into the sync chunk")); + QNDEBUG("Will include note into the sync chunk"); } } @@ -3778,15 +3768,15 @@ (resourceIt != resourceUsnIndex.end())) { const Resource & nextResource = *resourceIt; - QNDEBUG(QStringLiteral("Checking resource for the possibility to ") - << QStringLiteral("include it into the sync chunk: ") + QNDEBUG("Checking resource for the possibility to " + << "include it into the sync chunk: " << nextResource.qevercloudResource()); qint32 usn = nextResource.updateSequenceNumber(); if (usn < lastItemUsn) { lastItemUsn = usn; nextItemType = NextItemType::Resource; - QNDEBUG(QStringLiteral("Will include resource into the sync chunk")); + QNDEBUG("Will include resource into the sync chunk"); } } @@ -3794,15 +3784,15 @@ (linkedNotebookIt != linkedNotebookUsnIndex.end())) { const LinkedNotebook & nextLinkedNotebook = *linkedNotebookIt; - QNDEBUG(QStringLiteral("Checking linked notebook for the possibility ") - << QStringLiteral("to include it into the sync chunk: ") + QNDEBUG("Checking linked notebook for the possibility " + << "to include it into the sync chunk: " << nextLinkedNotebook.qevercloudLinkedNotebook()); qint32 usn = nextLinkedNotebook.updateSequenceNumber(); if (usn < lastItemUsn) { lastItemUsn = usn; nextItemType = NextItemType::LinkedNotebook; - QNDEBUG(QStringLiteral("Will include linked notebook into the sync chunk")); + QNDEBUG("Will include linked notebook into the sync chunk"); } } @@ -3820,9 +3810,9 @@ syncChunk.searches->append(savedSearchIt->qevercloudSavedSearch()); syncChunk.chunkHighUSN = savedSearchIt->updateSequenceNumber(); - QNDEBUG(QStringLiteral("Added saved search to sync chunk: ") + QNDEBUG("Added saved search to sync chunk: " << savedSearchIt->qevercloudSavedSearch() - << QStringLiteral("\nSync chunk high USN updated to ") + << "\nSync chunk high USN updated to " << syncChunk.chunkHighUSN); if (!m_data->m_onceAPIRateLimitExceedingTriggered) { @@ -3841,9 +3831,8 @@ syncChunk.tags->append(tagIt->qevercloudTag()); syncChunk.chunkHighUSN = tagIt->updateSequenceNumber(); - QNDEBUG(QStringLiteral("Added tag to sync chunk: ") - << tagIt->qevercloudTag() - << QStringLiteral("\nSync chunk high USN updated to ") + QNDEBUG("Added tag to sync chunk: " << tagIt->qevercloudTag() + << "\nSync chunk high USN updated to " << syncChunk.chunkHighUSN); if (!m_data->m_onceAPIRateLimitExceedingTriggered) { @@ -3862,14 +3851,14 @@ syncChunk.notebooks->append(notebookIt->qevercloudNotebook()); syncChunk.chunkHighUSN = notebookIt->updateSequenceNumber(); - QNDEBUG(QStringLiteral("Added notebook to sync chunk: ") + QNDEBUG("Added notebook to sync chunk: " << notebookIt->qevercloudNotebook() - << QStringLiteral("\nSync chunk high USN updated to ") + << "\nSync chunk high USN updated to " << syncChunk.chunkHighUSN); if (!m_data->m_onceAPIRateLimitExceedingTriggered) { Q_UNUSED(guidsOfCompleteSentItems.m_notebookGuids.insert( - notebookIt->guid())) + notebookIt->guid())) } ++notebookIt; @@ -3953,8 +3942,8 @@ syncChunk.notes->append(qecNote); syncChunk.chunkHighUSN = noteIt->updateSequenceNumber(); - QNDEBUG(QStringLiteral("Added note to sync chunk: ") << qecNote - << QStringLiteral("\nSync chunk high USN updated to ") + QNDEBUG("Added note to sync chunk: " << qecNote + << "\nSync chunk high USN updated to " << syncChunk.chunkHighUSN); ++noteIt; noteIt = nextNoteByUsnIterator(noteIt, linkedNotebookGuid); @@ -3992,12 +3981,12 @@ syncChunk.resources->append(qecResource); syncChunk.chunkHighUSN = resourceIt->updateSequenceNumber(); - QNDEBUG(QStringLiteral("Added resource to sync chunk: ") - << qecResource - << QStringLiteral("\nSync chunk high USN updated to ") + QNDEBUG("Added resource to sync chunk: " << qecResource + << "\nSync chunk high USN updated to " << syncChunk.chunkHighUSN); ++resourceIt; - resourceIt = nextResourceByUsnIterator(resourceIt, linkedNotebookGuid); + resourceIt = nextResourceByUsnIterator(resourceIt, + linkedNotebookGuid); } break; case NextItemType::LinkedNotebook: @@ -4009,29 +3998,29 @@ syncChunk.linkedNotebooks->append( linkedNotebookIt->qevercloudLinkedNotebook()); syncChunk.chunkHighUSN = linkedNotebookIt->updateSequenceNumber(); - QNDEBUG(QStringLiteral("Added linked notebook to sync chunk: ") + QNDEBUG("Added linked notebook to sync chunk: " << linkedNotebookIt->qevercloudLinkedNotebook() - << QStringLiteral("\nSync chunk high USN updated to ") + << "\nSync chunk high USN updated to " << syncChunk.chunkHighUSN); if (!m_data->m_onceAPIRateLimitExceedingTriggered) { Q_UNUSED(guidsOfCompleteSentItems.m_linkedNotebookGuids.insert( - linkedNotebookIt->guid())) + linkedNotebookIt->guid())) } ++linkedNotebookIt; } break; default: - QNWARNING(QStringLiteral("Unexpected next item type: ") << nextItemType); + QNWARNING("Unexpected next item type: " << nextItemType); break; } } if (!syncChunk.chunkHighUSN.isSet()) { syncChunk.chunkHighUSN = syncChunk.updateCount; - QNDEBUG(QStringLiteral("Sync chunk's high USN was still not set, set it ") - << QStringLiteral("to the update count: ") << syncChunk.updateCount); + QNDEBUG("Sync chunk's high USN was still not set, set it " + << "to the update count: " << syncChunk.updateCount); } if (fullSyncOnly) { @@ -4040,16 +4029,19 @@ return 0; } - if (linkedNotebookGuid.isEmpty() && !m_data->m_expungedSavedSearchGuids.isEmpty()) + if (linkedNotebookGuid.isEmpty() && + !m_data->m_expungedSavedSearchGuids.isEmpty()) { if (!syncChunk.expungedSearches.isSet()) { syncChunk.expungedSearches = QList<qevercloud::Guid>(); } - syncChunk.expungedSearches->reserve(m_data->m_expungedSavedSearchGuids.size()); + syncChunk.expungedSearches->reserve( + m_data->m_expungedSavedSearchGuids.size()); for(auto it = m_data->m_expungedSavedSearchGuids.constBegin(), - end = m_data->m_expungedSavedSearchGuids.constEnd(); it != end; ++it) + end = m_data->m_expungedSavedSearchGuids.constEnd(); + it != end; ++it) { syncChunk.expungedSearches->append(*it); } @@ -4076,7 +4068,9 @@ syncChunk.expungedNotebooks = QList<qevercloud::Guid>(); } - syncChunk.expungedNotebooks->reserve(m_data->m_expungedNotebookGuids.size()); + syncChunk.expungedNotebooks->reserve( + m_data->m_expungedNotebookGuids.size()); + for(auto it = m_data->m_expungedNotebookGuids.constBegin(), end = m_data->m_expungedNotebookGuids.constEnd(); it != end; ++it) { @@ -4107,8 +4101,10 @@ syncChunk.expungedLinkedNotebooks->reserve( m_data->m_expungedLinkedNotebookGuids.size()); + for(auto it = m_data->m_expungedLinkedNotebookGuids.constBegin(), - end = m_data->m_expungedLinkedNotebookGuids.constEnd(); it != end; ++it) + end = m_data->m_expungedLinkedNotebookGuids.constEnd(); + it != end; ++it) { syncChunk.expungedLinkedNotebooks->append(*it); } @@ -4120,9 +4116,9 @@ void FakeNoteStore::considerAllExistingDataItemsSentBeforeRateLimitBreachImpl( const QString & linkedNotebookGuid) { - QNDEBUG(QStringLiteral("FakeNoteStore::") - << QStringLiteral("considerAllExistingDataItemsSentBeforeRateLimitBreachImpl: ") - << QStringLiteral("linked notebook guid = ") + QNDEBUG("FakeNoteStore::" + << "considerAllExistingDataItemsSentBeforeRateLimitBreachImpl: " + << "linked notebook guid = " << linkedNotebookGuid); GuidsOfCompleteSentItems & guidsOfCompleteSentItems = @@ -4138,7 +4134,7 @@ end = savedSearchGuidIndex.end(); it != end; ++it) { Q_UNUSED(guidsOfCompleteSentItems.m_savedSearchGuids.insert(it->guid())) - QNTRACE(QStringLiteral("Marked saved search as processed: ") << *it); + QNTRACE("Marked saved search as processed: " << *it); } } @@ -4159,7 +4155,7 @@ } Q_UNUSED(guidsOfCompleteSentItems.m_notebookGuids.insert(notebook.guid())) - QNTRACE(QStringLiteral("Marked notebook as processed: ") << notebook); + QNTRACE("Marked notebook as processed: " << notebook); } const TagDataByGuid & tagGuidIndex = m_data->m_tags.get<TagByGuid>(); @@ -4177,7 +4173,7 @@ } Q_UNUSED(guidsOfCompleteSentItems.m_tagGuids.insert(tag.guid())) - QNTRACE(QStringLiteral("Marked tag as processed: ") << tag); + QNTRACE("Marked tag as processed: " << tag); } if (linkedNotebookGuid.isEmpty()) @@ -4187,19 +4183,20 @@ for(auto it = linkedNotebookGuidIndex.begin(), end = linkedNotebookGuidIndex.end(); it != end; ++it) { - Q_UNUSED(guidsOfCompleteSentItems.m_linkedNotebookGuids.insert(it->guid())) - QNTRACE(QStringLiteral("Marked linked notebook as processed: ") << *it); + Q_UNUSED(guidsOfCompleteSentItems.m_linkedNotebookGuids.insert( + it->guid())) + QNTRACE("Marked linked notebook as processed: " << *it); } } const NoteDataByGuid & noteGuidIndex = m_data->m_notes.get<NoteByGuid>(); - for(auto it = noteGuidIndex.begin(), end = noteGuidIndex.end(); it != end; ++it) + for(auto it = noteGuidIndex.begin(), + end = noteGuidIndex.end(); it != end; ++it) { const Note & note = *it; auto notebookIt = notebookGuidIndex.find(note.notebookGuid()); if (Q_UNLIKELY(notebookIt == notebookGuidIndex.end())) { - QNWARNING(QStringLiteral("Skipping note for which no notebook was found: ") - << note); + QNWARNING("Skipping note for which no notebook was found: " << note); continue; } @@ -4215,7 +4212,7 @@ } Q_UNUSED(guidsOfCompleteSentItems.m_noteGuids.insert(note.guid())) - QNTRACE(QStringLiteral("Marked note as processed: ") << note); + QNTRACE("Marked note as processed: " << note); } const ResourceDataByGuid & resourceGuidIndex = @@ -4226,16 +4223,16 @@ const Resource & resource = *it; auto noteIt = noteGuidIndex.find(resource.noteGuid()); if (Q_UNLIKELY(noteIt == noteGuidIndex.end())) { - QNWARNING(QStringLiteral("Skipping resource for which no note was found: ") - << resource); + QNWARNING("Skipping resource for which no note was found: " + << resource); continue; } const Note & note = *noteIt; auto notebookIt = notebookGuidIndex.find(note.notebookGuid()); if (Q_UNLIKELY(notebookIt == notebookGuidIndex.end())) { - QNWARNING(QStringLiteral("Skipping resource for which note no notebook ") - << QStringLiteral("was found: ") << note); + QNWARNING("Skipping resource for which note no notebook was found: " + << note); continue; } @@ -4251,7 +4248,7 @@ } Q_UNUSED(guidsOfCompleteSentItems.m_resourceGuids.insert(resource.guid())) - QNTRACE(QStringLiteral("Marked resource as processed: ") << resource); + QNTRACE("Marked resource as processed: " << resource); } } @@ -4275,19 +4272,20 @@ if (linkedNotebookGuid.isEmpty()) { m_data->m_maxUsnForUserOwnDataBeforeRateLimitBreach = maxUsn; - QNTRACE(QStringLiteral("Max USN for user own data before rate limit breach: ") + QNTRACE("Max USN for user own data before rate limit breach: " << maxUsn); } else { m_data->m_maxUsnsForLinkedNotebooksDataBeforeRateLimitBreach[linkedNotebookGuid] = maxUsn; - QNTRACE(QStringLiteral("Max USN for linked notebook with guid " ) - << linkedNotebookGuid << QStringLiteral(" is ") << maxUsn); + QNTRACE("Max USN for linked notebook with guid " << linkedNotebookGuid + << " is " << maxUsn); } } template <class ConstIterator, class UsnIndex> -ConstIterator FakeNoteStore::advanceIterator(ConstIterator it, const UsnIndex & index, - const QString & linkedNotebookGuid) const +ConstIterator FakeNoteStore::advanceIterator( + ConstIterator it, const UsnIndex & index, + const QString & linkedNotebookGuid) const { while(it != index.end()) { @@ -4315,8 +4313,9 @@ } FakeNoteStore::NoteDataByUSN::const_iterator -FakeNoteStore::nextNoteByUsnIterator(NoteDataByUSN::const_iterator it, - const QString & targetLinkedNotebookGuid) const +FakeNoteStore::nextNoteByUsnIterator( + NoteDataByUSN::const_iterator it, + const QString & targetLinkedNotebookGuid) const { const NoteDataByUSN & noteUsnIndex = m_data->m_notes.get<NoteByUSN>(); const NotebookDataByGuid & notebookGuidIndex = @@ -4326,10 +4325,10 @@ { const QString & notebookGuid = it->notebookGuid(); auto noteNotebookIt = notebookGuidIndex.find(notebookGuid); - if (Q_UNLIKELY(noteNotebookIt == notebookGuidIndex.end())) { - QNWARNING(QStringLiteral("Found note which notebook guid doesn't ") - << QStringLiteral("correspond to any existing notebook: ") - << *it); + if (Q_UNLIKELY(noteNotebookIt == notebookGuidIndex.end())) + { + QNWARNING("Found note which notebook guid doesn't " + << "correspond to any existing notebook: " << *it); ++it; continue; } @@ -4356,8 +4355,9 @@ } FakeNoteStore::ResourceDataByUSN::const_iterator -FakeNoteStore::nextResourceByUsnIterator(ResourceDataByUSN::const_iterator it, - const QString & targetLinkedNotebookGuid) const +FakeNoteStore::nextResourceByUsnIterator( + ResourceDataByUSN::const_iterator it, + const QString & targetLinkedNotebookGuid) const { const ResourceDataByUSN & resourceUsnIndex = m_data->m_resources.get<ResourceByUSN>(); @@ -4369,10 +4369,10 @@ const QString & noteGuid = it->noteGuid(); auto resourceNoteIt = noteGuidIndex.find(noteGuid); - if (Q_UNLIKELY(resourceNoteIt == noteGuidIndex.end())) { - QNWARNING(QStringLiteral("Found resource which note guid doesn't ") - << QStringLiteral("correspond to any existing note: ") - << *it); + if (Q_UNLIKELY(resourceNoteIt == noteGuidIndex.end())) + { + QNWARNING("Found resource which note guid doesn't " + << "correspond to any existing note: " << *it); ++it; continue; } @@ -4380,10 +4380,10 @@ const Note & note = *resourceNoteIt; const QString & notebookGuid = note.notebookGuid(); auto noteNotebookIt = notebookGuidIndex.find(notebookGuid); - if (Q_UNLIKELY(noteNotebookIt == notebookGuidIndex.end())) { - QNWARNING(QStringLiteral("Found note which notebook guid doesn't ") - << QStringLiteral("correspond to any existing notebook: ") - << note); + if (Q_UNLIKELY(noteNotebookIt == notebookGuidIndex.end())) + { + QNWARNING("Found note which notebook guid doesn't " + << "correspond to any existing notebook: " << note); ++it; continue; } diff -Nru libquentier-0.5.0/src/tests/synchronization/SynchronizationManagerSignalsCatcher.cpp libquentier-0.5.0/src/tests/synchronization/SynchronizationManagerSignalsCatcher.cpp --- libquentier-0.5.0/src/tests/synchronization/SynchronizationManagerSignalsCatcher.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/tests/synchronization/SynchronizationManagerSignalsCatcher.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -225,10 +225,10 @@ void SynchronizationManagerSignalsCatcher::onSyncChunkDownloadProgress( qint32 highestDownloadedUsn, qint32 highestServerUsn, qint32 lastPreviousUsn) { - QNDEBUG(QStringLiteral("SynchronizationManagerSignalsCatcher::") - << QStringLiteral("onSyncChunkDownloadProgress: highest downloaded USN = ") - << highestDownloadedUsn << QStringLiteral(", highest server USN = ") - << highestServerUsn << QStringLiteral(", last previous USN = ") + QNDEBUG("SynchronizationManagerSignalsCatcher::" + << "onSyncChunkDownloadProgress: highest downloaded USN = " + << highestDownloadedUsn << ", highest server USN = " + << highestServerUsn << ", last previous USN = " << lastPreviousUsn); SyncChunkDownloadProgress progress; @@ -243,12 +243,12 @@ qint32 highestDownloadedUsn, qint32 highestServerUsn, qint32 lastPreviousUsn, LinkedNotebook linkedNotebook) { - QNDEBUG(QStringLiteral("SynchronizationManagerSignalsCatcher::") - << QStringLiteral("onLinkedNotebookSyncChunkDownloadProgress: ") - << QStringLiteral("highest downloaded USN = ") - << highestDownloadedUsn << QStringLiteral(", highest server USN = ") - << highestServerUsn << QStringLiteral(", last previous USN = ") - << lastPreviousUsn << QStringLiteral(", linked notebook: ") + QNDEBUG("SynchronizationManagerSignalsCatcher::" + << "onLinkedNotebookSyncChunkDownloadProgress: " + << "highest downloaded USN = " + << highestDownloadedUsn << ", highest server USN = " + << highestServerUsn << ", last previous USN = " + << lastPreviousUsn << ", linked notebook: " << linkedNotebook); QVERIFY2(linkedNotebook.hasGuid(), diff -Nru libquentier-0.5.0/src/tests/synchronization/SynchronizationTester.cpp libquentier-0.5.0/src/tests/synchronization/SynchronizationTester.cpp --- libquentier-0.5.0/src/tests/synchronization/SynchronizationTester.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/tests/synchronization/SynchronizationTester.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -39,45 +39,50 @@ #define MODIFIED_LOCALLY_SUFFIX QStringLiteral("_modified_locally") #define MODIFIED_REMOTELY_SUFFIX QStringLiteral("_modified_remotely") -#define CATCH_EXCEPTION() \ - catch(const std::exception & exception) { \ - SysInfo sysInfo; \ - QFAIL(qPrintable(QStringLiteral("Caught exception: ") +\ - QString::fromUtf8(exception.what()) + \ - QStringLiteral(", backtrace: ") +\ - sysInfo.stackTrace())); \ - } +#define CATCH_EXCEPTION() \ + catch(const std::exception & exception) { \ + SysInfo sysInfo; \ + QFAIL(qPrintable(QStringLiteral("Caught exception: ") + \ + QString::fromUtf8(exception.what()) + \ + QStringLiteral(", backtrace: ") + \ + sysInfo.stackTrace())); \ + } \ +// CATCH_EXCEPTION #if QT_VERSION >= 0x050000 inline void nullMessageHandler(QtMsgType type, const QMessageLogContext &, const QString & message) { if (type != QtDebugMsg) { - QTextStream(stdout) << message << QStringLiteral("\n"); + QTextStream(stdout) << message << "\n"; } } #else inline void nullMessageHandler(QtMsgType type, const char * message) { if (type != QtDebugMsg) { - QTextStream(stdout) << message << QStringLiteral("\n"); + QTextStream(stdout) << message << "\n"; } } #endif -#define CHECK_EXPECTED(expected) \ - if (!catcher.expected()) { \ - QFAIL(qPrintable(QString::fromUtf8("SynchronizationManagerSignalsCatcher::") + \ - QString::fromUtf8(#expected) + \ - QString::fromUtf8(" unexpectedly returned false"))); \ - } - -#define CHECK_UNEXPECTED(unexpected) \ - if (catcher.unexpected()) { \ - QFAIL(qPrintable(QString::fromUtf8("SynchronizationManagerSignalsCatcher::") + \ - QString::fromUtf8(#unexpected) + \ - QString::fromUtf8(" unexpectedly returned true"))); \ - } +#define CHECK_EXPECTED(expected) \ + if (!catcher.expected()) { \ + QFAIL(qPrintable( \ + QString::fromUtf8("SynchronizationManagerSignalsCatcher::") + \ + QString::fromUtf8(#expected) + \ + QString::fromUtf8(" unexpectedly returned false"))); \ + } \ +// CHECK_EXPECTED + +#define CHECK_UNEXPECTED(unexpected) \ + if (catcher.unexpected()) { \ + QFAIL(qPrintable( \ + QString::fromUtf8("SynchronizationManagerSignalsCatcher::") + \ + QString::fromUtf8(#unexpected) + \ + QString::fromUtf8(" unexpectedly returned true"))); \ + } \ +// CHECK_UNEXPECTED namespace quentier { namespace test { @@ -116,7 +121,8 @@ QuentierRestartLogging(); m_testAccount = Account(m_testAccount.name(), Account::Type::Evernote, - m_testAccount.id() + 1, Account::EvernoteAccountType::Free, + m_testAccount.id() + 1, + Account::EvernoteAccountType::Free, QStringLiteral("www.evernote.com")); LocalStorageManager::StartupOptions startupOptions( LocalStorageManager::StartupOption::ClearDatabase | @@ -6386,29 +6392,28 @@ QString error; QTextStream strm(&error); - strm << QStringLiteral("The number of tags in local and remote storages " - "doesn't match: ") - << localTags.size() << QStringLiteral(" local ones vs ") - << remoteTags.size() << QStringLiteral(" remote ones\nLocal tags:\n"); + strm << "The number of tags in local and remote storages doesn't match: " + << localTags.size() << " local ones vs " + << remoteTags.size() << " remote ones\nLocal tags:\n"; for(auto it = localTags.constBegin(), end = localTags.constEnd(); it != end; ++it) { - strm << it.value() << QStringLiteral("\n"); + strm << it.value() << "\n"; } - strm << QStringLiteral("\nRemote tags:\n"); + strm << "\nRemote tags:\n"; for(auto it = remoteTags.constBegin(), end = remoteTags.constEnd(); it != end; ++it) { - strm << it.value() << QStringLiteral("\n"); + strm << it.value() << "\n"; } QNWARNING(error); } QVERIFY2(localTags.size() == remoteTags.size(), - qPrintable(QString::fromUtf8("The number of tags in local and remote " - "storages doesn't match: ") + + qPrintable(QString::fromUtf8("The number of tags in local and " + "remote storages doesn't match: ") + QString::number(localTags.size()) + QString::fromUtf8(" local ones vs ") + QString::number(remoteTags.size()) + @@ -6497,9 +6502,8 @@ } if (rit.value() != it.value()) { - QNWARNING(QStringLiteral("Found mismatch between local and remote " - "notes: local one: ") - << it.value() << QStringLiteral("\nRemote one: ") << rit.value()); + QNWARNING("Found mismatch between local and remote notes: local one: " + << it.value() << "\nRemote one: " << rit.value()); } QVERIFY2(rit.value() == it.value(), @@ -6936,7 +6940,7 @@ QFAIL("Local storage manager is null"); } - QString localLinkedNotebookGuid = QStringLiteral(""); + QString localLinkedNotebookGuid = QLatin1String(""); if (!linkedNotebookGuid.isEmpty()) { localLinkedNotebookGuid = linkedNotebookGuid; } @@ -6984,7 +6988,7 @@ QFAIL("Local storage manager is null"); } - QString localLinkedNotebookGuid = QStringLiteral(""); + QString localLinkedNotebookGuid = QLatin1String(""); if (!linkedNotebookGuid.isEmpty()) { localLinkedNotebookGuid = linkedNotebookGuid; } @@ -7032,7 +7036,7 @@ QFAIL("Local storage manager is null"); } - QString localLinkedNotebookGuid = QStringLiteral(""); + QString localLinkedNotebookGuid = QLatin1String(""); if (!linkedNotebookGuid.isEmpty()) { localLinkedNotebookGuid = linkedNotebookGuid; } @@ -7083,7 +7087,7 @@ QFAIL("Local storage manager is null"); } - QString localLinkedNotebookGuid = QStringLiteral(""); + QString localLinkedNotebookGuid = QLatin1String(""); if (!linkedNotebookGuid.isEmpty()) { localLinkedNotebookGuid = linkedNotebookGuid; } @@ -7146,10 +7150,11 @@ ErrorString errorDescription; QList<LinkedNotebook> localLinkedNotebooks = - pLocalStorageManager->listLinkedNotebooks(LocalStorageManager::ListAll, - errorDescription, 0, 0, - LocalStorageManager::ListLinkedNotebooksOrder::NoOrder, - LocalStorageManager::OrderDirection::Ascending); + pLocalStorageManager->listLinkedNotebooks( + LocalStorageManager::ListAll, + errorDescription, 0, 0, + LocalStorageManager::ListLinkedNotebooksOrder::NoOrder, + LocalStorageManager::OrderDirection::Ascending); if (localLinkedNotebooks.isEmpty() && !errorDescription.isEmpty()) { QFAIL(qPrintable(errorDescription.nonLocalizedString())); } @@ -7416,14 +7421,18 @@ listResourcesFromLocalStorage(0, linkedNotebookGuid, localResources); listResourcesFromFakeNoteStore(0, linkedNotebookGuid, remoteResources); -#define PRINT_CONTAINER_ITEMS_GUIDS_AND_USNS(container) \ - for(auto it = container.constBegin(), end = container.constEnd(); it != end; ++it) { \ - message += QStringLiteral(" guid = ") % it.key() % QStringLiteral(", USN = ") + \ - (it.value().updateSequenceNum.isSet() \ - ? QString::number(it.value().updateSequenceNum.ref()) \ - : QStringLiteral("<not set>")) + \ - QStringLiteral("\n"); \ - } +#define PRINT_CONTAINER_ITEMS_GUIDS_AND_USNS(container) \ + for(auto it = container.constBegin(), \ + end = container.constEnd(); it != end; ++it) \ + { \ + message += QStringLiteral(" guid = ") % it.key() % \ + QStringLiteral(", USN = ") + \ + (it.value().updateSequenceNum.isSet() \ + ? QString::number(it.value().updateSequenceNum.ref()) \ + : QStringLiteral("<not set>")) + \ + QStringLiteral("\n"); \ + } \ +// PRINT_CONTAINER_ITEMS_GUIDS_AND_USNS if (linkedNotebookGuid.isEmpty()) { message += QStringLiteral("\nLocal saved searches:\n"); diff -Nru libquentier-0.5.0/src/tests/TestMacros.h libquentier-0.5.0/src/tests/TestMacros.h --- libquentier-0.5.0/src/tests/TestMacros.h 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/tests/TestMacros.h 2019-07-11 10:46:53.000000000 +0000 @@ -23,25 +23,28 @@ #include <QDebug> #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) -#define VERIFY_QDEBUG_HELPER() \ - dbg.nospace(); \ - dbg.noquote() +#define VERIFY_QDEBUG_HELPER() \ + dbg.nospace(); \ + dbg.noquote() \ +// VERIFY_QDEBUG_HELPER #else -#define VERIFY_QDEBUG_HELPER() \ - dbg.nospace() +#define VERIFY_QDEBUG_HELPER() \ + dbg.nospace() \ +// VERIFY_QDEBUG_HELPER #endif -#define VERIFY2(condition, message) \ - if (!(condition)) \ - { \ - QString msg; \ - { \ - QDebug dbg(&msg); \ - VERIFY_QDEBUG_HELPER(); \ - dbg << message; \ - } \ - QFAIL(qPrintable(msg)); \ - } +#define VERIFY2(condition, message) \ + if (!(condition)) \ + { \ + QString msg; \ + { \ + QDebug dbg(&msg); \ + VERIFY_QDEBUG_HELPER(); \ + dbg << message; \ + } \ + QFAIL(qPrintable(msg)); \ + } \ +// VERIFY2 // 10 minutes should be enough #define MAX_ALLOWED_TEST_DURATION_MSEC 600000 diff -Nru libquentier-0.5.0/src/tests/types/ResourceRecognitionIndicesParsingTest.cpp libquentier-0.5.0/src/tests/types/ResourceRecognitionIndicesParsingTest.cpp --- libquentier-0.5.0/src/tests/types/ResourceRecognitionIndicesParsingTest.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/tests/types/ResourceRecognitionIndicesParsingTest.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -28,14 +28,13 @@ bool parseResourceRecognitionIndicesAndItemsTest(QString & error) { - QNDEBUG(QStringLiteral("parseResourceRecognitionIndicesAndItemsTest")); + QNDEBUG("parseResourceRecognitionIndicesAndItemsTest"); QFile resource(QStringLiteral(":/tests/recoIndex-all-in-one-example.xml")); if (!resource.open(QIODevice::ReadOnly)) { error = QStringLiteral("Can't open test file ") + resource.fileName(); - QNWARNING(error << QStringLiteral(", error: ") << resource.errorString() - << QStringLiteral(" (error code ") << resource.error() - << QStringLiteral(")")); + QNWARNING(error << ", error: " << resource.errorString() + << " (error code " << resource.error() << ")"); return false; } @@ -49,14 +48,15 @@ return false; } -#define CHECK_INDICES_PROPERTY(accessor, expected, property) \ - if (recoIndices.accessor() != QStringLiteral(expected)) { \ - error = QStringLiteral("Incorrectly parsed reco indices " property ": " \ - "expected \"" expected "\", got \"") + \ - recoIndices.accessor() + QStringLiteral("\""); \ - QNWARNING(error << QStringLiteral("; reco indices: ") << recoIndices); \ - return false; \ - } +#define CHECK_INDICES_PROPERTY(accessor, expected, property) \ + if (recoIndices.accessor() != QStringLiteral(expected)) { \ + error = QStringLiteral("Incorrectly parsed reco indices " property ": "\ + "expected \"" expected "\", got \"") + \ + recoIndices.accessor() + QStringLiteral("\""); \ + QNWARNING(error << "; reco indices: " << recoIndices); \ + return false; \ + } \ +// CHECK_INDICES_PROPERTY CHECK_INDICES_PROPERTY(docType, "picture", "doc type") CHECK_INDICES_PROPERTY(objectType, "ink", "object type") @@ -70,7 +70,7 @@ error = QStringLiteral("Incorrectly parsed reco indices object height: ") + QStringLiteral("expected 2592, got ") + QString::number(recoIndices.objectHeight()); - QNWARNING(error << QStringLiteral("; reco indices: ") << recoIndices); + QNWARNING(error << "; reco indices: " << recoIndices); return false; } @@ -78,7 +78,7 @@ error = QStringLiteral("Incorrectly parsed reco indices object width: ") + QStringLiteral("expected 1936, got ") + QString::number(recoIndices.objectWidth()); - QNWARNING(error << QStringLiteral("; reco indices: ") << recoIndices); + QNWARNING(error << "; reco indices: " << recoIndices); return false; } @@ -87,18 +87,20 @@ if (numItems != 2) { error = QStringLiteral("Incorrectly parsed reco indices items: expected ") + QStringLiteral("2 items, got ") + QString::number(numItems); - QNWARNING(error << QStringLiteral("; reco indices: ") << recoIndices); + QNWARNING(error << "; reco indices: " << recoIndices); return false; } -#define CHECK_ITEM_PROPERTY(item, accessor, expected, property) \ - if (item.accessor() != expected) { \ - error = QStringLiteral("Incorrectly parsed recognition item's " property ": " \ - "expected ") + QString::number(expected) + \ - QStringLiteral(", got ") + QString::number(item.accessor()); \ - QNWARNING(error << QStringLiteral("; reco indices: ") << recoIndices); \ - return false; \ - } +#define CHECK_ITEM_PROPERTY(item, accessor, expected, property) \ + if (item.accessor() != expected) { \ + error = QStringLiteral("Incorrectly parsed recognition item's " \ + property ": expected ") + \ + QString::number(expected) + \ + QStringLiteral(", got ") + QString::number(item.accessor()); \ + QNWARNING(error << "; reco indices: " << recoIndices); \ + return false; \ + } \ +// CHECK_ITEM_PROPERTY const ResourceRecognitionIndexItem & item0 = items[0]; CHECK_ITEM_PROPERTY(item0, x, 853, "x") @@ -106,16 +108,18 @@ CHECK_ITEM_PROPERTY(item0, w, 14, "w") CHECK_ITEM_PROPERTY(item0, h, 17, "h") - QVector<ResourceRecognitionIndexItem::ObjectItem> objectItems0 = item0.objectItems(); + QVector<ResourceRecognitionIndexItem::ObjectItem> objectItems0 = + item0.objectItems(); if (!objectItems0.empty()) { error = QStringLiteral("Incorrectly parsed recognition item's object ") + QStringLiteral("items: expected none of them, got ") + QString::number(objectItems0.size()); - QNWARNING(error << QStringLiteral("; reco indices: ") << recoIndices); + QNWARNING(error << "; reco indices: " << recoIndices); return false; } - QVector<ResourceRecognitionIndexItem::ShapeItem> shapeItems0 = item0.shapeItems(); + QVector<ResourceRecognitionIndexItem::ShapeItem> shapeItems0 = + item0.shapeItems(); if (!shapeItems0.empty()) { error = QStringLiteral("Incorrectly parsed recognition item's shape items: ") + QStringLiteral("expected none of them, got ") + @@ -124,45 +128,49 @@ return false; } - QVector<ResourceRecognitionIndexItem::BarcodeItem> barcodeItems0 = item0.barcodeItems(); + QVector<ResourceRecognitionIndexItem::BarcodeItem> barcodeItems0 = + item0.barcodeItems(); if (!barcodeItems0.empty()) { error = QStringLiteral("Incorrectly parsed recognition item's barcode ") + QStringLiteral("items: expected none of them, got ") + QString::number(barcodeItems0.size()); - QNWARNING(error << QStringLiteral("; reco indices: ") << recoIndices); + QNWARNING(error << "; reco indices: " << recoIndices); return false; } - QVector<ResourceRecognitionIndexItem::TextItem> textItems0 = item0.textItems(); + QVector<ResourceRecognitionIndexItem::TextItem> textItems0 = + item0.textItems(); if (textItems0.size() != 4) { error = QStringLiteral("Incorrectly parsed recognition item's text items: ") + QStringLiteral("expected 4 text items, got ") + QString::number(textItems0.size()); - QNWARNING(error << QStringLiteral("; reco indices: ") << recoIndices); + QNWARNING(error << "; reco indices: " << recoIndices); return false; } -#define CHECK_TEXT_ITEM_TEXT(item, global_index, index, expected) \ - const ResourceRecognitionIndexItem::TextItem & item##_textItem##index = \ - textItems##global_index[index]; \ - if (item##_textItem##index.m_text != QStringLiteral(expected)) \ - { \ - error = QStringLiteral("Incorrectly parsed recognition item's text " \ - "item's text: expected ") + \ - QStringLiteral(expected) + QStringLiteral(", got ") + \ - item##_textItem##index.m_text; \ - QNWARNING(error << QStringLiteral("; reco indices: ") << recoIndices); \ - return false; \ - } - -#define CHECK_TEXT_ITEM_WEIGHT(item, index, expected) \ - if (item##_textItem##index.m_weight != expected) { \ - error = QStringLiteral("Incorrectly parsed recognition item's text item's " \ - "text: expected " #expected ", got ") + \ - QString::number(item##_textItem##index.m_weight); \ - QNWARNING(error << QStringLiteral("; reco indices: ") << recoIndices); \ - return false; \ - } +#define CHECK_TEXT_ITEM_TEXT(item, global_index, index, expected) \ + const ResourceRecognitionIndexItem::TextItem & item##_textItem##index = \ + textItems##global_index[index]; \ + if (item##_textItem##index.m_text != QStringLiteral(expected)) \ + { \ + error = QStringLiteral("Incorrectly parsed recognition item's text " \ + "item's text: expected ") + \ + QStringLiteral(expected) + QStringLiteral(", got ") + \ + item##_textItem##index.m_text; \ + QNWARNING(error << "; reco indices: " << recoIndices); \ + return false; \ + } \ +// CHECK_TEXT_ITEM_TEXT + +#define CHECK_TEXT_ITEM_WEIGHT(item, index, expected) \ + if (item##_textItem##index.m_weight != expected) { \ + error = QStringLiteral("Incorrectly parsed recognition item's text " \ + "item's text: expected " #expected ", got ") + \ + QString::number(item##_textItem##index.m_weight); \ + QNWARNING(error << "; reco indices: " << recoIndices); \ + return false; \ + } \ +// CHECK_TEXT_ITEM_WEIGHT CHECK_TEXT_ITEM_TEXT(item0, 0, 0, "II") CHECK_TEXT_ITEM_WEIGHT(item0, 0, 31) @@ -189,7 +197,7 @@ error = QStringLiteral("Incorrectly parsed recognition item's stroke list: ") + QStringLiteral("expected 5 items in the list, got ") + QString::number(strokeList.size()); - QNWARNING(error << QStringLiteral("; reco indices: ") << recoIndices); + QNWARNING(error << "; reco indices: " << recoIndices); return false; } @@ -199,102 +207,155 @@ if (!strokeListOk) { error = QStringLiteral("Incorrectly parsed recognition item's stroke list: ") + QStringLiteral("not all expected numbers are found within the list"); - QNWARNING(error << QStringLiteral("; reco indices: ") << recoIndices); + QNWARNING(error << "; reco indices: " << recoIndices); return false; } - QVector<ResourceRecognitionIndexItem::ObjectItem> objectItems1 = item1.objectItems(); + QVector<ResourceRecognitionIndexItem::ObjectItem> objectItems1 = + item1.objectItems(); if (objectItems1.size() != 4) { - error = QStringLiteral("Incorrectly parsed recognition item's object items: ") + - QStringLiteral("expected 4, got ") + QString::number(objectItems1.size()); - QNWARNING(error << QStringLiteral("; reco indices: ") << recoIndices); + error = QStringLiteral("Incorrectly parsed recognition item's object ") + + QStringLiteral("items: expected 4, got ") + + QString::number(objectItems1.size()); + QNWARNING(error << "; reco indices: " << recoIndices); return false; } - QVector<ResourceRecognitionIndexItem::ShapeItem> shapeItems1 = item1.shapeItems(); + QVector<ResourceRecognitionIndexItem::ShapeItem> shapeItems1 = + item1.shapeItems(); if (shapeItems1.size() != 4) { - error = QStringLiteral("Incorrectly parsed recognition item's shape items: ") + - QStringLiteral("expected 4, got ") + QString::number(shapeItems1.size()); - QNWARNING(error << QStringLiteral("; reco indices: ") << recoIndices); + error = QStringLiteral("Incorrectly parsed recognition item's shape ") + + QStringLiteral("items: expected 4, got ") + + QString::number(shapeItems1.size()); + QNWARNING(error << "; reco indices: " << recoIndices); return false; } - QVector<ResourceRecognitionIndexItem::BarcodeItem> barcodeItems1 = item1.barcodeItems(); + QVector<ResourceRecognitionIndexItem::BarcodeItem> barcodeItems1 = + item1.barcodeItems(); if (barcodeItems1.size() != 3) { - error = QStringLiteral("Incorrectly parsed recognition item's barcode items: ") + - QStringLiteral("expected 3, got ") + QString::number(barcodeItems1.size()); - QNWARNING(error << QStringLiteral("; reco indices: ") << recoIndices); + error = QStringLiteral("Incorrectly parsed recognition item's barcode ") + + QStringLiteral("items: expected 3, got ") + + QString::number(barcodeItems1.size()); + QNWARNING(error << "; reco indices: " << recoIndices); return false; } QVector<ResourceRecognitionIndexItem::TextItem> textItems1 = item1.textItems(); if (textItems1.size() != 11) { - error = QStringLiteral("Incorrectly parsed recognition item's barcode items: ") + - QStringLiteral("expected 11, got ") + QString::number(textItems1.size()); - QNWARNING(error << QStringLiteral("; reco indices: ") << recoIndices); - return false; - } - -#define CHECK_SUB_ITEM_PROPERTY(subItemType, subItems, index, property, expected, ...) \ - { \ - const ResourceRecognitionIndexItem::subItemType & checkedItem = subItems[index]; \ - if (checkedItem.property != expected) { \ - error = QStringLiteral("Incorrectly parsed recognition item's " \ - #subItemType " " #property ": expected ") + \ - QString(__VA_ARGS__(expected)) + \ - QStringLiteral(", got ") + __VA_ARGS__(checkedItem.property); \ - QNWARNING(error << QStringLiteral("; reco indices: ") << recoIndices); \ - return false; \ - } \ - } - - CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 0, m_text, QStringLiteral("LONG")) - CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 0, m_weight, 32, QString::number) - CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 1, m_text, QStringLiteral("LONG")) - CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 1, m_weight, 25, QString::number) - CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 2, m_text, QStringLiteral("GOV")) - CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 2, m_weight, 23, QString::number) - CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 3, m_text, QStringLiteral("NOV")) - CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 3, m_weight, 23, QString::number) - CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 4, m_text, QStringLiteral("Lang")) - CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 4, m_weight, 19, QString::number) - CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 5, m_text, QStringLiteral("lane")) - CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 5, m_weight, 18, QString::number) - CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 6, m_text, QStringLiteral("CONN")) - CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 6, m_weight, 18, QString::number) - CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 7, m_text, QStringLiteral("bono")) - CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 7, m_weight, 17, QString::number) - CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 8, m_text, QStringLiteral("mono")) - CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 8, m_weight, 17, QString::number) - CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 9, m_text, QStringLiteral("LONON")) - CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 9, m_weight, 15, QString::number) - CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 10, m_text, QStringLiteral("LONGE")) - CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 10, m_weight, 15, QString::number) - - CHECK_SUB_ITEM_PROPERTY(ObjectItem, objectItems1, 0, m_objectType, QStringLiteral("face")) - CHECK_SUB_ITEM_PROPERTY(ObjectItem, objectItems1, 0, m_weight, 31, QString::number) - CHECK_SUB_ITEM_PROPERTY(ObjectItem, objectItems1, 1, m_objectType, QStringLiteral("lake")) - CHECK_SUB_ITEM_PROPERTY(ObjectItem, objectItems1, 1, m_weight, 30, QString::number) - CHECK_SUB_ITEM_PROPERTY(ObjectItem, objectItems1, 2, m_objectType, QStringLiteral("snow")) - CHECK_SUB_ITEM_PROPERTY(ObjectItem, objectItems1, 2, m_weight, 29, QString::number) - CHECK_SUB_ITEM_PROPERTY(ObjectItem, objectItems1, 3, m_objectType, QStringLiteral("road")) - CHECK_SUB_ITEM_PROPERTY(ObjectItem, objectItems1, 3, m_weight, 32, QString::number) - - CHECK_SUB_ITEM_PROPERTY(ShapeItem, shapeItems1, 0, m_shapeType, QStringLiteral("circle")) - CHECK_SUB_ITEM_PROPERTY(ShapeItem, shapeItems1, 0, m_weight, 31, QString::number) - CHECK_SUB_ITEM_PROPERTY(ShapeItem, shapeItems1, 1, m_shapeType, QStringLiteral("oval")) - CHECK_SUB_ITEM_PROPERTY(ShapeItem, shapeItems1, 1, m_weight, 29, QString::number) - CHECK_SUB_ITEM_PROPERTY(ShapeItem, shapeItems1, 2, m_shapeType, QStringLiteral("rectangle")) - CHECK_SUB_ITEM_PROPERTY(ShapeItem, shapeItems1, 2, m_weight, 30, QString::number) - CHECK_SUB_ITEM_PROPERTY(ShapeItem, shapeItems1, 3, m_shapeType, QStringLiteral("triangle")) - CHECK_SUB_ITEM_PROPERTY(ShapeItem, shapeItems1, 3, m_weight, 32, QString::number) - - CHECK_SUB_ITEM_PROPERTY(BarcodeItem, barcodeItems1, 0, m_barcode, QStringLiteral("5000600001")) - CHECK_SUB_ITEM_PROPERTY(BarcodeItem, barcodeItems1, 0, m_weight, 32, QString::number) - CHECK_SUB_ITEM_PROPERTY(BarcodeItem, barcodeItems1, 1, m_barcode, QStringLiteral("3000600001")) - CHECK_SUB_ITEM_PROPERTY(BarcodeItem, barcodeItems1, 1, m_weight, 25, QString::number) - CHECK_SUB_ITEM_PROPERTY(BarcodeItem, barcodeItems1, 2, m_barcode, QStringLiteral("2000600001")) - CHECK_SUB_ITEM_PROPERTY(BarcodeItem, barcodeItems1, 2, m_weight, 31, QString::number) + error = QStringLiteral("Incorrectly parsed recognition item's barcode ") + + QStringLiteral("items: expected 11, got ") + + QString::number(textItems1.size()); + QNWARNING(error << "; reco indices: " << recoIndices); + return false; + } + +#define CHECK_SUB_ITEM_PROPERTY(type, items, index, property, expected, ...) \ + { \ + const ResourceRecognitionIndexItem::type & checkedItem = items[index]; \ + if (checkedItem.property != expected) { \ + error = QStringLiteral("Incorrectly parsed recognition item's " \ + #type " " #property ": expected ") + \ + QString(__VA_ARGS__(expected)) + \ + QStringLiteral(", got ") + \ + __VA_ARGS__(checkedItem.property); \ + QNWARNING(error << "; reco indices: " << recoIndices); \ + return false; \ + } \ + } \ +// CHECK_SUB_ITEM_PROPERTY + + CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 0, m_text, + QStringLiteral("LONG")) + CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 0, m_weight, 32, + QString::number) + CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 1, m_text, + QStringLiteral("LONG")) + CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 1, m_weight, 25, + QString::number) + CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 2, m_text, + QStringLiteral("GOV")) + CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 2, m_weight, 23, + QString::number) + CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 3, m_text, + QStringLiteral("NOV")) + CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 3, m_weight, 23, + QString::number) + CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 4, m_text, + QStringLiteral("Lang")) + CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 4, m_weight, 19, + QString::number) + CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 5, m_text, + QStringLiteral("lane")) + CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 5, m_weight, 18, + QString::number) + CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 6, m_text, + QStringLiteral("CONN")) + CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 6, m_weight, 18, + QString::number) + CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 7, m_text, + QStringLiteral("bono")) + CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 7, m_weight, 17, + QString::number) + CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 8, m_text, + QStringLiteral("mono")) + CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 8, m_weight, 17, + QString::number) + CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 9, m_text, + QStringLiteral("LONON")) + CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 9, m_weight, 15, + QString::number) + CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 10, m_text, + QStringLiteral("LONGE")) + CHECK_SUB_ITEM_PROPERTY(TextItem, textItems1, 10, m_weight, 15, + QString::number) + + CHECK_SUB_ITEM_PROPERTY(ObjectItem, objectItems1, 0, m_objectType, + QStringLiteral("face")) + CHECK_SUB_ITEM_PROPERTY(ObjectItem, objectItems1, 0, m_weight, 31, + QString::number) + CHECK_SUB_ITEM_PROPERTY(ObjectItem, objectItems1, 1, m_objectType, + QStringLiteral("lake")) + CHECK_SUB_ITEM_PROPERTY(ObjectItem, objectItems1, 1, m_weight, 30, + QString::number) + CHECK_SUB_ITEM_PROPERTY(ObjectItem, objectItems1, 2, m_objectType, + QStringLiteral("snow")) + CHECK_SUB_ITEM_PROPERTY(ObjectItem, objectItems1, 2, m_weight, 29, + QString::number) + CHECK_SUB_ITEM_PROPERTY(ObjectItem, objectItems1, 3, m_objectType, + QStringLiteral("road")) + CHECK_SUB_ITEM_PROPERTY(ObjectItem, objectItems1, 3, m_weight, 32, + QString::number) + + CHECK_SUB_ITEM_PROPERTY(ShapeItem, shapeItems1, 0, m_shapeType, + QStringLiteral("circle")) + CHECK_SUB_ITEM_PROPERTY(ShapeItem, shapeItems1, 0, m_weight, 31, + QString::number) + CHECK_SUB_ITEM_PROPERTY(ShapeItem, shapeItems1, 1, m_shapeType, + QStringLiteral("oval")) + CHECK_SUB_ITEM_PROPERTY(ShapeItem, shapeItems1, 1, m_weight, 29, + QString::number) + CHECK_SUB_ITEM_PROPERTY(ShapeItem, shapeItems1, 2, m_shapeType, + QStringLiteral("rectangle")) + CHECK_SUB_ITEM_PROPERTY(ShapeItem, shapeItems1, 2, m_weight, 30, + QString::number) + CHECK_SUB_ITEM_PROPERTY(ShapeItem, shapeItems1, 3, m_shapeType, + QStringLiteral("triangle")) + CHECK_SUB_ITEM_PROPERTY(ShapeItem, shapeItems1, 3, m_weight, 32, + QString::number) + + CHECK_SUB_ITEM_PROPERTY(BarcodeItem, barcodeItems1, 0, m_barcode, + QStringLiteral("5000600001")) + CHECK_SUB_ITEM_PROPERTY(BarcodeItem, barcodeItems1, 0, m_weight, 32, + QString::number) + CHECK_SUB_ITEM_PROPERTY(BarcodeItem, barcodeItems1, 1, m_barcode, + QStringLiteral("3000600001")) + CHECK_SUB_ITEM_PROPERTY(BarcodeItem, barcodeItems1, 1, m_weight, 25, + QString::number) + CHECK_SUB_ITEM_PROPERTY(BarcodeItem, barcodeItems1, 2, m_barcode, + QStringLiteral("2000600001")) + CHECK_SUB_ITEM_PROPERTY(BarcodeItem, barcodeItems1, 2, m_weight, 31, + QString::number) return true; } diff -Nru libquentier-0.5.0/src/tests/types/TypesTester.cpp libquentier-0.5.0/src/tests/types/TypesTester.cpp --- libquentier-0.5.0/src/tests/types/TypesTester.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/tests/types/TypesTester.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -27,28 +27,29 @@ #include <QTextStream> #include <QtTest/QTest> -#define CATCH_EXCEPTION() \ - catch(const std::exception & exception) { \ - SysInfo sysInfo; \ - QFAIL(qPrintable(QStringLiteral("Caught exception: ") + \ - QString::fromUtf8(exception.what()) + \ - QStringLiteral(", backtrace: ") + \ - sysInfo.stackTrace())); \ - } +#define CATCH_EXCEPTION() \ + catch(const std::exception & exception) { \ + SysInfo sysInfo; \ + QFAIL(qPrintable(QStringLiteral("Caught exception: ") + \ + QString::fromUtf8(exception.what()) + \ + QStringLiteral(", backtrace: ") + \ + sysInfo.stackTrace())); \ + } \ +// CATCH_EXCEPTION #if QT_VERSION >= 0x050000 inline void nullMessageHandler(QtMsgType type, const QMessageLogContext &, const QString & message) { if (type != QtDebugMsg) { - QTextStream(stdout) << message << QStringLiteral("\n"); + QTextStream(stdout) << message << "\n"; } } #else inline void nullMessageHandler(QtMsgType type, const char * message) { if (type != QtDebugMsg) { - QTextStream(stdout) << message << QStringLiteral("\n"); + QTextStream(stdout) << message << "\n"; } } #endif diff -Nru libquentier-0.5.0/src/tests/utility/UtilityTester.cpp libquentier-0.5.0/src/tests/utility/UtilityTester.cpp --- libquentier-0.5.0/src/tests/utility/UtilityTester.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/tests/utility/UtilityTester.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -77,15 +77,15 @@ #endif } -#define CATCH_EXCEPTION() \ - catch(const std::exception & exception) { \ - SysInfo sysInfo; \ - QFAIL(qPrintable(QStringLiteral("Caught exception: ") + \ - QString::fromUtf8(exception.what()) + \ - QStringLiteral(", backtrace: ") + \ - sysInfo.stackTrace())); \ - } - +#define CATCH_EXCEPTION() \ + catch(const std::exception & exception) { \ + SysInfo sysInfo; \ + QFAIL(qPrintable(QStringLiteral("Caught exception: ") + \ + QString::fromUtf8(exception.what()) + \ + QStringLiteral(", backtrace: ") + \ + sysInfo.stackTrace())); \ + } \ +// CATCH_EXCEPTION void UtilityTester::encryptDecryptNoteTest() { diff -Nru libquentier-0.5.0/src/types/Account.cpp libquentier-0.5.0/src/types/Account.cpp --- libquentier-0.5.0/src/types/Account.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/types/Account.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -222,73 +222,73 @@ QTextStream & Account::print(QTextStream & strm) const { - strm << QStringLiteral("Account: {\n"); - strm << QStringLiteral(" name = ") << d->m_name << QStringLiteral(";\n"); - strm << QStringLiteral(" display name = ") << d->m_displayName - << QStringLiteral(";\n"); - strm << QStringLiteral(" id = ") << d->m_userId << QStringLiteral(";\n"); + strm << "Account: {\n"; + strm << " name = " << d->m_name << ";\n"; + strm << " display name = " << d->m_displayName + << ";\n"; + strm << " id = " << d->m_userId << ";\n"; - strm << QStringLiteral(" type = "); + strm << " type = "; switch(d->m_accountType) { case Account::Type::Local: - strm << QStringLiteral("Local"); + strm << "Local"; break; case Account::Type::Evernote: - strm << QStringLiteral("Evernote"); + strm << "Evernote"; break; default: - strm << QStringLiteral("Unknown"); + strm << "Unknown"; break; } - strm << QStringLiteral(";\n"); + strm << ";\n"; - strm << QStringLiteral(" Evernote account type = "); + strm << " Evernote account type = "; switch(d->m_evernoteAccountType) { case Account::EvernoteAccountType::Free: - strm << QStringLiteral("Free"); + strm << "Free"; break; case Account::EvernoteAccountType::Plus: - strm << QStringLiteral("Plus"); + strm << "Plus"; break; case Account::EvernoteAccountType::Premium: - strm << QStringLiteral("Premium"); + strm << "Premium"; break; case Account::EvernoteAccountType::Business: - strm << QStringLiteral("Business"); + strm << "Business"; break; default: - strm << QStringLiteral("Unknown"); + strm << "Unknown"; break; } - strm << QStringLiteral(";\n"); + strm << ";\n"; - strm << QStringLiteral(" Evernote host = ") - << d->m_evernoteHost << QStringLiteral(";\n"); - strm << QStringLiteral(" shard id = ") - << d->m_shardId << QStringLiteral(";\n"); - strm << QStringLiteral(" mail limit daily = ") - << d->m_mailLimitDaily << QStringLiteral(";\n"); - strm << QStringLiteral(" note size max = ") - << d->m_noteSizeMax << QStringLiteral(";\n"); - strm << QStringLiteral(" resource size max = ") - << d->m_resourceSizeMax << QStringLiteral(";\n"); - strm << QStringLiteral(" linked notebook max = ") - << d->m_linkedNotebookMax << QStringLiteral(";\n"); - strm << QStringLiteral(" note count max = ") - << d->m_noteCountMax << QStringLiteral(";\n"); - strm << QStringLiteral(" notebook count max = ") - << d->m_notebookCountMax << QStringLiteral(";\n"); - strm << QStringLiteral(" tag count max = ") - << d->m_tagCountMax << QStringLiteral(";\n"); - strm << QStringLiteral(" note tag count max = ") - << d->m_noteTagCountMax << QStringLiteral(";\n"); - strm << QStringLiteral(" saved search count max = ") - << d->m_savedSearchCountMax << QStringLiteral(";\n"); - strm << QStringLiteral(" note resource count max = ") - << d->m_noteResourceCountMax << QStringLiteral(";\n"); - strm << QStringLiteral("};\n"); + strm << " Evernote host = " + << d->m_evernoteHost << ";\n"; + strm << " shard id = " + << d->m_shardId << ";\n"; + strm << " mail limit daily = " + << d->m_mailLimitDaily << ";\n"; + strm << " note size max = " + << d->m_noteSizeMax << ";\n"; + strm << " resource size max = " + << d->m_resourceSizeMax << ";\n"; + strm << " linked notebook max = " + << d->m_linkedNotebookMax << ";\n"; + strm << " note count max = " + << d->m_noteCountMax << ";\n"; + strm << " notebook count max = " + << d->m_notebookCountMax << ";\n"; + strm << " tag count max = " + << d->m_tagCountMax << ";\n"; + strm << " note tag count max = " + << d->m_noteTagCountMax << ";\n"; + strm << " saved search count max = " + << d->m_savedSearchCountMax << ";\n"; + strm << " note resource count max = " + << d->m_noteResourceCountMax << ";\n"; + strm << "};\n"; return strm; } diff -Nru libquentier-0.5.0/src/types/data/NoteData.cpp libquentier-0.5.0/src/types/data/NoteData.cpp --- libquentier-0.5.0/src/types/data/NoteData.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/types/data/NoteData.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -289,18 +289,18 @@ "Note attributes field " "has invalid size")); -#define CHECK_NOTE_ATTRIBUTE(name) \ - if (attributes.name.isSet()) { \ - int name##Size = attributes.name->size(); \ - \ - if ( (name##Size < qevercloud::EDAM_ATTRIBUTE_LEN_MIN) || \ - (name##Size > qevercloud::EDAM_ATTRIBUTE_LEN_MAX) ) \ - { \ - error.details() = QStringLiteral( #name ); \ - errorDescription = error; \ - return false; \ - } \ - } +#define CHECK_NOTE_ATTRIBUTE(name) \ + if (attributes.name.isSet()) { \ + int name##Size = attributes.name->size(); \ + if ( (name##Size < qevercloud::EDAM_ATTRIBUTE_LEN_MIN) || \ + (name##Size > qevercloud::EDAM_ATTRIBUTE_LEN_MAX) ) \ + { \ + error.details() = QStringLiteral( #name ); \ + errorDescription = error; \ + return false; \ + } \ + } \ +// CHECK_NOTE_ATTRIBUTE CHECK_NOTE_ATTRIBUTE(author); CHECK_NOTE_ATTRIBUTE(source); diff -Nru libquentier-0.5.0/src/types/data/ResourceRecognitionIndexItemData.cpp libquentier-0.5.0/src/types/data/ResourceRecognitionIndexItemData.cpp --- libquentier-0.5.0/src/types/data/ResourceRecognitionIndexItemData.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/types/data/ResourceRecognitionIndexItemData.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -40,7 +40,7 @@ if (m_textItems.isEmpty() && m_objectItems.isEmpty() && m_shapeItems.isEmpty() && m_barcodeItems.isEmpty()) { - QNTRACE(QStringLiteral("Resource recognition index item is empty")); + QNTRACE("Resource recognition index item is empty"); return false; } @@ -51,9 +51,9 @@ if (textItem.m_weight < 0) { - QNTRACE(QStringLiteral("Resource recognition index item contains ") - << QStringLiteral("text item with weight less than 0: ") - << textItem.m_text << QStringLiteral(", weight = ") + QNTRACE("Resource recognition index item contains " + << "text item with weight less than 0: " + << textItem.m_text << ", weight = " << textItem.m_weight); return false; } @@ -66,9 +66,9 @@ if (objectItem.m_weight < 0) { - QNTRACE(QStringLiteral("Resource recognition index item contains ") - << QStringLiteral("object item with weight less than 0: ") - << objectItem.m_objectType << QStringLiteral(", weight = ") + QNTRACE("Resource recognition index item contains " + << "object item with weight less than 0: " + << objectItem.m_objectType << ", weight = " << objectItem.m_weight); return false; } @@ -88,9 +88,8 @@ (objectItem.m_objectType != QStringLiteral("road")) && (objectItem.m_objectType != QStringLiteral("car"))) { - QNTRACE(QStringLiteral("Resource recognition index object item has ") - << QStringLiteral("invalid object type: ") - << objectItem.m_objectType); + QNTRACE("Resource recognition index object item has " + << "invalid object type: " << objectItem.m_objectType); return false; } } @@ -102,9 +101,9 @@ if (shapeItem.m_weight < 0) { - QNTRACE(QStringLiteral("Resource recognition index item contains ") - << QStringLiteral("shape item with weight less than 0: ") - << shapeItem.m_shapeType << QStringLiteral(", weight = ") + QNTRACE("Resource recognition index item contains " + << "shape item with weight less than 0: " + << shapeItem.m_shapeType << ", weight = " << shapeItem.m_weight); return false; } @@ -117,8 +116,8 @@ (shapeItem.m_shapeType != QStringLiteral("arrow")) && (shapeItem.m_shapeType != QStringLiteral("polyline"))) { - QNTRACE(QStringLiteral("Resource recognition index shape item has ") - << QStringLiteral("invalid shape type: ") << shapeItem.m_shapeType); + QNTRACE("Resource recognition index shape item has " + << "invalid shape type: " << shapeItem.m_shapeType); return false; } } @@ -130,9 +129,9 @@ if (barcodeItem.m_weight < 0) { - QNTRACE(QStringLiteral("Resource recognition index item contains ") - << QStringLiteral("barcode item with weight less than 0: ") - << barcodeItem.m_barcode << QStringLiteral(", weight = ") + QNTRACE("Resource recognition index item contains " + << "barcode item with weight less than 0: " + << barcodeItem.m_barcode << ", weight = " << barcodeItem.m_weight); return false; } diff -Nru libquentier-0.5.0/src/types/data/ResourceRecognitionIndicesData.cpp libquentier-0.5.0/src/types/data/ResourceRecognitionIndicesData.cpp --- libquentier-0.5.0/src/types/data/ResourceRecognitionIndicesData.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/types/data/ResourceRecognitionIndicesData.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -40,15 +40,13 @@ bool ResourceRecognitionIndicesData::isValid() const { if (m_objectId.isEmpty()) { - QNTRACE(QStringLiteral("Resource recognition indices' object id " - "is not set")); + QNTRACE("Resource recognition indices' object id is not set"); return false; } if (m_objectType.isEmpty()) { - QNTRACE(QStringLiteral("Resource recognition indices' object type " - "is not set")); + QNTRACE("Resource recognition indices' object type is not set"); return false; } else if ((m_objectType != QStringLiteral("image")) && @@ -57,29 +55,25 @@ (m_objectType != QStringLiteral("video")) && (m_objectType != QStringLiteral("document"))) { - QNTRACE(QStringLiteral("Resource recognition indices' object type " - "is not valid")); + QNTRACE("Resource recognition indices' object type is not valid"); return false; } if (m_recoType.isEmpty()) { - QNTRACE(QStringLiteral("Resource recognition indices' recognition type " - "is not set")); + QNTRACE("Resource recognition indices' recognition type is not set"); return false; } else if ((m_recoType != QStringLiteral("service")) && (m_recoType != QStringLiteral("client"))) { - QNTRACE(QStringLiteral("Resource recognition indices' recognition type " - "is not valid")); + QNTRACE("Resource recognition indices' recognition type is not valid"); return false; } if (m_docType.isEmpty()) { - QNTRACE(QStringLiteral("Resource recognition indices' doc type " - "is not set")); + QNTRACE("Resource recognition indices' doc type is not set"); return false; } else if ((m_docType != QStringLiteral("printed")) && @@ -88,7 +82,7 @@ (m_docType != QStringLiteral("picture")) && (m_docType != QStringLiteral("unknown"))) { - QNTRACE(QStringLiteral("Resource recognition indices' doc type is not valid")); + QNTRACE("Resource recognition indices' doc type is not valid"); return false; } @@ -98,11 +92,11 @@ bool ResourceRecognitionIndicesData::setData( const QByteArray & rawRecognitionIndicesData) { - QNTRACE(QStringLiteral("ResourceRecognitionIndicesData::setData: ") + QNTRACE("ResourceRecognitionIndicesData::setData: " << rawRecognitionIndicesData); if (rawRecognitionIndicesData.isEmpty()) { - QNTRACE(QStringLiteral("Recognition data is empty")); + QNTRACE("Recognition data is empty"); clear(); return true; } @@ -193,23 +187,22 @@ } if (reader.hasError()) { - QNWARNING(QStringLiteral("Failed to parse resource recognition indices ") - << QStringLiteral("data: ") << reader.errorString() - << QStringLiteral(" (error code ") << reader.error() - << QStringLiteral(", original raw data: ") - << rawRecognitionIndicesData); + QNWARNING("Failed to parse resource recognition indices " + << "data: " << reader.errorString() + << " (error code " << reader.error() + << ", original raw data: " << rawRecognitionIndicesData); restoreFrom(backup); return false; } m_isNull = false; - QNTRACE(QStringLiteral("Successfully parsed ResourceRecognitionIndicesData")); + QNTRACE("Successfully parsed ResourceRecognitionIndicesData"); return true; } void ResourceRecognitionIndicesData::clear() { - QNTRACE(QStringLiteral("ResourceRecognitionIndicesData::clear")); + QNTRACE("ResourceRecognitionIndicesData::clear"); m_objectId.resize(0); m_objectType.resize(0); @@ -227,7 +220,7 @@ void ResourceRecognitionIndicesData::restoreFrom( const ResourceRecognitionIndicesData & data) { - QNTRACE(QStringLiteral("ResourceRecognitionIndicesData::restoreFrom")); + QNTRACE("ResourceRecognitionIndicesData::restoreFrom"); m_isNull = data.m_isNull; @@ -245,7 +238,7 @@ void ResourceRecognitionIndicesData::parseRecoIndexAttributes( const QXmlStreamAttributes & attributes) { - QNTRACE(QStringLiteral("ResourceRecognitionIndicesData::parseRecoIndexAttributes")); + QNTRACE("ResourceRecognitionIndicesData::parseRecoIndexAttributes"); for(auto it = attributes.constBegin(), end = attributes.constEnd(); it != end; ++it) @@ -304,8 +297,8 @@ const QXmlStreamAttributes & attributes, ResourceRecognitionIndexItem & item) const { - QNTRACE(QStringLiteral("ResourceRecognitionIndicesData::" - "parseCommonItemAttributes")); + QNTRACE("ResourceRecognitionIndicesData::" + "parseCommonItemAttributes"); for(auto it = attributes.constBegin(), end = attributes.constEnd(); it != end; ++it) @@ -410,8 +403,8 @@ const QXmlStreamAttributes & attributes, const QString & data, ResourceRecognitionIndexItem & item) const { - QNTRACE(QStringLiteral("ResourceRecognitionIndicesData::") - << QStringLiteral("parseTextItemAttributesAndData: data = ") << data); + QNTRACE("ResourceRecognitionIndicesData::" + << "parseTextItemAttributesAndData: data = " << data); int weight = -1; @@ -445,16 +438,16 @@ textItem.m_weight = weight; textItem.m_text = data; item.addTextItem(textItem); - QNTRACE(QStringLiteral("Added text item: text = ") << data - << QStringLiteral("; weight = ") << weight); + QNTRACE("Added text item: text = " << data + << "; weight = " << weight); } void ResourceRecognitionIndicesData::parseObjectItemAttributes( const QXmlStreamAttributes & attributes, ResourceRecognitionIndexItem & item) const { - QNTRACE(QStringLiteral("ResourceRecognitionIndicesData::" - "parseObjectItemAttributes")); + QNTRACE("ResourceRecognitionIndicesData::" + "parseObjectItemAttributes"); QString objectType; int weight = -1; @@ -493,16 +486,15 @@ objectItem.m_objectType = objectType; objectItem.m_weight = weight; item.addObjectItem(objectItem); - QNTRACE(QStringLiteral("Added object item: type = ") << objectType - << QStringLiteral(", weight = ") << weight); + QNTRACE("Added object item: type = " << objectType + << ", weight = " << weight); } void ResourceRecognitionIndicesData::parseShapeItemAttributes( const QXmlStreamAttributes & attributes, ResourceRecognitionIndexItem & item) const { - QNTRACE(QStringLiteral("ResourceRecognitionIndicesData::" - "parseShapeItemAttributes")); + QNTRACE("ResourceRecognitionIndicesData::parseShapeItemAttributes"); QString shapeType; int weight = -1; @@ -541,16 +533,15 @@ shapeItem.m_shapeType = shapeType; shapeItem.m_weight = weight; item.addShapeItem(shapeItem); - QNTRACE(QStringLiteral("Added shape item: type = ") << shapeType - << QStringLiteral(", weight = ") << weight); + QNTRACE("Added shape item: type = " << shapeType << ", weight = " << weight); } void ResourceRecognitionIndicesData::parseBarcodeItemAttributesAndData( const QXmlStreamAttributes & attributes, const QString & data, ResourceRecognitionIndexItem & item) const { - QNTRACE(QStringLiteral("ResourceRecognitionIndicesData::") - << QStringLiteral("parseBarcodeItemAttributesAndData: ") << data); + QNTRACE("ResourceRecognitionIndicesData::" + << "parseBarcodeItemAttributesAndData: " << data); int weight = -1; @@ -584,8 +575,7 @@ barcodeItem.m_weight = weight; barcodeItem.m_barcode = data; item.addBarcodeItem(barcodeItem); - QNTRACE(QStringLiteral("Added barcode item: barcode = ") << data - << QStringLiteral("; weight = ") << weight); + QNTRACE("Added barcode item: barcode = " << data << "; weight = " << weight); } } // namespace quentier diff -Nru libquentier-0.5.0/src/types/ErrorString.cpp libquentier-0.5.0/src/types/ErrorString.cpp --- libquentier-0.5.0/src/types/ErrorString.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/types/ErrorString.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -255,12 +255,12 @@ strm << *it; } else { - strm << QStringLiteral(", ") << *it; + strm << ", " << *it; } } if (!d->m_details.isEmpty()) { - strm << QStringLiteral(": ") << d->m_details; + strm << ": " << d->m_details; } return strm; diff -Nru libquentier-0.5.0/src/types/LinkedNotebook.cpp libquentier-0.5.0/src/types/LinkedNotebook.cpp --- libquentier-0.5.0/src/types/LinkedNotebook.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/types/LinkedNotebook.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -307,12 +307,10 @@ QTextStream & LinkedNotebook::print(QTextStream & strm) const { - strm << QStringLiteral("LinkedNotebook: {\n"); - strm << QStringLiteral("isDirty = ") - << (isDirty() ? QStringLiteral("true") : QStringLiteral("false")) - << QStringLiteral("\n"); + strm << "LinkedNotebook: {\n"; + strm << "isDirty = " << (isDirty() ? "true" : "false") << "\n"; strm << d->m_qecLinkedNotebook; - strm << QStringLiteral("};\n"); + strm << "};\n"; return strm; } diff -Nru libquentier-0.5.0/src/types/Notebook.cpp libquentier-0.5.0/src/types/Notebook.cpp --- libquentier-0.5.0/src/types/Notebook.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/types/Notebook.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -307,13 +307,14 @@ return d->m_qecNotebook.publishing->uri; } -#define CHECK_AND_SET_PUBLISHING \ - if (!d->m_qecNotebook.publishing.isSet()) { \ - d->m_qecNotebook.publishing = qevercloud::Publishing(); \ - } \ - if (!d->m_qecNotebook.published.isSet()) { \ - d->m_qecNotebook.published = true; \ - } +#define CHECK_AND_SET_PUBLISHING \ + if (!d->m_qecNotebook.publishing.isSet()) { \ + d->m_qecNotebook.publishing = qevercloud::Publishing(); \ + } \ + if (!d->m_qecNotebook.published.isSet()) { \ + d->m_qecNotebook.published = true; \ + } \ +// CHECK_AND_SET_PUBLISHING void Notebook::setPublishingUri(const QString & uri) { @@ -481,8 +482,8 @@ const auto & enSharedNotebook = sharedNotebook.qevercloudSharedNotebook(); if (sharedNotebooks.indexOf(enSharedNotebook) != -1) { - QNDEBUG(QStringLiteral("Can't add shared notebook: this shared notebook " - "already exists within the notebook")); + QNDEBUG("Can't add shared notebook: this shared notebook " + "already exists within the notebook"); return; } @@ -496,8 +497,8 @@ int index = sharedNotebooks->indexOf(enSharedNotebook); if (index == -1) { - QNDEBUG(QStringLiteral("Can't remove shared notebook: this shared " - "notebook doesn't exists within the notebook")); + QNDEBUG("Can't remove shared notebook: this shared " + "notebook doesn't exists within the notebook"); return; } @@ -515,10 +516,11 @@ return d->m_qecNotebook.businessNotebook->notebookDescription; } -#define CHECK_AND_SET_BUSINESS_NOTEBOOK \ - if (!d->m_qecNotebook.businessNotebook.isSet()) { \ - d->m_qecNotebook.businessNotebook = qevercloud::BusinessNotebook(); \ - } +#define CHECK_AND_SET_BUSINESS_NOTEBOOK \ + if (!d->m_qecNotebook.businessNotebook.isSet()) { \ + d->m_qecNotebook.businessNotebook = qevercloud::BusinessNotebook(); \ + } \ +// CHECK_AND_SET_BUSINESS_NOTEBOOK void Notebook::setBusinessNotebookDescription(const QString & businessNotebookDescription) { @@ -608,10 +610,11 @@ d->m_qecNotebook.restrictions->noReadNotes); } -#define CHECK_AND_SET_NOTEBOOK_RESTRICTIONS \ - if (!d->m_qecNotebook.restrictions.isSet()) { \ - d->m_qecNotebook.restrictions = qevercloud::NotebookRestrictions(); \ - } +#define CHECK_AND_SET_NOTEBOOK_RESTRICTIONS \ + if (!d->m_qecNotebook.restrictions.isSet()) { \ + d->m_qecNotebook.restrictions = qevercloud::NotebookRestrictions(); \ + } \ +// CHECK_AND_SET_NOTEBOOK_RESTRICTIONS void Notebook::setCanReadNotes(const bool canReadNotes) { @@ -960,10 +963,12 @@ return d->m_qecNotebook.recipientSettings->reminderNotifyEmail; } -#define CHECK_AND_SET_NOTEBOOK_RECIPIENT_SETTINGS \ - if (!d->m_qecNotebook.recipientSettings.isSet()) { \ - d->m_qecNotebook.recipientSettings = qevercloud::NotebookRecipientSettings(); \ - } +#define CHECK_AND_SET_NOTEBOOK_RECIPIENT_SETTINGS \ + if (!d->m_qecNotebook.recipientSettings.isSet()) { \ + d->m_qecNotebook.recipientSettings = \ + qevercloud::NotebookRecipientSettings(); \ + } \ +// CHECK_AND_SET_NOTEBOOK_RECIPIENT_SETTINGS void Notebook::setRecipientReminderNotifyEmail(const bool notifyEmail) { @@ -1062,47 +1067,23 @@ QTextStream & Notebook::print(QTextStream & strm) const { - strm << QStringLiteral("Notebook {\n"); - - strm << QStringLiteral(" local uid: ") << d->m_localUid.toString() - << QStringLiteral(";\n"); + strm << "Notebook {\n"; - strm << QStringLiteral(" linked notebook guid: ") + strm << " local uid: " << d->m_localUid.toString() << ";\n"; + strm << " linked notebook guid: " << (d->m_linkedNotebookGuid.isSet() ? d->m_linkedNotebookGuid.ref() - : QStringLiteral("<empty>")) << QStringLiteral(";\n"); + : QStringLiteral("<empty>")) << ";\n"; - strm << QStringLiteral(" dirty: ") - << (isDirty() - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(";\n"); - - strm << QStringLiteral(" local: ") - << (isLocal() - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(";\n"); - - strm << QStringLiteral(" last used: ") - << (isLastUsed() - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(";\n"); - strm << QStringLiteral(" default: ") - << (isDefaultNotebook() - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(";\n"); - strm << QStringLiteral(" favorited: ") - << (isFavorited() - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(";\n"); + strm << " dirty: " << (isDirty() ? "true" : "false") << ";\n"; + strm << " local: " << (isLocal() ? "true" : "false") << ";\n"; + strm << " last used: " << (isLastUsed() ? "true" : "false") << ";\n"; + strm << " default: " << (isDefaultNotebook() ? "true" : "false") << ";\n"; + strm << " favorited: " << (isFavorited() ? "true" : "false") << ";\n"; strm << d->m_qecNotebook; - strm << QStringLiteral("};\n"); + strm << "};\n"; return strm; } diff -Nru libquentier-0.5.0/src/types/Note.cpp libquentier-0.5.0/src/types/Note.cpp --- libquentier-0.5.0/src/types/Note.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/types/Note.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -418,8 +418,7 @@ tagGuids << *it; } - QNTRACE(QStringLiteral("Added ") << numTagGuids - << QStringLiteral(" tag guids to note")); + QNTRACE("Added " << numTagGuids << " tag guids to note"); } void Note::addTagGuid(const QString & guid) @@ -434,33 +433,31 @@ if (!d->m_qecNote.tagGuids->contains(guid)) { d->m_qecNote.tagGuids.ref() << guid; - QNDEBUG(QStringLiteral("Added tag guid ") << guid - << QStringLiteral(" to the note")); + QNDEBUG("Added tag guid " << guid << " to the note"); } } void Note::removeTagGuid(const QString & guid) { if (guid.isEmpty()) { - QNDEBUG(QStringLiteral("Cannot remove empty tag guid")); + QNDEBUG("Cannot remove empty tag guid"); return; } if (!d->m_qecNote.tagGuids.isSet()) { - QNDEBUG(QStringLiteral("No tag guids are set, cannot remove one")); + QNDEBUG("No tag guids are set, cannot remove one"); return; } QList<qevercloud::Guid> & tagGuids = d->m_qecNote.tagGuids.ref(); int removed = tagGuids.removeAll(guid); if (removed > 0) { - QNDEBUG(QStringLiteral("Removed tag guid ") << guid - << QStringLiteral(" (") << removed << QStringLiteral(") occurrences")); + QNDEBUG("Removed tag guid " << guid << " (" << removed << ") occurrences"); } else { - QNDEBUG(QStringLiteral("Haven't removed tag guid ") << guid - << QStringLiteral(" because there was no such guid within " - "the note's tag guids")); + QNDEBUG("Haven't removed tag guid " << guid + << " because there was no such guid within " + "the note's tag guids"); } } @@ -487,32 +484,31 @@ if (!d->m_tagLocalUids.contains(tagLocalUid)) { d->m_tagLocalUids << tagLocalUid; - QNDEBUG(QStringLiteral("Added tag local uid ") << tagLocalUid - << QStringLiteral(" to the note")); + QNDEBUG("Added tag local uid " << tagLocalUid << " to the note"); } } void Note::removeTagLocalUid(const QString & tagLocalUid) { if (tagLocalUid.isEmpty()) { - QNDEBUG(QStringLiteral("Cannot remove empty tag local uid")); + QNDEBUG("Cannot remove empty tag local uid"); return; } if (d->m_tagLocalUids.isEmpty()) { - QNDEBUG(QStringLiteral("No tag local uids are set, cannot remove one")); + QNDEBUG("No tag local uids are set, cannot remove one"); return; } int removed = d->m_tagLocalUids.removeAll(tagLocalUid); if (removed > 0) { - QNDEBUG(QStringLiteral("Removed tag local uid ") << tagLocalUid - << QStringLiteral(" (") << removed << QStringLiteral(") occurrences")); + QNDEBUG("Removed tag local uid " << tagLocalUid + << " (" << removed << ") occurrences"); } else { - QNDEBUG(QStringLiteral("Haven't removed tag local uid ") << tagLocalUid - << QStringLiteral(" because there was no such uid within " - "the note's tag local uids")); + QNDEBUG("Haven't removed tag local uid " << tagLocalUid + << " because there was no such uid within " + "the note's tag local uids"); } } @@ -587,8 +583,8 @@ } if (d->m_qecNote.resources->contains(resource.qevercloudResource())) { - QNDEBUG(QStringLiteral("Can't add resource to note: this note already " - "has this resource")); + QNDEBUG("Can't add resource to note: this note already " + "has this resource"); return; } @@ -597,15 +593,13 @@ info.localUid = resource.localUid(); info.isDirty = resource.isDirty(); d->m_resourcesAdditionalInfo.push_back(info); - QNDEBUG(QStringLiteral("Added resource to note, local uid = ") - << resource.localUid()); + QNDEBUG("Added resource to note, local uid = " << resource.localUid()); } bool Note::updateResource(const Resource & resource) { if (!d->m_qecNote.resources.isSet()) { - QNDEBUG(QStringLiteral("Can't update resource in note: note has no " - "attached resources")); + QNDEBUG("Can't update resource in note: note has no attached resources"); return false; } @@ -620,8 +614,8 @@ } if (targetResourceIndex < 0) { - QNDEBUG(QStringLiteral("Can't update resource in note: can't find " - "the resource to update")); + QNDEBUG("Can't update resource in note: can't find " + "the resource to update"); return false; } @@ -633,8 +627,8 @@ bool Note::removeResource(const Resource & resource) { if (!d->m_qecNote.resources.isSet()) { - QNDEBUG(QStringLiteral("Can't remove resource from note: note has no " - "attached resources")); + QNDEBUG("Can't remove resource from note: note has no " + "attached resources"); return false; } @@ -651,15 +645,15 @@ } if (targetResourceIndex < 0) { - QNDEBUG(QStringLiteral("Can't remove resource from note: can't find " - "the resource to remove")); + QNDEBUG("Can't remove resource from note: can't find " + "the resource to remove"); return false; } resources.removeAt(targetResourceIndex); d->m_resourcesAdditionalInfo.removeAt(targetResourceIndex); - QNDEBUG(QStringLiteral("Removed resource from note: ") << resource); + QNDEBUG("Removed resource from note: " << resource); return true; } @@ -749,8 +743,8 @@ const qevercloud::SharedNote & qecSharedNote = sharedNote.qevercloudSharedNote(); if (d->m_qecNote.sharedNotes->contains(qecSharedNote)) { - QNDEBUG(QStringLiteral("Can't add shared note: this note already " - "has this shared note")); + QNDEBUG("Can't add shared note: this note already " + "has this shared note"); return; } @@ -912,240 +906,225 @@ QTextStream & Note::print(QTextStream & strm) const { - strm << QStringLiteral("Note: { \n"); + strm << "Note: { \n"; -#define INSERT_DELIMITER \ - strm << QStringLiteral("; \n") +#define INSERT_DELIMITER \ + strm << "; \n" \ +// INSERT_DELIMITER const QString localUid_ = localUid(); if (!localUid_.isEmpty()) { - strm << QStringLiteral("localUid: ") << localUid_; + strm << "localUid: " << localUid_; } else { - strm << QStringLiteral("localUid is not set"); + strm << "localUid is not set"; } INSERT_DELIMITER; if (d->m_qecNote.guid.isSet()) { - strm << QStringLiteral("guid: ") << d->m_qecNote.guid; + strm << "guid: " << d->m_qecNote.guid; } else { - strm << QStringLiteral("guid is not set"); + strm << "guid is not set"; } INSERT_DELIMITER; if (d->m_qecNote.updateSequenceNum.isSet()) { - strm << QStringLiteral("updateSequenceNumber: ") + strm << "updateSequenceNumber: " << QString::number(d->m_qecNote.updateSequenceNum); } else { - strm << QStringLiteral("updateSequenceNumber is not set"); + strm << "updateSequenceNumber is not set"; } INSERT_DELIMITER; if (d->m_qecNote.title.isSet()) { - strm << QStringLiteral("title: ") << d->m_qecNote.title; + strm << "title: " << d->m_qecNote.title; } else { - strm << QStringLiteral("title is not set"); + strm << "title is not set"; } INSERT_DELIMITER; if (d->m_qecNote.content.isSet()) { - strm << QStringLiteral("content: ") << d->m_qecNote.content; + strm << "content: " << d->m_qecNote.content; } else { - strm << QStringLiteral("content is not set"); + strm << "content is not set"; } INSERT_DELIMITER; if (d->m_qecNote.contentHash.isSet()) { - strm << QStringLiteral("contentHash: ") + strm << "contentHash: " << d->m_qecNote.contentHash.ref().toHex(); } else { - strm << QStringLiteral("contentHash is not set"); + strm << "contentHash is not set"; } INSERT_DELIMITER; if (d->m_qecNote.contentLength.isSet()) { - strm << QStringLiteral("contentLength: ") + strm << "contentLength: " << QString::number(d->m_qecNote.contentLength); } else { - strm << QStringLiteral("contentLength is not set"); + strm << "contentLength is not set"; } INSERT_DELIMITER; if (d->m_qecNote.created.isSet()) { - strm << QStringLiteral("creationTimestamp: ") << d->m_qecNote.created - << QStringLiteral(", datetime: ") + strm << "creationTimestamp: " << d->m_qecNote.created + << ", datetime: " << printableDateTimeFromTimestamp(d->m_qecNote.created); } else { - strm << QStringLiteral("creationTimestamp is not set"); + strm << "creationTimestamp is not set"; } INSERT_DELIMITER; if (d->m_qecNote.updated.isSet()) { - strm << QStringLiteral("modificationTimestamp: ") << d->m_qecNote.updated - << QStringLiteral(", datetime: ") + strm << "modificationTimestamp: " << d->m_qecNote.updated + << ", datetime: " << printableDateTimeFromTimestamp(d->m_qecNote.updated); } else { - strm << QStringLiteral("modificationTimestamp is not set"); + strm << "modificationTimestamp is not set"; } INSERT_DELIMITER; if (d->m_qecNote.deleted.isSet()) { - strm << QStringLiteral("deletionTimestamp: ") << d->m_qecNote.deleted - << QStringLiteral(", datetime: ") + strm << "deletionTimestamp: " << d->m_qecNote.deleted + << ", datetime: " << printableDateTimeFromTimestamp(d->m_qecNote.deleted); } else { - strm << QStringLiteral("deletionTimestamp is not set"); + strm << "deletionTimestamp is not set"; } INSERT_DELIMITER; if (d->m_qecNote.active.isSet()) { - strm << QStringLiteral("active: ") - << (d->m_qecNote.active - ? QStringLiteral("true") - : QStringLiteral("false")); + strm << "active: " << (d->m_qecNote.active ? "true" : "false"); } else { - strm << QStringLiteral("active is not set"); + strm << "active is not set"; } INSERT_DELIMITER; if (d->m_qecNote.notebookGuid.isSet()) { - strm << QStringLiteral("notebookGuid: ") << d->m_qecNote.notebookGuid; + strm << "notebookGuid: " << d->m_qecNote.notebookGuid; } else { - strm << QStringLiteral("notebookGuid is not set"); + strm << "notebookGuid is not set"; } INSERT_DELIMITER; if (d->m_notebookLocalUid.isSet()) { - strm << QStringLiteral("notebookLocalUid: ") << d->m_notebookLocalUid; + strm << "notebookLocalUid: " << d->m_notebookLocalUid; } else { - strm << QStringLiteral("notebookLocalUid is not set"); + strm << "notebookLocalUid is not set"; } INSERT_DELIMITER; if (d->m_qecNote.tagGuids.isSet()) { - strm << QStringLiteral("tagGuids: {"); + strm << "tagGuids: {"; const QStringList tagGuids = d->m_qecNote.tagGuids.ref(); for(auto it = tagGuids.constBegin(), end = tagGuids.constEnd(); it != end; ++it) { - strm << QStringLiteral("'") << *it << QStringLiteral("'; "); + strm << "'" << *it << "'; "; } - strm << QStringLiteral("}"); + strm << "}"; } else { - strm << QStringLiteral("tagGuids are not set"); + strm << "tagGuids are not set"; } INSERT_DELIMITER; if (!d->m_tagLocalUids.isEmpty()) { - strm << QStringLiteral("tagLocalUids: {"); + strm << "tagLocalUids: {"; const QStringList tagLocalUids = d->m_tagLocalUids; for(auto it = tagLocalUids.constBegin(), end = tagLocalUids.constEnd(); it != end; ++it) { - strm << QStringLiteral("'") << *it << QStringLiteral("';"); + strm << "'" << *it << "';"; } - strm << QStringLiteral("}"); + strm << "}"; } else { - strm << QStringLiteral("tagLocalUids are not set"); + strm << "tagLocalUids are not set"; } INSERT_DELIMITER; - strm << QStringLiteral("thumbnail is ") - << (d->m_thumbnailData.isEmpty() - ? QStringLiteral("null") - : QStringLiteral("non-null")); + strm << "thumbnail is " + << (d->m_thumbnailData.isEmpty() ? "null" : "non-null"); INSERT_DELIMITER; if (d->m_qecNote.resources.isSet()) { - strm << QStringLiteral("resources: { \n"); + strm << "resources: { \n"; const QList<qevercloud::Resource> resources = d->m_qecNote.resources.ref(); int resourceIndex = 0; int resourcesAdditionalInfoSize = d->m_resourcesAdditionalInfo.size(); for(auto it = resources.constBegin(), end = resources.constEnd(); it != end; ++it) { - strm << *it << QStringLiteral("; \n"); + strm << *it << "; \n"; if (resourceIndex < resourcesAdditionalInfoSize) { const NoteData::ResourceAdditionalInfo & info = d->m_resourcesAdditionalInfo.at(resourceIndex); - strm << QStringLiteral("Resource additional info: local uid = ") - << info.localUid << QStringLiteral(", dirty = ") - << (info.isDirty - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral("; \n"); + strm << "Resource additional info: local uid = " + << info.localUid << ", dirty = " + << (info.isDirty ? "true" : "false") + << "; \n"; } ++resourceIndex; } - strm << QStringLiteral("}"); + strm << "}"; } else { - strm << QStringLiteral("resources are not set"); + strm << "resources are not set"; } INSERT_DELIMITER; if (d->m_qecNote.attributes.isSet()) { - strm << QStringLiteral("attributes: ") << d->m_qecNote.attributes; + strm << "attributes: " << d->m_qecNote.attributes; } else { - strm << QStringLiteral("attributes are not set"); + strm << "attributes are not set"; } INSERT_DELIMITER; if (d->m_qecNote.sharedNotes.isSet()) { - strm << QStringLiteral("shared notes:\n"); + strm << "shared notes:\n"; for(auto it = d->m_qecNote.sharedNotes.ref().constBegin(), end = d->m_qecNote.sharedNotes.ref().constEnd(); it != end; ++it) { - strm << *it << QStringLiteral("\n"); + strm << *it << "\n"; } } else { - strm << QStringLiteral("shared notes are not set"); + strm << "shared notes are not set"; } INSERT_DELIMITER; - strm << QStringLiteral("isDirty: ") - << (isDirty() - ? QStringLiteral("true") - : QStringLiteral("false")); + strm << "isDirty: " << (isDirty() ? "true" : "false"); INSERT_DELIMITER; - strm << QStringLiteral("isLocal: ") - << (d->m_isLocal - ? QStringLiteral("true") - : QStringLiteral("false")); + strm << "isLocal: " << (d->m_isLocal ? "true" : "false"); INSERT_DELIMITER; - strm << QStringLiteral("isFavorited = ") - << (isFavorited() - ? QStringLiteral("true") - : QStringLiteral("false")); + strm << "isFavorited = " << (isFavorited() ? "true" : "false"); INSERT_DELIMITER; #undef INSERT_DELIMITER - strm << QStringLiteral("}; \n"); + strm << "}; \n"; return strm; } diff -Nru libquentier-0.5.0/src/types/Resource.cpp libquentier-0.5.0/src/types/Resource.cpp --- libquentier-0.5.0/src/types/Resource.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/types/Resource.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -495,10 +495,8 @@ void Resource::setDataBody(const QByteArray & body) { - QNTRACE(QStringLiteral("Resource::setDataBody: body to set is ") - << (body.isEmpty() - ? QStringLiteral("empty") - : QStringLiteral("not empty"))); + QNTRACE("Resource::setDataBody: body to set is " + << (body.isEmpty() ? "empty" : "not empty")); qevercloud::Resource & enResource = d->m_qecResource; @@ -882,36 +880,31 @@ { const qevercloud::Resource & enResource = d->m_qecResource; - strm << QStringLiteral("Resource: { \n"); + strm << "Resource: { \n"; QString indent = QStringLiteral(" "); const QString localUid_ = localUid(); if (!localUid_.isEmpty()) { - strm << indent << QStringLiteral("local uid = ") << localUid_ - << QStringLiteral("; \n"); + strm << indent << "local uid = " << localUid_ << "; \n"; } else { - strm << indent << QStringLiteral("localUid is empty; \n"); + strm << indent << "localUid is empty; \n"; } - strm << indent << QStringLiteral("isDirty = ") - << (isDirty() - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral("; \n"); - strm << indent << QStringLiteral("indexInNote = ") - << QString::number(d->m_indexInNote) << QStringLiteral("; \n"); - strm << indent << QStringLiteral("note local uid = ") + strm << indent << "isDirty = " + << (isDirty() ? "true" : "false") << "; \n"; + strm << indent << "indexInNote = " + << QString::number(d->m_indexInNote) << "; \n"; + strm << indent << "note local uid = " << (d->m_noteLocalUid.isSet() ? d->m_noteLocalUid.ref() : QStringLiteral("<not set>")) - << QStringLiteral("; \n"); + << "; \n"; strm << indent << enResource; - strm << QStringLiteral("}; \n"); - + strm << "}; \n"; return strm; } diff -Nru libquentier-0.5.0/src/types/ResourceRecognitionIndexItem.cpp libquentier-0.5.0/src/types/ResourceRecognitionIndexItem.cpp --- libquentier-0.5.0/src/types/ResourceRecognitionIndexItem.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/types/ResourceRecognitionIndexItem.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -475,133 +475,126 @@ QTextStream & ResourceRecognitionIndexItem::print(QTextStream & strm) const { - strm << QStringLiteral("ResourceRecognitionIndexItem: {\n"); + strm << "ResourceRecognitionIndexItem: {\n"; if (d->m_x >= 0) { - strm << QStringLiteral(" x = ") << d->m_x << QStringLiteral(";\n"); + strm << " x = " << d->m_x << ";\n"; } else { - strm << QStringLiteral(" x is not set;\n"); + strm << " x is not set;\n"; } if (d->m_y >= 0) { - strm << QStringLiteral(" y = ") << d->m_y << QStringLiteral(";\n"); + strm << " y = " << d->m_y << ";\n"; } else { - strm << QStringLiteral(" y is not set;\n"); + strm << " y is not set;\n"; } if (d->m_h >= 0) { - strm << QStringLiteral(" h = ") << d->m_h << QStringLiteral(";\n"); + strm << " h = " << d->m_h << ";\n"; } else { - strm << QStringLiteral(" h is not set;\n"); + strm << " h is not set;\n"; } if (d->m_w >= 0) { - strm << QStringLiteral(" w = ") << d->m_w << QStringLiteral(";\n"); + strm << " w = " << d->m_w << ";\n"; } else { - strm << QStringLiteral(" w is not set;\n"); + strm << " w is not set;\n"; } if (d->m_offset >= 0) { - strm << QStringLiteral(" offset = ") << d->m_offset - << QStringLiteral(";\n"); + strm << " offset = " << d->m_offset << ";\n"; } else { - strm << QStringLiteral(" offset is not set;\n"); + strm << " offset is not set;\n"; } if (d->m_duration >= 0) { - strm << QStringLiteral(" duration = ") << d->m_duration - << QStringLiteral(";\n"); + strm << " duration = " << d->m_duration << ";\n"; } else { - strm << QStringLiteral(" duration is not set;\n"); + strm << " duration is not set;\n"; } if (!d->m_strokeList.isEmpty()) { - strm << QStringLiteral(" stroke list: "); + strm << " stroke list: "; for(auto it = d->m_strokeList.constBegin(), end = d->m_strokeList.constEnd(); it != end; ++it) { - strm << *it << QStringLiteral(" "); + strm << *it << " "; } - strm << QStringLiteral(";\n"); + strm << ";\n"; } else { - strm << QStringLiteral(" stroke list is not set;\n"); + strm << " stroke list is not set;\n"; } if (!d->m_textItems.isEmpty()) { - strm << QStringLiteral(" text items: \n"); + strm << " text items: \n"; for(auto it = d->m_textItems.constBegin(), end = d->m_textItems.constEnd(); it != end; ++it) { - strm << QStringLiteral(" text: ") << it->m_text - << QStringLiteral("; weight = ") << it->m_weight - << QStringLiteral(";\n"); + strm << " text: " << it->m_text + << "; weight = " << it->m_weight << ";\n"; } } else { - strm << QStringLiteral(" text items are not set;\n"); + strm << " text items are not set;\n"; } if (!d->m_objectItems.isEmpty()) { - strm << QStringLiteral(" object items: \n"); + strm << " object items: \n"; for(auto it = d->m_objectItems.constBegin(), end = d->m_objectItems.constEnd(); it != end; ++it) { - strm << QStringLiteral(" object type: ") << it->m_objectType - << QStringLiteral("; weight: ") << it->m_weight - << QStringLiteral(";\n"); + strm << " object type: " << it->m_objectType + << "; weight: " << it->m_weight << ";\n"; } } else { - strm << QStringLiteral(" object items are not set;\n"); + strm << " object items are not set;\n"; } if (!d->m_shapeItems.isEmpty()) { - strm << QStringLiteral(" shape items: \n"); + strm << " shape items: \n"; for(auto it = d->m_shapeItems.constBegin(), end = d->m_shapeItems.constEnd(); it != end; ++it) { - strm << QStringLiteral(" shape type: ") << it->m_shapeType - << QStringLiteral("; weight: ") << it->m_weight - << QStringLiteral(";\n"); + strm << " shape type: " << it->m_shapeType + << "; weight: " << it->m_weight << ";\n"; } } else { - strm << QStringLiteral(" shape items are not set;\n"); + strm << " shape items are not set;\n"; } if (!d->m_barcodeItems.isEmpty()) { - strm << QStringLiteral(" barcode items: \n"); + strm << " barcode items: \n"; for(auto it = d->m_barcodeItems.constBegin(), end = d->m_barcodeItems.constEnd(); it != end; ++it) { - strm << QStringLiteral(" barcode: ") << it->m_barcode - << QStringLiteral("; weight: ") << it->m_weight - << QStringLiteral(";\n"); + strm << " barcode: " << it->m_barcode + << "; weight: " << it->m_weight << ";\n"; } } else { - strm << QStringLiteral(" barcode items are not set;\n"); + strm << " barcode items are not set;\n"; } - strm << QStringLiteral("};\n"); - + strm << "};\n"; return strm; } diff -Nru libquentier-0.5.0/src/types/ResourceRecognitionIndices.cpp libquentier-0.5.0/src/types/ResourceRecognitionIndices.cpp --- libquentier-0.5.0/src/types/ResourceRecognitionIndices.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/types/ResourceRecognitionIndices.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -114,94 +114,85 @@ QTextStream & ResourceRecognitionIndices::print(QTextStream & strm) const { - strm << QStringLiteral("ResourceRecognitionIndices: {\n"); + strm << "ResourceRecognitionIndices: {\n"; if (isNull()) { - strm << QStringLiteral(" <null>\n};\n"); + strm << " <null>\n};\n"; return strm; } if (!d->m_objectId.isEmpty()) { - strm << QStringLiteral(" object id = ") << d->m_objectId - << QStringLiteral(";\n"); + strm << " object id = " << d->m_objectId << ";\n"; } else { - strm << QStringLiteral(" object id is not set;\n"); + strm << " object id is not set;\n"; } if (!d->m_objectType.isEmpty()) { - strm << QStringLiteral(" object type = ") << d->m_objectType - << QStringLiteral(";\n"); + strm << " object type = " << d->m_objectType << ";\n"; } else { - strm << QStringLiteral(" object type is not set;\n"); + strm << " object type is not set;\n"; } if (!d->m_recoType.isEmpty()) { - strm << QStringLiteral(" reco type = ") << d->m_recoType - << QStringLiteral(";\n"); + strm << " reco type = " << d->m_recoType << ";\n"; } else { - strm << QStringLiteral(" reco type is not set;\n"); + strm << " reco type is not set;\n"; } if (!d->m_engineVersion.isEmpty()) { - strm << QStringLiteral(" engine version = ") << d->m_engineVersion - << QStringLiteral(";\n"); + strm << " engine version = " << d->m_engineVersion << ";\n"; } else { - strm << QStringLiteral(" engine version is not set;\n"); + strm << " engine version is not set;\n"; } if (!d->m_docType.isEmpty()) { - strm << QStringLiteral(" doc type = ") << d->m_docType - << QStringLiteral(";\n"); + strm << " doc type = " << d->m_docType << ";\n"; } else { - strm << QStringLiteral(" doc type is not set;\n"); + strm << " doc type is not set;\n"; } if (!d->m_lang.isEmpty()) { - strm << QStringLiteral(" lang = ") << d->m_lang - << QStringLiteral(";\n"); + strm << " lang = " << d->m_lang << ";\n"; } else { - strm << QStringLiteral(" lang is not set;\n"); + strm << " lang is not set;\n"; } if (d->m_objectHeight >= 0) { - strm << QStringLiteral(" object height = ") << d->m_objectHeight - << QStringLiteral(";\n"); + strm << " object height = " << d->m_objectHeight << ";\n"; } else { - strm << QStringLiteral(" object height is not set;\n"); + strm << " object height is not set;\n"; } if (d->m_objectWidth >= 0) { - strm << QStringLiteral(" object width = ") << d->m_objectWidth - << QStringLiteral(";\n"); + strm << " object width = " << d->m_objectWidth << ";\n"; } else { - strm << QStringLiteral(" object width is not set;\n"); + strm << " object width is not set;\n"; } if (!d->m_items.isEmpty()) { - strm << QStringLiteral(" recognition items: \n"); + strm << " recognition items: \n"; for(auto it = d->m_items.constBegin(), end = d->m_items.constEnd(); it != end; ++it) { - strm << *it << QStringLiteral("\n"); + strm << *it << "\n"; } - strm << QStringLiteral("\n"); + strm << "\n"; } else { - strm << QStringLiteral(" no recognition items are set;\n"); + strm << " no recognition items are set;\n"; } - strm << QStringLiteral("};\n"); - + strm << "};\n"; return strm; } diff -Nru libquentier-0.5.0/src/types/SavedSearch.cpp libquentier-0.5.0/src/types/SavedSearch.cpp --- libquentier-0.5.0/src/types/SavedSearch.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/types/SavedSearch.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -262,10 +262,11 @@ } } -#define CHECK_AND_SET_SCOPE() \ - if (!d->m_qecSearch.scope.isSet()) { \ - d->m_qecSearch.scope = SavedSearchScope(); \ - } +#define CHECK_AND_SET_SCOPE() \ + if (!d->m_qecSearch.scope.isSet()) { \ + d->m_qecSearch.scope = SavedSearchScope(); \ + } \ +// CHECK_AND_SET_SCOPE bool SavedSearch::hasIncludeAccount() const { @@ -324,116 +325,101 @@ QTextStream & SavedSearch::print(QTextStream & strm) const { - strm << QStringLiteral("Saved search: { \n"); + strm << "Saved search: { \n"; const QString localUid_ = localUid(); if (!localUid_.isEmpty()) { - strm << QStringLiteral("localUid: ") << localUid_ - << QStringLiteral("; \n"); + strm << "localUid: " << localUid_ << "; \n"; } else { - strm << QStringLiteral("localUid is not set; \n"); + strm << "localUid is not set; \n"; } if (d->m_qecSearch.guid.isSet()) { - strm << QStringLiteral("guid: ") << d->m_qecSearch.guid - << QStringLiteral("; \n"); + strm << "guid: " << d->m_qecSearch.guid << "; \n"; } else { - strm << QStringLiteral("guid is not set; \n"); + strm << "guid is not set; \n"; } if (d->m_qecSearch.updateSequenceNum.isSet()) { - strm << QStringLiteral("updateSequenceNumber: ") + strm << "updateSequenceNumber: " << QString::number(d->m_qecSearch.updateSequenceNum) - << QStringLiteral("; \n"); + << "; \n"; } else { - strm << QStringLiteral("updateSequenceNumber is not set; \n"); + strm << "updateSequenceNumber is not set; \n"; } if (d->m_qecSearch.name.isSet()) { - strm << QStringLiteral("name: ") << d->m_qecSearch.name - << QStringLiteral("; \n"); + strm << "name: " << d->m_qecSearch.name << "; \n"; } else { - strm << QStringLiteral("name is not set; \n"); + strm << "name is not set; \n"; } if (d->m_qecSearch.query.isSet()) { - strm << QStringLiteral("query: ") << d->m_qecSearch.query - << QStringLiteral("; \n"); + strm << "query: " << d->m_qecSearch.query << "; \n"; } else { - strm << QStringLiteral("query is not set; \n"); + strm << "query is not set; \n"; } if (d->m_qecSearch.format.isSet()) { - strm << QStringLiteral("queryFormat: ") << d->m_qecSearch.format - << QStringLiteral("; \n"); + strm << "queryFormat: " << d->m_qecSearch.format << "; \n"; } else { - strm << QStringLiteral("queryFormat is not set; \n"); + strm << "queryFormat is not set; \n"; } if (d->m_qecSearch.scope.isSet()) { - strm << QStringLiteral("scope is set; \n"); + strm << "scope is set; \n"; const SavedSearchScope & scope = d->m_qecSearch.scope; if (scope.includeAccount.isSet()) { - strm << QStringLiteral("includeAccount: ") - << (scope.includeAccount - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral("; \n"); + strm << "includeAccount: " + << (scope.includeAccount ? "true" : "false") + << "; \n"; } else { - strm << QStringLiteral("includeAccount is not set; \n"); + strm << "includeAccount is not set; \n"; } if (scope.includePersonalLinkedNotebooks.isSet()) { - strm << QStringLiteral("includePersonalLinkedNotebooks: ") - << (scope.includePersonalLinkedNotebooks - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(";\n"); + strm << "includePersonalLinkedNotebooks: " + << (scope.includePersonalLinkedNotebooks ? "true" : "false") + << ";\n"; } else { - strm << QStringLiteral("includePersonalLinkedNotebooks is not set;\n"); + strm << "includePersonalLinkedNotebooks is not set;\n"; } if (scope.includeBusinessLinkedNotebooks.isSet()) { - strm << QStringLiteral("includeBusinessLinkedNotebooks: ") - << (scope.includeBusinessLinkedNotebooks - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral("; \n"); + strm << "includeBusinessLinkedNotebooks: " + << (scope.includeBusinessLinkedNotebooks ? "true" : "false") + << "; \n"; } else { - strm << QStringLiteral("includeBusinessLinkedNotebooks is not set;\n"); + strm << "includeBusinessLinkedNotebooks is not set;\n"; } } else { - strm << QStringLiteral("scope is not set; \n"); + strm << "scope is not set; \n"; return strm; } - strm << QStringLiteral("isFavorited = ") - << (isFavorited() - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral("; \n"); + strm << "isFavorited = " << (isFavorited() ? "true" : "false") << "; \n"; - strm << QStringLiteral("}; \n"); + strm << "}; \n"; return strm; } diff -Nru libquentier-0.5.0/src/types/SharedNotebook.cpp libquentier-0.5.0/src/types/SharedNotebook.cpp --- libquentier-0.5.0/src/types/SharedNotebook.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/types/SharedNotebook.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -273,12 +273,13 @@ return d->m_qecSharedNotebook.recipientSettings->reminderNotifyEmail.ref(); } -#define CHECK_AND_SET_RECIPIENT_SETTINGS \ - qevercloud::SharedNotebook & sharedNotebook = d->m_qecSharedNotebook; \ - if (!sharedNotebook.recipientSettings.isSet()) { \ - sharedNotebook.recipientSettings = \ - qevercloud::SharedNotebookRecipientSettings(); \ - } +#define CHECK_AND_SET_RECIPIENT_SETTINGS \ + qevercloud::SharedNotebook & sharedNotebook = d->m_qecSharedNotebook; \ + if (!sharedNotebook.recipientSettings.isSet()) { \ + sharedNotebook.recipientSettings = \ + qevercloud::SharedNotebookRecipientSettings(); \ + } \ +// CHECK_AND_SET_RECIPIENT_SETTINGS void SharedNotebook::setReminderNotifyEmail(const bool notifyEmail) { @@ -413,14 +414,14 @@ QTextStream & SharedNotebook::print(QTextStream & strm) const { - strm << QStringLiteral("SharedNotebook {\n"); - strm << QStringLiteral(" index in notebook: ") + strm << "SharedNotebook {\n"; + strm << " index in notebook: " << QString::number(d->m_indexInNotebook) - << QStringLiteral(";\n"); + << ";\n"; const qevercloud::SharedNotebook & sharedNotebook = d->m_qecSharedNotebook; strm << sharedNotebook; - strm << QStringLiteral("};\n"); + strm << "};\n"; return strm; } diff -Nru libquentier-0.5.0/src/types/SharedNote.cpp libquentier-0.5.0/src/types/SharedNote.cpp --- libquentier-0.5.0/src/types/SharedNote.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/types/SharedNote.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -678,12 +678,11 @@ QTextStream & SharedNote::print(QTextStream & strm) const { - strm << QStringLiteral("SharedNote {\n"); + strm << "SharedNote {\n"; strm << d->m_qecSharedNote; - strm << QStringLiteral("index in note = ") << d->m_indexInNote - << QStringLiteral(";\n"); - strm << QStringLiteral("};\n"); + strm << "index in note = " << d->m_indexInNote << ";\n"; + strm << "};\n"; return strm; } diff -Nru libquentier-0.5.0/src/types/Tag.cpp libquentier-0.5.0/src/types/Tag.cpp --- libquentier-0.5.0/src/types/Tag.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/types/Tag.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -283,82 +283,80 @@ QTextStream & Tag::print(QTextStream & strm) const { - strm << QStringLiteral("Tag { \n"); + strm << "Tag { \n"; -#define INSERT_DELIMITER \ - strm << QStringLiteral("; \n") +#define INSERT_DELIMITER \ + strm << "; \n" \ +// INSERT_DELIMITER const QString localUid_ = localUid(); if (!localUid_.isEmpty()) { - strm << QStringLiteral("localUid: ") << localUid_; + strm << "localUid: " << localUid_; } else { - strm << QStringLiteral("localUid is not set"); + strm << "localUid is not set"; } INSERT_DELIMITER; if (d->m_parentLocalUid.isSet()) { - strm << QStringLiteral("parent local uid: ") << d->m_parentLocalUid.ref(); + strm << "parent local uid: " << d->m_parentLocalUid.ref(); } else { - strm << QStringLiteral("parent local uid is not set"); + strm << "parent local uid is not set"; } INSERT_DELIMITER; if (d->m_qecTag.guid.isSet()) { - strm << QStringLiteral("guid: ") << d->m_qecTag.guid; + strm << "guid: " << d->m_qecTag.guid; } else { - strm << QStringLiteral("guid is not set"); + strm << "guid is not set"; } INSERT_DELIMITER; if (d->m_linkedNotebookGuid.isSet()) { - strm << QStringLiteral("linked notebook guid: ") << d->m_linkedNotebookGuid; + strm << "linked notebook guid: " << d->m_linkedNotebookGuid; } else { - strm << QStringLiteral("linked notebook guid is not set"); + strm << "linked notebook guid is not set"; } INSERT_DELIMITER; if (d->m_qecTag.name.isSet()) { - strm << QStringLiteral("name: ") << d->m_qecTag.name; + strm << "name: " << d->m_qecTag.name; } else { - strm << QStringLiteral("name is not set"); + strm << "name is not set"; } INSERT_DELIMITER; if (d->m_qecTag.parentGuid.isSet()) { - strm << QStringLiteral("parentGuid: ") << d->m_qecTag.parentGuid; + strm << "parentGuid: " << d->m_qecTag.parentGuid; } else { - strm << QStringLiteral("parentGuid is not set"); + strm << "parentGuid is not set"; } INSERT_DELIMITER; if (d->m_qecTag.updateSequenceNum.isSet()) { - strm << QStringLiteral("updateSequenceNumber: ") + strm << "updateSequenceNumber: " << QString::number(d->m_qecTag.updateSequenceNum); } else { - strm << QStringLiteral("updateSequenceNumber is not set"); + strm << "updateSequenceNumber is not set"; } INSERT_DELIMITER; - strm << QStringLiteral("isDirty: ") - << (isDirty() ? QStringLiteral("true") : QStringLiteral("false")); + strm << "isDirty: " << (isDirty() ? "true" : "false"); INSERT_DELIMITER; - strm << QStringLiteral("isLocal: ") - << (d->m_isLocal ? QStringLiteral("true") : QStringLiteral("false")); + strm << "isLocal: " << (d->m_isLocal ? "true" : "false"); INSERT_DELIMITER; - strm << QStringLiteral("isFavorited = ") - << (isFavorited() ? QStringLiteral("true") : QStringLiteral("false")); + strm << "isFavorited = " << (isFavorited() ? "true" : "false"); INSERT_DELIMITER; - strm << QStringLiteral("}; \n"); + strm << "}; \n"; return strm; } diff -Nru libquentier-0.5.0/src/types/User.cpp libquentier-0.5.0/src/types/User.cpp --- libquentier-0.5.0/src/types/User.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/types/User.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -660,151 +660,141 @@ QTextStream & User::print(QTextStream & strm) const { - strm << QStringLiteral("User { \n"); - strm << QStringLiteral("isDirty = ") - << (d->m_isDirty ? QStringLiteral("true") : QStringLiteral("false")) - << QStringLiteral("; \n"); - strm << QStringLiteral("isLocal = ") - << (d->m_isLocal ? QStringLiteral("true") : QStringLiteral("false")) - << QStringLiteral("; \n"); + strm << "User { \n"; + strm << "isDirty = " + << (d->m_isDirty ? "true" : "false") + << "; \n"; + strm << "isLocal = " + << (d->m_isLocal ? "true" : "false") + << "; \n"; const auto & enUser = d->m_qecUser; if (enUser.id.isSet()) { - strm << QStringLiteral("User ID = ") << QString::number(enUser.id) - << QStringLiteral("; \n"); + strm << "User ID = " << QString::number(enUser.id) << "; \n"; } else { - strm << QStringLiteral("User ID is not set; \n"); + strm << "User ID is not set; \n"; } if (enUser.username.isSet()) { - strm << QStringLiteral("username = ") << enUser.username - << QStringLiteral("; \n"); + strm << "username = " << enUser.username << "; \n"; } else { - strm << QStringLiteral("username is not set; \n"); + strm << "username is not set; \n"; } if (enUser.email.isSet()) { - strm << QStringLiteral("email = ") << enUser.email - << QStringLiteral("; \n"); + strm << "email = " << enUser.email << "; \n"; } else { - strm << QStringLiteral("email is not set; \n"); + strm << "email is not set; \n"; } if (enUser.name.isSet()) { - strm << QStringLiteral("name = ") << enUser.name - << QStringLiteral("; \n"); + strm << "name = " << enUser.name << "; \n"; } else { - strm << QStringLiteral("name is not set; \n"); + strm << "name is not set; \n"; } if (enUser.timezone.isSet()) { - strm << QStringLiteral("timezone = ") << enUser.timezone - << QStringLiteral("; \n"); + strm << "timezone = " << enUser.timezone << "; \n"; } else { - strm << QStringLiteral("timezone is not set; \n"); + strm << "timezone is not set; \n"; } if (enUser.privilege.isSet()) { - strm << QStringLiteral("privilege = ") << enUser.privilege - << QStringLiteral("; \n"); + strm << "privilege = " << enUser.privilege << "; \n"; } else { - strm << QStringLiteral("privilege is not set; \n"); + strm << "privilege is not set; \n"; } if (enUser.serviceLevel.isSet()) { - strm << QStringLiteral("service level = ") << enUser.serviceLevel - << QStringLiteral("; \n"); + strm << "service level = " << enUser.serviceLevel << "; \n"; } else { - strm << QStringLiteral("service level is not set; \n"); + strm << "service level is not set; \n"; } if (enUser.created.isSet()) { - strm << QStringLiteral("created = ") - << printableDateTimeFromTimestamp(enUser.created) - << QStringLiteral("; \n"); + strm << "created = " + << printableDateTimeFromTimestamp(enUser.created) << "; \n"; } else { - strm << QStringLiteral("created is not set; \n"); + strm << "created is not set; \n"; } if (enUser.updated.isSet()) { - strm << QStringLiteral("updated = ") - << printableDateTimeFromTimestamp(enUser.updated) - << QStringLiteral("; \n"); + strm << "updated = " + << printableDateTimeFromTimestamp(enUser.updated) << "; \n"; } else { - strm << QStringLiteral("updated is not set; \n"); + strm << "updated is not set; \n"; } if (enUser.deleted.isSet()) { - strm << QStringLiteral("deleted = ") - << printableDateTimeFromTimestamp(enUser.deleted) - << QStringLiteral("; \n"); + strm << "deleted = " + << printableDateTimeFromTimestamp(enUser.deleted) << "; \n"; } else { - strm << QStringLiteral("deleted is not set; \n"); + strm << "deleted is not set; \n"; } if (enUser.active.isSet()) { - strm << QStringLiteral("active = ") - << (enUser.active ? QStringLiteral("true") : QStringLiteral("false")) - << QStringLiteral("; \n"); + strm << "active = " + << (enUser.active ? "true" : "false") + << "; \n"; } else { - strm << QStringLiteral("active is not set; \n"); + strm << "active is not set; \n"; } if (enUser.attributes.isSet()) { strm << enUser.attributes; } else { - strm << QStringLiteral("attributes are not set; \n"); + strm << "attributes are not set; \n"; } if (enUser.accounting.isSet()) { strm << enUser.accounting; } else { - strm << QStringLiteral("accounting is not set; \n"); + strm << "accounting is not set; \n"; } if (enUser.businessUserInfo.isSet()) { strm << enUser.businessUserInfo; } else { - strm << QStringLiteral("business user info is not set; \n"); + strm << "business user info is not set; \n"; } if (enUser.photoUrl.isSet()) { - strm << QStringLiteral("photo url = ") - << enUser.photoUrl << QStringLiteral("; \n"); + strm << "photo url = " + << enUser.photoUrl << "; \n"; } else { - strm << QStringLiteral("photo url is not set; \n"); + strm << "photo url is not set; \n"; } if (enUser.photoLastUpdated.isSet()) { - strm << QStringLiteral("photo url last updated = ") + strm << "photo url last updated = " << printableDateTimeFromTimestamp(enUser.photoLastUpdated) - << QStringLiteral("; \n"); + << "; \n"; } else { - strm << QStringLiteral("photo url last updates is not set; \n"); + strm << "photo url last updates is not set; \n"; } if (enUser.accountLimits.isSet()) { strm << enUser.accountLimits; } else { - strm << QStringLiteral("account limits are not set; \n"); + strm << "account limits are not set; \n"; } return strm; diff -Nru libquentier-0.5.0/src/utility/ApplicationSettings.cpp libquentier-0.5.0/src/utility/ApplicationSettings.cpp --- libquentier-0.5.0/src/utility/ApplicationSettings.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/utility/ApplicationSettings.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -56,8 +56,8 @@ QString accountName = account.name(); if (Q_UNLIKELY(accountName.isEmpty())) { - QNWARNING(QStringLiteral("Detected attempt to create ApplicationSettings " - "for account with empty name")); + QNWARNING("Detected attempt to create ApplicationSettings " + "for account with empty name"); throw ApplicationSettingsInitializationException( ErrorString( QT_TRANSLATE_NOOP("ApplicationSettings", diff -Nru libquentier-0.5.0/src/utility/EncryptionManager_p.cpp libquentier-0.5.0/src/utility/EncryptionManager_p.cpp --- libquentier-0.5.0/src/utility/EncryptionManager_p.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/utility/EncryptionManager_p.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -131,11 +131,12 @@ { QByteArray encryptedTextData(EN_IDENT, 4); -#define GET_OPENSSL_ERROR \ - unsigned long errorCode = ERR_get_error(); \ - const char * errorLib = ERR_lib_error_string(errorCode); \ - const char * errorFunc = ERR_func_error_string(errorCode); \ - const char * errorReason = ERR_reason_error_string(errorCode) +#define GET_OPENSSL_ERROR \ + unsigned long errorCode = ERR_get_error(); \ + const char * errorLib = ERR_lib_error_string(errorCode); \ + const char * errorFunc = ERR_func_error_string(errorCode); \ + const char * errorReason = ERR_reason_error_string(errorCode) \ +// GET_OPENSSL_ERROR bool res = generateSalt(SaltKind::SALT, EN_AES_KEYSIZE, errorDescription); if (!res) { @@ -224,10 +225,8 @@ "cryptographically strong " "bytes for encryption")); GET_OPENSSL_ERROR; - QNWARNING(errorDescription << QStringLiteral("; ") - << saltText << QStringLiteral(": lib: ") << errorLib - << QStringLiteral("; func: ") << errorFunc - << QStringLiteral(", reason: ") << errorReason); + QNWARNING(errorDescription << "; " << saltText << ": lib: " << errorLib + << "; func: " << errorFunc << ", reason: " << errorReason); return false; } @@ -249,10 +248,10 @@ "can't generate cryptographic key")); GET_OPENSSL_ERROR; QNWARNING(errorDescription - << QStringLiteral(", openssl PKCS5_PBKDF2_HMAC failed: ") - << QStringLiteral(": lib: ") << errorLib - << QStringLiteral("; func: ") << errorFunc - << QStringLiteral(", reason: ") << errorReason); + << ", openssl PKCS5_PBKDF2_HMAC failed: " + << ": lib: " << errorLib + << "; func: " << errorFunc + << ", reason: " << errorReason); return false; } @@ -307,10 +306,10 @@ "AES algorithm")); GET_OPENSSL_ERROR; QNWARNING(errorDescription - << QStringLiteral(", openssl EVP_EnryptInit failed: ") - << QStringLiteral(": lib: ") << errorLib - << QStringLiteral("; func: ") << errorFunc - << QStringLiteral(", reason: ") << errorReason); + << ", openssl EVP_EnryptInit failed: " + << ": lib: " << errorLib + << "; func: " << errorFunc + << ", reason: " << errorReason); free(cipherText); EVP_CIPHER_CTX_free(pContext); return false; @@ -324,10 +323,10 @@ "AES algorithm")); GET_OPENSSL_ERROR; QNWARNING(errorDescription - << QStringLiteral(", openssl EVP_CipherUpdate failed: ") - << QStringLiteral(": lib: ") << errorLib - << QStringLiteral("; func: ") << errorFunc - << QStringLiteral(", reason: ") << errorReason); + << ", openssl EVP_CipherUpdate failed: " + << ": lib: " << errorLib + << "; func: " << errorFunc + << ", reason: " << errorReason); free(cipherText); EVP_CIPHER_CTX_free(pContext); return false; @@ -342,10 +341,10 @@ "AES algorithm")); GET_OPENSSL_ERROR; QNWARNING(errorDescription - << QStringLiteral(", openssl EVP_CipherFinal failed: ") - << QStringLiteral(": lib: ") << errorLib - << QStringLiteral("; func: ") << errorFunc - << QStringLiteral(", reason: ") << errorReason); + << ", openssl EVP_CipherFinal failed: " + << ": lib: " << errorLib + << "; func: " << errorFunc + << ", reason: " << errorReason); free(cipherText); EVP_CIPHER_CTX_free(pContext); return false; @@ -366,7 +365,7 @@ QByteArray & decryptedText, ErrorString & errorDescription) { - QNDEBUG(QStringLiteral("EncryptionManagerPrivate::decryptAes")); + QNDEBUG("EncryptionManagerPrivate::decryptAes"); QByteArray cipherText; bool bres = splitEncryptedData(encryptedText, EN_AES_KEYSIZE, EN_AES_HMACSIZE, @@ -378,7 +377,7 @@ QByteArray passphraseData = passphrase.toUtf8(); // Validate HMAC - QNTRACE(QStringLiteral("Validating hmac...")); + QNTRACE("Validating hmac"); unsigned char parsedHmac[EN_AES_HMACSIZE]; for(int i = 0; i < EN_AES_HMACSIZE; ++i) { @@ -402,17 +401,17 @@ errorDescription.setBase(QT_TRANSLATE_NOOP("EncryptionManagerPrivate", "can't decrypt text: " "invalid checksum")); - QNWARNING(errorDescription << QStringLiteral(", parsed hmac: ") + QNWARNING(errorDescription << ", parsed hmac: " << QByteArray(reinterpret_cast<const char*>(parsedHmac), EN_AES_HMACSIZE).toHex() - << QStringLiteral(", expected hmac: ") + << ", expected hmac: " << QByteArray(reinterpret_cast<const char*>(m_hmac), EN_AES_HMACSIZE).toHex()); return false; } } - QNTRACE(QStringLiteral("Successfully validated hmac")); + QNTRACE("Successfully validated hmac"); bres = generateKey(passphraseData, m_salt, EN_AES_KEYSIZE, errorDescription); if (!bres) { @@ -438,10 +437,10 @@ "can't decrypt the text")); GET_OPENSSL_ERROR; QNWARNING(errorDescription - << QStringLiteral(", openssl EVP_DecryptInit failed: ") - << QStringLiteral(": lib: ") << errorLib - << QStringLiteral("; func: ") << errorFunc - << QStringLiteral(", reason: ") << errorReason); + << ", openssl EVP_DecryptInit failed: " + << ": lib: " << errorLib + << "; func: " << errorFunc + << ", reason: " << errorReason); free(decipheredText); EVP_CIPHER_CTX_free(pContext); return false; @@ -455,10 +454,10 @@ "can't decrypt the text")); GET_OPENSSL_ERROR; QNWARNING(errorDescription - << QStringLiteral(", openssl EVP_DecryptUpdate failed: ") - << QStringLiteral(": lib: ") << errorLib - << QStringLiteral("; func: ") << errorFunc - << QStringLiteral(", reason: ") << errorReason); + << ", openssl EVP_DecryptUpdate failed: " + << ": lib: " << errorLib + << "; func: " << errorFunc + << ", reason: " << errorReason); free(decipheredText); EVP_CIPHER_CTX_free(pContext); return false; @@ -473,10 +472,10 @@ "can't decrypt the text")); GET_OPENSSL_ERROR; QNWARNING(errorDescription - << QStringLiteral(", openssl EVP_DecryptFinal failed: ") - << QStringLiteral(": lib: ") << errorLib - << QStringLiteral("; func: ") << errorFunc - << QStringLiteral(", reason: ") << errorReason); + << ", openssl EVP_DecryptFinal failed: " + << ": lib: " << errorLib + << "; func: " << errorFunc + << ", reason: " << errorReason); free(decipheredText); EVP_CIPHER_CTX_free(pContext); return false; @@ -507,9 +506,9 @@ errorDescription.setBase(QT_TRANSLATE_NOOP("EncryptionManagerPrivate", "encrypted data is too short " "for being valid")); - QNWARNING(errorDescription << QStringLiteral(": ") << encryptedDataSize - << QStringLiteral(" bytes while should be at least ") - << minLength << QStringLiteral(" bytes")); + QNWARNING(errorDescription << ": " << encryptedDataSize + << " bytes while should be at least " + << minLength << " bytes"); return false; } @@ -716,8 +715,9 @@ m_rc2_chunk_out.resize(8); -#define APPEND_UNICODE_CHAR(code, i) \ - m_rc2_chunk_out[i] = QChar(code) +#define APPEND_UNICODE_CHAR(code, i) \ + m_rc2_chunk_out[i] = QChar(code) \ +// APPEND_UNICODE_CHAR APPEND_UNICODE_CHAR(x10 & 255, 0); APPEND_UNICODE_CHAR((x10 >> 8) & 255, 1); @@ -821,9 +821,9 @@ bool conversionResult = false; x = static_cast<qint32>(x_str.toUInt(&conversionResult, 16)); if (Q_UNLIKELY(!conversionResult)) { - QNERROR(QStringLiteral("Can't convert string representation of hex ") - << QStringLiteral("number ") << x_str - << QStringLiteral(" to unsigned int!")); + QNERROR("Can't convert string representation of hex " + << "number " << x_str + << " to unsigned int!"); crc = 0; return crc; } diff -Nru libquentier-0.5.0/src/utility/FileCopier_p.cpp libquentier-0.5.0/src/utility/FileCopier_p.cpp --- libquentier-0.5.0/src/utility/FileCopier_p.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/utility/FileCopier_p.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -37,11 +37,11 @@ void FileCopierPrivate::copyFile(const QString & sourcePath, const QString & destPath) { - QNDEBUG(QStringLiteral("FileCopierPrivate::copyFile: source path = ") << sourcePath - << QStringLiteral(", dest path = ") << destPath); + QNDEBUG("FileCopierPrivate::copyFile: source path = " << sourcePath + << ", dest path = " << destPath); if ((m_sourcePath == sourcePath) && (m_destPath == destPath)) { - QNDEBUG(QStringLiteral("Paths haven't changed, nothing to do")); + QNDEBUG("Paths haven't changed, nothing to do"); return; } @@ -133,13 +133,13 @@ totalBytesWritten += bytesWritten; m_currentProgress = static_cast<double>(totalBytesWritten) / fromFileSize; - QNTRACE(QStringLiteral("File copying progress update: progress = ") + QNTRACE("File copying progress update: progress = " << m_currentProgress - << QStringLiteral(", total bytes written = ") + << ", total bytes written = " << totalBytesWritten - << QStringLiteral(", source file size = ") << fromFileSize - << QStringLiteral(", source path = ") << sourcePath - << QStringLiteral(", dest path = ") << destPath); + << ", source file size = " << fromFileSize + << ", source path = " << sourcePath + << ", dest path = " << destPath); Q_EMIT progressUpdate(m_currentProgress); @@ -148,8 +148,8 @@ } } - QNDEBUG(QStringLiteral("File copying is complete: source path = ") - << sourcePath << QStringLiteral(", dest path = ") << destPath); + QNDEBUG("File copying is complete: source path = " + << sourcePath << ", dest path = " << destPath); clear(); Q_EMIT finished(sourcePath, destPath); @@ -157,10 +157,10 @@ void FileCopierPrivate::cancel() { - QNDEBUG(QStringLiteral("FileCopierPrivate::cancel")); + QNDEBUG("FileCopierPrivate::cancel"); if (m_idle) { - QNDEBUG(QStringLiteral("Idle, nothing to cancel")); + QNDEBUG("Idle, nothing to cancel"); return; } @@ -169,7 +169,7 @@ void FileCopierPrivate::clear() { - QNDEBUG(QStringLiteral("FileCopierPrivate::clear")); + QNDEBUG("FileCopierPrivate::clear"); m_sourcePath.clear(); m_destPath.clear(); diff -Nru libquentier-0.5.0/src/utility/FileIOProcessorAsync_p.cpp libquentier-0.5.0/src/utility/FileIOProcessorAsync_p.cpp --- libquentier-0.5.0/src/utility/FileIOProcessorAsync_p.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/utility/FileIOProcessorAsync_p.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -34,28 +34,27 @@ void FileIOProcessorAsyncPrivate::setIdleTimePeriod(const qint32 seconds) { - QNDEBUG(QStringLiteral("FileIOProcessorAsyncPrivate::") - << QStringLiteral("setIdleTimePeriod: seconds = ") << seconds); + QNDEBUG("FileIOProcessorAsyncPrivate::setIdleTimePeriod: seconds = " << seconds); m_idleTimePeriodSeconds = seconds; } -#define RESTART_TIMER() \ - if (m_postOperationTimerId != 0) { \ - killTimer(m_postOperationTimerId); \ - } \ +#define RESTART_TIMER() \ + if (m_postOperationTimerId != 0) { \ + killTimer(m_postOperationTimerId); \ + } \ m_postOperationTimerId = startTimer(SEC_TO_MSEC(m_idleTimePeriodSeconds)); \ - QNTRACE(QStringLiteral("FileIOProcessorAsyncPrivate: started post operation ") \ - << QStringLiteral("timer with id ") << m_postOperationTimerId) + QNTRACE("FileIOProcessorAsyncPrivate: started post operation " \ + << "timer with id " << m_postOperationTimerId) \ +// RESTART_TIMER void FileIOProcessorAsyncPrivate::onWriteFileRequest(QString absoluteFilePath, QByteArray data, QUuid requestId, bool append) { - QNDEBUG(QStringLiteral("FileIOProcessorAsyncPrivate::onWriteFileRequest: ") - << QStringLiteral("file path = ") << absoluteFilePath - << QStringLiteral(", request id = ") << requestId - << QStringLiteral(", append = ") - << (append ? QStringLiteral("true") : QStringLiteral("false"))); + QNDEBUG("FileIOProcessorAsyncPrivate::onWriteFileRequest: " + << "file path = " << absoluteFilePath + << ", request id = " << requestId + << ", append = " << (append ? "true" : "false")); QFileInfo fileInfo(absoluteFilePath); QDir folder = fileInfo.absoluteDir(); @@ -103,7 +102,7 @@ } file.close(); - QNDEBUG(QStringLiteral("Successfully wrote file ") + absoluteFilePath); + QNDEBUG("Successfully wrote file " << absoluteFilePath); Q_EMIT writeFileRequestProcessed(true, ErrorString(), requestId); RESTART_TIMER(); } @@ -111,14 +110,14 @@ void FileIOProcessorAsyncPrivate::onReadFileRequest(QString absoluteFilePath, QUuid requestId) { - QNDEBUG(QStringLiteral("FileIOProcessorAsyncPrivate::onReadFileRequest: ") - << QStringLiteral("file path = ") << absoluteFilePath - << QStringLiteral(", request id = ") << requestId); + QNDEBUG("FileIOProcessorAsyncPrivate::onReadFileRequest: " + << "file path = " << absoluteFilePath + << ", request id = " << requestId); QFile file(absoluteFilePath); if (!file.exists()) { - QNTRACE(QStringLiteral("The file to read does not exist, sending empty " - "data in return")); + QNTRACE("The file to read does not exist, sending empty " + "data in return"); Q_EMIT readFileRequestProcessed(true, ErrorString(), QByteArray(), requestId); RESTART_TIMER(); @@ -143,16 +142,16 @@ void FileIOProcessorAsyncPrivate::timerEvent(QTimerEvent * pEvent) { if (!pEvent) { - QNWARNING(QStringLiteral("Detected null pointer to QTimerEvent in " - "FileIOProcessorAsyncPrivate")); + QNWARNING("Detected null pointer to QTimerEvent in " + "FileIOProcessorAsyncPrivate"); return; } qint32 timerId = pEvent->timerId(); if (timerId != m_postOperationTimerId) { - QNTRACE(QStringLiteral("Received unidentified timer event for " - "FileIOProcessorAsyncPrivate")); + QNTRACE("Received unidentified timer event for " + "FileIOProcessorAsyncPrivate"); return; } diff -Nru libquentier-0.5.0/src/utility/FileSystemWatcher_p.cpp libquentier-0.5.0/src/utility/FileSystemWatcher_p.cpp --- libquentier-0.5.0/src/utility/FileSystemWatcher_p.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/utility/FileSystemWatcher_p.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -228,9 +228,8 @@ QFileInfo info(filePath); if (!info.isFile()) { - QNTRACE(QStringLiteral("File ") << filePath - << QStringLiteral(" doesn't exist after some time since " - "its removal")); + QNTRACE("File " << filePath + << " doesn't exist after some time since its removal"); auto it = m_watchedFiles.find(filePath); if (it != m_watchedFiles.end()) { @@ -240,9 +239,8 @@ } else { - QNTRACE(QStringLiteral("File ") << filePath - << QStringLiteral(" exists again after some time since " - "its removal")); + QNTRACE("File " << filePath + << " exists again after some time since its removal"); auto it = m_watchedFiles.find(filePath); if (it != m_watchedFiles.end()) { m_watcher.addPath(filePath); @@ -261,9 +259,8 @@ QFileInfo info(directoryPath); if (!info.isDir()) { - QNTRACE(QStringLiteral("Directory ") << directoryPath - << QStringLiteral(" doesn't exist after some time since " - "its removal")); + QNTRACE("Directory " << directoryPath + << " doesn't exist after some time since its removal"); auto it = m_watchedDirectories.find(directoryPath); if (it != m_watchedDirectories.end()) { @@ -273,9 +270,8 @@ } else { - QNTRACE(QStringLiteral("Directory ") << directoryPath - << QStringLiteral(" exists again after some time since " - "its removal")); + QNTRACE("Directory " << directoryPath + << " exists again after some time since its removal"); auto it = m_watchedDirectories.find(directoryPath); if (it != m_watchedDirectories.end()) { m_watcher.addPath(directoryPath); diff -Nru libquentier-0.5.0/src/utility/Printable.cpp libquentier-0.5.0/src/utility/Printable.cpp --- libquentier-0.5.0/src/utility/Printable.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/utility/Printable.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -52,53 +52,63 @@ } // namespace quentier -#define PRINT_FIELD(obj, field, ...) \ - strm << indent << QStringLiteral( #field " = ") \ - << (obj.field.isSet() \ - ? __VA_ARGS__(obj.field.ref()) \ - : QStringLiteral("<empty>")) << QStringLiteral("; \n") - -#define PRINT_LIST_FIELD(obj, field, ...) \ - strm << indent << QStringLiteral( #field ); \ - if (obj.field.isSet()) \ - { \ - strm << QStringLiteral(": { \n"); \ - const auto & field##List = obj.field.ref(); \ - const int num##field = field##List.size(); \ - for(int i = 0; i < num##field; ++i) { \ - strm << indent << indent << QStringLiteral("[") << i \ - << QStringLiteral("]: ") \ - << __VA_ARGS__(field##List[i]) << QStringLiteral(";\n"); \ - } \ - strm << indent << QStringLiteral("};\n"); \ - } \ - else \ - { \ - strm << QStringLiteral("<empty>;\n"); \ - } - -#define PRINT_APPLICATION_DATA(obj) \ - if (obj.applicationData.isSet()) \ - { \ - const qevercloud::LazyMap & applicationData = obj.applicationData; \ - if (applicationData.keysOnly.isSet()) { \ - const QSet<QString> & keysOnly = applicationData.keysOnly; \ - strm << indent << QStringLiteral("applicationData: keys only: \n"); \ - for(auto it = keysOnly.begin(), end = keysOnly.end(); it != end; ++it) { \ - strm << *it << QStringLiteral("; "); \ - } \ - strm << QStringLiteral("\n"); \ - } \ - if (applicationData.fullMap.isSet()) { \ - const QMap<QString, QString> & fullMap = applicationData.fullMap; \ - strm << indent << QStringLiteral("applicationData: full map: \n"); \ - for(auto it = fullMap.begin(), end = fullMap.end(); it != end; ++it) { \ - strm << QStringLiteral("[") << it.key() << QStringLiteral("] = ") \ - << it.value() << QStringLiteral("; "); \ - } \ - strm << QStringLiteral("\n"); \ - } \ - } +#define PRINT_FIELD(obj, field, ...) \ + strm << indent << #field " = " \ + << (obj.field.isSet() \ + ? __VA_ARGS__(obj.field.ref()) \ + : QStringLiteral("<empty>")) << "; \n" \ +// PRINT_FIELD + +#define PRINT_LIST_FIELD(obj, field, ...) \ + strm << indent << #field; \ + if (obj.field.isSet()) \ + { \ + strm << ": { \n"; \ + const auto & field##List = obj.field.ref(); \ + const int num##field = field##List.size(); \ + for(int i = 0; i < num##field; ++i) { \ + strm << indent << indent << "[" << i \ + << "]: " \ + << __VA_ARGS__(field##List[i]) << ";\n"; \ + } \ + strm << indent << "};\n"; \ + } \ + else \ + { \ + strm << "<empty>;\n"; \ + } \ +// PRINT_LIST_FIELD + +#define PRINT_APPLICATION_DATA(obj) \ + if (obj.applicationData.isSet()) \ + { \ + const qevercloud::LazyMap & applicationData = obj.applicationData; \ + if (applicationData.keysOnly.isSet()) \ + { \ + const QSet<QString> & keysOnly = applicationData.keysOnly; \ + strm << indent << "applicationData: keys only: \n"; \ + for(auto it = keysOnly.begin(), \ + end = keysOnly.end(); it != end; ++it) \ + { \ + strm << *it << "; "; \ + } \ + strm << "\n"; \ + } \ + \ + if (applicationData.fullMap.isSet()) \ + { \ + const QMap<QString, QString> & fullMap = applicationData.fullMap; \ + strm << indent << "applicationData: full map: \n"; \ + for(auto it = fullMap.begin(), \ + end = fullMap.end(); it != end; ++it) \ + { \ + strm << "[" << it.key() << "] = " \ + << it.value() << "; "; \ + } \ + strm << "\n"; \ + } \ + } \ +// PRINT_APPLICATION_DATA QString byteArrayToHex(const QByteArray & bytes) { @@ -128,7 +138,7 @@ QTextStream & operator <<(QTextStream & strm, const qevercloud::Contact & contact) { - strm << QStringLiteral("qevercloud::Contact: {\n"); + strm << "qevercloud::Contact: {\n"; const char * indent = " "; PRINT_FIELD(contact, name); @@ -141,20 +151,21 @@ PRINT_FIELD(contact, messagingPermitExpires, quentier::printableDateTimeFromTimestamp); - strm << QStringLiteral("}; \n"); + strm << "}; \n"; return strm; } QString boolToString(const bool value) -{ return (value ? QStringLiteral("true") : QStringLiteral("false")); } +{ + return (value ? QStringLiteral("true") : QStringLiteral("false")); +} QTextStream & operator <<(QTextStream & strm, const qevercloud::Identity & identity) { - strm << QStringLiteral("qevercloud::Identity: {\n"); + strm << "qevercloud::Identity: {\n"; const char * indent = " "; - strm << indent << QStringLiteral("id = ") << QString::number(identity.id) - << QStringLiteral(";\n"); + strm << indent << "id = " << QString::number(identity.id) << ";\n"; PRINT_FIELD(identity, contact, ToString); PRINT_FIELD(identity, userId, QString::number); @@ -164,13 +175,13 @@ PRINT_FIELD(identity, userConnected, boolToString); PRINT_FIELD(identity, eventId, QString::number); - strm << QStringLiteral("}; \n"); + strm << "}; \n"; return strm; } QTextStream & operator <<(QTextStream & strm, const qevercloud::BusinessUserInfo & info) { - strm << QStringLiteral("qevercloud::BusinessUserInfo: {\n"); + strm << "qevercloud::BusinessUserInfo: {\n"; const char * indent = " "; PRINT_FIELD(info, businessId, QString::number); @@ -179,7 +190,7 @@ PRINT_FIELD(info, email); PRINT_FIELD(info, updated, quentier::printableDateTimeFromTimestamp); - strm << QStringLiteral("}; \n"); + strm << "}; \n"; return strm; } @@ -219,7 +230,7 @@ QTextStream & operator <<(QTextStream & strm, const qevercloud::Accounting & accounting) { - strm << QStringLiteral("qevercloud::Accounting: { \n"); + strm << "qevercloud::Accounting: { \n"; const char * indent = " "; PRINT_FIELD(accounting, uploadLimitEnd, @@ -258,14 +269,14 @@ PRINT_FIELD(accounting, availablePoints, QString::number); - strm << QStringLiteral("}; \n"); + strm << "}; \n"; return strm; } QTextStream & operator <<(QTextStream & strm, const qevercloud::AccountLimits & limits) { - strm << QStringLiteral("qevercloud::AccountLimits: {\n"); + strm << "qevercloud::AccountLimits: {\n"; const char * indent = " "; PRINT_FIELD(limits, userMailLimitDaily, QString::number); @@ -300,7 +311,7 @@ QTextStream & operator <<(QTextStream & strm, const qevercloud::UserAttributes & attributes) { - strm << QStringLiteral("qevercloud::UserAttributes: {\n"); + strm << "qevercloud::UserAttributes: {\n"; const char * indent = " "; PRINT_FIELD(attributes, defaultLocationName); @@ -340,14 +351,14 @@ quentier::printableDateTimeFromTimestamp); PRINT_FIELD(attributes, salesforcePushEnabled, boolToString); - strm << QStringLiteral("};\n"); + strm << "};\n"; return strm; } QTextStream & operator <<(QTextStream & strm, const qevercloud::NoteAttributes & attributes) { - strm << QStringLiteral("qevercloud::NoteAttributes: {\n"); + strm << "qevercloud::NoteAttributes: {\n"; const char * indent = " "; PRINT_FIELD(attributes, subjectDate, @@ -379,18 +390,18 @@ if (attributes.classifications.isSet()) { - strm << indent << QStringLiteral("classifications: "); + strm << indent << "classifications: "; const QMap<QString, QString> & classifications = attributes.classifications; for(auto it = classifications.begin(), end = classifications.end(); it != end; ++it) { - strm << QStringLiteral("[") << it.key() << QStringLiteral("] = ") - << it.value() << QStringLiteral("; "); + strm << "[" << it.key() << "] = " + << it.value() << "; "; } - strm << QStringLiteral("\n"); + strm << "\n"; } - strm << QStringLiteral("};\n"); + strm << "};\n"; return strm; } @@ -538,7 +549,7 @@ QTextStream & operator <<(QTextStream & strm, const qevercloud::NotebookRestrictions & restrictions) { - strm << QStringLiteral("NotebookRestrictions: {\n"); + strm << "NotebookRestrictions: {\n"; const char * indent = " "; PRINT_FIELD(restrictions, noReadNotes, boolToString); @@ -566,7 +577,7 @@ PRINT_FIELD(restrictions, expungeWhichSharedNotebookRestrictions, sharedNotebookInstanceRestrictionsToString); - strm << QStringLiteral("};\n"); + strm << "};\n"; return strm; } @@ -582,7 +593,7 @@ QTextStream & operator <<(QTextStream & strm, const qevercloud::ResourceAttributes & attributes) { - strm << QStringLiteral("ResourceAttributes: {\n"); + strm << "ResourceAttributes: {\n"; const char * indent = " "; PRINT_FIELD(attributes, sourceURL); @@ -597,13 +608,13 @@ PRINT_FIELD(attributes, attachment, boolToString); PRINT_APPLICATION_DATA(attributes) - strm << QStringLiteral("};\n"); + strm << "};\n"; return strm; } QTextStream & operator <<(QTextStream & strm, const qevercloud::Resource & resource) { - strm << QStringLiteral("qevercloud::Resource {\n"); + strm << "qevercloud::Resource {\n"; const char * indent = " "; PRINT_FIELD(resource, guid); @@ -612,23 +623,23 @@ if (resource.data.isSet()) { - strm << indent << QStringLiteral("Data: {\n"); + strm << indent << "Data: {\n"; PRINT_FIELD(resource.data.ref(), size, QString::number); PRINT_FIELD(resource.data.ref(), bodyHash, byteArrayToHex); - strm << indent << QStringLiteral("body: ") + strm << indent << "body: " << (resource.data->body.isSet() - ? QStringLiteral("is set") - : QStringLiteral("is not set")) - << QStringLiteral(";\n"); + ? "is set" + : "is not set") + << ";\n"; if (resource.data->body.isSet() && (resource.data->body->size() < 4096)) { - strm << indent << QStringLiteral("raw data body content: ") - << resource.data->body.ref() << QStringLiteral(";\n"); + strm << indent << "raw data body content: " + << resource.data->body.ref() << ";\n"; } - strm << indent << QStringLiteral("};\n"); + strm << indent << "};\n"; } PRINT_FIELD(resource, mime); @@ -637,7 +648,7 @@ if (resource.recognition.isSet()) { - strm << indent << QStringLiteral("Recognition data: {\n"); + strm << indent << "Recognition data: {\n"; PRINT_FIELD(resource.recognition.ref(), size, QString::number); PRINT_FIELD(resource.recognition.ref(), bodyHash, byteArrayToHex); @@ -646,68 +657,67 @@ if (resource.recognition->body.isSet() && (resource.recognition->body->size() < 4096)) { - strm << indent << QStringLiteral("raw recognition body content: ") - << resource.recognition->body.ref() << QStringLiteral(";\n"); + strm << indent << "raw recognition body content: " + << resource.recognition->body.ref() << ";\n"; } - strm << indent << QStringLiteral("};\n"); + strm << indent << "};\n"; } if (resource.alternateData.isSet()) { - strm << indent << QStringLiteral("Alternate data: {\n"); + strm << indent << "Alternate data: {\n"; PRINT_FIELD(resource.alternateData.ref(), size, QString::number); PRINT_FIELD(resource.alternateData.ref(), bodyHash, byteArrayToHex); - strm << indent << QStringLiteral("body: ") + strm << indent << "body: " << (resource.alternateData->body.isSet() - ? QStringLiteral("is set") - : QStringLiteral("is not set")) - << QStringLiteral(";\n"); + ? "is set" + : "is not set") + << ";\n"; if (resource.alternateData->body.isSet() && (resource.alternateData->body->size() < 4096)) { - strm << indent << QStringLiteral("raw alternate data body content: ") - << resource.alternateData->body.ref() << QStringLiteral(";\n"); + strm << indent << "raw alternate data body content: " + << resource.alternateData->body.ref() << ";\n"; } - strm << indent << QStringLiteral("};\n"); + strm << indent << "};\n"; } if (resource.attributes.isSet()) { strm << indent << resource.attributes.ref(); } - strm << QStringLiteral("};\n"); + strm << "};\n"; return strm; } QTextStream & operator<<(QTextStream & strm, const qevercloud::SyncChunk & syncChunk) { - strm << QStringLiteral("qevercloud::SyncChunk: {\n"); + strm << "qevercloud::SyncChunk: {\n"; const char * indent = " "; PRINT_FIELD(syncChunk, chunkHighUSN, QString::number); - strm << indent << QStringLiteral("currentTime = ") + strm << indent << "currentTime = " << quentier::printableDateTimeFromTimestamp(syncChunk.currentTime) - << QStringLiteral(";\n"); - strm << indent << QStringLiteral("updateCount = ") << syncChunk.updateCount - << QStringLiteral(";\n"); + << ";\n"; + strm << indent << "updateCount = " << syncChunk.updateCount << ";\n"; if (syncChunk.notes.isSet()) { for(auto it = syncChunk.notes->constBegin(), end = syncChunk.notes->constEnd(); it != end; ++it) { - strm << indent << QStringLiteral("note: guid = ") + strm << indent << "note: guid = " << (it->guid.isSet() ? it->guid.ref() : QStringLiteral("<empty>")) - << QStringLiteral(", update sequence number = ") + << ", update sequence number = " << (it->updateSequenceNum.isSet() ? QString::number(it->updateSequenceNum.ref()) : QStringLiteral("<empty>")) - << QStringLiteral(";\n"); + << ";\n"; } } @@ -716,13 +726,13 @@ for(auto it = syncChunk.notebooks->constBegin(), end = syncChunk.notebooks->constEnd(); it != end; ++it) { - strm << indent << QStringLiteral("notebook: guid = ") + strm << indent << "notebook: guid = " << (it->guid.isSet() ? it->guid.ref() : QStringLiteral("<empty>")) - << QStringLiteral(", update sequence number = ") + << ", update sequence number = " << (it->updateSequenceNum.isSet() ? QString::number(it->updateSequenceNum.ref()) : QStringLiteral("<empty>")) - << QStringLiteral(";\n"); + << ";\n"; } } @@ -731,13 +741,13 @@ for(auto it = syncChunk.tags->constBegin(), end = syncChunk.tags->constEnd(); it != end; ++it) { - strm << indent << QStringLiteral("tag: guid = ") + strm << indent << "tag: guid = " << (it->guid.isSet() ? it->guid.ref() : QStringLiteral("<empty>")) - << QStringLiteral(", update sequence number = ") + << ", update sequence number = " << (it->updateSequenceNum.isSet() ? QString::number(it->updateSequenceNum.ref()) : QStringLiteral("<empty>")) - << QStringLiteral(";\n"); + << ";\n"; } } @@ -746,13 +756,13 @@ for(auto it = syncChunk.searches->constBegin(), end = syncChunk.searches->constEnd(); it != end; ++it) { - strm << indent << QStringLiteral("saved search: guid = ") + strm << indent << "saved search: guid = " << (it->guid.isSet() ? it->guid.ref() : QStringLiteral("<empty>")) - << QStringLiteral(", update sequence number = ") + << ", update sequence number = " << (it->updateSequenceNum.isSet() ? QString::number(it->updateSequenceNum.ref()) : QStringLiteral("<empty>")) - << QStringLiteral(";\n"); + << ";\n"; } } @@ -761,17 +771,17 @@ for(auto it = syncChunk.resources->constBegin(), end = syncChunk.resources->constEnd(); it != end; ++it) { - strm << indent << QStringLiteral("resource: guid = ") + strm << indent << "resource: guid = " << (it->guid.isSet() ? it->guid.ref() : QStringLiteral("<empty>")) - << QStringLiteral(", update sequence number = ") + << ", update sequence number = " << (it->updateSequenceNum.isSet() ? QString::number(it->updateSequenceNum.ref()) : QStringLiteral("<empty>")) - << QStringLiteral(", note guid = ") + << ", note guid = " << (it->noteGuid.isSet() ? it->noteGuid.ref() : QStringLiteral("<empty>")) - << QStringLiteral(";\n"); + << ";\n"; } } @@ -780,13 +790,13 @@ for(auto it = syncChunk.linkedNotebooks->constBegin(), end = syncChunk.linkedNotebooks->constEnd(); it != end; ++it) { - strm << indent << QStringLiteral("linked notebook: guid = ") + strm << indent << "linked notebook: guid = " << (it->guid.isSet() ? it->guid.ref() : QStringLiteral("<empty>")) - << QStringLiteral(", update sequence number = ") + << ", update sequence number = " << (it->updateSequenceNum.isSet() ? QString::number(it->updateSequenceNum.ref()) : QStringLiteral("<empty>")) - << QStringLiteral(";\n"); + << ";\n"; } } @@ -795,8 +805,7 @@ for(auto it = syncChunk.expungedLinkedNotebooks->constBegin(), end = syncChunk.expungedLinkedNotebooks->constEnd(); it != end; ++it) { - strm << indent << QStringLiteral("expunged linked notebook guid = ") - << *it << QStringLiteral(";\n"); + strm << indent << "expunged linked notebook guid = " << *it << ";\n"; } } @@ -805,8 +814,7 @@ for(auto it = syncChunk.expungedNotebooks->constBegin(), end = syncChunk.expungedNotebooks->constEnd(); it != end; ++it) { - strm << indent << QStringLiteral("expunged notebook guid = ") - << *it << QStringLiteral(";\n"); + strm << indent << "expunged notebook guid = " << *it << ";\n"; } } @@ -815,8 +823,7 @@ for(auto it = syncChunk.expungedNotes->constBegin(), end = syncChunk.expungedNotes->constEnd(); it != end; ++it) { - strm << indent << QStringLiteral("expunged note guid = ") - << *it << QStringLiteral(";\n"); + strm << indent << "expunged note guid = " << *it << ";\n"; } } @@ -825,8 +832,7 @@ for(auto it = syncChunk.expungedSearches->constBegin(), end = syncChunk.expungedSearches->constEnd(); it != end; ++it) { - strm << indent << QStringLiteral("expunged search guid = ") - << *it << QStringLiteral(";\n"); + strm << indent << "expunged search guid = " << *it << ";\n"; } } @@ -835,8 +841,7 @@ for(auto it = syncChunk.expungedTags->constBegin(), end = syncChunk.expungedTags->constEnd(); it != end; ++it) { - strm << indent << QStringLiteral("expunged tag guid = ") << *it - << QStringLiteral(";\n"); + strm << indent << "expunged tag guid = " << *it << ";\n"; } } @@ -845,7 +850,7 @@ QTextStream & operator<<(QTextStream & strm, const qevercloud::Tag & tag) { - strm << QStringLiteral("qevercloud::Tag: {\n"); + strm << "qevercloud::Tag: {\n"; const char * indent = " "; PRINT_FIELD(tag, guid); @@ -853,14 +858,14 @@ PRINT_FIELD(tag, parentGuid); PRINT_FIELD(tag, updateSequenceNum, QString::number); - strm << QStringLiteral("};\n"); + strm << "};\n"; return strm; } QTextStream & operator<<(QTextStream & strm, const qevercloud::SavedSearch & savedSearch) { - strm << QStringLiteral("qevercloud::SavedSearch: {\n"); + strm << "qevercloud::SavedSearch: {\n"; const char * indent = " "; PRINT_FIELD(savedSearch, guid); @@ -869,45 +874,45 @@ PRINT_FIELD(savedSearch, format, queryFormatToString); PRINT_FIELD(savedSearch, updateSequenceNum, QString::number); - strm << indent << QStringLiteral("SavedSearchScope = "); + strm << indent << "SavedSearchScope = "; if (savedSearch.scope.isSet()) { - strm << QStringLiteral("{\n"); - strm << indent << indent << QStringLiteral("includeAccount = ") + strm << "{\n"; + strm << indent << indent << "includeAccount = " << (savedSearch.scope->includeAccount.isSet() ? (savedSearch.scope->includeAccount.ref() - ? QStringLiteral("true") - : QStringLiteral("false")) - : QStringLiteral("<empty>")) << QStringLiteral(";\n"); + ? "true" + : "false") + : "<empty>") << ";\n"; strm << indent << indent - << QStringLiteral("includePersonalLinkedNotebooks = ") + << "includePersonalLinkedNotebooks = " << (savedSearch.scope->includePersonalLinkedNotebooks.isSet() ? (savedSearch.scope->includePersonalLinkedNotebooks.ref() - ? QStringLiteral("true") - : QStringLiteral("false")) - : QStringLiteral("<empty>")) << QStringLiteral(";\n"); + ? "true" + : "false") + : "<empty>") << ";\n"; strm << indent << indent - << QStringLiteral("includeBusinessLinkedNotebooks = ") + << "includeBusinessLinkedNotebooks = " << (savedSearch.scope->includeBusinessLinkedNotebooks.isSet() ? (savedSearch.scope->includeBusinessLinkedNotebooks.ref() - ? QStringLiteral("true") - : QStringLiteral("false")) - : QStringLiteral("<empty>")) << QStringLiteral(";\n"); - strm << indent << QStringLiteral("};\n"); + ? "true" + : "false") + : "<empty>") << ";\n"; + strm << indent << "};\n"; } else { - strm << QStringLiteral("<empty>;\n"); + strm << "<empty>;\n"; } - strm << QStringLiteral("};\n"); + strm << "};\n"; return strm; } QTextStream & operator<<(QTextStream & strm, const qevercloud::LinkedNotebook & linkedNotebook) { - strm << QStringLiteral("qevercloud::LinkedNotebook: {\n"); + strm << "qevercloud::LinkedNotebook: {\n"; const char * indent = " "; PRINT_FIELD(linkedNotebook, shareName); @@ -922,13 +927,13 @@ PRINT_FIELD(linkedNotebook, stack); PRINT_FIELD(linkedNotebook, businessId, QString::number); - strm << QStringLiteral("};\n"); + strm << "};\n"; return strm; } QTextStream & operator<<(QTextStream & strm, const qevercloud::Notebook & notebook) { - strm << QStringLiteral("qevercloud::Notebook: {\n"); + strm << "qevercloud::Notebook: {\n"; const char * indent = " "; PRINT_FIELD(notebook, guid); @@ -943,7 +948,7 @@ if (notebook.sharedNotebooks.isSet()) { - strm << indent << QStringLiteral("sharedNotebooks: {\n"); + strm << indent << "sharedNotebooks: {\n"; for(auto it = notebook.sharedNotebooks->begin(), end = notebook.sharedNotebooks->end(); it != end; ++it) @@ -951,21 +956,21 @@ strm << indent << indent << *it; } - strm << indent << QStringLiteral("};\n"); + strm << indent << "};\n"; } PRINT_FIELD(notebook, businessNotebook, ToString); PRINT_FIELD(notebook, contact, ToString); PRINT_FIELD(notebook, restrictions, ToString); - strm << QStringLiteral("};\n"); + strm << "};\n"; return strm; } QTextStream & operator<<(QTextStream & strm, const qevercloud::Publishing & publishing) { - strm << QStringLiteral("qevercloud::Publishing: {\n"); + strm << "qevercloud::Publishing: {\n"; const char * indent = " "; PRINT_FIELD(publishing, uri); @@ -973,14 +978,14 @@ PRINT_FIELD(publishing, ascending, boolToString); PRINT_FIELD(publishing, publicDescription); - strm << QStringLiteral("};\n"); + strm << "};\n"; return strm; } QTextStream & operator<<(QTextStream & strm, const qevercloud::SharedNotebook & sharedNotebook) { - strm << QStringLiteral("qevercloud::SharedNotebook: {\n"); + strm << "qevercloud::SharedNotebook: {\n"; const char * indent = " "; PRINT_FIELD(sharedNotebook, id, QString::number); @@ -1001,27 +1006,27 @@ PRINT_FIELD(sharedNotebook, serviceAssigned, quentier::printableDateTimeFromTimestamp); - strm << QStringLiteral("};\n"); + strm << "};\n"; return strm; } QTextStream & operator<<(QTextStream & strm, const qevercloud::BusinessNotebook & businessNotebook) { - strm << QStringLiteral("qevercloud::BusinessNotebook: {\n"); + strm << "qevercloud::BusinessNotebook: {\n"; const char * indent = " "; PRINT_FIELD(businessNotebook, notebookDescription); PRINT_FIELD(businessNotebook, privilege, sharedNotebookPrivilegeLevelToString); PRINT_FIELD(businessNotebook, recommended, boolToString); - strm << QStringLiteral("};\n"); + strm << "};\n"; return strm; } QTextStream & operator<<(QTextStream & strm, const qevercloud::User & user) { - strm << QStringLiteral("qevercloud::User: {\n"); + strm << "qevercloud::User: {\n"; const char * indent = " "; PRINT_FIELD(user, id, QString::number); @@ -1038,20 +1043,20 @@ PRINT_FIELD(user, accounting, ToString); PRINT_FIELD(user, businessUserInfo, ToString); - strm << QStringLiteral("};\n"); + strm << "};\n"; return strm; } QTextStream & operator<<(QTextStream & strm, const qevercloud::SharedNotebookRecipientSettings & settings) { - strm << QStringLiteral("qevercloud::SharedNotebookRecipientSettings: {\n"); + strm << "qevercloud::SharedNotebookRecipientSettings: {\n"; const char * indent = " "; PRINT_FIELD(settings, reminderNotifyEmail, boolToString); PRINT_FIELD(settings, reminderNotifyInApp, boolToString); - strm << QStringLiteral("};\n"); + strm << "};\n"; return strm; } @@ -1079,21 +1084,21 @@ QTextStream & operator<<(QTextStream & strm, const qevercloud::SponsoredGroupRole::type & role) { - strm << QStringLiteral("qevercloud::SponsoredGroupRole: "); + strm << "qevercloud::SponsoredGroupRole: "; switch (role) { case qevercloud::SponsoredGroupRole::GROUP_MEMBER: - strm << QStringLiteral("GROUP_MEMBER"); + strm << "GROUP_MEMBER"; break; case qevercloud::SponsoredGroupRole::GROUP_ADMIN: - strm << QStringLiteral("GROUP_ADMIN"); + strm << "GROUP_ADMIN"; break; case qevercloud::SponsoredGroupRole::GROUP_OWNER: - strm << QStringLiteral("GROUP_OWNER"); + strm << "GROUP_OWNER"; break; default: - strm << QStringLiteral("Unknown"); + strm << "Unknown"; break; } @@ -1103,7 +1108,7 @@ QTextStream & operator<<(QTextStream & strm, const qevercloud::NoteRestrictions & restrictions) { - strm << QStringLiteral("qevercloud::NoteRestrictions {\n"); + strm << "qevercloud::NoteRestrictions {\n"; const char * indent = " "; PRINT_FIELD(restrictions, noUpdateTitle, boolToString); @@ -1112,14 +1117,14 @@ PRINT_FIELD(restrictions, noShare, boolToString); PRINT_FIELD(restrictions, noSharePublicly, boolToString); - strm << QStringLiteral("};\n"); + strm << "};\n"; return strm; } QTextStream & operator<<(QTextStream & strm, const qevercloud::NoteLimits & limits) { - strm << QStringLiteral("qevercloud::NoteLimits {\n"); + strm << "qevercloud::NoteLimits {\n"; const char * indent = " "; PRINT_FIELD(limits, noteResourceCountMax, QString::number); @@ -1128,13 +1133,13 @@ PRINT_FIELD(limits, noteSizeMax, QString::number); PRINT_FIELD(limits, uploaded, QString::number); - strm << QStringLiteral("};\n"); + strm << "};\n"; return strm; } QTextStream & operator<<(QTextStream & strm, const qevercloud::Note & note) { - strm << QStringLiteral("qevercloud::Note {\n"); + strm << "qevercloud::Note {\n"; const char * indent = " "; PRINT_FIELD(note, guid); @@ -1155,7 +1160,7 @@ PRINT_FIELD(note, restrictions, ToString); PRINT_FIELD(note, limits, ToString); - strm << QStringLiteral("};\n"); + strm << "};\n"; return strm; } @@ -1178,7 +1183,7 @@ QTextStream & operator<<(QTextStream & strm, const qevercloud::SharedNote & sharedNote) { - strm << QStringLiteral("qevercloud::SharedNote: {\n"); + strm << "qevercloud::SharedNote: {\n"; const char * indent = " "; PRINT_FIELD(sharedNote, sharerUserID, QString::number); @@ -1191,76 +1196,76 @@ PRINT_FIELD(sharedNote, serviceAssigned, quentier::printableDateTimeFromTimestamp); - strm << QStringLiteral("};\n"); + strm << "};\n"; return strm; } QTextStream & operator<<(QTextStream & strm, const qevercloud::EDAMErrorCode::type & obj) { - strm << QStringLiteral("qevercloud::EDAMErrorCode: "); + strm << "qevercloud::EDAMErrorCode: "; switch(obj) { case qevercloud::EDAMErrorCode::UNKNOWN: - strm << QStringLiteral("UNKNOWN"); + strm << "UNKNOWN"; break; case qevercloud::EDAMErrorCode::BAD_DATA_FORMAT: - strm << QStringLiteral("BAD_DATA_FORMAT"); + strm << "BAD_DATA_FORMAT"; break; case qevercloud::EDAMErrorCode::PERMISSION_DENIED: - strm << QStringLiteral("PERMISSION_DENIED"); + strm << "PERMISSION_DENIED"; break; case qevercloud::EDAMErrorCode::INTERNAL_ERROR: - strm << QStringLiteral("INTERNAL_ERROR"); + strm << "INTERNAL_ERROR"; break; case qevercloud::EDAMErrorCode::DATA_REQUIRED: - strm << QStringLiteral("DATA_REQUIRED"); + strm << "DATA_REQUIRED"; break; case qevercloud::EDAMErrorCode::LIMIT_REACHED: - strm << QStringLiteral("LIMIT_REACHED"); + strm << "LIMIT_REACHED"; break; case qevercloud::EDAMErrorCode::QUOTA_REACHED: - strm << QStringLiteral("QUOTA_REACHED"); + strm << "QUOTA_REACHED"; break; case qevercloud::EDAMErrorCode::INVALID_AUTH: - strm << QStringLiteral("INVALID_AUTH"); + strm << "INVALID_AUTH"; break; case qevercloud::EDAMErrorCode::AUTH_EXPIRED: - strm << QStringLiteral("AUTH_EXPIRED"); + strm << "AUTH_EXPIRED"; break; case qevercloud::EDAMErrorCode::DATA_CONFLICT: - strm << QStringLiteral("DATA_CONFLICT"); + strm << "DATA_CONFLICT"; break; case qevercloud::EDAMErrorCode::ENML_VALIDATION: - strm << QStringLiteral("ENML_VALIDATION"); + strm << "ENML_VALIDATION"; break; case qevercloud::EDAMErrorCode::SHARD_UNAVAILABLE: - strm << QStringLiteral("SHARD_UNAVAILABLE"); + strm << "SHARD_UNAVAILABLE"; break; case qevercloud::EDAMErrorCode::LEN_TOO_SHORT: - strm << QStringLiteral("LEN_TOO_SHORT"); + strm << "LEN_TOO_SHORT"; break; case qevercloud::EDAMErrorCode::LEN_TOO_LONG: - strm << QStringLiteral("LEN_TOO_LONG"); + strm << "LEN_TOO_LONG"; break; case qevercloud::EDAMErrorCode::TOO_FEW: - strm << QStringLiteral("TOO_FEW"); + strm << "TOO_FEW"; break; case qevercloud::EDAMErrorCode::TOO_MANY: - strm << QStringLiteral("TOO_MANY"); + strm << "TOO_MANY"; break; case qevercloud::EDAMErrorCode::UNSUPPORTED_OPERATION: - strm << QStringLiteral("UNSUPPORTED_OPERATION"); + strm << "UNSUPPORTED_OPERATION"; break; case qevercloud::EDAMErrorCode::TAKEN_DOWN: - strm << QStringLiteral("TAKEN_DOWN"); + strm << "TAKEN_DOWN"; break; case qevercloud::EDAMErrorCode::RATE_LIMIT_REACHED: - strm << QStringLiteral("RATE_LIMIT_REACHED"); + strm << "RATE_LIMIT_REACHED"; break; default: - strm << QStringLiteral("<unknown>"); + strm << "<unknown>"; break; } @@ -1270,26 +1275,26 @@ QTextStream & operator<<(QTextStream & strm, const qevercloud::SyncState & syncState) { - strm << QStringLiteral("qevercloud::SyncState {\n") - << QStringLiteral(" current time = ") + strm << "qevercloud::SyncState {\n" + << " current time = " << quentier::printableDateTimeFromTimestamp(syncState.currentTime) - << QStringLiteral(";\n") - << QStringLiteral(" full sync before = ") + << ";\n" + << " full sync before = " << quentier::printableDateTimeFromTimestamp(syncState.fullSyncBefore) - << QStringLiteral(";\n") - << QStringLiteral(" update count = ") - << QString::number(syncState.updateCount) << QStringLiteral(";\n") - << QStringLiteral(" uploaded = ") + << ";\n" + << " update count = " + << QString::number(syncState.updateCount) << ";\n" + << " uploaded = " << (syncState.uploaded.isSet() ? QString::number(syncState.uploaded.ref()) : QStringLiteral("<not set>")) - << QStringLiteral(";\n") - << QStringLiteral(" user last updated = ") + << ";\n" + << " user last updated = " << (syncState.userLastUpdated.isSet() ? quentier::printableDateTimeFromTimestamp(syncState.userLastUpdated) : QStringLiteral("<not set>")) - << QStringLiteral(";\n") - << QStringLiteral("};\n"); + << ";\n" + << "};\n"; return strm; } @@ -1297,117 +1302,117 @@ QTextStream & operator<<(QTextStream & strm, const qevercloud::SyncChunkFilter & filter) { - strm << QStringLiteral("qevercloud::SyncChunkFilter {\n") - << QStringLiteral(" include notes = ") + strm << "qevercloud::SyncChunkFilter {\n" + << " include notes = " << (filter.includeNotes.isSet() ? (filter.includeNotes.ref() - ? QStringLiteral("true") - : QStringLiteral("false")) - : QStringLiteral("<not set>")) - << QStringLiteral(";\n") - << QStringLiteral(" include note resources = ") + ? "true" + : "false") + : "<not set>") + << ";\n" + << " include note resources = " << (filter.includeNoteResources.isSet() ? (filter.includeNoteResources.ref() - ? QStringLiteral("true") - : QStringLiteral("false")) - : QStringLiteral("<not set>")) - << QStringLiteral(";\n") - << QStringLiteral(" include note attributes = ") + ? "true" + : "false") + : "<not set>") + << ";\n" + << " include note attributes = " << (filter.includeNoteAttributes.isSet() ? (filter.includeNoteAttributes.ref() - ? QStringLiteral("true") - : QStringLiteral("false")) - : QStringLiteral("<not set>")) - << QStringLiteral(";\n") - << QStringLiteral(" include notebooks = ") + ? "true" + : "false") + : "<not set>") + << ";\n" + << " include notebooks = " << (filter.includeNotebooks.isSet() ? (filter.includeNotebooks.ref() - ? QStringLiteral("true") - : QStringLiteral("false")) - : QStringLiteral("<not set>")) - << QStringLiteral(";\n") - << QStringLiteral(" include tags = ") + ? "true" + : "false") + : "<not set>") + << ";\n" + << " include tags = " << (filter.includeTags.isSet() ? (filter.includeTags.ref() - ? QStringLiteral("true") - : QStringLiteral("false")) - : QStringLiteral("<not set>")) - << QStringLiteral(";\n") - << QStringLiteral(" include saved searches = ") + ? "true" + : "false") + : "<not set>") + << ";\n" + << " include saved searches = " << (filter.includeSearches.isSet() ? (filter.includeSearches.ref() - ? QStringLiteral("true") - : QStringLiteral("false")) - : QStringLiteral("<not set>")) - << QStringLiteral(";\n") - << QStringLiteral(" include resources = ") + ? "true" + : "false") + : "<not set>") + << ";\n" + << " include resources = " << (filter.includeResources.isSet() ? (filter.includeResources.ref() - ? QStringLiteral("true") - : QStringLiteral("false")) - : QStringLiteral("<not set>")) - << QStringLiteral(";\n") - << QStringLiteral(" include linked notebooks = ") + ? "true" + : "false") + : "<not set>") + << ";\n" + << " include linked notebooks = " << (filter.includeLinkedNotebooks.isSet() ? (filter.includeLinkedNotebooks.ref() - ? QStringLiteral("true") - : QStringLiteral("false")) - : QStringLiteral("<not set>")) - << QStringLiteral(";\n") - << QStringLiteral(" include expunged = ") + ? "true" + : "false") + : "<not set>") + << ";\n" + << " include expunged = " << (filter.includeExpunged.isSet() ? (filter.includeExpunged.ref() - ? QStringLiteral("true") - : QStringLiteral("false")) - : QStringLiteral("<not set>")) - << QStringLiteral(";\n") - << QStringLiteral(" include note application data full map = ") + ? "true" + : "false") + : "<not set>") + << ";\n" + << " include note application data full map = " << (filter.includeNoteApplicationDataFullMap.isSet() ? (filter.includeNoteApplicationDataFullMap.ref() - ? QStringLiteral("true") - : QStringLiteral("false")) - : QStringLiteral("<not set>")) - << QStringLiteral(";\n") - << QStringLiteral(" include resource application data full map = ") + ? "true" + : "false") + : "<not set>") + << ";\n" + << " include resource application data full map = " << (filter.includeResourceApplicationDataFullMap.isSet() ? (filter.includeResourceApplicationDataFullMap.ref() - ? QStringLiteral("true") - : QStringLiteral("false")) - : QStringLiteral("<not set>")) - << QStringLiteral(";\n") - << QStringLiteral(" include shared notes = ") + ? "true" + : "false") + : "<not set>") + << ";\n" + << " include shared notes = " << (filter.includeSharedNotes.isSet() ? (filter.includeSharedNotes.ref() - ? QStringLiteral("true") - : QStringLiteral("false")) - : QStringLiteral("<not set>")) - << QStringLiteral(";\n") - << QStringLiteral(" omit shared notebooks = ") + ? "true" + : "false") + : "<not set>") + << ";\n" + << " omit shared notebooks = " << (filter.omitSharedNotebooks.isSet() ? (filter.omitSharedNotebooks.ref() - ? QStringLiteral("true") - : QStringLiteral("false")) - : QStringLiteral("<not set>")) - << QStringLiteral(";\n") - << QStringLiteral(" require note content class = ") + ? "true" + : "false") + : "<not set>") + << ";\n" + << " require note content class = " << (filter.requireNoteContentClass.isSet() ? filter.requireNoteContentClass.ref() : QStringLiteral("<not set>")) - << QStringLiteral(";\n"); + << ";\n"; - strm << QStringLiteral(" notebook guids: "); + strm << " notebook guids: "; if (filter.notebookGuids.isSet()) { - strm << QStringLiteral("\n"); + strm << "\n"; for(auto it = filter.notebookGuids->constBegin(), end = filter.notebookGuids->constEnd(); it != end; ++it) { - strm << QStringLiteral(" ") << *it << QStringLiteral("\n"); + strm << " " << *it << "\n"; } } else { - strm << QStringLiteral("<not set>;\n"); + strm << "<not set>;\n"; } return strm; @@ -1416,56 +1421,56 @@ QTextStream & operator<<(QTextStream & strm, const qevercloud::NoteResultSpec & spec) { - strm << QStringLiteral("qevercloud::NoteResultSpec: {\n") - << QStringLiteral(" include content = ") + strm << "qevercloud::NoteResultSpec: {\n" + << " include content = " << (spec.includeContent.isSet() ? (spec.includeContent.ref() - ? QStringLiteral("true") - : QStringLiteral("false")) - : QStringLiteral("<not set>")) - << QStringLiteral("\n include resources data = ") + ? "true" + : "false") + : "<not set>") + << "\n include resources data = " << (spec.includeResourcesData.isSet() ? (spec.includeResourcesData.ref() - ? QStringLiteral("true") - : QStringLiteral("false")) - : QStringLiteral("<not set>")) - << QStringLiteral("\n include resources recognition = ") + ? "true" + : "false") + : "<not set>") + << "\n include resources recognition = " << (spec.includeResourcesRecognition.isSet() ? (spec.includeResourcesRecognition.ref() - ? QStringLiteral("true") - : QStringLiteral("false")) - : QStringLiteral("<not set>")) - << QStringLiteral("\n include resources alternate data = ") + ? "true" + : "false") + : "<not set>") + << "\n include resources alternate data = " << (spec.includeResourcesAlternateData.isSet() ? (spec.includeResourcesAlternateData.ref() - ? QStringLiteral("true") - : QStringLiteral("false")) - : QStringLiteral("<not set>")) - << QStringLiteral("\n include shared notes = ") + ? "true" + : "false") + : "<not set>") + << "\n include shared notes = " << (spec.includeSharedNotes.isSet() ? (spec.includeSharedNotes.ref() - ? QStringLiteral("true") - : QStringLiteral("false")) - : QStringLiteral("<not set>")) - << QStringLiteral("\n include note app data values = ") + ? "true" + : "false") + : "<not set>") + << "\n include note app data values = " << (spec.includeNoteAppDataValues.isSet() ? (spec.includeNoteAppDataValues.ref() - ? QStringLiteral("true") - : QStringLiteral("false")) - : QStringLiteral("<not set>")) - << QStringLiteral("\n include resource app data values = ") + ? "true" + : "false") + : "<not set>") + << "\n include resource app data values = " << (spec.includeResourceAppDataValues.isSet() ? (spec.includeResourceAppDataValues.ref() - ? QStringLiteral("true") - : QStringLiteral("false")) - : QStringLiteral("<not set>")) - << QStringLiteral("\n include account limits = ") + ? "true" + : "false") + : "<not set>") + << "\n include account limits = " << (spec.includeAccountLimits.isSet() ? (spec.includeAccountLimits.ref() - ? QStringLiteral("true") - : QStringLiteral("false")) - : QStringLiteral("<not set>")) - << QStringLiteral("\n};\n"); + ? "true" + : "false") + : "<not set>") + << "\n};\n"; return strm; } @@ -1473,25 +1478,24 @@ QTextStream & operator<<(QTextStream & strm, const qevercloud::EvernoteOAuthWebView::OAuthResult & result) { - strm << QStringLiteral("qevercloud::EvernoteOAuthWebView::OAuthResult {\n"); + strm << "qevercloud::EvernoteOAuthWebView::OAuthResult {\n"; - strm << QStringLiteral(" noteStoreUrl = ") << result.noteStoreUrl - << QStringLiteral(";\n"); - strm << QStringLiteral(" expires = ") + strm << " noteStoreUrl = " << result.noteStoreUrl << ";\n"; + strm << " expires = " << quentier::printableDateTimeFromTimestamp(result.expires) - << QStringLiteral(";\n"); - strm << QStringLiteral(" shardId = ") << result.shardId - << QStringLiteral(";\n"); - strm << QStringLiteral(" userId = ") << QString::number(result.userId) - << QStringLiteral(";\n"); - strm << QStringLiteral(" webApiUrlPrefix = ") << result.webApiUrlPrefix - << QStringLiteral(";\n"); - strm << QStringLiteral(" authenticationToken ") + << ";\n"; + strm << " shardId = " << result.shardId + << ";\n"; + strm << " userId = " << QString::number(result.userId) + << ";\n"; + strm << " webApiUrlPrefix = " << result.webApiUrlPrefix + << ";\n"; + strm << " authenticationToken " << (result.authenticationToken.isEmpty() - ? QStringLiteral("is empty") - : QStringLiteral("is not empty")) << QStringLiteral(";\n"); + ? "is empty" + : "is not empty") << ";\n"; - strm << QStringLiteral("};\n"); + strm << "};\n"; return strm; } #endif diff -Nru libquentier-0.5.0/src/utility/QtKeychainWrapper.cpp libquentier-0.5.0/src/utility/QtKeychainWrapper.cpp --- libquentier-0.5.0/src/utility/QtKeychainWrapper.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/utility/QtKeychainWrapper.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -66,9 +66,8 @@ this, QNSLOT(QtKeychainWrapper,onWritePasswordJobFinished, QKeychain::Job*)); - QNDEBUG(QStringLiteral("Starting write password job for service ") << service - << QStringLiteral("; key = ") << key - << QStringLiteral(", job id = ") << jobId); + QNDEBUG("Starting write password job for service " << service + << "; key = " << key << ", job id = " << jobId); pJob->start(); } @@ -86,9 +85,8 @@ this, QNSLOT(QtKeychainWrapper,onReadPasswordJobFinished, QKeychain::Job*)); - QNDEBUG(QStringLiteral("Starting read password job for service ") << service - << QStringLiteral("; key = ") << key - << QStringLiteral(", job id = ") << jobId); + QNDEBUG("Starting read password job for service " << service + << "; key = " << key << ", job id = " << jobId); pJob->start(); } @@ -106,22 +104,20 @@ this, QNSLOT(QtKeychainWrapper,onDeletePasswordJobFinished, QKeychain::Job*)); - QNDEBUG(QStringLiteral("Starting delete password job for service ") << service - << QStringLiteral("; key = ") << key << QStringLiteral(", job id = ") - << jobId); + QNDEBUG("Starting delete password job for service " << service + << "; key = " << key << ", job id = " << jobId); pJob->start(); } void QtKeychainWrapper::onWritePasswordJobFinished(QKeychain::Job * pJob) { - QNDEBUG(QStringLiteral("QtKeychainWrapper::onWritePasswordJobFinished")); + QNDEBUG("QtKeychainWrapper::onWritePasswordJobFinished"); QKeychain::WritePasswordJob * pWritePasswordJob = qobject_cast<QKeychain::WritePasswordJob*>(pJob); auto it = m_writePasswordJobs.find(pWritePasswordJob); if (Q_UNLIKELY(it == m_writePasswordJobs.end())) { - QNWARNING(QStringLiteral("Failed to find the write password job's " - "corresponding job id")); + QNWARNING("Failed to find the write password job's corresponding job id"); return; } @@ -138,22 +134,21 @@ pWritePasswordJob->deleteLater(); m_writePasswordJobs.erase(it); - QNDEBUG(QStringLiteral("Finished write password job with id ") << jobId - << QStringLiteral(", error code = ") << errorCode - << QStringLiteral(", error description = ") << errorDescription); + QNDEBUG("Finished write password job with id " << jobId + << ", error code = " << errorCode + << ", error description = " << errorDescription); Q_EMIT writePasswordJobFinished(jobId, errorCode, errorDescription); } void QtKeychainWrapper::onReadPasswordJobFinished(QKeychain::Job * pJob) { - QNDEBUG(QStringLiteral("QtKeychainWrapper::onReadPasswordJobFinished")); + QNDEBUG("QtKeychainWrapper::onReadPasswordJobFinished"); QKeychain::ReadPasswordJob * pReadPasswordJob = qobject_cast<QKeychain::ReadPasswordJob*>(pJob); auto it = m_readPasswordJobs.find(pReadPasswordJob); if (Q_UNLIKELY(it == m_readPasswordJobs.end())) { - QNWARNING(QStringLiteral("Failed to find the read password job's " - "corresponding job id")); + QNWARNING("Failed to find the read password job's corresponding job id"); return; } @@ -181,22 +176,21 @@ pReadPasswordJob->deleteLater(); m_readPasswordJobs.erase(it); - QNDEBUG(QStringLiteral("Finished read password job with id ") << jobId - << QStringLiteral(", error code = ") << errorCode - << QStringLiteral(", error description = ") << errorDescription); + QNDEBUG("Finished read password job with id " << jobId + << ", error code = " << errorCode + << ", error description = " << errorDescription); Q_EMIT readPasswordJobFinished(jobId, errorCode, errorDescription, password); } void QtKeychainWrapper::onDeletePasswordJobFinished(QKeychain::Job * pJob) { - QNDEBUG(QStringLiteral("QtKeychainWrapper::onDeletePasswordJobFinished")); + QNDEBUG("QtKeychainWrapper::onDeletePasswordJobFinished"); QKeychain::DeletePasswordJob * pDeletePasswordJob = qobject_cast<QKeychain::DeletePasswordJob*>(pJob); auto it = m_deletePasswordJobs.find(pDeletePasswordJob); if (Q_UNLIKELY(it == m_deletePasswordJobs.end())) { - QNWARNING(QStringLiteral("Failed to find the delete password job's " - "corresponding job id")); + QNWARNING("Failed to find the delete password job's corresponding job id"); return; } @@ -213,9 +207,9 @@ pDeletePasswordJob->deleteLater(); m_deletePasswordJobs.erase(it); - QNDEBUG(QStringLiteral("Finished delete password job with id ") << jobId - << QStringLiteral(", error code = ") << errorCode - << QStringLiteral(", error description = ") << errorDescription); + QNDEBUG("Finished delete password job with id " << jobId + << ", error code = " << errorCode + << ", error description = " << errorDescription); Q_EMIT deletePasswordJobFinished(jobId, errorCode, errorDescription); } diff -Nru libquentier-0.5.0/src/utility/QuentierApplication.cpp libquentier-0.5.0/src/utility/QuentierApplication.cpp --- libquentier-0.5.0/src/utility/QuentierApplication.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/utility/QuentierApplication.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -39,8 +39,8 @@ catch(const std::exception & e) { SysInfo sysInfo; - QNERROR(QStringLiteral("Caught unhandled exception: ") << e.what() - << QStringLiteral(", backtrace: ") << sysInfo.stackTrace()); + QNERROR("Caught unhandled exception: " << e.what() + << ", backtrace: " << sysInfo.stackTrace()); return false; } } diff -Nru libquentier-0.5.0/src/utility/QuentierUndoCommand.cpp libquentier-0.5.0/src/utility/QuentierUndoCommand.cpp --- libquentier-0.5.0/src/utility/QuentierUndoCommand.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/utility/QuentierUndoCommand.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -39,18 +39,18 @@ void QuentierUndoCommand::undo() { - QNTRACE(QStringLiteral("QuentierUndoCommand::undo")); + QNTRACE("QuentierUndoCommand::undo"); m_onceUndoExecuted = true; undoImpl(); } void QuentierUndoCommand::redo() { - QNTRACE(QStringLiteral("QuentierUndoCommand::redo")); + QNTRACE("QuentierUndoCommand::redo"); if (Q_UNLIKELY(!m_onceUndoExecuted)) { - QNTRACE(QStringLiteral("Ignoring the attempt to execute redo for command ") - << text() << QStringLiteral(" as there was no previous undo")); + QNTRACE("Ignoring the attempt to execute redo for command " + << text() << " as there was no previous undo"); return; } diff -Nru libquentier-0.5.0/src/utility/ShortcutManager_p.cpp libquentier-0.5.0/src/utility/ShortcutManager_p.cpp --- libquentier-0.5.0/src/utility/ShortcutManager_p.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/utility/ShortcutManager_p.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -49,17 +49,15 @@ const Account & account, const QString & context) const { - QNDEBUG(QStringLiteral("ShortcutManagerPrivate::shortcut: key = ") << key - << QStringLiteral(", context = ") << context - << QStringLiteral(", account: ") << account.name()); + QNDEBUG("ShortcutManagerPrivate::shortcut: key = " << key + << ", context = " << context << ", account: " << account.name()); QKeySequence userKeySequence = userShortcut(key, account, context); if (!userKeySequence.isEmpty()) { return userKeySequence; } - QNDEBUG(QStringLiteral("User shortcut is empty, fallback to the default " - "shortcut")); + QNDEBUG("User shortcut is empty, fallback to the default shortcut"); return defaultShortcut(key, account, context); } @@ -67,17 +65,16 @@ const Account & account, const QString & context) const { - QNDEBUG(QStringLiteral("ShortcutManagerPrivate::shortcut: non-standard key = ") - << nonStandardKey << QStringLiteral(", context = ") << context - << QStringLiteral(", account: ") << account.name()); + QNDEBUG("ShortcutManagerPrivate::shortcut: non-standard key = " + << nonStandardKey << ", context = " << context + << ", account: " << account.name()); QKeySequence userKeySequence = userShortcut(nonStandardKey, account, context); if (!userKeySequence.isEmpty()) { return userKeySequence; } - QNDEBUG(QStringLiteral("User shortcut is empty, fallback to the default " - "shortcut")); + QNDEBUG("User shortcut is empty, fallback to the default shortcut"); return defaultShortcut(nonStandardKey, account, context); } @@ -87,10 +84,9 @@ { QString keyString = keyToString(key); - QNDEBUG(QStringLiteral("ShortcutManagerPrivate::defaultShortcut: key = ") - << keyString << QStringLiteral(" (") << key - << QStringLiteral("), context = ") << context - << QStringLiteral(", account: ") << account.name()); + QNDEBUG("ShortcutManagerPrivate::defaultShortcut: key = " << keyString + << " (" << key << "), context = " << context << ", account: " + << account.name()); if (Q_UNLIKELY(keyString.isEmpty())) { return QKeySequence(); @@ -111,20 +107,20 @@ if (keySequence.isEmpty()) { - QNTRACE(QStringLiteral("Can't find default shortcut in app settings")); + QNTRACE("Can't find default shortcut in app settings"); if ((key >= 0) && (key < QKeySequence::UnknownKey)) { - QNTRACE(QStringLiteral("Returning the platform-specific default " - "from QKeySequence")); + QNTRACE("Returning the platform-specific default " + "from QKeySequence"); return QKeySequence(key); } else { - QNTRACE(QStringLiteral("Returning empty shortcut")); + QNTRACE("Returning empty shortcut"); return QKeySequence(); } } - QNTRACE(QStringLiteral("Key sequence: ") << keySequence); + QNTRACE("Key sequence: " << keySequence); return keySequence; } @@ -132,9 +128,9 @@ const Account & account, const QString & context) const { - QNDEBUG(QStringLiteral("ShortcutManagerPrivate::defaultShortcut: non-standard key = ") - << nonStandardKey << QStringLiteral(", context = ") << context - << QStringLiteral(", account: ") << account.name()); + QNDEBUG("ShortcutManagerPrivate::defaultShortcut: non-standard key = " + << nonStandardKey << ", context = " << context << ", account: " + << account.name()); if (Q_UNLIKELY(nonStandardKey.isEmpty())) { return QKeySequence(); @@ -154,8 +150,8 @@ } if (keySequence.isEmpty()) { - QNTRACE(QStringLiteral("Can't find default shortcut in app settings, " - "returning empty shortcut")); + QNTRACE("Can't find default shortcut in app settings, returning empty " + "shortcut"); return QKeySequence(); } @@ -168,10 +164,8 @@ { QString keyString = keyToString(key); - QNDEBUG(QStringLiteral("ShortcutManagerPrivate::userShortcut: key = ") - << keyString << QStringLiteral(" (") << key - << QStringLiteral("), context = ") << context - << QStringLiteral(", account: ") << account.name()); + QNDEBUG("ShortcutManagerPrivate::userShortcut: key = " << keyString << " (" + << key << "), context = " << context << ", account: " << account.name()); if (Q_UNLIKELY(keyString.isEmpty())) { return QKeySequence(); @@ -183,18 +177,18 @@ /* default shortcut = */ false, /* non-standard shortcut = */ false)); QVariant value = settings.value(keyString); - QNTRACE(QStringLiteral("Read from app settings: ") << value); + QNTRACE("Read from app settings: " << value); settings.endGroup(); if (!value.isValid()) { - QNTRACE(QStringLiteral("Couldn't find user shortcut for standard key ") - << keyString << QStringLiteral(" (") << key << QStringLiteral(")")); + QNTRACE("Couldn't find user shortcut for standard key " << keyString + << " (" << key << ")"); return QKeySequence(); } QKeySequence keySequence = QKeySequence(value.toString(), QKeySequence::PortableText); - QNTRACE(QStringLiteral("Key sequence: ") << keySequence); + QNTRACE("Key sequence: " << keySequence); return keySequence; } @@ -202,9 +196,9 @@ const Account & account, const QString & context) const { - QNDEBUG(QStringLiteral("ShortcutManagerPrivate::userShortcut: non-standard key = ") - << nonStandardKey << QStringLiteral(", context = ") << context - << QStringLiteral(", account: ") << account.name()); + QNDEBUG("ShortcutManagerPrivate::userShortcut: non-standard key = " + << nonStandardKey << ", context = " << context << ", account: " + << account.name()); if (Q_UNLIKELY(nonStandardKey.isEmpty())) { return QKeySequence(); @@ -216,18 +210,18 @@ /* default shortcut = */ false, /* non-standard shortcut = */ true)); QVariant value = settings.value(nonStandardKey); - QNTRACE(QStringLiteral("Read from app settings: ") << value); + QNTRACE("Read from app settings: " << value); settings.endGroup(); if (!value.isValid()) { - QNTRACE(QStringLiteral("Couldn't find user shortcut for non-standard key ") + QNTRACE("Couldn't find user shortcut for non-standard key " << nonStandardKey); return QKeySequence(); } QKeySequence keySequence = QKeySequence(value.toString(), QKeySequence::PortableText); - QNTRACE(QStringLiteral("Key sequence: ") << keySequence); + QNTRACE("Key sequence: " << keySequence); return keySequence; } @@ -237,11 +231,9 @@ { QString keyString = keyToString(key); - QNDEBUG(QStringLiteral("ShortcutManagerPrivate::setUserShortcut: key = ") - << keyString << QStringLiteral(" (") << key - << QStringLiteral("), shortcut = ") << shortcut - << QStringLiteral(", context = ") << context - << QStringLiteral(", account: ") << account.name()); + QNDEBUG("ShortcutManagerPrivate::setUserShortcut: key = " + << keyString << " (" << key << "), shortcut = " << shortcut + << ", context = " << context << ", account: " << account.name()); if (Q_UNLIKELY(keyString.isEmpty())) { return; @@ -267,11 +259,9 @@ const Account & account, QString context) { - QNDEBUG(QStringLiteral("ShortcutManagerPrivate::setNonStandardUserShortcut: ") - << QStringLiteral("non-standard key = ") << nonStandardKey - << QStringLiteral(", shortcut = ") << shortcut - << QStringLiteral(", context = ") << context - << QStringLiteral(", account: ") << account.name()); + QNDEBUG("ShortcutManagerPrivate::setNonStandardUserShortcut: non-standard key = " + << nonStandardKey << ", shortcut = " << shortcut << ", context = " + << context << ", account: " << account.name()); if (Q_UNLIKELY(nonStandardKey.isEmpty())) { return; @@ -299,11 +289,9 @@ { QString keyString = keyToString(key); - QNDEBUG(QStringLiteral("ShortcutManagerPrivate::setDefaultShortcut: key = ") - << keyString << QStringLiteral(" (") << key - << QStringLiteral("), shortcut = ") << shortcut - << QStringLiteral(", context = ") << context - << QStringLiteral(", account: ") << account.name()); + QNDEBUG("ShortcutManagerPrivate::setDefaultShortcut: key = " + << keyString << " (" << key << "), shortcut = " << shortcut + << ", context = " << context << ", account: " << account.name()); if (Q_UNLIKELY(keyString.isEmpty())) { return; @@ -331,7 +319,7 @@ } if (userKeySequence.isEmpty()) { - QNTRACE(QStringLiteral("Found no user shortcut overriding the default one")); + QNTRACE("Found no user shortcut overriding the default one"); Q_EMIT shortcutChanged(key, shortcut, account, context); } } @@ -341,11 +329,10 @@ const Account & account, QString context) { - QNDEBUG(QStringLiteral("ShortcutManagerPrivate::setNonStandardDefaultShortcut: ") - << QStringLiteral("non-standard key = ") << nonStandardKey - << QStringLiteral(", shortcut = ") << shortcut - << QStringLiteral(", context = ") << context - << QStringLiteral(", account: ") << account.name()); + QNDEBUG("ShortcutManagerPrivate::setNonStandardDefaultShortcut: " + << "non-standard key = " << nonStandardKey << ", shortcut = " + << shortcut << ", context = " << context << ", account: " + << account.name()); if (Q_UNLIKELY(nonStandardKey.isEmpty())) { return; @@ -372,14 +359,14 @@ } if (userKeySequence.isEmpty()) { - QNTRACE(QStringLiteral("Found no user shortcut overriding the default one")); + QNTRACE("Found no user shortcut overriding the default one"); Q_EMIT nonStandardShortcutChanged(nonStandardKey, shortcut, account, context); } } QString ShortcutManagerPrivate::keyToString(const int key) const { - QNTRACE(QStringLiteral("ShortcutManagerPrivate::keyToString: key = ") << key); + QNTRACE("ShortcutManagerPrivate::keyToString: key = " << key); if (key < ShortcutManager::NewNote) { @@ -463,9 +450,8 @@ #endif default: { - QNDEBUG(QStringLiteral("The key ") << key - << QStringLiteral(" doesn't correspond to any of " - "QKeySequence::StandardKey items")); + QNDEBUG("The key " << key << " doesn't correspond to any of " + "QKeySequence::StandardKey items"); return QString(); } } @@ -547,9 +533,8 @@ PRINT_ITEM(UnknownKey); default: { - QNDEBUG(QStringLiteral("The key ") << key - << QStringLiteral(" doesn't correspond to any of " - "ShortcutManager::QuentierShortcutKey items")); + QNDEBUG("The key " << key << " doesn't correspond to any of " + "ShortcutManager::QuentierShortcutKey items"); return QString(); } } @@ -561,24 +546,24 @@ const bool defaultShortcut, const bool nonStandardShortcut) const { - QNDEBUG(QStringLiteral("ShortcutManagerPrivate::shortcutGroupString: context = ") - << context << QStringLiteral(", default shortcut = ") + QNDEBUG("ShortcutManagerPrivate::shortcutGroupString: context = " + << context << ", default shortcut = " << (defaultShortcut - ? QStringLiteral("true") - : QStringLiteral("false")) - << QStringLiteral(", non-standard shortcut = ") + ? "true" + : "false") + << ", non-standard shortcut = " << (nonStandardShortcut - ? QStringLiteral("true") - : QStringLiteral("false"))); + ? "true" + : "false")); - return (QString(defaultShortcut - ? QStringLiteral("DefaultShortcuts-") - : QStringLiteral("UserShortcuts-")) + + return (defaultShortcut + ? QStringLiteral("DefaultShortcuts-") + : QStringLiteral("UserShortcuts-")) + (context.isEmpty() - ? QString(nonStandardShortcut - ? QStringLiteral("NonStandard") - : QStringLiteral("General")) - : context)); + ? (nonStandardShortcut + ? QStringLiteral("NonStandard") + : QStringLiteral("General")) + : context); } } // namespace quentier diff -Nru libquentier-0.5.0/src/utility/StringUtils_p.cpp libquentier-0.5.0/src/utility/StringUtils_p.cpp --- libquentier-0.5.0/src/utility/StringUtils_p.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/utility/StringUtils_p.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -50,9 +50,9 @@ void StringUtilsPrivate::removeDiacritics(QString & str) const { - QNTRACE(QStringLiteral("str before normalizing by D form: ") << str); + QNTRACE("str before normalizing by KD form: " << str); str = str.normalized(QString::NormalizationForm_KD); - QNTRACE(QStringLiteral("str after normalizing by KD form: ") << str); + QNTRACE("str after normalizing by KD form: " << str); for(int i = 0; i < str.length(); ++i) { @@ -75,7 +75,7 @@ str.replace(i, 1, replacement); } - QNTRACE(QStringLiteral("str after removing diacritics: ") << str); + QNTRACE("str after removing diacritics: " << str); } void StringUtilsPrivate::removeNewlines(QString & str) const diff -Nru libquentier-0.5.0/src/utility/TagSortByParentChildRelations.cpp libquentier-0.5.0/src/utility/TagSortByParentChildRelations.cpp --- libquentier-0.5.0/src/utility/TagSortByParentChildRelations.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/utility/TagSortByParentChildRelations.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -30,11 +30,11 @@ { QString log; QTextStream strm(&log); - strm << QStringLiteral("Tags list before performing the topological sort: "); + strm << "Tags list before performing the topological sort: "; for(auto it = tagList.constBegin(), end = tagList.constEnd(); it != end; ++it) { - strm << *it << QStringLiteral(", "); + strm << *it << ", "; } strm.flush(); QNTRACE(log); @@ -55,8 +55,8 @@ { if (!tagHasGuid(*it)) { allTagsHaveGuids = false; - QNDEBUG(QStringLiteral("Not all tags have guids, won't use guids " - "to track parent-child relations")); + QNDEBUG("Not all tags have guids, won't use guids to track " + "parent-child relations"); break; } } @@ -98,15 +98,14 @@ { QString localUid = tagLocalUid(*it); QString parentTagLocalUid = tagParentLocalUid(*it); - QNTRACE(QStringLiteral("Adding tag local uid ") << localUid - << QStringLiteral(" and tag parent local uid ") - << parentTagLocalUid << QStringLiteral(" to the graph")); + QNTRACE("Adding tag local uid " << localUid + << " and tag parent local uid " << parentTagLocalUid + << " to the graph"); graph.addChild(parentTagLocalUid, localUid); } else { - QNTRACE(QStringLiteral("Skipping tag without either guid or local uid: ") - << *it); + QNTRACE("Skipping tag without either guid or local uid: " << *it); } } @@ -148,10 +147,10 @@ } if (Q_UNLIKELY(it == tagList.end())) { - QNDEBUG(QStringLiteral("Skipping the tag guid or local uid not found " - "within the original set (probably the guid of " - "some parent tag not present within " - "the sorted subset): ") << id); + QNDEBUG("Skipping the tag guid or local uid not found " + "within the original set (probably the guid of " + "some parent tag not present within the sorted subset): " + << id); continue; } @@ -165,11 +164,11 @@ { QString log; QTextStream strm(&log); - strm << QStringLiteral("Tags list after performing the topological sort: "); + strm << "Tags list after performing the topological sort: "; for(auto it = tagList.constBegin(), end = tagList.constEnd(); it != end; ++it) { - strm << *it << QStringLiteral("\n"); + strm << *it << "\n"; } strm.flush(); QNTRACE(log); diff -Nru libquentier-0.5.0/src/utility/unix/darwin/SysInfoDarwin.cpp libquentier-0.5.0/src/utility/unix/darwin/SysInfoDarwin.cpp --- libquentier-0.5.0/src/utility/unix/darwin/SysInfoDarwin.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/utility/unix/darwin/SysInfoDarwin.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -120,6 +120,12 @@ else if (qstr.startsWith(QStringLiteral("16."))) { return QStringLiteral("macOS 10.12 Sierra"); } + else if (qstr.startsWith(QStringLiteral("17."))) { + return QStringLiteral("macOS 10.13 High Sierra"); + } + else if (qstr.startsWith(QStringLiteral("18."))) { + return QStringLiteral("macOS 10.14 Mojave"); + } return QStringLiteral("Unknown Darwin"); } diff -Nru libquentier-0.5.0/src/utility/Utility.cpp libquentier-0.5.0/src/utility/Utility.cpp --- libquentier-0.5.0/src/utility/Utility.cpp 2019-06-19 09:02:56.000000000 +0000 +++ libquentier-0.5.0/src/utility/Utility.cpp 2019-07-11 10:46:53.000000000 +0000 @@ -204,8 +204,8 @@ const QStringList styleNames = QStyleFactory::keys(); #if !defined(Q_OS_MAC) && (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) if (styleNames.isEmpty()) { - QNINFO(QStringLiteral("No valid styles were found in QStyleFactory! " - "Fallback to the last resort of plastique style")); + QNINFO("No valid styles were found in QStyleFactory! " + "Fallback to the last resort of plastique style"); return new QPlastiqueStyle; } @@ -265,7 +265,7 @@ const QString relativePathFromAbsolutePath(const QString & absolutePath, const QString & relativePathRootFolder) { - QNDEBUG(QStringLiteral("relativePathFromAbsolutePath: ") << absolutePath); + QNDEBUG("relativePathFromAbsolutePath: " << absolutePath); int position = absolutePath.indexOf(relativePathRootFolder, 0, #if defined(Q_OS_WIN) || defined(Q_OS_MAC) @@ -275,8 +275,8 @@ #endif ); if (position < 0) { - QNINFO(QStringLiteral("Can't find folder ") << relativePathRootFolder - << QStringLiteral(" within path ") << absolutePath); + QNINFO("Can't find folder " << relativePathRootFolder << " within path " + << absolutePath); return QString(); } @@ -286,7 +286,7 @@ const QString getCurrentUserName() { - QNDEBUG(QStringLiteral("getCurrentUserName")); + QNDEBUG("getCurrentUserName"); QString userName; @@ -306,8 +306,8 @@ if (userName.isEmpty()) { - QNTRACE(QStringLiteral("Native platform API failed to provide the username, " - "trying environment variables fallback")); + QNTRACE("Native platform API failed to provide the username, " + "trying environment variables fallback"); userName = QString::fromLocal8Bit(qgetenv("USER")); if (userName.isEmpty()) { @@ -315,13 +315,13 @@ } } - QNTRACE(QStringLiteral("Username = ") << userName); + QNTRACE("Username = " << userName); return userName; } const QString getCurrentUserFullName() { - QNDEBUG(QStringLiteral("getCurrentUserFullName")); + QNDEBUG("getCurrentUserFullName"); QString userFullName; @@ -369,19 +369,19 @@ void openUrl(const QUrl & url) { - QNDEBUG(QStringLiteral("openUrl: ") << url); + QNDEBUG("openUrl: " << url); QDesktopServices::openUrl(url); } bool removeFile(const QString & filePath) { - QNDEBUG(QStringLiteral("removeFile: ") << filePath); + QNDEBUG("removeFile: " << filePath); QFile file(filePath); file.close(); // NOTE: this line seems to be mandatory on Windows bool res = file.remove(); if (res) { - QNTRACE(QStringLiteral("Successfully removed file ") << filePath); + QNTRACE("Successfully removed file " << filePath); return true; } @@ -390,14 +390,14 @@ // NOTE: there appears to be a bug in Qt for Windows, QFile::remove // returns false for any *.lnk files even though the files are actually // getting removed - QNTRACE(QStringLiteral("Skipping the reported failure at removing the .lnk file")); + QNTRACE("Skipping the reported failure at removing the .lnk file"); return true; } #endif - QNWARNING(QStringLiteral("Cannot remove file ") << filePath - << QStringLiteral(": ") << file.errorString() - << QStringLiteral(", error code ") << file.error()); + QNWARNING("Cannot remove file " << filePath + << ": " << file.errorString() + << ", error code " << file.error()); return false; }