Commit e5c508e5 authored by Sandro Knauß's avatar Sandro Knauß

get rid of objectTreeParser()->showOnlyOneMimePart()

Summary:
the showOnlyOneMimePart setting is strange and mostly unused
 in objecttreeparser. Only used once at processing and later needed for the renderer.

Test Plan: run tests

Reviewers: vkrause

Subscribers: #kde_pim

Tags: #kde_pim

Differential Revision: https://phabricator.kde.org/D8573
parent 035cbe26
......@@ -989,10 +989,10 @@ void ViewerPrivate::parseContent(KMime::Content *content)
mNodeHelper->removeTempFiles();
mNodeHelper->setNodeUnprocessed(mMessage.data(), true);
MailViewerSource otpSource(this);
MimeTreeParser::ObjectTreeParser otp(&otpSource, mNodeHelper,
mMessage.data() != content /* show only single node */);
MimeTreeParser::ObjectTreeParser otp(&otpSource, mNodeHelper);
//TODO: needs to end up in renderer: mMessage.data() != content /* show only single node */);
otp.setAllowAsync(!mPrinting);
otp.parseObjectTree(content);
otp.parseObjectTree(content, mMessage.data() != content /* parse/show only single node */);
// TODO: Setting the signature state to nodehelper is not enough, it should actually
// be added to the store, so that the message list correctly displays the signature state
......
......@@ -72,7 +72,7 @@ MessagePart::Ptr ApplicationPGPEncryptedBodyPartFormatter::process(Interface::Bo
part.nodeHelper()->setNodeProcessed(data, false); // Set the data node to done to prevent it from being processed
} else if (KMime::Content *newNode = part.nodeHelper()->decryptedNodeForContent(data)) {
// if we already have a decrypted node for this encrypted node, don't do the decryption again
return MessagePart::Ptr(new MimeMessagePart(part.objectTreeParser(), newNode, part.objectTreeParser()->showOnlyOneMimePart()));
return MessagePart::Ptr(new MimeMessagePart(part.objectTreeParser(), newNode, false));
} else {
mp->startDecryption(data);
if (!messagePart->inProgress) {
......
......@@ -47,7 +47,6 @@ MessagePart::Ptr TextPlainBodyPartFormatter::process(Interface::BodyPart &part)
QString label = NodeHelper::fileName(node);
const bool bDrawFrame = !isFirstTextPart
&& !part.objectTreeParser()->showOnlyOneMimePart()
&& !label.isEmpty();
TextMessagePart::Ptr mp;
......
......@@ -109,7 +109,7 @@ public:
auto preferredMode = part.source()->preferredMode();
bool isHtmlPreferred = (preferredMode == Util::Html) || (preferredMode == Util::MultipartHtml);
if (node->parent() && node->parent()->contentType()->subType() == "related" && isHtmlPreferred && !part.objectTreeParser()->showOnlyOneMimePart()) {
if (node->parent() && node->parent()->contentType()->subType() == "related" && isHtmlPreferred) {
QString fileName = mp->temporaryFilePath();
QString href = QUrl::fromLocalFile(fileName).url();
QByteArray cid = node->contentID()->identifier();
......@@ -123,7 +123,7 @@ public:
// Show it inline if showOnlyOneMimePart(), which means the user clicked the image
// in the message structure viewer manually, and therefore wants to see the full image
if (part.objectTreeParser()->showOnlyOneMimePart() && !part.processResult()->neverDisplayInline()) {
if (false && !part.processResult()->neverDisplayInline()) {
part.nodeHelper()->setNodeDisplayedEmbedded(node, true);
}
......
......@@ -181,11 +181,6 @@ bool MessagePart::isHtml() const
return false;
}
bool MessagePart::isHidden() const
{
return false;
}
Interface::ObjectTreeSource *MessagePart::source() const
{
Q_ASSERT(mOtp);
......@@ -278,7 +273,6 @@ TextMessagePart::TextMessagePart(ObjectTreeParser *otp, KMime::Content *node, bo
: MessagePartList(otp)
, mDrawFrame(drawFrame)
, mDecryptMessage(decryptMessage)
, mIsHidden(false)
{
if (!node) {
qCWarning(MIMETREEPARSER_LOG) << "not a valid node";
......@@ -286,7 +280,6 @@ TextMessagePart::TextMessagePart(ObjectTreeParser *otp, KMime::Content *node, bo
}
setContent(node);
mIsHidden = mOtp->nodeHelper()->isNodeDisplayedHidden(node);
parseContent();
}
......@@ -387,11 +380,6 @@ KMMsgSignatureState TextMessagePart::signatureState() const
return mSignatureState;
}
bool TextMessagePart::isHidden() const
{
return mIsHidden;
}
bool TextMessagePart::showLink() const
{
return !temporaryFilePath().isEmpty();
......
......@@ -68,7 +68,6 @@ class MIMETREEPARSER_EXPORT MessagePart : public QObject
Q_PROPERTY(bool isAttachment READ isAttachment)
Q_PROPERTY(bool root READ isRoot)
Q_PROPERTY(bool isHtml READ isHtml)
Q_PROPERTY(bool isHidden READ isHidden)
Q_PROPERTY(QString attachmentIndex READ attachmentIndex CONSTANT)
Q_PROPERTY(QString link READ attachmentLink CONSTANT)
public:
......@@ -112,7 +111,6 @@ public:
bool isRoot() const;
virtual bool isHtml() const;
virtual bool isHidden() const;
PartMetaData *partMetaData() const;
......@@ -195,8 +193,6 @@ public:
bool decryptMessage() const;
bool isHidden() const override;
bool showLink() const;
bool showTextFrame() const;
void setShowTextFrame(bool showFrame);
......@@ -215,7 +211,6 @@ private:
KMMsgEncryptionState mEncryptionState;
bool mDrawFrame;
bool mDecryptMessage;
bool mIsHidden;
friend class ObjectTreeParser;
};
......@@ -228,14 +223,11 @@ public:
AttachmentMessagePart(MimeTreeParser::ObjectTreeParser *otp, KMime::Content *node, bool drawFrame, bool decryptMessage);
virtual ~AttachmentMessagePart();
//IconType asIcon() const;
bool neverDisplayInline() const;
void setNeverDisplayInline(bool displayInline);
bool isImage() const;
void setIsImage(bool image);
//bool isHidden() const override;
private:
bool mIsImage;
bool mNeverDisplayInline;
......
......@@ -60,24 +60,22 @@
using namespace MimeTreeParser;
ObjectTreeParser::ObjectTreeParser(const ObjectTreeParser *topLevelParser, bool showOnlyOneMimePart)
ObjectTreeParser::ObjectTreeParser(const ObjectTreeParser *topLevelParser)
: mSource(topLevelParser->mSource)
, mNodeHelper(topLevelParser->mNodeHelper)
, mHtmlWriter(topLevelParser->mHtmlWriter)
, mTopLevelContent(topLevelParser->mTopLevelContent)
, mShowOnlyOneMimePart(showOnlyOneMimePart)
, mHasPendingAsyncJobs(false)
, mAllowAsync(topLevelParser->mAllowAsync)
{
init();
}
ObjectTreeParser::ObjectTreeParser(Interface::ObjectTreeSource *source, MimeTreeParser::NodeHelper *nodeHelper, bool showOnlyOneMimePart)
ObjectTreeParser::ObjectTreeParser(Interface::ObjectTreeSource *source, MimeTreeParser::NodeHelper *nodeHelper)
: mSource(source)
, mNodeHelper(nodeHelper)
, mHtmlWriter(nullptr)
, mTopLevelContent(nullptr)
, mShowOnlyOneMimePart(showOnlyOneMimePart)
, mHasPendingAsyncJobs(false)
, mAllowAsync(false)
{
......@@ -102,7 +100,6 @@ ObjectTreeParser::ObjectTreeParser(const ObjectTreeParser &other)
, //TODO(Andras) hm, review what happens if mDeleteNodeHelper was true in the source
mHtmlWriter(other.mHtmlWriter)
, mTopLevelContent(other.mTopLevelContent)
, mShowOnlyOneMimePart(other.showOnlyOneMimePart())
, mHasPendingAsyncJobs(other.hasPendingAsyncJobs())
, mAllowAsync(other.allowAsync())
, mDeleteNodeHelper(false)
......@@ -157,10 +154,10 @@ void ObjectTreeParser::copyContentFrom(const ObjectTreeParser *other)
//-----------------------------------------------------------------------------
void ObjectTreeParser::parseObjectTree(KMime::Content *node)
void ObjectTreeParser::parseObjectTree(KMime::Content *node, bool parseOnlySingleNode)
{
mTopLevelContent = node;
mParsedPart = parseObjectTreeInternal(node, showOnlyOneMimePart());
mParsedPart = parseObjectTreeInternal(node, parseOnlySingleNode);
if (mParsedPart) {
mParsedPart->fix();
......@@ -176,7 +173,7 @@ void ObjectTreeParser::parseObjectTree(KMime::Content *node)
}
if (htmlWriter()) {
mSource->render(mParsedPart, htmlWriter());
mSource->render(mParsedPart, htmlWriter(), parseOnlySingleNode);
}
}
}
......@@ -346,16 +343,6 @@ QByteArray ObjectTreeParser::htmlContentCharset() const
return mHtmlContentCharset;
}
bool ObjectTreeParser::showOnlyOneMimePart() const
{
return mShowOnlyOneMimePart;
}
void ObjectTreeParser::setShowOnlyOneMimePart(bool show)
{
mShowOnlyOneMimePart = show;
}
HtmlWriter *ObjectTreeParser::htmlWriter() const
{
if (mHtmlWriter) {
......
......@@ -270,9 +270,9 @@ class MIMETREEPARSER_EXPORT ObjectTreeParser
ObjectTreeParser(const ObjectTreeParser &other);
public:
explicit ObjectTreeParser(Interface::ObjectTreeSource *source, NodeHelper *nodeHelper = nullptr, bool showOneMimePart = false);
explicit ObjectTreeParser(Interface::ObjectTreeSource *source, NodeHelper *nodeHelper = nullptr);
explicit ObjectTreeParser(const ObjectTreeParser *topLevelParser, bool showOneMimePart = false);
explicit ObjectTreeParser(const ObjectTreeParser *topLevelParser);
virtual ~ObjectTreeParser();
void setAllowAsync(bool allow);
......@@ -304,16 +304,13 @@ public:
QByteArray plainTextContentCharset() const;
QByteArray htmlContentCharset() const;
bool showOnlyOneMimePart() const;
void setShowOnlyOneMimePart(bool show);
HtmlWriter *htmlWriter() const;
NodeHelper *nodeHelper() const;
/** Parse beginning at a given node and recursively parsing
the children of that node and it's next sibling. */
void parseObjectTree(KMime::Content *node);
void parseObjectTree(KMime::Content *node, bool parseOnlySingleNode=false);
MessagePartPtr parsedPart() const;
private:
......
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