From bd098e7ed6f8e52e3b97f60def974c5d8c47369a Mon Sep 17 00:00:00 2001 From: Michael Bohlender Date: Thu, 4 Feb 2016 16:47:08 +0100 Subject: inintial composer controller + hook up to composer ui --- framework/mail/CMakeLists.txt | 1 + framework/mail/composer.cpp | 109 ++++++++++++++++++++++++++++++++++++++++++ framework/mail/composer.h | 71 +++++++++++++++++++++++++++ framework/mail/mailplugin.cpp | 2 + 4 files changed, 183 insertions(+) create mode 100644 framework/mail/composer.cpp create mode 100644 framework/mail/composer.h (limited to 'framework') diff --git a/framework/mail/CMakeLists.txt b/framework/mail/CMakeLists.txt index 9957adc3..6616e492 100644 --- a/framework/mail/CMakeLists.txt +++ b/framework/mail/CMakeLists.txt @@ -9,6 +9,7 @@ set(mailplugin_SRCS objecttreesource.cpp stringhtmlwriter.cpp csshelper.cpp + composer.cpp ) add_definitions(-DMAIL_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data") diff --git a/framework/mail/composer.cpp b/framework/mail/composer.cpp new file mode 100644 index 00000000..aa1ec7fc --- /dev/null +++ b/framework/mail/composer.cpp @@ -0,0 +1,109 @@ +/* + Copyright (c) 2016 Michael Bohlender + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + This library 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 Library General Public + License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + + +#include "composer.h" + +Composer::Composer(QObject *parent) : QObject(parent) +{ + +} + +QString Composer::to() const +{ + return m_to; +} + +void Composer::setTo(const QString &to) +{ + if(m_to != to) { + m_to = to; + emit toChanged(); + } +} + +QString Composer::cc() const +{ + return m_cc; +} + +void Composer::setCc(const QString &cc) +{ + if(m_cc != cc) { + m_cc = cc; + emit ccChanged(); + } +} + +QString Composer::bcc() const +{ + return m_bcc; +} + +void Composer::setBcc(const QString &bcc) +{ + if(m_bcc != bcc) { + m_bcc = bcc; + emit bccChanged(); + } +} + +QString Composer::subject() const +{ + return m_subject; +} + +void Composer::setSubject(const QString &subject) +{ + if(m_subject != subject) { + m_subject = subject; + emit subjectChanged(); + } +} + +QString Composer::body() const +{ + return m_body; +} + +void Composer::setBody(const QString &body) +{ + if(m_body != body) { + m_body = body; + emit bodyChanged(); + } +} + +void Composer::send() +{ + //TODO + clear(); +} + +void Composer::saveAsDraft() +{ + //TODO + clear(); +} + +void Composer::clear() +{ + setSubject(""); + setBody(""); +} \ No newline at end of file diff --git a/framework/mail/composer.h b/framework/mail/composer.h new file mode 100644 index 00000000..a9741f6b --- /dev/null +++ b/framework/mail/composer.h @@ -0,0 +1,71 @@ +/* + Copyright (c) 2016 Michael Bohlender + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + This library 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 Library General Public + License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + +#pragma once + +#include +#include + + +class Composer : public QObject +{ + Q_OBJECT + Q_PROPERTY (QString to READ to WRITE setTo NOTIFY toChanged) + Q_PROPERTY (QString cc READ cc WRITE setCc NOTIFY ccChanged) + Q_PROPERTY (QString bcc READ bcc WRITE setBcc NOTIFY bccChanged) + Q_PROPERTY (QString subject READ subject WRITE setSubject NOTIFY subjectChanged) + Q_PROPERTY (QString body READ body WRITE setBody NOTIFY bodyChanged) + +public: + explicit Composer(QObject *parent = Q_NULLPTR); + + QString to() const; + void setTo(const QString &to); + + QString cc() const; + void setCc(const QString &cc); + + QString bcc() const; + void setBcc(const QString &bcc); + + QString subject() const; + void setSubject(const QString &subject); + + QString body() const; + void setBody(const QString &body); + +signals: + void subjectChanged(); + void bodyChanged(); + void toChanged(); + void ccChanged(); + void bccChanged(); + +public slots: + void send(); + void saveAsDraft(); + void clear(); + +private: + QString m_to; + QString m_cc; + QString m_bcc; + QString m_subject; + QString m_body; +}; diff --git a/framework/mail/mailplugin.cpp b/framework/mail/mailplugin.cpp index 8b35dfb7..691d4a15 100644 --- a/framework/mail/mailplugin.cpp +++ b/framework/mail/mailplugin.cpp @@ -22,6 +22,7 @@ #include "maillistmodel.h" #include "folderlistmodel.h" +#include "composer.h" #include @@ -31,4 +32,5 @@ void MailPlugin::registerTypes (const char *uri) qmlRegisterType(uri, 1, 0, "FolderListModel"); qmlRegisterType(uri, 1, 0, "MailListModel"); + qmlRegisterType(uri, 1, 0, "Composer"); } -- cgit v1.2.3