Commit 8117adbf authored by Sandro Knauß's avatar Sandro Knauß

Move UpdateMode away from MessageViewer::Viewer into MessageViewer namespace

Need to update kdepim & kdepim-addons

Differential Revision: https://phabricator.kde.org/D871
parent e1ad3d23
......@@ -18,7 +18,7 @@ include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
include(ECMQtDeclareLoggingCategory)
include(ECMAddTests)
set(MESSAGELIB_LIB_VERSION "5.1.63")
set(MESSAGELIB_LIB_VERSION "5.1.64")
set(KF5_VERSION "5.17.0")
set(KDEPIMLIBS_LIB_VERSION "5.1.42")
......
......@@ -77,5 +77,5 @@ ecm_add_test(converthtmltoplaintexttest.cpp ../src/viewer/converthtmltoplaintext
set(KDEPIMLIBS_RUN_ISOLATED_TESTS TRUE)
set(KDEPIMLIBS_RUN_SQLITE_ISOLATED_TESTS TRUE)
add_akonadi_isolated_test_advanced( viewertest.cpp "" "KF5::MessageViewer;KF5::XmlGui")
add_akonadi_isolated_test_advanced(viewertest.cpp "" "KF5::MessageViewer;KF5::XmlGui")
......@@ -239,7 +239,7 @@ void UnencryptedMessageTest::testAsync()
QEventLoop loop;
ObjectTreeParser otp(&emptySource, &nodeHelper);
connect(&nodeHelper, SIGNAL(update(MessageViewer::Viewer::UpdateMode)), &loop, SLOT(quit()));
connect(&nodeHelper, &NodeHelper::update, &loop, &QEventLoop::quit);
otp.setAllowAsync(true);
otp.parseObjectTree(originalMessage.data());
loop.exec();
......
......@@ -57,7 +57,7 @@ void ContactDisplayMessageMemento::slotSearchJobFinished(KJob *job)
Akonadi::ContactSearchJob *searchJob = static_cast<Akonadi::ContactSearchJob *>(job);
if (searchJob->error()) {
qCWarning(MESSAGEVIEWER_LOG) << "Unable to fetch contact:" << searchJob->errorText();
Q_EMIT update(Viewer::Delayed);
Q_EMIT update(Delayed);
return;
}
......@@ -73,7 +73,7 @@ void ContactDisplayMessageMemento::slotSearchJobFinished(KJob *job)
if (!mPhoto.isEmpty()) {
//We have a data raw => we can update message
if (mPhoto.isIntern()) {
Q_EMIT update(Viewer::Delayed);
Q_EMIT update(Delayed);
} else {
QUrl url = QUrl::fromUserInput(mPhoto.url(), QString(), QUrl::AssumeLocalFile);
QImage image;
......@@ -98,7 +98,7 @@ void ContactDisplayMessageMemento::slotSearchJobFinished(KJob *job)
}
if (ok) {
mImageFromUrl = image;
Q_EMIT update(Viewer::Delayed);
Q_EMIT update(Delayed);
}
}
}
......@@ -193,6 +193,6 @@ void ContactDisplayMessageMemento::slotGravatarResolvUrlFinished(Gravatar::Grava
{
if (job && job->hasGravatar()) {
mGravatarPixmap = job->pixmap();
Q_EMIT update(Viewer::Delayed);
Q_EMIT update(Delayed);
}
}
......@@ -61,7 +61,7 @@ public:
Q_SIGNALS:
// TODO: Factor our update and detach into base class
void update(MessageViewer::Viewer::UpdateMode);
void update(MessageViewer::UpdateMode);
void changeDisplayMail(Viewer::DisplayFormatMessage displayAsHtml, bool remoteContent);
private Q_SLOTS:
......
/*
Copyright (c) 2016 Sandro Knauß <sknauss@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _MESSAGEVIEWER_ENUMS_H
#define _MESSAGEVIEWER_ENUMS_H
namespace MessageViewer
{
/**
* The display update mode: Force updates the display immediately, Delayed updates
* after some time (150ms by default)
*/
enum UpdateMode {
Force = 0,
Delayed
};
/** Flags for the encryption state. */
typedef enum {
KMMsgEncryptionStateUnknown = ' ',
KMMsgNotEncrypted = 'N',
KMMsgPartiallyEncrypted = 'P',
KMMsgFullyEncrypted = 'F',
KMMsgEncryptionProblematic = 'X'
} KMMsgEncryptionState;
/** Flags for the signature state. */
typedef enum {
KMMsgSignatureStateUnknown = ' ',
KMMsgNotSigned = 'N',
KMMsgPartiallySigned = 'P',
KMMsgFullySigned = 'F',
KMMsgSignatureProblematic = 'X'
} KMMsgSignatureState;
}
#endif
......@@ -24,7 +24,7 @@
#include <QString>
#include "interfaces/bodypart.h"
#include "messageviewer/viewer.h"
#include "viewer/enums.h"
namespace MessageViewer
{
......@@ -54,12 +54,12 @@ public:
void detach() Q_DECL_OVERRIDE;
Q_SIGNALS:
void update(MessageViewer::Viewer::UpdateMode);
void update(MessageViewer::UpdateMode);
protected Q_SLOTS:
void notify()
{
Q_EMIT update(Viewer::Force);
Q_EMIT update(MessageViewer::Force);
}
protected:
......
......@@ -21,8 +21,8 @@
#define _MESSAGEVIEWER_NODEHELPER_H
#include "messageviewer_export.h"
#include "partmetadata.h"
#include "messageviewer/viewer.h"
#include "messageviewer/partmetadata.h"
#include "messageviewer/enums.h"
#include <KMime/Message>
......@@ -50,24 +50,6 @@ class AttachmentTemporaryFilesDirs;
namespace MessageViewer
{
/** Flags for the encryption state. */
typedef enum {
KMMsgEncryptionStateUnknown = ' ',
KMMsgNotEncrypted = 'N',
KMMsgPartiallyEncrypted = 'P',
KMMsgFullyEncrypted = 'F',
KMMsgEncryptionProblematic = 'X'
} KMMsgEncryptionState;
/** Flags for the signature state. */
typedef enum {
KMMsgSignatureStateUnknown = ' ',
KMMsgNotSigned = 'N',
KMMsgPartiallySigned = 'P',
KMMsgFullySigned = 'F',
KMMsgSignatureProblematic = 'X'
} KMMsgSignatureState;
/**
* @author Andras Mantia <andras@kdab.net>
*/
......@@ -270,7 +252,7 @@ public:
QVector<KMime::Content *> attachmentsOfExtraContents() const;
Q_SIGNALS:
void update(MessageViewer::Viewer::UpdateMode);
void update(MessageViewer::UpdateMode);
private:
Q_DISABLE_COPY(NodeHelper)
......
......@@ -686,8 +686,8 @@ bool ObjectTreeParser::okDecryptMIME(KMime::Content &data,
if (allowAsync()) {
QObject::connect(newM, &CryptoBodyPartMemento::update,
nodeHelper(), &NodeHelper::update);
QObject::connect(newM, SIGNAL(update(MessageViewer::Viewer::UpdateMode)), mSource->sourceObject(),
SLOT(update(MessageViewer::Viewer::UpdateMode)));
QObject::connect(newM, SIGNAL(update(MessageViewer::UpdateMode)), mSource->sourceObject(),
SLOT(update(MessageViewer::UpdateMode)));
if (newM->start()) {
decryptionStarted = true;
mHasPendingAsyncJobs = true;
......@@ -2018,8 +2018,8 @@ bool ObjectTreeParser::okVerify(const QByteArray &data, const Kleo::CryptoBacken
if (allowAsync()) {
QObject::connect(m, &CryptoBodyPartMemento::update,
mNodeHelper, &NodeHelper::update);
QObject::connect(m, SIGNAL(update(MessageViewer::Viewer::UpdateMode)),
mSource->sourceObject(), SLOT(update(MessageViewer::Viewer::UpdateMode)));
QObject::connect(m, SIGNAL(update(MessageViewer::UpdateMode)),
mSource->sourceObject(), SLOT(update(MessageViewer::UpdateMode)));
if (m->start()) {
messagePart.inProgress = true;
......
......@@ -579,7 +579,7 @@ bool KMailProtocolURLHandler::handleClick(const QUrl &url, ViewerPrivate *w) con
const QString urlPath(url.path());
if (urlPath == QLatin1String("showHTML")) {
w->setDisplayFormatMessageOverwrite(MessageViewer::Viewer::Html);
w->update(Viewer::Force);
w->update(Force);
return true;
} else if (urlPath == QLatin1String("goOnline")) {
w->goOnline();
......@@ -589,43 +589,43 @@ bool KMailProtocolURLHandler::handleClick(const QUrl &url, ViewerPrivate *w) con
return true;
} else if (urlPath == QLatin1String("loadExternal")) {
w->setHtmlLoadExtOverride(!w->htmlLoadExtOverride());
w->update(Viewer::Force);
w->update(Force);
return true;
} else if (urlPath == QLatin1String("decryptMessage")) {
w->setDecryptMessageOverwrite(true);
w->update(Viewer::Force);
w->update(Force);
return true;
} else if (urlPath == QLatin1String("showSignatureDetails")) {
w->setShowSignatureDetails(true);
w->update(Viewer::Force);
w->update(Force);
return true;
} else if (urlPath == QLatin1String("hideSignatureDetails")) {
w->setShowSignatureDetails(false);
w->update(Viewer::Force);
w->update(Force);
return true;
} else if (urlPath == QLatin1String("showAttachmentQuicklist")) {
w->setShowAttachmentQuicklist(true);
w->update(Viewer::Force);
w->update(Force);
return true;
} else if (urlPath == QLatin1String("hideAttachmentQuicklist")) {
w->setShowAttachmentQuicklist(false);
w->update(Viewer::Force);
w->update(Force);
return true;
} else if (urlPath == QLatin1String("showFullToAddressList")) {
w->setShowFullToAddressList(true);
w->update(Viewer::Force);
w->update(Force);
return true;
} else if (urlPath == QLatin1String("hideFullToAddressList")) {
w->setShowFullToAddressList(false);
w->update(Viewer::Force);
w->update(Force);
return true;
} else if (urlPath == QLatin1String("showFullCcAddressList")) {
w->setShowFullCcAddressList(true);
w->update(Viewer::Force);
w->update(Force);
return true;
} else if (urlPath == QLatin1String("hideFullCcAddressList")) {
w->setShowFullCcAddressList(false);
w->update(Viewer::Force);
w->update(Force);
return true;
}
}
......
......@@ -341,7 +341,7 @@ bool Viewer::event(QEvent *e)
if (e->type() == QEvent::PaletteChange) {
delete d->mCSSHelper;
d->mCSSHelper = new CSSHelper(d->mViewer);
d->update(Viewer::Force); // Force update
d->update(Force); // Force update
return true;
}
return QWidget::event(e);
......@@ -480,7 +480,7 @@ QUrl Viewer::imageUrlClicked() const
return d->mImageUrl;
}
void Viewer::update(MessageViewer::Viewer::UpdateMode updateMode)
void Viewer::update(MessageViewer::UpdateMode updateMode)
{
Q_D(Viewer);
d->update(updateMode);
......@@ -492,7 +492,7 @@ void Viewer::setMessagePart(KMime::Content *aMsgPart)
d->setMessagePart(aMsgPart);
}
void Viewer::clear(Viewer::UpdateMode updateMode)
void Viewer::clear(UpdateMode updateMode)
{
setMessage(KMime::Message::Ptr(), updateMode);
}
......@@ -623,7 +623,7 @@ void Viewer::slotChangeDisplayMail(Viewer::DisplayFormatMessage mode, bool loadE
{
setHtmlLoadExtOverride(loadExternal);
setDisplayFormatMessageOverwrite(mode);
update(Viewer::Force);
update(Force);
}
QAction *Viewer::saveMessageDisplayFormatAction() const
......
......@@ -24,6 +24,7 @@
#include "messageviewer_export.h"
#include "messageviewer/viewerplugininterface.h"
#include "messageviewer/enums.h"
#include <kmime/kmime_message.h>
......@@ -136,15 +137,6 @@ public:
PrintPreview
};
/**
* The display update mode: Force updates the display immediately, Delayed updates
* after some time (150ms by default)
*/
enum UpdateMode {
Force = 0,
Delayed
};
enum ResourceOnlineMode {
AllResources = 0,
SelectedResource = 1
......
......@@ -434,7 +434,7 @@ void ViewerPrivate::itemModifiedResult(KJob *job)
if (job->error()) {
qCDebug(MESSAGEVIEWER_LOG) << "Item update failed:" << job->errorString();
} else {
setMessageItem(mMessageItem, MessageViewer::Viewer::Force);
setMessageItem(mMessageItem, MessageViewer::Force);
}
}
......@@ -1189,7 +1189,7 @@ void ViewerPrivate::setAttachmentStrategy(const AttachmentStrategy *strategy)
return;
}
mAttachmentStrategy = strategy ? strategy : AttachmentStrategy::smart();
update(Viewer::Force);
update(Force);
}
QString ViewerPrivate::overrideEncoding() const
......@@ -1225,7 +1225,7 @@ void ViewerPrivate::setOverrideEncoding(const QString &encoding)
}
}
}
update(Viewer::Force);
update(Force);
}
void ViewerPrivate::setPrinting(bool enable)
......@@ -1237,14 +1237,14 @@ void ViewerPrivate::printMessage(const Akonadi::Item &message)
{
disconnect(mPartHtmlWriter.data(), &WebKitPartHtmlWriter::finished, this, &ViewerPrivate::slotPrintMsg);
connect(mPartHtmlWriter.data(), &WebKitPartHtmlWriter::finished, this, &ViewerPrivate::slotPrintMsg);
setMessageItem(message, Viewer::Force);
setMessageItem(message, Force);
}
void ViewerPrivate::printPreviewMessage(const Akonadi::Item &message)
{
disconnect(mPartHtmlWriter.data(), &WebKitPartHtmlWriter::finished, this, &ViewerPrivate::slotPrintPreview);
connect(mPartHtmlWriter.data(), &WebKitPartHtmlWriter::finished, this, &ViewerPrivate::slotPrintPreview);
setMessageItem(message, Viewer::Force);
setMessageItem(message, Force);
}
void ViewerPrivate::resetStateForNewMessage()
......@@ -1279,7 +1279,7 @@ void ViewerPrivate::resetStateForNewMessage()
}
void ViewerPrivate::setMessageInternal(const KMime::Message::Ptr &message,
Viewer::UpdateMode updateMode)
UpdateMode updateMode)
{
mViewerPluginToolManager->updateActions(mMessageItem);
mMessage = message;
......@@ -1294,7 +1294,7 @@ void ViewerPrivate::setMessageInternal(const KMime::Message::Ptr &message,
}
void ViewerPrivate::setMessageItem(const Akonadi::Item &item, Viewer::UpdateMode updateMode)
void ViewerPrivate::setMessageItem(const Akonadi::Item &item, UpdateMode updateMode)
{
resetStateForNewMessage();
foreach (const Akonadi::Item::Id monitoredId, mMonitor.itemsMonitoredEx()) {
......@@ -1317,7 +1317,7 @@ void ViewerPrivate::setMessageItem(const Akonadi::Item &item, Viewer::UpdateMode
setMessageInternal(mMessageItem.payload<KMime::Message::Ptr>(), updateMode);
}
void ViewerPrivate::setMessage(const KMime::Message::Ptr &aMsg, Viewer::UpdateMode updateMode)
void ViewerPrivate::setMessage(const KMime::Message::Ptr &aMsg, UpdateMode updateMode)
{
resetStateForNewMessage();
......@@ -1497,12 +1497,12 @@ void ViewerPrivate::createWidgets()
void ViewerPrivate::slotStyleChanged(MessageViewer::HeaderStylePlugin *plugin)
{
mHeaderStylePlugin = plugin;
update(Viewer::Force);
update(Force);
}
void ViewerPrivate::slotStyleUpdated()
{
update(Viewer::Force);
update(Force);
}
void ViewerPrivate::createActions()
......@@ -1930,10 +1930,10 @@ const QTextCodec *ViewerPrivate::codecForName(const QByteArray &_str)
return KCharsets::charsets()->codecForName(QLatin1String(codec));
}
void ViewerPrivate::update(MessageViewer::Viewer::UpdateMode updateMode)
void ViewerPrivate::update(MessageViewer::UpdateMode updateMode)
{
// Avoid flicker, somewhat of a cludge
if (updateMode == Viewer::Force) {
if (updateMode == Force) {
// stop the timer to avoid calling updateReaderWin twice
mUpdateReaderWinTimer.stop();
saveRelativePosition();
......@@ -2027,7 +2027,7 @@ void ViewerPrivate::slotLoadExternalReference()
return;
}
setHtmlLoadExtOverride(true);
update(Viewer::Force);
update(Force);
}
void ViewerPrivate::slotToggleHtmlMode()
......@@ -2038,7 +2038,7 @@ void ViewerPrivate::slotToggleHtmlMode()
mScamDetectionWarning->setVisible(false);
const bool useHtml = !htmlMail();
setDisplayFormatMessageOverwrite(useHtml ? MessageViewer::Viewer::Html : MessageViewer::Viewer::Text);
update(Viewer::Force);
update(Force);
}
void ViewerPrivate::slotFind()
......@@ -2053,7 +2053,7 @@ void ViewerPrivate::slotFind()
void ViewerPrivate::slotToggleFixedFont()
{
mUseFixedFont = !mUseFixedFont;
update(Viewer::Force);
update(Force);
}
void ViewerPrivate::slotToggleMimePartTree()
......@@ -2156,7 +2156,7 @@ void ViewerPrivate::slotMimePartSelected(const QModelIndex &index)
#ifndef QT_NO_TREEVIEW
KMime::Content *content = static_cast<KMime::Content *>(index.internalPointer());
if (!mMimePartTree->mimePartModel()->parent(index).isValid() && index.row() == 0) {
update(Viewer::Force);
update(Force);
} else {
setMessagePart(content);
}
......@@ -2246,7 +2246,7 @@ void ViewerPrivate::slotSetEncoding()
} else {
mOverrideEncoding = NodeHelper::encodingForName(mSelectEncodingAction->currentText());
}
update(Viewer::Force);
update(Force);
}
QString ViewerPrivate::picsPath()
......@@ -2305,7 +2305,7 @@ void ViewerPrivate::injectAttachments()
void ViewerPrivate::slotSettingsChanged()
{
update(Viewer::Force);
update(Force);
}
void ViewerPrivate::slotMimeTreeContextMenuRequested(const QPoint &pos)
......@@ -2509,7 +2509,7 @@ void ViewerPrivate::slotLevelQuote(int l)
{
if (mLevelQuote != l) {
mLevelQuote = l;
update(Viewer::Force);
update(Force);
}
}
......@@ -2808,7 +2808,7 @@ void ViewerPrivate::slotItemChanged(const Akonadi::Item &item, const QSet<QByteA
return;
}
if (parts.contains("PLD:RFC822")) {
setMessageItem(item, Viewer::Force);
setMessageItem(item, Force);
}
}
......@@ -2823,7 +2823,7 @@ void ViewerPrivate::slotItemMoved(const Akonadi::Item &item, const Akonadi::Coll
void ViewerPrivate::slotClear()
{
q->clear(Viewer::Force);
q->clear(Force);
Q_EMIT itemRemoved();
}
......@@ -2991,7 +2991,7 @@ void ViewerPrivate::addHelpTextAction(QAction *act, const QString &text)
void ViewerPrivate::slotRefreshMessage(const Akonadi::Item &item)
{
if (item.id() == mMessageItem.id()) {
setMessageItem(item, MessageViewer::Viewer::Force);
setMessageItem(item, MessageViewer::Force);
}
}
......
......@@ -314,20 +314,20 @@ public:
void resetStateForNewMessage();
void setMessageInternal(const KMime::Message::Ptr &message, Viewer::UpdateMode updateMode);
void setMessageInternal(const KMime::Message::Ptr &message, UpdateMode updateMode);
/** Set the Akonadi item that will be displayed.
* @param item - the Akonadi item to be displayed. If it doesn't hold a mail (KMime::Message::Ptr as payload data),
* an empty page is shown.
* @param updateMode - update the display immediately or not. See MailViewer::UpdateMode.
*/
void setMessageItem(const Akonadi::Item &item, Viewer::UpdateMode updateMode = Viewer::Delayed);
void setMessageItem(const Akonadi::Item &item, UpdateMode updateMode = Delayed);
/** Set the message that shall be shown.
* @param msg - the message to be shown. If 0, an empty page is displayed.
* @param updateMode - update the display immediately or not. See MailViewer::UpdateMode.
*/
void setMessage(const KMime::Message::Ptr &msg, Viewer::UpdateMode updateMode = Viewer::Delayed);
void setMessage(const KMime::Message::Ptr &msg, UpdateMode updateMode = Delayed);
/** Instead of settings a message to be shown sets a message part
to be shown */
......@@ -553,7 +553,7 @@ public Q_SLOTS:
void slotUrlCopy();
void slotSaveMessage();
/** Re-parse the current message. */
void update(MessageViewer::Viewer::UpdateMode updateMode = Viewer::Delayed);
void update(MessageViewer::UpdateMode updateMode = Delayed);
void slotSpeakText();
void slotCopyImageLocation();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment