Handle new folder types
See https://github.com/syncthing/syncthing/pull/4942
This commit is contained in:
parent
f8dabbc78d
commit
2fcc94f567
|
@ -10,7 +10,7 @@ set(META_APP_CATEGORIES "Network;FileTransfer")
|
|||
set(META_GUI_OPTIONAL false)
|
||||
set(META_VERSION_MAJOR 0)
|
||||
set(META_VERSION_MINOR 8)
|
||||
set(META_VERSION_PATCH 0)
|
||||
set(META_VERSION_PATCH 1)
|
||||
set(META_VERSION_EXACT_SONAME ON)
|
||||
|
||||
project(${META_PROJECT_NAME})
|
||||
|
|
|
@ -523,7 +523,7 @@ void Application::printDir(const RelevantDir &relevantDir) const
|
|||
nullptr, 6);
|
||||
}
|
||||
}
|
||||
printProperty("Read-only", dir->readOnly);
|
||||
printProperty("Type", dir->dirTypeString());
|
||||
printProperty("Ignore permissions", dir->ignorePermissions);
|
||||
printProperty("Auto-normalize", dir->autoNormalize);
|
||||
printProperty("Rescan interval", TimeSpan::fromSeconds(dir->rescanInterval));
|
||||
|
|
|
@ -1116,7 +1116,7 @@ void SyncthingConnection::readDirs(const QJsonArray &dirs)
|
|||
}
|
||||
}
|
||||
}
|
||||
dirItem->readOnly = dirObj.value(QStringLiteral("readOnly")).toBool(false);
|
||||
dirItem->assignDirType(dirObj.value(QLatin1String("type")).toString());
|
||||
dirItem->rescanInterval = dirObj.value(QStringLiteral("rescanIntervalS")).toInt(-1);
|
||||
dirItem->ignorePermissions = dirObj.value(QStringLiteral("ignorePerms")).toBool(false);
|
||||
dirItem->autoNormalize = dirObj.value(QStringLiteral("autoNormalize")).toBool(false);
|
||||
|
|
|
@ -29,6 +29,20 @@ QString statusString(SyncthingDirStatus status)
|
|||
default:
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString dirTypeString(SyncthingDirType dirType)
|
||||
{
|
||||
switch (dirType) {
|
||||
case SyncthingDirType::Unknown:
|
||||
return QCoreApplication::translate("SyncthingDirType", "unknown");
|
||||
case SyncthingDirType::SendReceive:
|
||||
return QCoreApplication::translate("SyncthingDirType", "Send & Receive");
|
||||
case SyncthingDirType::SendOnly:
|
||||
return QCoreApplication::translate("SyncthingDirType", "Send only");
|
||||
case SyncthingDirType::ReceiveOnly:
|
||||
return QCoreApplication::translate("SyncthingDirType", "Receive only");
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool SyncthingDir::checkWhetherStatusUpdateRelevant(DateTime time)
|
||||
|
@ -110,6 +124,21 @@ bool SyncthingDir::assignStatus(const QString &statusStr, ChronoUtilities::DateT
|
|||
return finalizeStatusUpdate(newStatus);
|
||||
}
|
||||
|
||||
bool SyncthingDir::assignDirType(const QString &dirTypeStr)
|
||||
{
|
||||
if (dirTypeStr == QLatin1String("sendreceive") || dirTypeStr == QLatin1String("readwrite")) {
|
||||
dirType = SyncthingDirType::SendReceive;
|
||||
} else if (dirTypeStr == QLatin1String("sendonly") || dirTypeStr == QLatin1String("readonly")) {
|
||||
dirType = SyncthingDirType::SendOnly;
|
||||
} else if (dirTypeStr == QLatin1String("receiveonly")) {
|
||||
dirType = SyncthingDirType::ReceiveOnly;
|
||||
} else {
|
||||
dirType = SyncthingDirType::Unknown;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
QString SyncthingDir::statusString() const
|
||||
{
|
||||
if (paused) {
|
||||
|
|
|
@ -14,7 +14,11 @@ namespace Data {
|
|||
|
||||
enum class SyncthingDirStatus { Unknown, Idle, Unshared, Scanning, Synchronizing, OutOfSync };
|
||||
|
||||
QString statusString(SyncthingDirStatus status);
|
||||
QString LIB_SYNCTHING_CONNECTOR_EXPORT statusString(SyncthingDirStatus status);
|
||||
|
||||
enum class SyncthingDirType { Unknown, SendReceive, SendOnly, ReceiveOnly };
|
||||
|
||||
QString LIB_SYNCTHING_CONNECTOR_EXPORT dirTypeString(SyncthingDirType dirType);
|
||||
|
||||
struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingItemError {
|
||||
SyncthingItemError(const QString &message = QString(), const QString &path = QString())
|
||||
|
@ -111,8 +115,10 @@ struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDir {
|
|||
SyncthingDir(const QString &id = QString(), const QString &label = QString(), const QString &path = QString());
|
||||
bool assignStatus(const QString &statusStr, ChronoUtilities::DateTime time);
|
||||
bool assignStatus(SyncthingDirStatus newStatus, ChronoUtilities::DateTime time);
|
||||
bool assignDirType(const QString &dirType);
|
||||
const QString &displayName() const;
|
||||
QString statusString() const;
|
||||
QString dirTypeString() const;
|
||||
QStringRef pathWithoutTrailingSlash() const;
|
||||
bool isLocallyUpToDate() const;
|
||||
bool areRemotesUpToDate() const;
|
||||
|
@ -122,10 +128,7 @@ struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDir {
|
|||
QString path;
|
||||
QStringList deviceIds;
|
||||
QStringList deviceNames;
|
||||
bool readOnly = false;
|
||||
bool ignorePermissions = false;
|
||||
bool ignorePatterns = false;
|
||||
bool autoNormalize = false;
|
||||
SyncthingDirType dirType = SyncthingDirType::Unknown;
|
||||
int rescanInterval = 0;
|
||||
int minDiskFreePercentage = 0;
|
||||
SyncthingDirStatus status = SyncthingDirStatus::Idle;
|
||||
|
@ -147,6 +150,9 @@ struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDir {
|
|||
int blocksToBeDownloaded = 0;
|
||||
QString downloadLabel;
|
||||
unsigned int downloadPercentage = 0;
|
||||
bool ignorePermissions = false;
|
||||
bool ignorePatterns = false;
|
||||
bool autoNormalize = false;
|
||||
bool paused = false;
|
||||
bool lastFileDeleted = false;
|
||||
|
||||
|
@ -167,6 +173,11 @@ inline const QString &SyncthingDir::displayName() const
|
|||
return label.isEmpty() ? id : label;
|
||||
}
|
||||
|
||||
inline QString SyncthingDir::dirTypeString() const
|
||||
{
|
||||
return ::Data::dirTypeString(dirType);
|
||||
}
|
||||
|
||||
inline bool SyncthingDir::isLocallyUpToDate() const
|
||||
{
|
||||
return neededStats.isNull();
|
||||
|
|
|
@ -390,7 +390,7 @@ void ConnectionTests::checkDirectories() const
|
|||
CPPUNIT_ASSERT_EQUAL(QStringLiteral("test1"), dir1.displayName());
|
||||
CPPUNIT_ASSERT_EQUAL(QStringLiteral("/tmp/some/path/1/"), dir1.path);
|
||||
CPPUNIT_ASSERT_EQUAL(QStringLiteral("idle"), dir1.statusString());
|
||||
CPPUNIT_ASSERT(!dir1.readOnly);
|
||||
CPPUNIT_ASSERT_EQUAL(SyncthingDirType::SendReceive, dir1.dirType);
|
||||
CPPUNIT_ASSERT(!dir1.paused);
|
||||
CPPUNIT_ASSERT_EQUAL(QSet<QString>({ QStringLiteral("MMGUI6U-WUEZQCP-XZZ6VYB-LCT4TVC-ER2HAVX-QYT6X7D-S6ZSG2B-323KLQ7"),
|
||||
QStringLiteral("6EIS2PN-J2IHWGS-AXS3YUL-HC5FT3K-77ZXTLL-AKQLJ4C-7SWVPUS-AZW4RQ4") }),
|
||||
|
@ -403,7 +403,7 @@ void ConnectionTests::checkDirectories() const
|
|||
CPPUNIT_ASSERT_EQUAL(QStringLiteral("/tmp/some/path/2/"), dir2.path);
|
||||
CPPUNIT_ASSERT_EQUAL(QStringLiteral("/tmp/some/path/2"), dir2.pathWithoutTrailingSlash().toString());
|
||||
CPPUNIT_ASSERT_EQUAL(QStringLiteral("paused"), dir2.statusString());
|
||||
CPPUNIT_ASSERT(!dir2.readOnly);
|
||||
CPPUNIT_ASSERT_EQUAL(SyncthingDirType::SendReceive, dir2.dirType);
|
||||
CPPUNIT_ASSERT(dir2.paused);
|
||||
CPPUNIT_ASSERT_EQUAL(
|
||||
QSet<QString>({ QStringLiteral("MMGUI6U-WUEZQCP-XZZ6VYB-LCT4TVC-ER2HAVX-QYT6X7D-S6ZSG2B-323KLQ7") }), dir2.deviceIds.toSet());
|
||||
|
|
|
@ -125,7 +125,7 @@ QVariant SyncthingDirectoryModel::data(const QModelIndex &index, int role) const
|
|||
case 4:
|
||||
return tr("Shared with");
|
||||
case 5:
|
||||
return tr("Read-only");
|
||||
return tr("Type");
|
||||
case 6:
|
||||
return tr("Rescan interval");
|
||||
case 7:
|
||||
|
@ -160,7 +160,7 @@ QVariant SyncthingDirectoryModel::data(const QModelIndex &index, int role) const
|
|||
return tr("not shared");
|
||||
}
|
||||
case 5:
|
||||
return dir.readOnly ? tr("yes") : tr("no");
|
||||
return dir.dirTypeString();
|
||||
case 6:
|
||||
return QString::fromLatin1(
|
||||
TimeSpan::fromSeconds(dir.rescanInterval).toString(TimeSpanOutputFormat::WithMeasures, true).data());
|
||||
|
|
Loading…
Reference in New Issue