diff options
-rw-r--r-- | framework/mail/CMakeLists.txt | 1 | ||||
-rw-r--r-- | framework/mail/folderlistcontroller.cpp | 44 | ||||
-rw-r--r-- | framework/mail/folderlistcontroller.h | 35 | ||||
-rw-r--r-- | framework/mail/mailplugin.cpp | 8 |
4 files changed, 88 insertions, 0 deletions
diff --git a/framework/mail/CMakeLists.txt b/framework/mail/CMakeLists.txt index f1c14470..7d7569a7 100644 --- a/framework/mail/CMakeLists.txt +++ b/framework/mail/CMakeLists.txt | |||
@@ -4,6 +4,7 @@ set(mailplugin_SRCS | |||
4 | maillistmodel.cpp | 4 | maillistmodel.cpp |
5 | singlemailcontroller.cpp | 5 | singlemailcontroller.cpp |
6 | folderlistmodel.cpp | 6 | folderlistmodel.cpp |
7 | folderlistcontroller.cpp | ||
7 | ) | 8 | ) |
8 | 9 | ||
9 | add_library(mailplugin SHARED ${mailplugin_SRCS}) | 10 | add_library(mailplugin SHARED ${mailplugin_SRCS}) |
diff --git a/framework/mail/folderlistcontroller.cpp b/framework/mail/folderlistcontroller.cpp new file mode 100644 index 00000000..900e378d --- /dev/null +++ b/framework/mail/folderlistcontroller.cpp | |||
@@ -0,0 +1,44 @@ | |||
1 | #include "folderlistcontroller.h" | ||
2 | |||
3 | #include "folderlistmodel.h" | ||
4 | |||
5 | #include <QDebug> | ||
6 | |||
7 | FolderListController::FolderListController(QObject *parent) : QObject(parent), m_model(new FolderListModel) | ||
8 | { | ||
9 | |||
10 | } | ||
11 | |||
12 | QString FolderListController::accountId() const | ||
13 | { | ||
14 | return m_accountId; | ||
15 | } | ||
16 | |||
17 | void FolderListController::setAccountId(const QString &id) | ||
18 | { | ||
19 | if(m_accountId != id) { | ||
20 | m_accountId = id; | ||
21 | |||
22 | loadFolders(id); | ||
23 | |||
24 | emit accountIdChanged(); | ||
25 | } | ||
26 | } | ||
27 | |||
28 | void FolderListController::loadFolders(const QString &id) | ||
29 | { | ||
30 | //load foldermodel from akonadi | ||
31 | |||
32 | } | ||
33 | |||
34 | |||
35 | void FolderListController::addFolder(const QString &name) | ||
36 | { | ||
37 | qDebug() << "User Action: add folder " << name; | ||
38 | } | ||
39 | |||
40 | void FolderListController::deleteFolder(const QString &id) | ||
41 | { | ||
42 | qDebug() << "User Action: delete folder " << id; | ||
43 | } | ||
44 | |||
diff --git a/framework/mail/folderlistcontroller.h b/framework/mail/folderlistcontroller.h new file mode 100644 index 00000000..18f5624d --- /dev/null +++ b/framework/mail/folderlistcontroller.h | |||
@@ -0,0 +1,35 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #include <QObject> | ||
4 | #include <QScopedPointer> | ||
5 | #include <QString> | ||
6 | #include <QAbstractItemModel> | ||
7 | |||
8 | class FolderListController : public QObject | ||
9 | { | ||
10 | Q_OBJECT | ||
11 | Q_PROPERTY (QString accountId READ accountId WRITE setAccountId NOTIFY accountIdChanged) | ||
12 | Q_PROPERTY (QAbstractItemModel *model READ model CONSTANT) | ||
13 | |||
14 | public: | ||
15 | explicit FolderListController(QObject *parent = Q_NULLPTR); | ||
16 | |||
17 | QString accountId() const; | ||
18 | void setAccountId(const QString &id); | ||
19 | |||
20 | QAbstractItemModel *model() const; | ||
21 | |||
22 | void loadFolders(const QString &id); | ||
23 | |||
24 | signals: | ||
25 | void accountIdChanged(); | ||
26 | |||
27 | public slots: | ||
28 | void deleteFolder(const QString &id); | ||
29 | void addFolder(const QString &name); | ||
30 | |||
31 | |||
32 | private: | ||
33 | QString m_accountId; | ||
34 | QScopedPointer<QAbstractItemModel> m_model; | ||
35 | }; | ||
diff --git a/framework/mail/mailplugin.cpp b/framework/mail/mailplugin.cpp index 36c75e7f..e5988591 100644 --- a/framework/mail/mailplugin.cpp +++ b/framework/mail/mailplugin.cpp | |||
@@ -3,6 +3,8 @@ | |||
3 | #include "maillistcontroller.h" | 3 | #include "maillistcontroller.h" |
4 | #include "maillistmodel.h" | 4 | #include "maillistmodel.h" |
5 | #include "singlemailcontroller.h" | 5 | #include "singlemailcontroller.h" |
6 | #include "folderlistcontroller.h" | ||
7 | #include "folderlistmodel.h" | ||
6 | 8 | ||
7 | #include <QAbstractItemModel> | 9 | #include <QAbstractItemModel> |
8 | #include <QtQml> | 10 | #include <QtQml> |
@@ -11,6 +13,12 @@ void MailPlugin::registerTypes (const char *uri) | |||
11 | { | 13 | { |
12 | Q_ASSERT(uri == QLatin1String("org.kde.akonadi2.mail")); | 14 | Q_ASSERT(uri == QLatin1String("org.kde.akonadi2.mail")); |
13 | qmlRegisterType<QAbstractItemModel>(); | 15 | qmlRegisterType<QAbstractItemModel>(); |
16 | |||
17 | qmlRegisterType<FolderListModel>(); | ||
18 | qmlRegisterType<FolderListController>(uri, 1, 0, "FolderList"); | ||
19 | |||
20 | qmlRegisterType<MailListModel>(); | ||
14 | qmlRegisterType<MailListController>(uri, 1, 0, "MailList"); | 21 | qmlRegisterType<MailListController>(uri, 1, 0, "MailList"); |
22 | |||
15 | qmlRegisterType<SingleMailController>(uri, 1, 0, "SingleMail"); | 23 | qmlRegisterType<SingleMailController>(uri, 1, 0, "SingleMail"); |
16 | } | 24 | } |