blob: 134a31e2088afca960e4f298328c82537dcf1dac [file] [log] [blame]
Sébastien Blin1f915762020-08-03 13:27:42 -04001/*
2 * Copyright (C) 2019-2020 by Savoir-faire Linux
3 * Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
4 * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <QAbstractItemModel>
23
24#include "api/account.h"
25#include "api/contact.h"
26#include "api/conversation.h"
27
28class AccountListModel : public QAbstractListModel
29{
30 Q_OBJECT
31
32public:
33 enum Role { Alias = Qt::UserRole + 1, Username, Picture, Type, Status, ID };
34
35 explicit AccountListModel(QObject *parent = 0);
36 ~AccountListModel();
37
38 /*
39 * QAbstractListModel override.
40 */
41 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
42 int columnCount(const QModelIndex &parent) const override;
43 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
44 /*
45 * Override role name as access point in qml.
46 */
47 QHash<int, QByteArray> roleNames() const override;
48 QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
49 QModelIndex parent(const QModelIndex &child) const;
50 Qt::ItemFlags flags(const QModelIndex &index) const;
51
52 /*
53 * This function is to reset the model when there's new account added.
54 */
55 Q_INVOKABLE void reset();
56};