Move status strings to connector backend
This commit is contained in:
parent
e7c03881f1
commit
eab769b654
|
@ -327,24 +327,7 @@ void Application::printStatus(const ArgumentOccurrence &)
|
||||||
setStyle(cout);
|
setStyle(cout);
|
||||||
printProperty("Label", dir->label);
|
printProperty("Label", dir->label);
|
||||||
printProperty("Path", dir->path);
|
printProperty("Path", dir->path);
|
||||||
const char *status;
|
printProperty("Status", statusString(dir->status));
|
||||||
switch(dir->status) {
|
|
||||||
case SyncthingDirStatus::Idle:
|
|
||||||
status = "idle"; break;
|
|
||||||
case SyncthingDirStatus::Unshared:
|
|
||||||
status = "unshared"; break;
|
|
||||||
case SyncthingDirStatus::Scanning:
|
|
||||||
status = "scanning"; break;
|
|
||||||
case SyncthingDirStatus::Synchronizing:
|
|
||||||
status = "synchronizing"; break;
|
|
||||||
case SyncthingDirStatus::Paused:
|
|
||||||
status = "paused"; break;
|
|
||||||
case SyncthingDirStatus::OutOfSync:
|
|
||||||
status = "out of sync"; break;
|
|
||||||
default:
|
|
||||||
status = "unknown";
|
|
||||||
}
|
|
||||||
printProperty("Status", status);
|
|
||||||
printProperty("Last scan time", dir->lastScanTime);
|
printProperty("Last scan time", dir->lastScanTime);
|
||||||
printProperty("Last file time", dir->lastFileTime);
|
printProperty("Last file time", dir->lastFileTime);
|
||||||
printProperty("Last file name", dir->lastFileName);
|
printProperty("Last file name", dir->lastFileName);
|
||||||
|
@ -377,26 +360,11 @@ void Application::printStatus(const ArgumentOccurrence &)
|
||||||
cout << dev->name.toLocal8Bit().data() << '\n';
|
cout << dev->name.toLocal8Bit().data() << '\n';
|
||||||
setStyle(cout);
|
setStyle(cout);
|
||||||
printProperty("ID", dev->id);
|
printProperty("ID", dev->id);
|
||||||
const char *status;
|
QString status;
|
||||||
if(dev->paused) {
|
if(dev->paused) {
|
||||||
status = "paused";
|
status = QStringLiteral("paused");
|
||||||
} else {
|
} else {
|
||||||
switch(dev->status) {
|
status = statusString(dev->status);
|
||||||
case SyncthingDevStatus::Disconnected:
|
|
||||||
status = "disconnected"; break;
|
|
||||||
case SyncthingDevStatus::OwnDevice:
|
|
||||||
status = "own device"; break;
|
|
||||||
case SyncthingDevStatus::Idle:
|
|
||||||
status = "idle"; break;
|
|
||||||
case SyncthingDevStatus::Synchronizing:
|
|
||||||
status = "synchronizing"; break;
|
|
||||||
case SyncthingDevStatus::OutOfSync:
|
|
||||||
status = "out of sync"; break;
|
|
||||||
case SyncthingDevStatus::Rejected:
|
|
||||||
status = "rejected"; break;
|
|
||||||
default:
|
|
||||||
status = "unknown";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
printProperty("Status", status);
|
printProperty("Status", status);
|
||||||
printProperty("Addresses", dev->addresses);
|
printProperty("Addresses", dev->addresses);
|
||||||
|
|
|
@ -1,7 +1,27 @@
|
||||||
#include "./syncthingdev.h"
|
#include "./syncthingdev.h"
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
|
||||||
|
QString statusString(SyncthingDevStatus status)
|
||||||
|
{
|
||||||
|
switch(status) {
|
||||||
|
case SyncthingDevStatus::Unknown:
|
||||||
|
return QCoreApplication::translate("SyncthingDevStatus", "unknown");
|
||||||
|
case SyncthingDevStatus::Disconnected:
|
||||||
|
return QCoreApplication::translate("SyncthingDevStatus", "disconnected");
|
||||||
|
case SyncthingDevStatus::OwnDevice:
|
||||||
|
return QCoreApplication::translate("SyncthingDevStatus", "own device");
|
||||||
|
case SyncthingDevStatus::Idle:
|
||||||
|
return QCoreApplication::translate("SyncthingDevStatus", "idle");
|
||||||
|
case SyncthingDevStatus::Synchronizing:
|
||||||
|
return QCoreApplication::translate("SyncthingDevStatus", "synchronizing");
|
||||||
|
case SyncthingDevStatus::OutOfSync:
|
||||||
|
return QCoreApplication::translate("SyncthingDevStatus", "out of sync");
|
||||||
|
case SyncthingDevStatus::Rejected:
|
||||||
|
return QCoreApplication::translate("SyncthingDevStatus", "rejected");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Data
|
} // namespace Data
|
||||||
|
|
|
@ -21,6 +21,8 @@ enum class SyncthingDevStatus
|
||||||
Rejected
|
Rejected
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QString statusString(SyncthingDevStatus status);
|
||||||
|
|
||||||
struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDev
|
struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDev
|
||||||
{
|
{
|
||||||
SyncthingDev(const QString &id = QString(), const QString &name = QString());
|
SyncthingDev(const QString &id = QString(), const QString &name = QString());
|
||||||
|
|
|
@ -4,12 +4,33 @@
|
||||||
|
|
||||||
#include <QStringBuilder>
|
#include <QStringBuilder>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
using namespace ChronoUtilities;
|
using namespace ChronoUtilities;
|
||||||
using namespace ConversionUtilities;
|
using namespace ConversionUtilities;
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
|
||||||
|
QString statusString(SyncthingDirStatus status)
|
||||||
|
{
|
||||||
|
switch(status) {
|
||||||
|
case SyncthingDirStatus::Unknown:
|
||||||
|
return QCoreApplication::translate("SyncthingDirStatus", "unknown");
|
||||||
|
case SyncthingDirStatus::Idle:
|
||||||
|
return QCoreApplication::translate("SyncthingDirStatus", "idle");
|
||||||
|
case SyncthingDirStatus::Unshared:
|
||||||
|
return QCoreApplication::translate("SyncthingDirStatus", "unshared");
|
||||||
|
case SyncthingDirStatus::Scanning:
|
||||||
|
return QCoreApplication::translate("SyncthingDirStatus", "scanning");
|
||||||
|
case SyncthingDirStatus::Synchronizing:
|
||||||
|
return QCoreApplication::translate("SyncthingDirStatus", "synchronizing");
|
||||||
|
case SyncthingDirStatus::Paused:
|
||||||
|
return QCoreApplication::translate("SyncthingDirStatus", "paused");
|
||||||
|
case SyncthingDirStatus::OutOfSync:
|
||||||
|
return QCoreApplication::translate("SyncthingDirStatus", "out of sync");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Assigns the status from the specified status string.
|
* \brief Assigns the status from the specified status string.
|
||||||
* \returns Returns whether the status has actually changed.
|
* \returns Returns whether the status has actually changed.
|
||||||
|
|
|
@ -23,6 +23,8 @@ enum class SyncthingDirStatus
|
||||||
OutOfSync
|
OutOfSync
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QString statusString(SyncthingDirStatus status);
|
||||||
|
|
||||||
struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDirError
|
struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDirError
|
||||||
{
|
{
|
||||||
SyncthingDirError(const QString &message, const QString &path) :
|
SyncthingDirError(const QString &message, const QString &path) :
|
||||||
|
|
Loading…
Reference in New Issue