blob: 5efda459aa057ef43589d2de8f0632454be36feb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
// SPDX-FileCopyrightText: 2020 Kitsune Ral <Kitsune-Ral@users.sf.net>
// SPDX-FileCopyrightText: Tobias Fella <fella@posteo.de>
// SPDX-License-Identifier: LGPL-2.1-or-later
#pragma once
#include <QtCore/QObject>
#include <QtCore/QList>
#include <QtCore/QAbstractListModel>
namespace Quotient {
class Connection;
class AccountRegistry : public QAbstractListModel {
Q_OBJECT
public:
enum EventRoles {
ConnectionRole = Qt::UserRole + 1,
};
static AccountRegistry &instance() {
static AccountRegistry _instance;
return _instance;
}
const QVector<Connection*> accounts() const;
void add(Connection* a);
void drop(Connection* a);
bool isLoggedIn(const QString& userId) const;
bool isEmpty() const;
int count() const;
bool contains(Connection*) const;
Connection* get(const QString& userId);
[[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
[[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
private:
AccountRegistry();
QVector<Connection *> m_accounts;
};
}
|