2020-01-18 16:37:20 +01:00
|
|
|
#ifndef DATA_SYNCTHINGRECENTCHANGESMODEL_H
|
|
|
|
#define DATA_SYNCTHINGRECENTCHANGESMODEL_H
|
|
|
|
|
|
|
|
#include "./syncthingmodel.h"
|
|
|
|
|
2020-03-17 18:55:50 +01:00
|
|
|
#include "../connector/syncthingconnectionstatus.h"
|
2020-03-17 18:56:59 +01:00
|
|
|
#include "../connector/syncthingdir.h"
|
2020-01-18 16:37:20 +01:00
|
|
|
|
2020-01-19 19:56:30 +01:00
|
|
|
#include <deque>
|
2020-01-18 16:37:20 +01:00
|
|
|
|
|
|
|
namespace Data {
|
|
|
|
|
|
|
|
struct LIB_SYNCTHING_MODEL_EXPORT SyncthingRecentChange {
|
|
|
|
QString directoryId;
|
|
|
|
QString directoryName;
|
|
|
|
SyncthingFileChange fileChange;
|
|
|
|
};
|
|
|
|
|
|
|
|
class LIB_SYNCTHING_MODEL_EXPORT SyncthingRecentChangesModel : public SyncthingModel {
|
|
|
|
Q_OBJECT
|
2020-01-19 19:56:30 +01:00
|
|
|
Q_PROPERTY(int maxRows READ maxRows WRITE setMaxRows)
|
2020-01-18 16:37:20 +01:00
|
|
|
public:
|
|
|
|
enum SyncthingRecentChangesModelRole {
|
|
|
|
Action = Qt::UserRole + 1,
|
|
|
|
ActionIcon,
|
|
|
|
ModifiedBy,
|
|
|
|
DirectoryId,
|
|
|
|
DirectoryName,
|
|
|
|
Path,
|
|
|
|
EventTime,
|
|
|
|
ExtendedAction,
|
|
|
|
ItemType,
|
|
|
|
};
|
2020-01-19 19:56:30 +01:00
|
|
|
explicit SyncthingRecentChangesModel(SyncthingConnection &connection, int maxRows = 200, QObject *parent = nullptr);
|
2020-01-18 16:37:20 +01:00
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
QHash<int, QByteArray> roleNames() const override;
|
|
|
|
const QVector<int> &colorRoles() const override;
|
|
|
|
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
QModelIndex parent(const QModelIndex &child) const override;
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
|
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
|
|
|
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
|
|
|
int rowCount(const QModelIndex &parent) const override;
|
|
|
|
int columnCount(const QModelIndex &parent) const override;
|
2020-01-19 19:56:30 +01:00
|
|
|
int maxRows() const;
|
|
|
|
void setMaxRows(int maxRows);
|
2020-01-18 16:37:20 +01:00
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void fileChanged(const SyncthingDir &dir, int index, const SyncthingFileChange &change);
|
|
|
|
void handleConfigInvalidated() override;
|
|
|
|
void handleNewConfigAvailable() override;
|
2020-03-17 18:55:50 +01:00
|
|
|
void handleStatusChanged(SyncthingStatus status);
|
2020-01-18 16:37:20 +01:00
|
|
|
|
|
|
|
private:
|
2020-01-19 19:56:30 +01:00
|
|
|
void ensureWithinLimit();
|
|
|
|
|
|
|
|
std::deque<SyncthingRecentChange> m_changes;
|
|
|
|
int m_maxRows;
|
2020-01-18 16:37:20 +01:00
|
|
|
};
|
|
|
|
|
2020-01-19 19:56:30 +01:00
|
|
|
inline int SyncthingRecentChangesModel::maxRows() const
|
|
|
|
{
|
|
|
|
return m_maxRows;
|
|
|
|
}
|
|
|
|
|
2020-01-18 16:37:20 +01:00
|
|
|
} // namespace Data
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(Data::SyncthingRecentChange)
|
|
|
|
|
|
|
|
#endif // DATA_SYNCTHINGRECENTCHANGESMODEL_H
|