Commit 104167ad authored by Carl Schwan's avatar Carl Schwan 🚴
Browse files

Make InfoPart and TextPart API more QML friendly

parent 6c0d587e
Pipeline #57413 passed with stage
in 44 minutes and 52 seconds
......@@ -48,7 +48,11 @@ QString InfoPart::from() const
void InfoPart::setFrom(const QString &from)
{
if (d->from == from) {
return;
}
d->from = from;
Q_EMIT fromChanged();
}
QStringList InfoPart::to() const
......@@ -58,7 +62,11 @@ QStringList InfoPart::to() const
void InfoPart::setTo(const QStringList &to)
{
if (d->to == to) {
return;
}
d->to = to;
Q_EMIT toChanged();
}
QStringList InfoPart::cc() const
......@@ -68,7 +76,11 @@ QStringList InfoPart::cc() const
void InfoPart::setCc(const QStringList &cc)
{
if (d->cc == cc) {
return;
}
d->cc = cc;
Q_EMIT ccChanged();
}
QStringList InfoPart::bcc() const
......@@ -78,7 +90,11 @@ QStringList InfoPart::bcc() const
void InfoPart::setBcc(const QStringList &bcc)
{
if (d->bcc == bcc) {
return;
}
d->bcc = bcc;
Q_EMIT bccChanged();
}
QString InfoPart::subject() const
......@@ -88,7 +104,11 @@ QString InfoPart::subject() const
void InfoPart::setSubject(const QString &subject)
{
if (d->subject == subject) {
return;
}
d->subject = subject;
Q_EMIT subjectChanged();
}
QStringList InfoPart::replyTo() const
......@@ -98,7 +118,11 @@ QStringList InfoPart::replyTo() const
void InfoPart::setReplyTo(const QStringList &replyTo)
{
if (d->replyTo == replyTo) {
return;
}
d->replyTo = replyTo;
Q_EMIT replyToChanged();
}
int InfoPart::transportId() const
......@@ -113,7 +137,11 @@ void InfoPart::setTransportId(int tid)
void InfoPart::setFcc(const QString &fcc)
{
if (d->fcc == fcc) {
return;
}
d->fcc = fcc;
Q_EMIT fccChanged();
}
QString InfoPart::fcc() const
......@@ -128,7 +156,11 @@ bool InfoPart::urgent() const
void InfoPart::setUrgent(bool urgent)
{
if (d->urgent == urgent) {
return;
}
d->urgent = urgent;
Q_EMIT urgentChanged();
}
QString InfoPart::inReplyTo() const
......@@ -138,7 +170,11 @@ QString InfoPart::inReplyTo() const
void InfoPart::setInReplyTo(const QString &inReplyTo)
{
if (d->inReplyTo == inReplyTo) {
return;
}
d->inReplyTo = inReplyTo;
Q_EMIT inReplyToChanged();
}
QString InfoPart::references() const
......@@ -168,5 +204,9 @@ QString InfoPart::userAgent() const
void InfoPart::setUserAgent(const QString &userAgent)
{
if (d->userAgent == userAgent) {
return;
}
d->userAgent = userAgent;
Q_EMIT userAgentChanged();
}
......@@ -15,12 +15,43 @@
namespace MessageComposer
{
/**
* @brief The InfoPart class
* @brief The InfoPart class contains the message header.
*/
class MESSAGECOMPOSER_EXPORT InfoPart : public MessageComposer::MessagePart
{
Q_OBJECT
/// The email address and optionally the name of the author of the mail.
Q_PROPERTY(QString from READ from WRITE setFrom NOTIFY fromChanged)
/// The email address and optionally the name of the primary recipients.
Q_PROPERTY(QStringList to READ to WRITE setTo NOTIFY toChanged)
/// Carbon copy: The email address and optionally the name of the secondary recipients.
Q_PROPERTY(QStringList cc READ cc WRITE setCc NOTIFY ccChanged)
/// Blind Carbon copy: The email address and optionally the name of the secondary recipients.
/// Only specified during SMTP delivery but not in the final mail delivery.
Q_PROPERTY(QStringList bcc READ bcc WRITE setBcc NOTIFY bccChanged)
/// Reply-To: Email address that should be used to reply to this mail.
Q_PROPERTY(QStringList replyTo READ replyTo WRITE setReplyTo NOTIFY replyToChanged)
/// Subject of the message.
Q_PROPERTY(QString subject READ subject WRITE setSubject NOTIFY subjectChanged)
/// The name of a file, to which a copy of the sent message should be appended.
Q_PROPERTY(QString fcc READ fcc WRITE setFcc NOTIFY fccChanged)
/// User agent of the sender.
Q_PROPERTY(QString userAgent READ userAgent WRITE setUserAgent NOTIFY userAgentChanged)
/// Set urgency of the message.
Q_PROPERTY(bool urgent READ urgent WRITE setUrgent NOTIFY urgentChanged)
/// In-Reply-To: Id of the message this message is a reply to.
Q_PROPERTY(QString inReplyTo READ inReplyTo WRITE setInReplyTo NOTIFY inReplyToChanged)
public:
explicit InfoPart(QObject *parent = nullptr);
~InfoPart() override;
......@@ -61,6 +92,18 @@ public:
Q_REQUIRED_RESULT int transportId() const;
void setTransportId(int tid);
Q_SIGNALS:
void toChanged();
void fromChanged();
void ccChanged();
void bccChanged();
void replyToChanged();
void subjectChanged();
void urgentChanged();
void userAgentChanged();
void inReplyToChanged();
void fccChanged();
private:
class Private;
Private *const d;
......
......@@ -41,7 +41,11 @@ bool TextPart::isWordWrappingEnabled() const
void TextPart::setWordWrappingEnabled(bool enabled)
{
if (d->wordWrappingEnabled == enabled) {
return;
}
d->wordWrappingEnabled = enabled;
Q_EMIT wordWrappingChanged();
}
bool TextPart::warnBadCharset() const
......@@ -51,7 +55,11 @@ bool TextPart::warnBadCharset() const
void TextPart::setWarnBadCharset(bool warn)
{
if (d->warnBadCharset == warn) {
return;
}
d->warnBadCharset = warn;
Q_EMIT warnBadCharsetChanged();
}
QString TextPart::cleanPlainText() const
......@@ -61,7 +69,11 @@ QString TextPart::cleanPlainText() const
void TextPart::setCleanPlainText(const QString &text)
{
if (d->cleanPlainText == text) {
return;
}
d->cleanPlainText = text;
Q_EMIT cleanPlainTextChanged();
}
QString TextPart::wrappedPlainText() const
......@@ -71,7 +83,11 @@ QString TextPart::wrappedPlainText() const
void TextPart::setWrappedPlainText(const QString &text)
{
if (d->wrappedPlainText == text) {
return;
}
d->wrappedPlainText = text;
Q_EMIT wrappedPlainTextChanged();
}
bool TextPart::isHtmlUsed() const
......@@ -86,7 +102,11 @@ QString TextPart::cleanHtml() const
void TextPart::setCleanHtml(const QString &text)
{
if (d->cleanHtml == text) {
return;
}
d->cleanHtml = text;
Q_EMIT cleanHtmlChanged();
}
bool TextPart::hasEmbeddedImages() const
......
......@@ -21,6 +21,19 @@ class MESSAGECOMPOSER_EXPORT TextPart : public MessagePart
{
Q_OBJECT
/// True iff the text is word wrapped. By default: true.
Q_PROPERTY(bool isWordWrappingEnabled READ isWordWrappingEnabled WRITE setWordWrappingEnabled NOTIFY wordWrappingChanged)
/// Default true.
Q_PROPERTY(bool warnBadCharset READ warnBadCharset WRITE setWarnBadCharset NOTIFY warnBadCharsetChanged)
Q_PROPERTY(QString cleanPlainText READ cleanPlainText WRITE setCleanPlainText NOTIFY cleanPlainTextChanged)
Q_PROPERTY(QString wrappedPlainText READ wrappedPlainText WRITE setWrappedPlainText NOTIFY wrappedPlainTextChanged)
Q_PROPERTY(QString cleanHtml READ cleanHtml WRITE setCleanHtml NOTIFY cleanHtmlChanged)
Q_PROPERTY(bool isHtmlUsed READ isHtmlUsed NOTIFY cleanHtmlChanged)
Q_PROPERTY(bool hasEmbeddedImages READ hasEmbeddedImages NOTIFY embeddedImagesChanged)
Q_PROPERTY(KPIMTextEdit::ImageList embeddedImages READ embeddedImages WRITE setEmbeddedImages NOTIFY embeddedImagesChanged)
public:
explicit TextPart(QObject *parent = nullptr);
~TextPart() override;
......@@ -45,6 +58,14 @@ public:
Q_REQUIRED_RESULT KPIMTextEdit::ImageList embeddedImages() const;
void setEmbeddedImages(const KPIMTextEdit::ImageList &images);
Q_SIGNALS:
void wordWrappingChanged();
void warnBadCharsetChanged();
void cleanPlainTextChanged();
void wrappedPlainTextChanged();
void cleanHtmlChanged();
void embeddedImagesChanged();
private:
class Private;
Private *const d;
......
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