diff options
-rw-r--r-- | applications/kmail-quick/CMakeLists.txt | 2 | ||||
-rw-r--r-- | applications/kmail-quick/main.cpp | 9 | ||||
-rw-r--r-- | framework/CMakeLists.txt | 2 | ||||
-rw-r--r-- | framework/mail/CMakeLists.txt | 1 | ||||
-rw-r--r-- | framework/mail/maillistcontroller.cpp | 22 | ||||
-rw-r--r-- | framework/mail/maillistcontroller.h | 9 | ||||
-rw-r--r-- | framework/mail/maillistmodel.cpp | 55 | ||||
-rw-r--r-- | framework/mail/maillistmodel.h | 15 | ||||
-rw-r--r-- | framework/mail/mailplugin.cpp | 5 |
9 files changed, 50 insertions, 70 deletions
diff --git a/applications/kmail-quick/CMakeLists.txt b/applications/kmail-quick/CMakeLists.txt index 19199e18..570eff0b 100644 --- a/applications/kmail-quick/CMakeLists.txt +++ b/applications/kmail-quick/CMakeLists.txt | |||
@@ -26,3 +26,5 @@ find_package(KF5 REQUIRED COMPONENTS | |||
26 | kpackage_install_package(package org.kde.pim.kmail-quick genericqml) | 26 | kpackage_install_package(package org.kde.pim.kmail-quick genericqml) |
27 | install(FILES package/metadata.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} RENAME org.kde.pim.kmail-quick.desktop) | 27 | install(FILES package/metadata.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} RENAME org.kde.pim.kmail-quick.desktop) |
28 | 28 | ||
29 | add_executable(kmail-quick main.cpp) | ||
30 | qt5_use_modules(kmail-quick Gui Quick) | ||
diff --git a/applications/kmail-quick/main.cpp b/applications/kmail-quick/main.cpp new file mode 100644 index 00000000..62fec7fe --- /dev/null +++ b/applications/kmail-quick/main.cpp | |||
@@ -0,0 +1,9 @@ | |||
1 | #include <QGuiApplication> | ||
2 | #include <QQmlApplicationEngine> | ||
3 | |||
4 | int main(int argc, char *argv[]) | ||
5 | { | ||
6 | QGuiApplication app(argc, argv); | ||
7 | QQmlApplicationEngine engine(QUrl::fromLocalFile("/home/chrigi/kdebuild/akonadinext/source/kontact-quick/applications/kmail-quick/package/contents/ui/main.qml")); | ||
8 | return app.exec(); | ||
9 | } | ||
diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt index 37c15e16..1e0dd958 100644 --- a/framework/CMakeLists.txt +++ b/framework/CMakeLists.txt | |||
@@ -19,6 +19,8 @@ find_package(Qt5 COMPONENTS REQUIRED Core Qml) | |||
19 | set(CMAKE_AUTOMOC ON) | 19 | set(CMAKE_AUTOMOC ON) |
20 | add_definitions("-Wall -std=c++0x -g") | 20 | add_definitions("-Wall -std=c++0x -g") |
21 | include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/common) | 21 | include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/common) |
22 | include_directories(SYSTEM /work/install/include/) | ||
23 | include_directories(SYSTEM /work/install/include/KF5/) | ||
22 | 24 | ||
23 | enable_testing() | 25 | enable_testing() |
24 | 26 | ||
diff --git a/framework/mail/CMakeLists.txt b/framework/mail/CMakeLists.txt index 100b9d9e..0327d457 100644 --- a/framework/mail/CMakeLists.txt +++ b/framework/mail/CMakeLists.txt | |||
@@ -7,6 +7,7 @@ set(mailplugin_SRCS | |||
7 | add_library(mailplugin SHARED ${mailplugin_SRCS}) | 7 | add_library(mailplugin SHARED ${mailplugin_SRCS}) |
8 | 8 | ||
9 | qt5_use_modules(mailplugin Core Quick Qml) | 9 | qt5_use_modules(mailplugin Core Quick Qml) |
10 | target_link_libraries(mailplugin /work/install/lib64/libakonadi2common.so) | ||
10 | 11 | ||
11 | install(TARGETS mailplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/akonadi2/mail) | 12 | install(TARGETS mailplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/akonadi2/mail) |
12 | install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/akonadi2/mail) \ No newline at end of file | 13 | install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/akonadi2/mail) \ No newline at end of file |
diff --git a/framework/mail/maillistcontroller.cpp b/framework/mail/maillistcontroller.cpp index 60d29f7c..19fdfffb 100644 --- a/framework/mail/maillistcontroller.cpp +++ b/framework/mail/maillistcontroller.cpp | |||
@@ -2,13 +2,19 @@ | |||
2 | 2 | ||
3 | #include <QStringList> | 3 | #include <QStringList> |
4 | 4 | ||
5 | #include <akonadi2common/clientapi.h> | ||
6 | #include <akonadi2common/query.h> | ||
7 | |||
8 | #include "maillistmodel.h" | ||
9 | |||
5 | MailListController::MailListController(QObject *parent) : QObject(parent), m_model(new MailListModel) | 10 | MailListController::MailListController(QObject *parent) : QObject(parent), m_model(new MailListModel) |
6 | { | 11 | { |
7 | } | 12 | } |
8 | 13 | ||
9 | MailListModel *MailListController::model() const | 14 | QAbstractItemModel *MailListController::model() const |
10 | { | 15 | { |
11 | return m_model.data(); | 16 | return m_model.data(); |
17 | |||
12 | } | 18 | } |
13 | 19 | ||
14 | QString MailListController::query() const | 20 | QString MailListController::query() const |
@@ -18,18 +24,14 @@ QString MailListController::query() const | |||
18 | 24 | ||
19 | void MailListController::setQuery(const QString &query) | 25 | void MailListController::setQuery(const QString &query) |
20 | { | 26 | { |
21 | if ( m_query != query) { | 27 | qDebug() << "set query"; |
22 | m_query = query; | 28 | if (m_query != query) { |
23 | m_model->runQuery(query); | 29 | m_query = query; |
24 | emit queryChanged(); | 30 | emit queryChanged(); |
25 | } | 31 | } |
26 | } | 32 | } |
27 | 33 | ||
28 | void MailListController::addMail(QString subject) | 34 | void MailListController::addMail(QString subject) |
29 | { | 35 | { |
30 | QStringList list; | 36 | qDebug() << "add mail"; |
31 | |||
32 | list << subject; | ||
33 | |||
34 | m_model->addMails(list); | ||
35 | } | 37 | } |
diff --git a/framework/mail/maillistcontroller.h b/framework/mail/maillistcontroller.h index 8aa5713b..b5a95374 100644 --- a/framework/mail/maillistcontroller.h +++ b/framework/mail/maillistcontroller.h | |||
@@ -5,19 +5,20 @@ | |||
5 | #include <QObject> | 5 | #include <QObject> |
6 | #include <QScopedPointer> | 6 | #include <QScopedPointer> |
7 | #include <QString> | 7 | #include <QString> |
8 | #include <QAbstractItemModel> | ||
8 | 9 | ||
9 | class MailListController : public QObject | 10 | class MailListController : public QObject |
10 | { | 11 | { |
11 | Q_OBJECT | 12 | Q_OBJECT |
12 | Q_PROPERTY (QString query READ query WRITE setQuery NOTIFY queryChanged) | 13 | Q_PROPERTY (QString query READ query WRITE setQuery NOTIFY queryChanged) |
13 | Q_PROPERTY (MailListModel *model READ model CONSTANT) | 14 | Q_PROPERTY (QAbstractItemModel *model READ model CONSTANT) |
14 | 15 | ||
15 | public: | 16 | public: |
16 | explicit MailListController(QObject *parent = Q_NULLPTR); | 17 | explicit MailListController(QObject *parent = Q_NULLPTR); |
17 | 18 | ||
18 | QString query() const; | 19 | QString query() const; |
19 | void setQuery(const QString &query); | 20 | void setQuery(const QString &query); |
20 | MailListModel *model() const; | 21 | QAbstractItemModel *model() const; |
21 | 22 | ||
22 | signals: | 23 | signals: |
23 | void queryChanged(); | 24 | void queryChanged(); |
@@ -27,5 +28,5 @@ public slots: | |||
27 | 28 | ||
28 | private: | 29 | private: |
29 | QString m_query; | 30 | QString m_query; |
30 | QScopedPointer<MailListModel> m_model; | 31 | QScopedPointer<QAbstractItemModel> m_model; |
31 | }; \ No newline at end of file | 32 | }; |
diff --git a/framework/mail/maillistmodel.cpp b/framework/mail/maillistmodel.cpp index 14219ee2..f18861c4 100644 --- a/framework/mail/maillistmodel.cpp +++ b/framework/mail/maillistmodel.cpp | |||
@@ -1,10 +1,12 @@ | |||
1 | #include "maillistmodel.h" | 1 | #include "maillistmodel.h" |
2 | 2 | ||
3 | #include <QDateTime> | 3 | MailListModel::MailListModel(QObject *parent) : ListModelResult<Akonadi2::ApplicationDomain::Mail::Ptr>(QList<QByteArray>() << "subject" << "uid") |
4 | |||
5 | MailListModel::MailListModel(QObject *parent) : QAbstractListModel(parent), m_msgs() | ||
6 | { | 4 | { |
7 | 5 | Akonadi2::Query query; | |
6 | query.syncOnDemand = false; | ||
7 | query.processAll = false; | ||
8 | query.liveQuery = true; | ||
9 | setEmitter(Akonadi2::Store::load<Akonadi2::ApplicationDomain::Mail>(query)); | ||
8 | } | 10 | } |
9 | 11 | ||
10 | MailListModel::~MailListModel() | 12 | MailListModel::~MailListModel() |
@@ -21,53 +23,16 @@ QHash< int, QByteArray > MailListModel::roleNames() const | |||
21 | return roles; | 23 | return roles; |
22 | } | 24 | } |
23 | 25 | ||
24 | 26 | QVariant MailListModel::data(const QModelIndex &idx, int role) const | |
25 | QVariant MailListModel::data(const QModelIndex &index, int role) const | ||
26 | { | 27 | { |
27 | if (!index.isValid()) { | 28 | switch (role) { |
28 | return QVariant(); | ||
29 | } | ||
30 | |||
31 | if (index.row() >= m_msgs.count() || index.row() < 0) { | ||
32 | return QVariant(); | ||
33 | } | ||
34 | switch (role) { | ||
35 | case Subject: | 29 | case Subject: |
36 | return m_msgs.at(index.row()); | 30 | return ListModelResult<Akonadi2::ApplicationDomain::Mail::Ptr>::data(index(idx.row(), 0, idx.parent()), Qt::DisplayRole); |
37 | } | ||
38 | return QVariant(); | ||
39 | } | ||
40 | |||
41 | int MailListModel::rowCount(const QModelIndex &parent) const | ||
42 | { | ||
43 | return m_msgs.size(); | ||
44 | } | ||
45 | |||
46 | bool MailListModel::addMails(const QStringList &items) | ||
47 | { | ||
48 | beginInsertRows(QModelIndex(), rowCount(), rowCount() + items.size() - 1); | ||
49 | |||
50 | m_msgs += items; | ||
51 | |||
52 | endInsertRows(); | ||
53 | |||
54 | return true; | ||
55 | } | ||
56 | |||
57 | void MailListModel::clearMails() | ||
58 | { | ||
59 | if (!m_msgs.isEmpty()) { | ||
60 | beginResetModel(); | ||
61 | m_msgs.clear(); | ||
62 | endResetModel(); | ||
63 | } | 31 | } |
32 | return QVariant(); | ||
64 | } | 33 | } |
65 | 34 | ||
66 | void MailListModel::runQuery(const QString& query) | 35 | void MailListModel::runQuery(const QString& query) |
67 | { | 36 | { |
68 | clearMails(); | ||
69 | QStringList itemlist; | ||
70 | itemlist << "I feel tiny" << "Big News!" << "[FUN] lets do things"; | ||
71 | addMails(itemlist); | ||
72 | } | 37 | } |
73 | 38 | ||
diff --git a/framework/mail/maillistmodel.h b/framework/mail/maillistmodel.h index 72a26c59..b0a153a5 100644 --- a/framework/mail/maillistmodel.h +++ b/framework/mail/maillistmodel.h | |||
@@ -3,7 +3,11 @@ | |||
3 | #include <QAbstractListModel> | 3 | #include <QAbstractListModel> |
4 | #include <QStringList> | 4 | #include <QStringList> |
5 | 5 | ||
6 | class MailListModel : public QAbstractListModel | 6 | #include <akonadi2common/clientapi.h> |
7 | #include <akonadi2common/query.h> | ||
8 | #include <akonadi2common/listmodelresult.h> | ||
9 | |||
10 | class MailListModel : public ListModelResult<Akonadi2::ApplicationDomain::Mail::Ptr> | ||
7 | { | 11 | { |
8 | Q_OBJECT | 12 | Q_OBJECT |
9 | 13 | ||
@@ -17,13 +21,6 @@ public: | |||
17 | 21 | ||
18 | QHash<int, QByteArray> roleNames() const; | 22 | QHash<int, QByteArray> roleNames() const; |
19 | QVariant data(const QModelIndex &index, int role) const; | 23 | QVariant data(const QModelIndex &index, int role) const; |
20 | int rowCount(const QModelIndex &parent = QModelIndex()) const; | ||
21 | |||
22 | bool addMails(const QStringList &items); | ||
23 | void clearMails(); | ||
24 | 24 | ||
25 | void runQuery(const QString &query); | 25 | void runQuery(const QString &query); |
26 | 26 | }; | |
27 | private: | ||
28 | QStringList m_msgs; | ||
29 | }; \ No newline at end of file | ||
diff --git a/framework/mail/mailplugin.cpp b/framework/mail/mailplugin.cpp index b9800541..ea8a5ec9 100644 --- a/framework/mail/mailplugin.cpp +++ b/framework/mail/mailplugin.cpp | |||
@@ -2,12 +2,13 @@ | |||
2 | 2 | ||
3 | #include "maillistcontroller.h" | 3 | #include "maillistcontroller.h" |
4 | #include "maillistmodel.h" | 4 | #include "maillistmodel.h" |
5 | #include <QAbstractItemModel> | ||
5 | 6 | ||
6 | #include <QtQml> | 7 | #include <QtQml> |
7 | 8 | ||
8 | void MailPlugin::registerTypes (const char *uri) | 9 | void MailPlugin::registerTypes (const char *uri) |
9 | { | 10 | { |
10 | Q_ASSERT(uri == QLatin1String("org.kde.akonadi2.mail")); | 11 | Q_ASSERT(uri == QLatin1String("org.kde.akonadi2.mail")); |
12 | qmlRegisterType<QAbstractItemModel>(); | ||
11 | qmlRegisterType<MailListController>(uri, 1, 0, "MailList"); | 13 | qmlRegisterType<MailListController>(uri, 1, 0, "MailList"); |
12 | qmlRegisterType<MailListModel>(uri, 1, 0, "MailListModel"); | 14 | } |
13 | } \ No newline at end of file | ||