Move SyncthingDev and SyncthingDir to extra files
This commit is contained in:
parent
9fa2a028e8
commit
dd8e443c15
|
@ -297,15 +297,15 @@ void Application::printStatus(const ArgumentOccurrence &)
|
||||||
printProperty("Path", dir->path);
|
printProperty("Path", dir->path);
|
||||||
const char *status;
|
const char *status;
|
||||||
switch(dir->status) {
|
switch(dir->status) {
|
||||||
case DirStatus::Idle:
|
case SyncthingDirStatus::Idle:
|
||||||
status = "idle"; break;
|
status = "idle"; break;
|
||||||
case DirStatus::Scanning:
|
case SyncthingDirStatus::Scanning:
|
||||||
status = "scanning"; break;
|
status = "scanning"; break;
|
||||||
case DirStatus::Synchronizing:
|
case SyncthingDirStatus::Synchronizing:
|
||||||
status = "synchronizing"; break;
|
status = "synchronizing"; break;
|
||||||
case DirStatus::Paused:
|
case SyncthingDirStatus::Paused:
|
||||||
status = "paused"; break;
|
status = "paused"; break;
|
||||||
case DirStatus::OutOfSync:
|
case SyncthingDirStatus::OutOfSync:
|
||||||
status = "out of sync"; break;
|
status = "out of sync"; break;
|
||||||
default:
|
default:
|
||||||
status = "unknown";
|
status = "unknown";
|
||||||
|
@ -323,7 +323,7 @@ void Application::printStatus(const ArgumentOccurrence &)
|
||||||
printProperty("Min. free disk percentage", dir->minDiskFreePercentage);
|
printProperty("Min. free disk percentage", dir->minDiskFreePercentage);
|
||||||
if(!dir->errors.empty()) {
|
if(!dir->errors.empty()) {
|
||||||
cout << " Errors\n";
|
cout << " Errors\n";
|
||||||
for(const DirError &error : dir->errors) {
|
for(const SyncthingDirError &error : dir->errors) {
|
||||||
printProperty(" - Message", error.message);
|
printProperty(" - Message", error.message);
|
||||||
printProperty(" File", error.path);
|
printProperty(" File", error.path);
|
||||||
}
|
}
|
||||||
|
@ -348,17 +348,17 @@ void Application::printStatus(const ArgumentOccurrence &)
|
||||||
status = "paused";
|
status = "paused";
|
||||||
} else {
|
} else {
|
||||||
switch(dev->status) {
|
switch(dev->status) {
|
||||||
case DevStatus::Disconnected:
|
case SyncthingDevStatus::Disconnected:
|
||||||
status = "disconnected"; break;
|
status = "disconnected"; break;
|
||||||
case DevStatus::OwnDevice:
|
case SyncthingDevStatus::OwnDevice:
|
||||||
status = "own device"; break;
|
status = "own device"; break;
|
||||||
case DevStatus::Idle:
|
case SyncthingDevStatus::Idle:
|
||||||
status = "idle"; break;
|
status = "idle"; break;
|
||||||
case DevStatus::Synchronizing:
|
case SyncthingDevStatus::Synchronizing:
|
||||||
status = "synchronizing"; break;
|
status = "synchronizing"; break;
|
||||||
case DevStatus::OutOfSync:
|
case SyncthingDevStatus::OutOfSync:
|
||||||
status = "out of sync"; break;
|
status = "out of sync"; break;
|
||||||
case DevStatus::Rejected:
|
case SyncthingDevStatus::Rejected:
|
||||||
status = "rejected"; break;
|
status = "rejected"; break;
|
||||||
default:
|
default:
|
||||||
status = "unknown";
|
status = "unknown";
|
||||||
|
|
|
@ -9,6 +9,8 @@ set(META_PROJECT_VARNAME_UPPER LIB_SYNCTHING_CONNECTOR)
|
||||||
|
|
||||||
# add project files
|
# add project files
|
||||||
set(HEADER_FILES
|
set(HEADER_FILES
|
||||||
|
syncthingdir.h
|
||||||
|
syncthingdev.h
|
||||||
syncthingconnection.h
|
syncthingconnection.h
|
||||||
syncthingconnectionsettings.h
|
syncthingconnectionsettings.h
|
||||||
syncthingconfig.h
|
syncthingconfig.h
|
||||||
|
@ -16,6 +18,8 @@ set(HEADER_FILES
|
||||||
utils.h
|
utils.h
|
||||||
)
|
)
|
||||||
set(SRC_FILES
|
set(SRC_FILES
|
||||||
|
syncthingdir.cpp
|
||||||
|
syncthingdev.cpp
|
||||||
syncthingconnection.cpp
|
syncthingconnection.cpp
|
||||||
syncthingconnectionsettings.cpp
|
syncthingconnectionsettings.cpp
|
||||||
syncthingconfig.cpp
|
syncthingconfig.cpp
|
||||||
|
|
|
@ -34,101 +34,6 @@ QNetworkAccessManager &networkAccessManager()
|
||||||
return *networkAccessManager;
|
return *networkAccessManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Assigns the status from the specified status string.
|
|
||||||
* \returns Returns whether the status has actually changed.
|
|
||||||
*/
|
|
||||||
bool SyncthingDir::assignStatus(const QString &statusStr, ChronoUtilities::DateTime time)
|
|
||||||
{
|
|
||||||
if(lastStatusUpdate > time) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
lastStatusUpdate = time;
|
|
||||||
}
|
|
||||||
DirStatus newStatus;
|
|
||||||
if(statusStr == QLatin1String("idle")) {
|
|
||||||
progressPercentage = 0;
|
|
||||||
newStatus = errors.empty() ? DirStatus::Idle : DirStatus::OutOfSync;
|
|
||||||
} else if(statusStr == QLatin1String("scanning")) {
|
|
||||||
newStatus = DirStatus::Scanning;
|
|
||||||
} else if(statusStr == QLatin1String("syncing")) {
|
|
||||||
if(!errors.empty()) {
|
|
||||||
errors.clear(); // errors become obsolete
|
|
||||||
status = DirStatus::Unknown; // ensure status changed signal is emitted
|
|
||||||
}
|
|
||||||
newStatus = DirStatus::Synchronizing;
|
|
||||||
} else if(statusStr == QLatin1String("error")) {
|
|
||||||
progressPercentage = 0;
|
|
||||||
newStatus = DirStatus::OutOfSync;
|
|
||||||
} else {
|
|
||||||
newStatus = errors.empty() ? DirStatus::Idle : DirStatus::OutOfSync;
|
|
||||||
}
|
|
||||||
if(newStatus != status) {
|
|
||||||
switch(status) {
|
|
||||||
case DirStatus::Scanning:
|
|
||||||
lastScanTime = DateTime::now();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
;
|
|
||||||
}
|
|
||||||
status = newStatus;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SyncthingDir::assignStatus(DirStatus newStatus, DateTime time)
|
|
||||||
{
|
|
||||||
if(lastStatusUpdate > time) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
lastStatusUpdate = time;
|
|
||||||
}
|
|
||||||
switch(newStatus) {
|
|
||||||
case DirStatus::Idle:
|
|
||||||
case DirStatus::Unknown:
|
|
||||||
if(!errors.empty()) {
|
|
||||||
newStatus = DirStatus::OutOfSync;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
;
|
|
||||||
}
|
|
||||||
if(newStatus != status) {
|
|
||||||
switch(status) {
|
|
||||||
case DirStatus::Scanning:
|
|
||||||
lastScanTime = DateTime::now();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
;
|
|
||||||
}
|
|
||||||
status = newStatus;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
SyncthingItemDownloadProgress::SyncthingItemDownloadProgress(const QString &containingDirPath, const QString &relativeItemPath, const QJsonObject &values) :
|
|
||||||
relativePath(relativeItemPath),
|
|
||||||
fileInfo(containingDirPath % QChar('/') % QString(relativeItemPath).replace(QChar('\\'), QChar('/'))),
|
|
||||||
blocksCurrentlyDownloading(values.value(QStringLiteral("Pulling")).toInt()),
|
|
||||||
blocksAlreadyDownloaded(values.value(QStringLiteral("Pulled")).toInt()),
|
|
||||||
totalNumberOfBlocks(values.value(QStringLiteral("Total")).toInt()),
|
|
||||||
downloadPercentage((blocksAlreadyDownloaded > 0 && totalNumberOfBlocks > 0)
|
|
||||||
? (static_cast<unsigned int>(blocksAlreadyDownloaded) * 100 / static_cast<unsigned int>(totalNumberOfBlocks))
|
|
||||||
: 0),
|
|
||||||
blocksCopiedFromOrigin(values.value(QStringLiteral("CopiedFromOrigin")).toInt()),
|
|
||||||
blocksCopiedFromElsewhere(values.value(QStringLiteral("CopiedFromElsewhere")).toInt()),
|
|
||||||
blocksReused(values.value(QStringLiteral("Reused")).toInt()),
|
|
||||||
bytesAlreadyHandled(values.value(QStringLiteral("BytesDone")).toInt()),
|
|
||||||
totalNumberOfBytes(values.value(QStringLiteral("BytesTotal")).toInt()),
|
|
||||||
label(QStringLiteral("%1 / %2 - %3 %").arg(
|
|
||||||
QString::fromLatin1(dataSizeToString(blocksAlreadyDownloaded > 0 ? static_cast<uint64>(blocksAlreadyDownloaded) * syncthingBlockSize : 0).data()),
|
|
||||||
QString::fromLatin1(dataSizeToString(totalNumberOfBlocks > 0 ? static_cast<uint64>(totalNumberOfBlocks) * syncthingBlockSize : 0).data()),
|
|
||||||
QString::number(downloadPercentage))
|
|
||||||
)
|
|
||||||
{}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \class SyncthingConnection
|
* \class SyncthingConnection
|
||||||
* \brief The SyncthingConnection class allows Qt applications to access Syncthing.
|
* \brief The SyncthingConnection class allows Qt applications to access Syncthing.
|
||||||
|
@ -199,7 +104,7 @@ QString SyncthingConnection::statusText() const
|
||||||
bool SyncthingConnection::hasOutOfSyncDirs() const
|
bool SyncthingConnection::hasOutOfSyncDirs() const
|
||||||
{
|
{
|
||||||
for(const SyncthingDir &dir : m_dirs) {
|
for(const SyncthingDir &dir : m_dirs) {
|
||||||
if(dir.status == DirStatus::OutOfSync) {
|
if(dir.status == SyncthingDirStatus::OutOfSync) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -799,7 +704,7 @@ void SyncthingConnection::readDevs(const QJsonArray &devs)
|
||||||
devItem.compression = devObj.value(QStringLiteral("compression")).toString();
|
devItem.compression = devObj.value(QStringLiteral("compression")).toString();
|
||||||
devItem.certName = devObj.value(QStringLiteral("certName")).toString();
|
devItem.certName = devObj.value(QStringLiteral("certName")).toString();
|
||||||
devItem.introducer = devObj.value(QStringLiteral("introducer")).toBool(false);
|
devItem.introducer = devObj.value(QStringLiteral("introducer")).toBool(false);
|
||||||
devItem.status = devItem.id == m_myId ? DevStatus::OwnDevice : DevStatus::Unknown;
|
devItem.status = devItem.id == m_myId ? SyncthingDevStatus::OwnDevice : SyncthingDevStatus::Unknown;
|
||||||
m_devs.push_back(move(devItem));
|
m_devs.push_back(move(devItem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -829,7 +734,7 @@ void SyncthingConnection::readStatus()
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for(SyncthingDev &dev : m_devs) {
|
for(SyncthingDev &dev : m_devs) {
|
||||||
if(dev.id == m_myId) {
|
if(dev.id == m_myId) {
|
||||||
dev.status = DevStatus::OwnDevice;
|
dev.status = SyncthingDevStatus::OwnDevice;
|
||||||
emit devStatusChanged(dev, index);
|
emit devStatusChanged(dev, index);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -888,19 +793,19 @@ void SyncthingConnection::readConnections()
|
||||||
const QJsonObject connectionObj(connectionsObj.value(dev.id).toObject());
|
const QJsonObject connectionObj(connectionsObj.value(dev.id).toObject());
|
||||||
if(!connectionObj.isEmpty()) {
|
if(!connectionObj.isEmpty()) {
|
||||||
switch(dev.status) {
|
switch(dev.status) {
|
||||||
case DevStatus::OwnDevice:
|
case SyncthingDevStatus::OwnDevice:
|
||||||
break;
|
break;
|
||||||
case DevStatus::Disconnected:
|
case SyncthingDevStatus::Disconnected:
|
||||||
case DevStatus::Unknown:
|
case SyncthingDevStatus::Unknown:
|
||||||
if(connectionObj.value(QStringLiteral("connected")).toBool(false)) {
|
if(connectionObj.value(QStringLiteral("connected")).toBool(false)) {
|
||||||
dev.status = DevStatus::Idle;
|
dev.status = SyncthingDevStatus::Idle;
|
||||||
} else {
|
} else {
|
||||||
dev.status = DevStatus::Disconnected;
|
dev.status = SyncthingDevStatus::Disconnected;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if(!connectionObj.value(QStringLiteral("connected")).toBool(false)) {
|
if(!connectionObj.value(QStringLiteral("connected")).toBool(false)) {
|
||||||
dev.status = DevStatus::Disconnected;
|
dev.status = SyncthingDevStatus::Disconnected;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dev.paused = connectionObj.value(QStringLiteral("paused")).toBool(false);
|
dev.paused = connectionObj.value(QStringLiteral("paused")).toBool(false);
|
||||||
|
@ -1244,10 +1149,10 @@ void SyncthingConnection::readDirEvent(DateTime eventTime, const QString &eventT
|
||||||
const QJsonObject error(errorVal.toObject());
|
const QJsonObject error(errorVal.toObject());
|
||||||
if(!error.isEmpty()) {
|
if(!error.isEmpty()) {
|
||||||
auto &errors = dirInfo->errors;
|
auto &errors = dirInfo->errors;
|
||||||
DirError dirError(error.value(QStringLiteral("error")).toString(), error.value(QStringLiteral("path")).toString());
|
SyncthingDirError dirError(error.value(QStringLiteral("error")).toString(), error.value(QStringLiteral("path")).toString());
|
||||||
if(find(errors.cbegin(), errors.cend(), dirError) == errors.cend()) {
|
if(find(errors.cbegin(), errors.cend(), dirError) == errors.cend()) {
|
||||||
errors.emplace_back(move(dirError));
|
errors.emplace_back(move(dirError));
|
||||||
dirInfo->assignStatus(DirStatus::OutOfSync, eventTime);
|
dirInfo->assignStatus(SyncthingDirStatus::OutOfSync, eventTime);
|
||||||
emitNotification(eventTime, dirInfo->errors.back().message);
|
emitNotification(eventTime, dirInfo->errors.back().message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1286,7 +1191,7 @@ void SyncthingConnection::readDirEvent(DateTime eventTime, const QString &eventT
|
||||||
if(current > 0 && total > 0) {
|
if(current > 0 && total > 0) {
|
||||||
dirInfo->progressPercentage = current * 100 / total;
|
dirInfo->progressPercentage = current * 100 / total;
|
||||||
dirInfo->progressRate = rate;
|
dirInfo->progressRate = rate;
|
||||||
dirInfo->assignStatus(DirStatus::Scanning, eventTime); // ensure state is scanning
|
dirInfo->assignStatus(SyncthingDirStatus::Scanning, eventTime); // ensure state is scanning
|
||||||
emit dirStatusChanged(*dirInfo, index);
|
emit dirStatusChanged(*dirInfo, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1307,28 +1212,28 @@ void SyncthingConnection::readDeviceEvent(DateTime eventTime, const QString &eve
|
||||||
// dev status changed, depending on event type
|
// dev status changed, depending on event type
|
||||||
int index;
|
int index;
|
||||||
if(SyncthingDev *devInfo = findDevInfo(dev, index)) {
|
if(SyncthingDev *devInfo = findDevInfo(dev, index)) {
|
||||||
DevStatus status = devInfo->status;
|
SyncthingDevStatus status = devInfo->status;
|
||||||
bool paused = devInfo->paused;
|
bool paused = devInfo->paused;
|
||||||
if(eventType == QLatin1String("DeviceConnected")) {
|
if(eventType == QLatin1String("DeviceConnected")) {
|
||||||
status = DevStatus::Idle; // TODO: figure out when dev is actually syncing
|
status = SyncthingDevStatus::Idle; // TODO: figure out when dev is actually syncing
|
||||||
} else if(eventType == QLatin1String("DeviceDisconnected")) {
|
} else if(eventType == QLatin1String("DeviceDisconnected")) {
|
||||||
status = DevStatus::Disconnected;
|
status = SyncthingDevStatus::Disconnected;
|
||||||
} else if(eventType == QLatin1String("DevicePaused")) {
|
} else if(eventType == QLatin1String("DevicePaused")) {
|
||||||
paused = true;
|
paused = true;
|
||||||
} else if(eventType == QLatin1String("DeviceRejected")) {
|
} else if(eventType == QLatin1String("DeviceRejected")) {
|
||||||
status = DevStatus::Rejected;
|
status = SyncthingDevStatus::Rejected;
|
||||||
} else if(eventType == QLatin1String("DeviceResumed")) {
|
} else if(eventType == QLatin1String("DeviceResumed")) {
|
||||||
paused = false;
|
paused = false;
|
||||||
// FIXME: correct to assume device which has just been resumed is still disconnected?
|
// FIXME: correct to assume device which has just been resumed is still disconnected?
|
||||||
status = DevStatus::Disconnected;
|
status = SyncthingDevStatus::Disconnected;
|
||||||
} else if(eventType == QLatin1String("DeviceDiscovered")) {
|
} else if(eventType == QLatin1String("DeviceDiscovered")) {
|
||||||
// we know about this device already, set status anyways because it might still be unknown
|
// we know about this device already, set status anyways because it might still be unknown
|
||||||
status = DevStatus::Disconnected;
|
status = SyncthingDevStatus::Disconnected;
|
||||||
} else {
|
} else {
|
||||||
return; // can't handle other event types currently
|
return; // can't handle other event types currently
|
||||||
}
|
}
|
||||||
if(devInfo->status != status || devInfo->paused != paused) {
|
if(devInfo->status != status || devInfo->paused != paused) {
|
||||||
if(devInfo->status != DevStatus::OwnDevice) { // don't mess with the status of the own device
|
if(devInfo->status != SyncthingDevStatus::OwnDevice) { // don't mess with the status of the own device
|
||||||
devInfo->status = status;
|
devInfo->status = status;
|
||||||
}
|
}
|
||||||
devInfo->paused = paused;
|
devInfo->paused = paused;
|
||||||
|
@ -1371,10 +1276,10 @@ void SyncthingConnection::readItemFinished(DateTime eventTime, const QJsonObject
|
||||||
}
|
}
|
||||||
emit dirStatusChanged(*dirInfo, index);
|
emit dirStatusChanged(*dirInfo, index);
|
||||||
}
|
}
|
||||||
} else if(dirInfo->status == DirStatus::OutOfSync) {
|
} else if(dirInfo->status == SyncthingDirStatus::OutOfSync) {
|
||||||
// FIXME: find better way to check whether the event is still relevant
|
// FIXME: find better way to check whether the event is still relevant
|
||||||
dirInfo->errors.emplace_back(error, item);
|
dirInfo->errors.emplace_back(error, item);
|
||||||
dirInfo->status = DirStatus::OutOfSync;
|
dirInfo->status = SyncthingDirStatus::OutOfSync;
|
||||||
emit dirStatusChanged(*dirInfo, index);
|
emit dirStatusChanged(*dirInfo, index);
|
||||||
emitNotification(eventTime, error);
|
emitNotification(eventTime, error);
|
||||||
}
|
}
|
||||||
|
@ -1469,10 +1374,10 @@ void SyncthingConnection::setStatus(SyncthingStatus status)
|
||||||
bool scanning = false;
|
bool scanning = false;
|
||||||
bool synchronizing = false;
|
bool synchronizing = false;
|
||||||
for(const SyncthingDir &dir : m_dirs) {
|
for(const SyncthingDir &dir : m_dirs) {
|
||||||
if(dir.status == DirStatus::Synchronizing) {
|
if(dir.status == SyncthingDirStatus::Synchronizing) {
|
||||||
synchronizing = true;
|
synchronizing = true;
|
||||||
break;
|
break;
|
||||||
} else if(dir.status == DirStatus::Scanning) {
|
} else if(dir.status == SyncthingDirStatus::Scanning) {
|
||||||
scanning = true;
|
scanning = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
#ifndef SYNCTHINGCONNECTION_H
|
#ifndef SYNCTHINGCONNECTION_H
|
||||||
#define SYNCTHINGCONNECTION_H
|
#define SYNCTHINGCONNECTION_H
|
||||||
|
|
||||||
#include "./global.h"
|
#include "./syncthingdir.h"
|
||||||
|
#include "./syncthingdev.h"
|
||||||
#include <c++utilities/chrono/datetime.h>
|
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QSslError>
|
#include <QSslError>
|
||||||
#include <QFileInfo>
|
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -38,115 +36,6 @@ enum class SyncthingStatus
|
||||||
BeingDestroyed
|
BeingDestroyed
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class DirStatus
|
|
||||||
{
|
|
||||||
Unknown,
|
|
||||||
Idle,
|
|
||||||
Scanning,
|
|
||||||
Synchronizing,
|
|
||||||
Paused,
|
|
||||||
OutOfSync
|
|
||||||
};
|
|
||||||
|
|
||||||
struct LIB_SYNCTHING_CONNECTOR_EXPORT DirError
|
|
||||||
{
|
|
||||||
DirError(const QString &message, const QString &path) :
|
|
||||||
message(message),
|
|
||||||
path(path)
|
|
||||||
{}
|
|
||||||
|
|
||||||
bool operator ==(const DirError &other) const
|
|
||||||
{
|
|
||||||
return message == other.message && path == other.path;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString message;
|
|
||||||
QString path;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingItemDownloadProgress
|
|
||||||
{
|
|
||||||
SyncthingItemDownloadProgress(const QString &containingDirPath, const QString &relativeItemPath, const QJsonObject &values);
|
|
||||||
QString relativePath;
|
|
||||||
QFileInfo fileInfo;
|
|
||||||
int blocksCurrentlyDownloading = 0;
|
|
||||||
int blocksAlreadyDownloaded = 0;
|
|
||||||
int totalNumberOfBlocks = 0;
|
|
||||||
unsigned int downloadPercentage = 0;
|
|
||||||
int blocksCopiedFromOrigin = 0;
|
|
||||||
int blocksCopiedFromElsewhere = 0;
|
|
||||||
int blocksReused = 0;
|
|
||||||
int bytesAlreadyHandled;
|
|
||||||
int totalNumberOfBytes = 0;
|
|
||||||
QString label;
|
|
||||||
ChronoUtilities::DateTime lastUpdate;
|
|
||||||
static constexpr unsigned int syncthingBlockSize = 128 * 1024;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDir
|
|
||||||
{
|
|
||||||
QString id;
|
|
||||||
QString label;
|
|
||||||
QString path;
|
|
||||||
QStringList devices;
|
|
||||||
bool readOnly = false;
|
|
||||||
bool ignorePermissions = false;
|
|
||||||
bool autoNormalize = false;
|
|
||||||
int rescanInterval = 0;
|
|
||||||
int minDiskFreePercentage = 0;
|
|
||||||
DirStatus status = DirStatus::Idle;
|
|
||||||
ChronoUtilities::DateTime lastStatusUpdate;
|
|
||||||
int progressPercentage = 0;
|
|
||||||
int progressRate = 0;
|
|
||||||
std::vector<DirError> errors;
|
|
||||||
int globalBytes = 0, globalDeleted = 0, globalFiles = 0;
|
|
||||||
int localBytes = 0, localDeleted = 0, localFiles = 0;
|
|
||||||
int neededByted = 0, neededFiles = 0;
|
|
||||||
ChronoUtilities::DateTime lastScanTime;
|
|
||||||
ChronoUtilities::DateTime lastFileTime;
|
|
||||||
QString lastFileName;
|
|
||||||
bool lastFileDeleted = false;
|
|
||||||
std::vector<SyncthingItemDownloadProgress> downloadingItems;
|
|
||||||
int blocksAlreadyDownloaded = 0;
|
|
||||||
int blocksToBeDownloaded = 0;
|
|
||||||
unsigned int downloadPercentage = 0;
|
|
||||||
QString downloadLabel;
|
|
||||||
|
|
||||||
bool assignStatus(const QString &statusStr, ChronoUtilities::DateTime time);
|
|
||||||
bool assignStatus(DirStatus newStatus, ChronoUtilities::DateTime time);
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class DevStatus
|
|
||||||
{
|
|
||||||
Unknown,
|
|
||||||
Disconnected,
|
|
||||||
OwnDevice,
|
|
||||||
Idle,
|
|
||||||
Synchronizing,
|
|
||||||
OutOfSync,
|
|
||||||
Rejected
|
|
||||||
};
|
|
||||||
|
|
||||||
struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDev
|
|
||||||
{
|
|
||||||
QString id;
|
|
||||||
QString name;
|
|
||||||
QStringList addresses;
|
|
||||||
QString compression;
|
|
||||||
QString certName;
|
|
||||||
DevStatus status;
|
|
||||||
int progressPercentage = 0;
|
|
||||||
int progressRate = 0;
|
|
||||||
bool introducer = false;
|
|
||||||
bool paused = false;
|
|
||||||
int totalIncomingTraffic = 0;
|
|
||||||
int totalOutgoingTraffic = 0;
|
|
||||||
QString connectionAddress;
|
|
||||||
QString connectionType;
|
|
||||||
QString clientVersion;
|
|
||||||
ChronoUtilities::DateTime lastSeen;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingLogEntry
|
struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingLogEntry
|
||||||
{
|
{
|
||||||
SyncthingLogEntry(const QString &when, const QString &message) :
|
SyncthingLogEntry(const QString &when, const QString &message) :
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
#include "./syncthingdev.h"
|
||||||
|
|
||||||
|
namespace Data {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace Data
|
|
@ -0,0 +1,46 @@
|
||||||
|
#ifndef DATA_SYNCTHINGDEV_H
|
||||||
|
#define DATA_SYNCTHINGDEV_H
|
||||||
|
|
||||||
|
#include "./global.h"
|
||||||
|
|
||||||
|
#include <c++utilities/chrono/datetime.h>
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
namespace Data {
|
||||||
|
|
||||||
|
enum class SyncthingDevStatus
|
||||||
|
{
|
||||||
|
Unknown,
|
||||||
|
Disconnected,
|
||||||
|
OwnDevice,
|
||||||
|
Idle,
|
||||||
|
Synchronizing,
|
||||||
|
OutOfSync,
|
||||||
|
Rejected
|
||||||
|
};
|
||||||
|
|
||||||
|
struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDev
|
||||||
|
{
|
||||||
|
QString id;
|
||||||
|
QString name;
|
||||||
|
QStringList addresses;
|
||||||
|
QString compression;
|
||||||
|
QString certName;
|
||||||
|
SyncthingDevStatus status;
|
||||||
|
int progressPercentage = 0;
|
||||||
|
int progressRate = 0;
|
||||||
|
bool introducer = false;
|
||||||
|
bool paused = false;
|
||||||
|
int totalIncomingTraffic = 0;
|
||||||
|
int totalOutgoingTraffic = 0;
|
||||||
|
QString connectionAddress;
|
||||||
|
QString connectionType;
|
||||||
|
QString clientVersion;
|
||||||
|
ChronoUtilities::DateTime lastSeen;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Data
|
||||||
|
|
||||||
|
#endif // DATA_SYNCTHINGDEV_H
|
|
@ -0,0 +1,108 @@
|
||||||
|
#include "./syncthingdir.h"
|
||||||
|
|
||||||
|
#include <c++utilities/conversion/stringconversion.h>
|
||||||
|
|
||||||
|
#include <QStringBuilder>
|
||||||
|
#include <QJsonObject>
|
||||||
|
|
||||||
|
using namespace ChronoUtilities;
|
||||||
|
using namespace ConversionUtilities;
|
||||||
|
|
||||||
|
namespace Data {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Assigns the status from the specified status string.
|
||||||
|
* \returns Returns whether the status has actually changed.
|
||||||
|
*/
|
||||||
|
bool SyncthingDir::assignStatus(const QString &statusStr, ChronoUtilities::DateTime time)
|
||||||
|
{
|
||||||
|
if(lastStatusUpdate > time) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
lastStatusUpdate = time;
|
||||||
|
}
|
||||||
|
SyncthingDirStatus newStatus;
|
||||||
|
if(statusStr == QLatin1String("idle")) {
|
||||||
|
progressPercentage = 0;
|
||||||
|
newStatus = errors.empty() ? SyncthingDirStatus::Idle : SyncthingDirStatus::OutOfSync;
|
||||||
|
} else if(statusStr == QLatin1String("scanning")) {
|
||||||
|
newStatus = SyncthingDirStatus::Scanning;
|
||||||
|
} else if(statusStr == QLatin1String("syncing")) {
|
||||||
|
if(!errors.empty()) {
|
||||||
|
errors.clear(); // errors become obsolete
|
||||||
|
status = SyncthingDirStatus::Unknown; // ensure status changed signal is emitted
|
||||||
|
}
|
||||||
|
newStatus = SyncthingDirStatus::Synchronizing;
|
||||||
|
} else if(statusStr == QLatin1String("error")) {
|
||||||
|
progressPercentage = 0;
|
||||||
|
newStatus = SyncthingDirStatus::OutOfSync;
|
||||||
|
} else {
|
||||||
|
newStatus = errors.empty() ? SyncthingDirStatus::Idle : SyncthingDirStatus::OutOfSync;
|
||||||
|
}
|
||||||
|
if(newStatus != status) {
|
||||||
|
switch(status) {
|
||||||
|
case SyncthingDirStatus::Scanning:
|
||||||
|
lastScanTime = DateTime::now();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
;
|
||||||
|
}
|
||||||
|
status = newStatus;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SyncthingDir::assignStatus(SyncthingDirStatus newStatus, DateTime time)
|
||||||
|
{
|
||||||
|
if(lastStatusUpdate > time) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
lastStatusUpdate = time;
|
||||||
|
}
|
||||||
|
switch(newStatus) {
|
||||||
|
case SyncthingDirStatus::Idle:
|
||||||
|
case SyncthingDirStatus::Unknown:
|
||||||
|
if(!errors.empty()) {
|
||||||
|
newStatus = SyncthingDirStatus::OutOfSync;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
;
|
||||||
|
}
|
||||||
|
if(newStatus != status) {
|
||||||
|
switch(status) {
|
||||||
|
case SyncthingDirStatus::Scanning:
|
||||||
|
lastScanTime = DateTime::now();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
;
|
||||||
|
}
|
||||||
|
status = newStatus;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SyncthingItemDownloadProgress::SyncthingItemDownloadProgress(const QString &containingDirPath, const QString &relativeItemPath, const QJsonObject &values) :
|
||||||
|
relativePath(relativeItemPath),
|
||||||
|
fileInfo(containingDirPath % QChar('/') % QString(relativeItemPath).replace(QChar('\\'), QChar('/'))),
|
||||||
|
blocksCurrentlyDownloading(values.value(QStringLiteral("Pulling")).toInt()),
|
||||||
|
blocksAlreadyDownloaded(values.value(QStringLiteral("Pulled")).toInt()),
|
||||||
|
totalNumberOfBlocks(values.value(QStringLiteral("Total")).toInt()),
|
||||||
|
downloadPercentage((blocksAlreadyDownloaded > 0 && totalNumberOfBlocks > 0)
|
||||||
|
? (static_cast<unsigned int>(blocksAlreadyDownloaded) * 100 / static_cast<unsigned int>(totalNumberOfBlocks))
|
||||||
|
: 0),
|
||||||
|
blocksCopiedFromOrigin(values.value(QStringLiteral("CopiedFromOrigin")).toInt()),
|
||||||
|
blocksCopiedFromElsewhere(values.value(QStringLiteral("CopiedFromElsewhere")).toInt()),
|
||||||
|
blocksReused(values.value(QStringLiteral("Reused")).toInt()),
|
||||||
|
bytesAlreadyHandled(values.value(QStringLiteral("BytesDone")).toInt()),
|
||||||
|
totalNumberOfBytes(values.value(QStringLiteral("BytesTotal")).toInt()),
|
||||||
|
label(QStringLiteral("%1 / %2 - %3 %").arg(
|
||||||
|
QString::fromLatin1(dataSizeToString(blocksAlreadyDownloaded > 0 ? static_cast<uint64>(blocksAlreadyDownloaded) * syncthingBlockSize : 0).data()),
|
||||||
|
QString::fromLatin1(dataSizeToString(totalNumberOfBlocks > 0 ? static_cast<uint64>(totalNumberOfBlocks) * syncthingBlockSize : 0).data()),
|
||||||
|
QString::number(downloadPercentage))
|
||||||
|
)
|
||||||
|
{}
|
||||||
|
|
||||||
|
} // namespace Data
|
|
@ -0,0 +1,95 @@
|
||||||
|
#ifndef DATA_SYNCTHINGDIR_H
|
||||||
|
#define DATA_SYNCTHINGDIR_H
|
||||||
|
|
||||||
|
#include "./global.h"
|
||||||
|
|
||||||
|
#include <c++utilities/chrono/datetime.h>
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
|
QT_FORWARD_DECLARE_CLASS(QJsonObject)
|
||||||
|
|
||||||
|
namespace Data {
|
||||||
|
|
||||||
|
enum class SyncthingDirStatus
|
||||||
|
{
|
||||||
|
Unknown,
|
||||||
|
Idle,
|
||||||
|
Scanning,
|
||||||
|
Synchronizing,
|
||||||
|
Paused,
|
||||||
|
OutOfSync
|
||||||
|
};
|
||||||
|
|
||||||
|
struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDirError
|
||||||
|
{
|
||||||
|
SyncthingDirError(const QString &message, const QString &path) :
|
||||||
|
message(message),
|
||||||
|
path(path)
|
||||||
|
{}
|
||||||
|
|
||||||
|
bool operator ==(const SyncthingDirError &other) const
|
||||||
|
{
|
||||||
|
return message == other.message && path == other.path;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString message;
|
||||||
|
QString path;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingItemDownloadProgress
|
||||||
|
{
|
||||||
|
SyncthingItemDownloadProgress(const QString &containingDirPath, const QString &relativeItemPath, const QJsonObject &values);
|
||||||
|
QString relativePath;
|
||||||
|
QFileInfo fileInfo;
|
||||||
|
int blocksCurrentlyDownloading = 0;
|
||||||
|
int blocksAlreadyDownloaded = 0;
|
||||||
|
int totalNumberOfBlocks = 0;
|
||||||
|
unsigned int downloadPercentage = 0;
|
||||||
|
int blocksCopiedFromOrigin = 0;
|
||||||
|
int blocksCopiedFromElsewhere = 0;
|
||||||
|
int blocksReused = 0;
|
||||||
|
int bytesAlreadyHandled;
|
||||||
|
int totalNumberOfBytes = 0;
|
||||||
|
QString label;
|
||||||
|
ChronoUtilities::DateTime lastUpdate;
|
||||||
|
static constexpr unsigned int syncthingBlockSize = 128 * 1024;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDir
|
||||||
|
{
|
||||||
|
QString id;
|
||||||
|
QString label;
|
||||||
|
QString path;
|
||||||
|
QStringList devices;
|
||||||
|
bool readOnly = false;
|
||||||
|
bool ignorePermissions = false;
|
||||||
|
bool autoNormalize = false;
|
||||||
|
int rescanInterval = 0;
|
||||||
|
int minDiskFreePercentage = 0;
|
||||||
|
SyncthingDirStatus status = SyncthingDirStatus::Idle;
|
||||||
|
ChronoUtilities::DateTime lastStatusUpdate;
|
||||||
|
int progressPercentage = 0;
|
||||||
|
int progressRate = 0;
|
||||||
|
std::vector<SyncthingDirError> errors;
|
||||||
|
int globalBytes = 0, globalDeleted = 0, globalFiles = 0;
|
||||||
|
int localBytes = 0, localDeleted = 0, localFiles = 0;
|
||||||
|
int neededByted = 0, neededFiles = 0;
|
||||||
|
ChronoUtilities::DateTime lastScanTime;
|
||||||
|
ChronoUtilities::DateTime lastFileTime;
|
||||||
|
QString lastFileName;
|
||||||
|
bool lastFileDeleted = false;
|
||||||
|
std::vector<SyncthingItemDownloadProgress> downloadingItems;
|
||||||
|
int blocksAlreadyDownloaded = 0;
|
||||||
|
int blocksToBeDownloaded = 0;
|
||||||
|
unsigned int downloadPercentage = 0;
|
||||||
|
QString downloadLabel;
|
||||||
|
|
||||||
|
bool assignStatus(const QString &statusStr, ChronoUtilities::DateTime time);
|
||||||
|
bool assignStatus(SyncthingDirStatus newStatus, ChronoUtilities::DateTime time);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Data
|
||||||
|
|
||||||
|
#endif // DATA_SYNCTHINGDIR_H
|
|
@ -153,13 +153,13 @@ QVariant SyncthingDeviceModel::data(const QModelIndex &index, int role) const
|
||||||
return tr("Paused");
|
return tr("Paused");
|
||||||
} else {
|
} else {
|
||||||
switch(dev.status) {
|
switch(dev.status) {
|
||||||
case DevStatus::Unknown: return tr("Unknown status");
|
case SyncthingDevStatus::Unknown: return tr("Unknown status");
|
||||||
case DevStatus::OwnDevice: return tr("Own device");
|
case SyncthingDevStatus::OwnDevice: return tr("Own device");
|
||||||
case DevStatus::Idle: return tr("Idle");
|
case SyncthingDevStatus::Idle: return tr("Idle");
|
||||||
case DevStatus::Disconnected: return tr("Disconnected");
|
case SyncthingDevStatus::Disconnected: return tr("Disconnected");
|
||||||
case DevStatus::Synchronizing: return dev.progressPercentage > 0 ? tr("Synchronizing (%1 %)").arg(dev.progressPercentage) : tr("Synchronizing");
|
case SyncthingDevStatus::Synchronizing: return dev.progressPercentage > 0 ? tr("Synchronizing (%1 %)").arg(dev.progressPercentage) : tr("Synchronizing");
|
||||||
case DevStatus::OutOfSync: return tr("Out of sync");
|
case SyncthingDevStatus::OutOfSync: return tr("Out of sync");
|
||||||
case DevStatus::Rejected: return tr("Rejected");
|
case SyncthingDevStatus::Rejected: return tr("Rejected");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -172,13 +172,13 @@ QVariant SyncthingDeviceModel::data(const QModelIndex &index, int role) const
|
||||||
return m_pausedIcon;
|
return m_pausedIcon;
|
||||||
} else {
|
} else {
|
||||||
switch(dev.status) {
|
switch(dev.status) {
|
||||||
case DevStatus::Unknown:
|
case SyncthingDevStatus::Unknown:
|
||||||
case DevStatus::Disconnected: return m_unknownIcon;
|
case SyncthingDevStatus::Disconnected: return m_unknownIcon;
|
||||||
case DevStatus::OwnDevice:
|
case SyncthingDevStatus::OwnDevice:
|
||||||
case DevStatus::Idle: return m_idleIcon;
|
case SyncthingDevStatus::Idle: return m_idleIcon;
|
||||||
case DevStatus::Synchronizing: return m_syncIcon;
|
case SyncthingDevStatus::Synchronizing: return m_syncIcon;
|
||||||
case DevStatus::OutOfSync:
|
case SyncthingDevStatus::OutOfSync:
|
||||||
case DevStatus::Rejected: return m_errorIcon;
|
case SyncthingDevStatus::Rejected: return m_errorIcon;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -196,13 +196,13 @@ QVariant SyncthingDeviceModel::data(const QModelIndex &index, int role) const
|
||||||
case 1:
|
case 1:
|
||||||
if(!dev.paused) {
|
if(!dev.paused) {
|
||||||
switch(dev.status) {
|
switch(dev.status) {
|
||||||
case DevStatus::Unknown: break;
|
case SyncthingDevStatus::Unknown: break;
|
||||||
case DevStatus::Disconnected: break;
|
case SyncthingDevStatus::Disconnected: break;
|
||||||
case DevStatus::OwnDevice:
|
case SyncthingDevStatus::OwnDevice:
|
||||||
case DevStatus::Idle: return QColor(Qt::darkGreen);
|
case SyncthingDevStatus::Idle: return QColor(Qt::darkGreen);
|
||||||
case DevStatus::Synchronizing: return QColor(Qt::darkBlue);
|
case SyncthingDevStatus::Synchronizing: return QColor(Qt::darkBlue);
|
||||||
case DevStatus::OutOfSync:
|
case SyncthingDevStatus::OutOfSync:
|
||||||
case DevStatus::Rejected: return QColor(Qt::red);
|
case SyncthingDevStatus::Rejected: return QColor(Qt::red);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -213,7 +213,7 @@ QVariant SyncthingDeviceModel::data(const QModelIndex &index, int role) const
|
||||||
case DevicePaused:
|
case DevicePaused:
|
||||||
return dev.paused;
|
return dev.paused;
|
||||||
case IsOwnDevice:
|
case IsOwnDevice:
|
||||||
return dev.status == DevStatus::OwnDevice;
|
return dev.status == SyncthingDevStatus::OwnDevice;
|
||||||
default:
|
default:
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,12 +165,12 @@ QVariant SyncthingDirectoryModel::data(const QModelIndex &index, int role) const
|
||||||
case 0: return dir.label.isEmpty() ? dir.id : dir.label;
|
case 0: return dir.label.isEmpty() ? dir.id : dir.label;
|
||||||
case 1:
|
case 1:
|
||||||
switch(dir.status) {
|
switch(dir.status) {
|
||||||
case DirStatus::Unknown: return tr("Unknown status");
|
case SyncthingDirStatus::Unknown: return tr("Unknown status");
|
||||||
case DirStatus::Idle: return tr("Idle");
|
case SyncthingDirStatus::Idle: return tr("Idle");
|
||||||
case DirStatus::Scanning: return dir.progressPercentage > 0 ? tr("Scanning (%1 %)").arg(dir.progressPercentage) : tr("Scanning");
|
case SyncthingDirStatus::Scanning: return dir.progressPercentage > 0 ? tr("Scanning (%1 %)").arg(dir.progressPercentage) : tr("Scanning");
|
||||||
case DirStatus::Synchronizing: return dir.progressPercentage > 0 ? tr("Synchronizing (%1 %)").arg(dir.progressPercentage) : tr("Synchronizing");
|
case SyncthingDirStatus::Synchronizing: return dir.progressPercentage > 0 ? tr("Synchronizing (%1 %)").arg(dir.progressPercentage) : tr("Synchronizing");
|
||||||
case DirStatus::Paused: return tr("Paused");
|
case SyncthingDirStatus::Paused: return tr("Paused");
|
||||||
case DirStatus::OutOfSync: return tr("Out of sync");
|
case SyncthingDirStatus::OutOfSync: return tr("Out of sync");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -179,12 +179,12 @@ QVariant SyncthingDirectoryModel::data(const QModelIndex &index, int role) const
|
||||||
switch(index.column()) {
|
switch(index.column()) {
|
||||||
case 0:
|
case 0:
|
||||||
switch(dir.status) {
|
switch(dir.status) {
|
||||||
case DirStatus::Unknown: return m_unknownIcon;
|
case SyncthingDirStatus::Unknown: return m_unknownIcon;
|
||||||
case DirStatus::Idle: return m_idleIcon;
|
case SyncthingDirStatus::Idle: return m_idleIcon;
|
||||||
case DirStatus::Scanning: return m_otherIcon;
|
case SyncthingDirStatus::Scanning: return m_otherIcon;
|
||||||
case DirStatus::Synchronizing: return m_syncIcon;
|
case SyncthingDirStatus::Synchronizing: return m_syncIcon;
|
||||||
case DirStatus::Paused: return m_pausedIcon;
|
case SyncthingDirStatus::Paused: return m_pausedIcon;
|
||||||
case DirStatus::OutOfSync: return m_errorIcon;
|
case SyncthingDirStatus::OutOfSync: return m_errorIcon;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -200,12 +200,12 @@ QVariant SyncthingDirectoryModel::data(const QModelIndex &index, int role) const
|
||||||
case 0: break;
|
case 0: break;
|
||||||
case 1:
|
case 1:
|
||||||
switch(dir.status) {
|
switch(dir.status) {
|
||||||
case DirStatus::Unknown: break;
|
case SyncthingDirStatus::Unknown: break;
|
||||||
case DirStatus::Idle: return QColor(Qt::darkGreen);
|
case SyncthingDirStatus::Idle: return QColor(Qt::darkGreen);
|
||||||
case DirStatus::Scanning: return QColor(Qt::blue);
|
case SyncthingDirStatus::Scanning: return QColor(Qt::blue);
|
||||||
case DirStatus::Synchronizing: return QColor(Qt::blue);
|
case SyncthingDirStatus::Synchronizing: return QColor(Qt::blue);
|
||||||
case DirStatus::Paused: break;
|
case SyncthingDirStatus::Paused: break;
|
||||||
case DirStatus::OutOfSync: return QColor(Qt::red);
|
case SyncthingDirStatus::OutOfSync: return QColor(Qt::red);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ void DirView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
// show errors
|
// show errors
|
||||||
auto *textViewDlg = new TextViewDialog(tr("Errors of %1").arg(dir->label.isEmpty() ? dir->id : dir->label));
|
auto *textViewDlg = new TextViewDialog(tr("Errors of %1").arg(dir->label.isEmpty() ? dir->id : dir->label));
|
||||||
auto *browser = textViewDlg->browser();
|
auto *browser = textViewDlg->browser();
|
||||||
for(const DirError &error : dir->errors) {
|
for(const SyncthingDirError &error : dir->errors) {
|
||||||
browser->append(error.path % QChar(':') % QChar(' ') % QChar('\n') % error.message % QChar('\n'));
|
browser->append(error.path % QChar(':') % QChar(' ') % QChar('\n') % error.message % QChar('\n'));
|
||||||
}
|
}
|
||||||
textViewDlg->show();
|
textViewDlg->show();
|
||||||
|
|
|
@ -287,17 +287,17 @@
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui/dirview.cpp" line="67"/>
|
<location filename="../gui/dirview.cpp" line="68"/>
|
||||||
<source>Copy value</source>
|
<source>Copy value</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui/dirview.cpp" line="69"/>
|
<location filename="../gui/dirview.cpp" line="70"/>
|
||||||
<source>Copy label/ID</source>
|
<source>Copy label/ID</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui/dirview.cpp" line="70"/>
|
<location filename="../gui/dirview.cpp" line="71"/>
|
||||||
<source>Copy path</source>
|
<source>Copy path</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
|
|
@ -287,17 +287,17 @@
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui/dirview.cpp" line="67"/>
|
<location filename="../gui/dirview.cpp" line="68"/>
|
||||||
<source>Copy value</source>
|
<source>Copy value</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui/dirview.cpp" line="69"/>
|
<location filename="../gui/dirview.cpp" line="70"/>
|
||||||
<source>Copy label/ID</source>
|
<source>Copy label/ID</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../gui/dirview.cpp" line="70"/>
|
<location filename="../gui/dirview.cpp" line="71"/>
|
||||||
<source>Copy path</source>
|
<source>Copy path</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
|
Loading…
Reference in New Issue