2016-08-25 00:45:32 +02:00
|
|
|
#ifndef DATA_SYNCTHINGDIRECTORYMODEL_H
|
|
|
|
#define DATA_SYNCTHINGDIRECTORYMODEL_H
|
|
|
|
|
2016-11-02 21:05:32 +01:00
|
|
|
#include "./syncthingmodel.h"
|
2016-09-30 23:55:25 +02:00
|
|
|
|
2016-08-25 00:45:32 +02:00
|
|
|
#include <QIcon>
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace Data {
|
|
|
|
|
|
|
|
struct SyncthingDir;
|
|
|
|
|
2017-05-01 03:34:43 +02:00
|
|
|
class LIB_SYNCTHING_MODEL_EXPORT SyncthingDirectoryModel : public SyncthingModel {
|
2016-08-25 00:45:32 +02:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2017-08-29 23:55:05 +02:00
|
|
|
enum SyncthingDirectoryModelRole {
|
|
|
|
DirectoryStatus = Qt::UserRole + 1,
|
|
|
|
DirectoryPaused,
|
|
|
|
DirectoryStatusString,
|
|
|
|
DirectoryStatusColor,
|
|
|
|
DirectoryId,
|
|
|
|
DirectoryPath,
|
2018-11-03 21:30:17 +01:00
|
|
|
DirectoryPullErrorCount,
|
2017-09-07 19:21:00 +02:00
|
|
|
DirectoryDetail,
|
2019-02-27 20:41:50 +01:00
|
|
|
DirectoryDetailIcon,
|
2017-08-29 23:55:05 +02:00
|
|
|
};
|
2017-02-23 14:59:00 +01:00
|
|
|
|
2016-08-25 00:45:32 +02:00
|
|
|
explicit SyncthingDirectoryModel(SyncthingConnection &connection, QObject *parent = nullptr);
|
|
|
|
|
|
|
|
public Q_SLOTS:
|
2018-10-10 21:26:46 +02:00
|
|
|
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;
|
2016-08-25 00:45:32 +02:00
|
|
|
const SyncthingDir *dirInfo(const QModelIndex &index) const;
|
|
|
|
|
2016-09-21 21:09:12 +02:00
|
|
|
private Q_SLOTS:
|
2019-02-16 01:40:06 +01:00
|
|
|
void dirStatusChanged(const SyncthingDir &dir, int index);
|
|
|
|
void handleConfigInvalidated() override;
|
|
|
|
void handleNewConfigAvailable() override;
|
2019-05-19 21:51:55 +02:00
|
|
|
void handleStatusIconsChanged() override;
|
2016-08-25 00:45:32 +02:00
|
|
|
|
|
|
|
private:
|
2017-08-29 23:55:05 +02:00
|
|
|
static QString dirStatusString(const SyncthingDir &dir);
|
2017-09-01 17:13:01 +02:00
|
|
|
QVariant dirStatusColor(const SyncthingDir &dir) const;
|
2019-02-16 01:40:06 +01:00
|
|
|
void updateRowCount();
|
2017-08-24 00:00:57 +02:00
|
|
|
|
2016-08-25 00:45:32 +02:00
|
|
|
const std::vector<SyncthingDir> &m_dirs;
|
2019-02-16 01:40:06 +01:00
|
|
|
std::vector<int> m_rowCount;
|
2016-08-25 00:45:32 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Data
|
|
|
|
|
2017-08-29 23:55:05 +02:00
|
|
|
Q_DECLARE_METATYPE(QModelIndex)
|
|
|
|
|
2016-08-25 00:45:32 +02:00
|
|
|
#endif // DATA_SYNCTHINGDIRECTORYMODEL_H
|