Skip to content

Commit

Permalink
Add SyncStatus to the tables
Browse files Browse the repository at this point in the history
Issue: #9000
  • Loading branch information
TheOneRing committed Sep 14, 2021
1 parent 4ed5b59 commit 92ec18c
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 9 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/9000
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Display the error type in the issue protocol and allow filtering

We now display the error type in the not synced protocol and allow to filter by the
error type.

https://github.com/owncloud/client/issues/9000
22 changes: 18 additions & 4 deletions src/common/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
#define UTILITY_H

#include "ocsynclib.h"
#include <QString>
#include <QByteArray>
#include <QDateTime>
#include <QElapsedTimer>
#include <QLoggingCategory>
#include <QMap>
#include <QMetaEnum>
#include <QString>
#include <QUrl>
#include <QUrlQuery>
#include <functional>
Expand All @@ -42,12 +43,13 @@ namespace OCC {

class SyncJournal;

Q_DECLARE_LOGGING_CATEGORY(lcUtility)
OCSYNC_EXPORT Q_DECLARE_LOGGING_CATEGORY(lcUtility)

/** \addtogroup libsync
/** \addtogroup libsync
* @{
*/
namespace Utility {
namespace Utility
{
OCSYNC_EXPORT void sleep(int sec);
OCSYNC_EXPORT void usleep(int usec);
OCSYNC_EXPORT QString formatFingerprint(const QByteArray &, bool colonSeparated = true);
Expand Down Expand Up @@ -265,6 +267,18 @@ namespace Utility {
};

#endif

template <class E>
QString enumName(E value)
{
return QMetaEnum::fromType<E>().valueToKeys(value);
}
template <class E = void>
QString enumDisplayName(E)
{
static_assert(std::is_same<E, void>::value, "Not implemented");
Q_UNREACHABLE();
}
}
/** @} */ // \addtogroup

Expand Down
4 changes: 1 addition & 3 deletions src/csync/csync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@

QDebug operator<<(QDebug debug, const SyncInstructions &enumValue)
{
static const QMetaObject *mo = qt_getEnumMetaObject(SyncInstruction());
static const int enumIdx = mo->indexOfEnumerator(qt_getEnumName(SyncInstruction()));
static const QMetaEnum me = mo->enumerator(enumIdx);
static const QMetaEnum me = QMetaEnum::fromType<SyncInstruction>();
QDebugStateSaver saver(debug);
debug.nospace().noquote() << me.enumName() << "(" << me.valueToKeys(enumValue) << ")";
return debug;
Expand Down
2 changes: 1 addition & 1 deletion src/csync/csync.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ enum SyncInstruction {
CSYNC_INSTRUCTION_EVAL = 1 << 0, // DEPRECATED REMOVED
};
// clang-format on
Q_ENUM_NS(SyncInstruction)
Q_FLAG_NS(SyncInstruction)
Q_DECLARE_FLAGS(SyncInstructions, SyncInstruction)
Q_DECLARE_OPERATORS_FOR_FLAGS(SyncInstructions)

Expand Down
8 changes: 8 additions & 0 deletions src/gui/models/protocolitemmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ QVariant ProtocolItemModel::data(const QModelIndex &index, int role) const
return Utility::fileNameForGuiUse(item.path());
case ProtocolItemRole::Account:
return item.folder()->accountState()->account()->displayName();
case ProtocolItemRole::Status:
return Utility::enumDisplayName(item.status());
case ProtocolItemRole::ColumnCount:
Q_UNREACHABLE();
break;
Expand Down Expand Up @@ -103,6 +105,8 @@ QVariant ProtocolItemModel::data(const QModelIndex &index, int role) const
return item.path();
case ProtocolItemRole::Account:
return item.folder()->accountState()->account()->displayName();
case ProtocolItemRole::Status:
return Utility::enumName(item.status());
case ProtocolItemRole::ColumnCount:
Q_UNREACHABLE();
break;
Expand Down Expand Up @@ -131,6 +135,8 @@ QVariant ProtocolItemModel::headerData(int section, Qt::Orientation orientation,
return tr("Size");
case ProtocolItemRole::Account:
return tr("Account");
case ProtocolItemRole::Status:
return tr("Status");
case ProtocolItemRole::ColumnCount:
Q_UNREACHABLE();
break;
Expand All @@ -150,6 +156,8 @@ QVariant ProtocolItemModel::headerData(int section, Qt::Orientation orientation,
return 64;
case ProtocolItemRole::Account:
return 20;
case ProtocolItemRole::Status:
return 20;
case ProtocolItemRole::ColumnCount:
Q_UNREACHABLE();
break;
Expand Down
1 change: 1 addition & 0 deletions src/gui/models/protocolitemmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class ProtocolItemModel : public QAbstractTableModel
Size,
Account,
Time,
Status,

ColumnCount
};
Expand Down
1 change: 1 addition & 0 deletions src/gui/protocolwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ ProtocolWidget::ProtocolWidget(QWidget *parent)
header->setSectionResizeMode(QHeaderView::Interactive);
header->setExpandingColumn(static_cast<int>(ProtocolItemModel::ProtocolItemRole::File));
header->setSortIndicator(static_cast<int>(ProtocolItemModel::ProtocolItemRole::Time), Qt::DescendingOrder);
header->hideSection(static_cast<int>(ProtocolItemModel::ProtocolItemRole::Status));
header->setContextMenuPolicy(Qt::CustomContextMenu);
connect(header, &QHeaderView::customContextMenuRequested, header, [header, this] {
showHeaderContextMenu(header, _sortModel);
Expand Down
32 changes: 31 additions & 1 deletion src/libsync/syncfileitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
#include "common/utility.h"
#include "filesystem.h"

#include <QLoggingCategory>
#include "csync/vio/csync_vio_local.h"

#include <QCoreApplication>

namespace OCC {

Q_LOGGING_CATEGORY(lcFileItem, "sync.fileitem", QtInfoMsg)
Expand Down Expand Up @@ -74,4 +75,33 @@ SyncFileItemPtr SyncFileItem::fromSyncJournalFileRecord(const SyncJournalFileRec
return item;
}

template <>
QString Utility::enumDisplayName(SyncFileItem::Status s)
{
switch (s) {
case SyncFileItem::NoStatus:
return QCoreApplication::translate("SyncFileItem::Status", "Undefined");
case OCC::SyncFileItem::FatalError:
return QCoreApplication::translate("SyncFileItem::Status", "Fatal Error");
case OCC::SyncFileItem::NormalError:
return QCoreApplication::translate("SyncFileItem::Status", "Error");
case OCC::SyncFileItem::SoftError:
return QCoreApplication::translate("SyncFileItem::Status", "Info");
case OCC::SyncFileItem::Success:
return QCoreApplication::translate("SyncFileItem::Status", "Success");
case OCC::SyncFileItem::Conflict:
return QCoreApplication::translate("SyncFileItem::Status", "Conflict");
case OCC::SyncFileItem::FileIgnored:
return QCoreApplication::translate("SyncFileItem::Status", "Error Ignored");
case OCC::SyncFileItem::Restoration:
return QCoreApplication::translate("SyncFileItem::Status", "Restored");
case OCC::SyncFileItem::DetailError:
return QCoreApplication::translate("SyncFileItem::Status", "Error");
case OCC::SyncFileItem::BlacklistedError:
return QCoreApplication::translate("SyncFileItem::Status", "Blacklisted");
case OCC::SyncFileItem::Excluded:
return QCoreApplication::translate("SyncFileItem::Status", "Excluded");
}
Q_UNREACHABLE();
}
}
7 changes: 7 additions & 0 deletions src/libsync/syncfileitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <set>

#include <common/utility.h>
#include <csync.h>

#include <owncloudlib.h>
Expand Down Expand Up @@ -275,6 +276,11 @@ class OWNCLOUDSYNC_EXPORT SyncFileItem
QString _directDownloadCookies;
};


template <>
OWNCLOUDSYNC_EXPORT QString Utility::enumDisplayName(SyncFileItem::Status s);


inline bool operator<(const SyncFileItemPtr &item1, const SyncFileItemPtr &item2)
{
return *item1 < *item2;
Expand All @@ -286,4 +292,5 @@ using SyncFileItemSet = std::set<SyncFileItemPtr>;
Q_DECLARE_METATYPE(OCC::SyncFileItem)
Q_DECLARE_METATYPE(OCC::SyncFileItemPtr)


#endif // SYNCFILEITEM_H

0 comments on commit 92ec18c

Please sign in to comment.