-
Notifications
You must be signed in to change notification settings - Fork 3
/
syncservice.cpp
63 lines (50 loc) · 1.28 KB
/
syncservice.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "syncservice.h"
#include <QtNetwork>
SyncService::SyncService(QSettings *settings) :
_settings(settings),
_filePath(""),
_state(SyncState::Failed)
{
}
SyncService::~SyncService()
{
}
QString SyncService::getFilePath() const
{
return _filePath;
}
void SyncService::setFilePath(const QString &filePath)
{
_filePath = filePath;
emit filePathChanged(_filePath);
}
SyncService::SyncState SyncService::getState() const
{
return _state;
}
void SyncService::setState(SyncService::SyncState state)
{
_state = state;
emit stateChanged(_state);
}
void SyncService::clearCache()
{
QDir cache(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
cache.setFilter(QDir::NoDotAndDotDot | QDir::Files);
foreach(QString dirItem, cache.entryList())
cache.remove(dirItem);
cache.setFilter(QDir::NoDotAndDotDot | QDir::Dirs);
foreach( QString dirItem, cache.entryList())
{
QDir subDir(cache.absoluteFilePath(dirItem));
subDir.removeRecursively();
}
clearCachedSettings();
}
void SyncService::clearCachedSettings()
{
}
QString SyncService::cacheFilePath(const QString filePath)
{
return QDir::cleanPath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QDir::separator() + filePath);
}