File indexing completed on 2024-05-05 17:04:25
0001 /* This file is part of the KDE project 0002 * Copyright 2014 Dan Leinir Turthra Jensen <admin@leinir.dk> 0003 * 0004 * This program is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU General Public License as 0006 * published by the Free Software Foundation; either version 2 of 0007 * the License or (at your option) version 3 or any later version 0008 * accepted by the membership of KDE e.V. (or its successor approved 0009 * by the membership of KDE e.V.), which shall act as a proxy 0010 * defined in Section 14 of version 3 of the license. 0011 * 0012 * This program is distributed in the hope that it will be useful, 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0015 * GNU General Public License for more details. 0016 * 0017 * You should have received a copy of the GNU General Public License 0018 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0019 * 0020 */ 0021 0022 #ifndef CLOUDACCOUNTSMODEL_H 0023 #define CLOUDACCOUNTSMODEL_H 0024 0025 #include <QAbstractListModel> 0026 0027 class CloudAccountsModel : public QAbstractListModel 0028 { 0029 Q_OBJECT 0030 public: 0031 enum CloudAccountRoles { 0032 TextRole = Qt::UserRole + 1, 0033 SelectedRole, 0034 AccountTypeRole, 0035 StackComponentRole, 0036 AccountDetailsRole 0037 }; 0038 explicit CloudAccountsModel(QObject* parent = 0); 0039 ~CloudAccountsModel() override; 0040 QVariant data(const QModelIndex& index, int role) const override; 0041 int rowCount(const QModelIndex& parent) const override; 0042 Q_INVOKABLE void selectIndex(int newSelection); 0043 0044 /** 0045 * Add an account to the list. If removeExisting is true, the call will first remove any existing 0046 * accounts with the same text. 0047 * 0048 * @param text The user visible name of the account shown in the UI 0049 * @param accountType The type of account, either DropBox, Git or WebDav 0050 * @param stackComponent The name of the component instantiated to show the files available through 0051 * the account 0052 * @param accountDetails A pure QObject with a set of dynamic properties containing information used 0053 * by the service. For example, the local repository location for Git 0054 * @param removeExisting Whether or not to remove any existing accounts with the given text before 0055 * adding this one. Currently used by DropBox to ensure there is only one 0056 * account at a given moment 0057 */ 0058 Q_INVOKABLE void addAccount(QString text, QString accountType, QString stackComponent, QObject* accountDetails, bool removeExisting = false); 0059 Q_INVOKABLE void renameAccount(int index, QString newText); 0060 Q_INVOKABLE void removeAccountByName(QString text); 0061 Q_INVOKABLE void removeAccount(int index); 0062 0063 Q_INVOKABLE QObject* accountDetails(int index); 0064 Q_INVOKABLE void setAccountDetails(int index, QObject* newDetails); 0065 private: 0066 class Private; 0067 Private* d; 0068 }; 0069 0070 #endif // CLOUDACCOUNTSMODEL_H