Commit 3905a5cd authored by Laurent Montel's avatar Laurent Montel 😁

Allow to debug mode

parent 75d88687
......@@ -57,6 +57,12 @@ bool MailViewerSource::showSignatureDetails() const
void MailViewerSource::setHtmlMode(MimeTreeParser::Util::HtmlMode mode, const QList<MimeTreeParser::Util::HtmlMode> &availableModes)
{
qDebug() << " void MailViewerSource::setHtmlMode(MimeTreeParser::Util::HtmlMode mode, const QList<MimeTreeParser::Util::HtmlMode> &availableModes)";
for (int i = 0; i < availableModes.count(); ++i) {
qDebug() << "MailViewerSource::setHtmlMode Mode " << MimeTreeParser::Util::htmlModeToString(availableModes.at(i));
}
qDebug() << "MailViewerSource::setHtmlMode prefered " << MimeTreeParser::Util::htmlModeToString(mode);
mViewer->mColorBar->setAvailableModes(availableModes);
mViewer->mColorBar->setMode(mode);
}
......
......@@ -2166,8 +2166,12 @@ Viewer::DisplayFormatMessage translateToDisplayFormat(MimeTreeParser::Util::Html
void ViewerPrivate::slotToggleHtmlMode()
{
const auto availableModes = mColorBar->availableModes();
const auto availableModes = mColorBar->availableModes();
const int availableModeSize(availableModes.size());
for (int i = 0; i < availableModeSize; ++i) {
qDebug() << " Mode " << MimeTreeParser::Util::htmlModeToString(availableModes.at(i));
}
qDebug() << " availableModeSize"<<availableModeSize;
if (mColorBar->isNormal() || availableModeSize < 2) {
return;
}
......@@ -2176,6 +2180,11 @@ void ViewerPrivate::slotToggleHtmlMode()
const int pos = (availableModes.indexOf(mode) + 1) % availableModeSize;
setDisplayFormatMessageOverwrite(translateToDisplayFormat(availableModes[pos]));
update(MimeTreeParser::Force);
for (int i = 0; i < availableModeSize; ++i) {
qDebug() << "AFTER Mode " << MimeTreeParser::Util::htmlModeToString(availableModes.at(i));
}
qDebug() << " Assign modes " << availableModes;
mColorBar->setAvailableModes(availableModes);
}
......
......@@ -27,6 +27,7 @@
#include <QMimeDatabase>
#include <QString>
using namespace MimeTreeParser;
using namespace MimeTreeParser::Util;
bool MimeTreeParser::Util::isTypeBlacklisted(KMime::Content *node)
......@@ -127,10 +128,28 @@ QString MimeTreeParser::Util::iconNameForContent(KMime::Content *node)
QByteArray mimeType = node->contentType()->mimeType();
if (mimeType.isNull() || mimeType == "application/octet-stream") {
const QString mime = mimetype(node->contentDisposition()->filename()).name();
const QString mime = MimeTreeParser::Util::mimetype(node->contentDisposition()->filename()).name();
mimeType = mime.toLatin1();
}
mimeType = mimeType.toLower();
return iconNameForMimetype(QLatin1String(mimeType), node->contentDisposition()->filename(),
return MimeTreeParser::Util::iconNameForMimetype(QLatin1String(mimeType), node->contentDisposition()->filename(),
node->contentType()->name());
}
QString MimeTreeParser::Util::htmlModeToString(HtmlMode mode)
{
switch (mode) {
case Normal: ///< A normal plaintext message, non-multipart
return QStringLiteral("Normal PlainText Message, non-multipart");
case Html: ///< A HTML message, non-multipart
return QStringLiteral("A HTML message, non-multipart");
case MultipartPlain: ///< A multipart/alternative message, the plain text part is currently displayed
return QStringLiteral("A multipart/alternative message, the plain text part is currently displayed");
case MultipartHtml: ///< A multipart/altervative message, the HTML part is currently displayed
return QStringLiteral("A multipart/altervative message, the HTML part is currently displayed");
case MultipartIcal: ///< A multipart/altervative message, the ICal part is currently displayed
return QStringLiteral("A multipart/altervative message, the ICal part is currently displayed");
}
return {};
}
......@@ -47,15 +47,17 @@ enum HtmlMode {
MultipartIcal ///< A multipart/altervative message, the ICal part is currently displayed
};
bool MIMETREEPARSER_EXPORT isTypeBlacklisted(KMime::Content *node);
MIMETREEPARSER_EXPORT QString htmlModeToString(Util::HtmlMode mode);
QString MIMETREEPARSER_EXPORT labelForContent(KMime::Content *node);
MIMETREEPARSER_EXPORT bool isTypeBlacklisted(KMime::Content *node);
QMimeType MIMETREEPARSER_EXPORT mimetype(const QString &name);
MIMETREEPARSER_EXPORT QString labelForContent(KMime::Content *node);
QString MIMETREEPARSER_EXPORT iconNameForMimetype(const QString &mimeType, const QString &fallbackFileName1 = QString(), const QString &fallbackFileName2 = QString());
MIMETREEPARSER_EXPORT QMimeType mimetype(const QString &name);
QString MIMETREEPARSER_EXPORT iconNameForContent(KMime::Content *node);
MIMETREEPARSER_EXPORT QString iconNameForMimetype(const QString &mimeType, const QString &fallbackFileName1 = QString(), const QString &fallbackFileName2 = QString());
MIMETREEPARSER_EXPORT QString iconNameForContent(KMime::Content *node);
}
}
......
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