MauiKit Accounts

mauiaccounts.h
1/*
2 * <one line to give the program's name and a brief idea of what it does.>
3 * Copyright (C) 2019 camilo <chiguitar@unal.edu.co>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#pragma once
20#include <QObject>
21
22#include <MauiKit4/Core/mauilist.h>
23
24#include "accounts_export.h"
25
26class AccountsDB;
27
28/**
29 * @brief MauiAccounts class provides an interface to access the system registered accounts, the current active account and a bridge to add account data to the host system backend solution.
30 * This properties and functions are exposed to all the Maui Applications that might want to use the accounts with the `Accounts` property.
31 */
32class ACCOUNTS_EXPORT MauiAccounts : public MauiList
33{
34 Q_OBJECT
35 Q_PROPERTY(int currentAccountIndex READ getCurrentAccountIndex WRITE setCurrentAccountIndex NOTIFY currentAccountIndexChanged)
36 Q_PROPERTY(QVariantMap currentAccount READ getCurrentAccount NOTIFY currentAccountChanged)
37
38public:
39 static MauiAccounts *instance()
40 {
41 if (m_instance)
42 return m_instance;
43
44 m_instance = new MauiAccounts;
45 return m_instance;
46 }
47
48 MauiAccounts(const MauiAccounts &) = delete;
49 MauiAccounts &operator=(const MauiAccounts &) = delete;
50 MauiAccounts(MauiAccounts &&) = delete;
51 MauiAccounts &operator=(MauiAccounts &&) = delete;
52
53 const FMH::MODEL_LIST &items() const final override;
54
55 /**
56 * @brief setCurrentAccountIndex
57 * @param index
58 */
59 void setCurrentAccountIndex(const int &index);
60
61 /**
62 * @brief getCurrentAccountIndex
63 * @return
64 */
65 int getCurrentAccountIndex() const;
66
67 /**
68 * @brief getCurrentAccount
69 * @return
70 */
71 QVariantMap getCurrentAccount() const;
72
73 /**
74 * @brief getCount
75 * @return
76 */
77 uint getCount() const;
78
79 /**
80 * @brief get
81 * @param index
82 * @return
83 */
84 QVariantMap get(const int &index) const;
85
86public Q_SLOTS:
87 /**
88 * @brief getCloudAccountsList
89 * @return
90 */
91 QVariantList getCloudAccountsList();
92
93 /**
94 * @brief getCloudAccounts
95 * @return
96 */
97 FMH::MODEL_LIST getCloudAccounts();
98
99 /**
100 * @brief registerAccount
101 * @param account
102 */
103 void registerAccount(const QVariantMap &account);
104
105 /**
106 * @brief removeAccount
107 * @param index
108 */
109 void removeAccount(const int &index);
110
111 /**
112 * @brief removeAccountAndFiles
113 * @param index
114 */
115 void removeAccountAndFiles(const int &index);
116
117 /**
118 * @brief refresh
119 */
120 void refresh();
121
122private:
123 MauiAccounts();
125
126 static MauiAccounts *m_instance;
127
128 AccountsDB *db;
129 FMH::MODEL_LIST m_data;
130 QVariantMap m_currentAccount;
131
132 int m_currentAccountIndex = -1;
133 void setAccounts();
134
135 bool addCloudAccount(const QString &server, const QString &user, const QString &password);
136 bool removeCloudAccount(const QString &server, const QString &user);
137
138 QVariantList get(const QString &queryTxt);
139
141 /**
142 * @brief accountAdded
143 * @param account
144 */
145 void accountAdded(QVariantMap account);
146
147 /**
148 * @brief accountRemoved
149 * @param account
150 */
151 void accountRemoved(QVariantMap account);
152
153 /**
154 * @brief currentAccountChanged
155 * @param account
156 */
157 void currentAccountChanged(QVariantMap account);
158
159 /**
160 * @brief currentAccountIndexChanged
161 * @param index
162 */
164};
MauiAccounts class provides an interface to access the system registered accounts,...
void accountRemoved(QVariantMap account)
accountRemoved
QVariantMap get(const int &index) const
get
void accountAdded(QVariantMap account)
accountAdded
void currentAccountIndexChanged(int index)
currentAccountIndexChanged
uint getCount() const
getCount
void currentAccountChanged(QVariantMap account)
currentAccountChanged
virtual const FMH::MODEL_LIST & items() const=0
QVariantMap get(const int &index) const
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:39:19 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.