File indexing completed on 2024-06-23 05:18:34

0001 /*
0002   SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com>
0003 
0004   SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "textpart.h"
0008 
0009 using namespace MessageComposer;
0010 
0011 class TextPart::TextPartPrivate
0012 {
0013 public:
0014     TextPartPrivate() = default;
0015 
0016     KPIMTextEdit::ImageList embeddedImages;
0017     QString cleanPlainText;
0018     QString wrappedPlainText;
0019     QString cleanHtml;
0020     bool wordWrappingEnabled = true;
0021     bool warnBadCharset = true;
0022 };
0023 
0024 TextPart::TextPart(QObject *parent)
0025     : MessagePart(parent)
0026     , d(new TextPartPrivate)
0027 {
0028 }
0029 
0030 TextPart::~TextPart() = default;
0031 
0032 bool TextPart::isWordWrappingEnabled() const
0033 {
0034     return d->wordWrappingEnabled;
0035 }
0036 
0037 void TextPart::setWordWrappingEnabled(bool enabled)
0038 {
0039     if (d->wordWrappingEnabled == enabled) {
0040         return;
0041     }
0042     d->wordWrappingEnabled = enabled;
0043     Q_EMIT wordWrappingChanged();
0044 }
0045 
0046 bool TextPart::warnBadCharset() const
0047 {
0048     return d->warnBadCharset;
0049 }
0050 
0051 void TextPart::setWarnBadCharset(bool warn)
0052 {
0053     if (d->warnBadCharset == warn) {
0054         return;
0055     }
0056     d->warnBadCharset = warn;
0057     Q_EMIT warnBadCharsetChanged();
0058 }
0059 
0060 QString TextPart::cleanPlainText() const
0061 {
0062     return d->cleanPlainText;
0063 }
0064 
0065 void TextPart::setCleanPlainText(const QString &text)
0066 {
0067     if (d->cleanPlainText == text) {
0068         return;
0069     }
0070     d->cleanPlainText = text;
0071     Q_EMIT cleanPlainTextChanged();
0072 }
0073 
0074 QString TextPart::wrappedPlainText() const
0075 {
0076     return d->wrappedPlainText;
0077 }
0078 
0079 void TextPart::setWrappedPlainText(const QString &text)
0080 {
0081     if (d->wrappedPlainText == text) {
0082         return;
0083     }
0084     d->wrappedPlainText = text;
0085     Q_EMIT wrappedPlainTextChanged();
0086 }
0087 
0088 bool TextPart::isHtmlUsed() const
0089 {
0090     return !d->cleanHtml.isEmpty();
0091 }
0092 
0093 QString TextPart::cleanHtml() const
0094 {
0095     return d->cleanHtml;
0096 }
0097 
0098 void TextPart::setCleanHtml(const QString &text)
0099 {
0100     if (d->cleanHtml == text) {
0101         return;
0102     }
0103     d->cleanHtml = text;
0104     Q_EMIT cleanHtmlChanged();
0105 }
0106 
0107 bool TextPart::hasEmbeddedImages() const
0108 {
0109     return !d->embeddedImages.isEmpty();
0110 }
0111 
0112 KPIMTextEdit::ImageList TextPart::embeddedImages() const
0113 {
0114     return d->embeddedImages;
0115 }
0116 
0117 void TextPart::setEmbeddedImages(const KPIMTextEdit::ImageList &images)
0118 {
0119     d->embeddedImages = images;
0120 }
0121 
0122 #include "moc_textpart.cpp"