9 #include <QtCore/QAbstractListModel>
11 #include <qt6keychain/keychain.h>
17 private QVector<Connection*> {
20 Q_PROPERTY(
int accountCount READ rowCount NOTIFY accountCountChanged)
23 Q_PROPERTY(QStringList accountsLoading READ accountsLoading NOTIFY accountsLoadingChanged)
25 using vector_t = QVector<Connection*>;
26 using const_iterator = vector_t::const_iterator;
27 using const_reference = vector_t::const_reference;
30 AccountRole = Qt::UserRole + 1,
31 ConnectionRole = AccountRole,
32 UserIdRole = Qt::DisplayRole
35 explicit AccountRegistry(QObject* parent =
nullptr);
42 const vector_t& accounts()
const {
return *
this; }
43 void add(Connection* a);
44 void drop(Connection* a);
45 const_iterator begin()
const {
return vector_t::begin(); }
46 const_iterator end()
const {
return vector_t::end(); }
47 const_reference front()
const {
return vector_t::front(); }
48 const_reference back()
const {
return vector_t::back(); }
49 bool isLoggedIn(
const QString& userId)
const;
50 Connection* get(
const QString& userId)
const;
52 using vector_t::isEmpty, vector_t::empty;
53 using vector_t::size, vector_t::count, vector_t::capacity;
54 using vector_t::cbegin, vector_t::cend, vector_t::contains;
58 [[nodiscard]] QVariant data(
const QModelIndex& index,
59 int role)
const override;
60 [[nodiscard]]
int rowCount(
61 const QModelIndex& parent = QModelIndex())
const override;
62 [[nodiscard]] QHash<
int, QByteArray> roleNames()
const override;
64 QStringList accountsLoading()
const;
66 [[deprecated(
"This may leak Connection objects when failing and cannot be"
67 "fixed without breaking the API; do not use it")]]
71 void accountCountChanged();
72 void accountsLoadingChanged();
74 void keychainError(QKeychain::Error error);
75 void loginError(Connection* connection, QString message, QString details);
76 void resolveError(Connection* connection, QString error);