Warning, file /maui/mauikit-filebrowsing/src/code/syncinglist.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 #include "syncinglist.h"
0002 #include "fm.h"
0003 
0004 SyncingList::SyncingList(QObject *parent)
0005     : QObject(parent)
0006     , fm(new FM(this))
0007 {
0008     this->setList();
0009 }
0010 
0011 void SyncingList::setList()
0012 {
0013     emit this->preListChanged();
0014 
0015     this->list = this->fm->getCloudAccounts();
0016     qDebug() << "SYNCIGN LIST" << list;
0017 
0018     emit this->postListChanged();
0019 }
0020 
0021 QVariantMap SyncingList::get(const int &index) const
0022 {
0023     if (index >= this->list.size() || index < 0)
0024         return QVariantMap();
0025 
0026     return FMH::toMap(this->list.at(index));
0027 }
0028 
0029 void SyncingList::refresh()
0030 {
0031     this->setList();
0032 }
0033 
0034 void SyncingList::insert(const QVariantMap &data)
0035 {
0036     auto model = FMH::toModel(data);
0037 
0038     if (this->fm->addCloudAccount(model[FMH::MODEL_KEY::SERVER], model[FMH::MODEL_KEY::USER], model[FMH::MODEL_KEY::PASSWORD])) {
0039         this->setList();
0040     }
0041 }
0042 
0043 void SyncingList::removeAccount(const QString &server, const QString &user)
0044 {
0045     if (this->fm->removeCloudAccount(server, user)) {
0046         this->refresh();
0047     }
0048 }
0049 
0050 void SyncingList::removeAccountAndFiles(const QString &server, const QString &user)
0051 {
0052     if (this->fm->removeCloudAccount(server, user)) {
0053         this->refresh();
0054     }
0055 
0056     this->fm->removeDir(FM::resolveUserCloudCachePath(server, user));
0057 }
0058 
0059 FMH::MODEL_LIST SyncingList::items() const
0060 {
0061     return this->list;
0062 }