MauiKit File Browsing

syncinglist.cpp
1#include "syncinglist.h"
2#include "fm.h"
3
4SyncingList::SyncingList(QObject *parent)
5 : QObject(parent)
6 , fm(new FM(this))
7{
8 this->setList();
9}
10
11void SyncingList::setList()
12{
13 emit this->preListChanged();
14
15 this->list = this->fm->getCloudAccounts();
16 qDebug() << "SYNCIGN LIST" << list;
17
18 emit this->postListChanged();
19}
20
21QVariantMap SyncingList::get(const int &index) const
22{
23 if (index >= this->list.size() || index < 0)
24 return QVariantMap();
25
26 return FMH::toMap(this->list.at(index));
27}
28
29void SyncingList::refresh()
30{
31 this->setList();
32}
33
34void SyncingList::insert(const QVariantMap &data)
35{
36 auto model = FMH::toModel(data);
37
38 if (this->fm->addCloudAccount(model[FMH::MODEL_KEY::SERVER], model[FMH::MODEL_KEY::USER], model[FMH::MODEL_KEY::PASSWORD])) {
39 this->setList();
40 }
41}
42
43void SyncingList::removeAccount(const QString &server, const QString &user)
44{
45 if (this->fm->removeCloudAccount(server, user)) {
46 this->refresh();
47 }
48}
49
50void SyncingList::removeAccountAndFiles(const QString &server, const QString &user)
51{
52 if (this->fm->removeCloudAccount(server, user)) {
53 this->refresh();
54 }
55
56 this->fm->removeDir(FM::resolveUserCloudCachePath(server, user));
57}
58
59FMH::MODEL_LIST SyncingList::items() const
60{
61 return this->list;
62}
The FM class stands for File Management, and exposes methods for file listing, browsing and handling,...
Definition fm.h:98
static QString resolveUserCloudCachePath(const QString &server, const QString &user)
Given the server address and the user name, resolve a local path for the cache of the files.
Definition fm.cpp:421
const FMH::MODEL toModel(const QVariantMap &map)
const QVariantMap toMap(const MODEL &model)
const_reference at(qsizetype i) const const
qsizetype size() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 26 2024 11:53:26 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.