aboutsummaryrefslogtreecommitdiff
path: root/accounts_model.h
diff options
context:
space:
mode:
authorlink2xt <link2xt@testrun.org>2020-11-05 22:03:37 +0300
committerlink2xt <link2xt@testrun.org>2020-11-05 23:08:08 +0300
commitfe89c7a4ff760564f3cdbcd8e27c04eadd9f79d8 (patch)
tree39d56b00509277afca8743adcf6051bd42121e99 /accounts_model.h
parentdaa31b783ad1dead6cbed79b428792702612aa31 (diff)
downloadkdeltachat-fe89c7a4ff760564f3cdbcd8e27c04eadd9f79d8.tar.gz
kdeltachat-fe89c7a4ff760564f3cdbcd8e27c04eadd9f79d8.zip
Move accounts model from C++ to QML
C++ models are not well documented and it is easier to manage the model in QML. Now all QObjects are thin wrappers around Delta Chat core structures.
Diffstat (limited to 'accounts_model.h')
-rw-r--r--accounts_model.h51
1 files changed, 0 insertions, 51 deletions
diff --git a/accounts_model.h b/accounts_model.h
deleted file mode 100644
index 5541f7e..0000000
--- a/accounts_model.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#pragma once
-
-#include <QAbstractListModel>
-#include <deltachat.h>
-
-#include "eventemitter.h"
-#include "context.h"
-
-class AccountsModel : public QAbstractListModel {
- Q_OBJECT
- Q_PROPERTY(size_t accountCount READ accountCount NOTIFY accountCountChanged)
- Q_PROPERTY(uint32_t selectedAccount READ selectedAccount WRITE setSelectedAccount NOTIFY selectedAccountChanged)
-
-public:
- enum AccountRoles {
- NumberRole = Qt::UserRole + 1
- };
- explicit AccountsModel(QObject *parent = nullptr);
- ~AccountsModel();
-
- int rowCount(const QModelIndex & parent = QModelIndex()) const;
-
- QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
-
- size_t accountCount() const;
-
- uint32_t selectedAccount();
- void setSelectedAccount(uint32_t selectedAccount);
-
- Q_INVOKABLE uint32_t addAccount();
- Q_INVOKABLE void removeAccount(uint32_t accountId);
- Q_INVOKABLE uint32_t importAccount(const QString &filename);
- Q_INVOKABLE Context *getSelectedAccount();
-
- Q_INVOKABLE void startIo();
- Q_INVOKABLE void stopIo();
- Q_INVOKABLE void maybeNetwork();
-
- Q_INVOKABLE DcAccountsEventEmitter *getEventEmitter();
-
-signals:
- void accountCountChanged();
- void selectedAccountChanged();
-
-protected:
- QHash<int, QByteArray> roleNames() const;
-
-private:
- dc_accounts_t *m_accounts{nullptr};
- uint32_t m_selectedAccount{0};
-};