2023-05-02 14:55:17 +03:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2023 by Matthieu Gallien <matthieu.gallien@nextcloud.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SYNCCONFLICTSMODEL_H
|
|
|
|
#define SYNCCONFLICTSMODEL_H
|
|
|
|
|
|
|
|
#include "tray/activitydata.h"
|
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
#include <QMimeDatabase>
|
|
|
|
#include <QLocale>
|
|
|
|
|
|
|
|
namespace OCC {
|
|
|
|
|
|
|
|
class SyncConflictsModel : public QAbstractListModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
Q_PROPERTY(OCC::ActivityList conflictActivities READ conflictActivities WRITE setConflictActivities NOTIFY conflictActivitiesChanged)
|
|
|
|
|
2023-05-12 14:17:38 +03:00
|
|
|
Q_PROPERTY(bool allExistingsSelected READ allExistingsSelected NOTIFY allExistingsSelectedChanged)
|
|
|
|
|
|
|
|
Q_PROPERTY(bool allConflictingSelected READ allConflictingSelected NOTIFY allConflictingSelectedChanged)
|
|
|
|
|
2023-05-02 14:55:17 +03:00
|
|
|
struct ConflictInfo {
|
|
|
|
QString mExistingFileName;
|
|
|
|
QString mExistingSize;
|
|
|
|
QString mConflictSize;
|
|
|
|
QString mExistingDate;
|
|
|
|
QString mConflictDate;
|
|
|
|
QUrl mExistingPreviewUrl;
|
|
|
|
QUrl mConflictPreviewUrl;
|
|
|
|
bool mExistingSelected = false;
|
|
|
|
bool mConflictSelected = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum class SyncConflictRoles : int {
|
|
|
|
ExistingFileName = Qt::UserRole,
|
|
|
|
ExistingSize,
|
|
|
|
ConflictSize,
|
|
|
|
ExistingDate,
|
|
|
|
ConflictDate,
|
|
|
|
ExistingSelected,
|
|
|
|
ConflictSelected,
|
|
|
|
ExistingPreviewUrl,
|
|
|
|
ConflictPreviewUrl,
|
|
|
|
};
|
|
|
|
|
|
|
|
Q_ENUM(SyncConflictRoles)
|
|
|
|
|
|
|
|
explicit SyncConflictsModel(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
[[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
|
|
|
|
[[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
|
|
|
|
2023-05-12 14:17:38 +03:00
|
|
|
[[nodiscard]] bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
|
|
|
|
2023-05-02 14:55:17 +03:00
|
|
|
[[nodiscard]] QHash<int,QByteArray> roleNames() const override;
|
|
|
|
|
2023-05-12 14:17:38 +03:00
|
|
|
[[nodiscard]] Qt::ItemFlags flags(const QModelIndex &index) const override;
|
|
|
|
|
2023-05-02 14:55:17 +03:00
|
|
|
[[nodiscard]] OCC::ActivityList conflictActivities() const;
|
|
|
|
|
2023-05-12 14:17:38 +03:00
|
|
|
[[nodiscard]] bool allExistingsSelected() const;
|
|
|
|
|
|
|
|
[[nodiscard]] bool allConflictingSelected() const;
|
|
|
|
|
2023-05-02 14:55:17 +03:00
|
|
|
public slots:
|
|
|
|
void setConflictActivities(OCC::ActivityList conflicts);
|
|
|
|
|
2023-05-12 14:17:38 +03:00
|
|
|
void selectAllExisting(bool selected);
|
|
|
|
|
|
|
|
void selectAllConflicting(bool selected);
|
|
|
|
|
2023-05-02 14:55:17 +03:00
|
|
|
signals:
|
|
|
|
void conflictActivitiesChanged();
|
|
|
|
|
2023-05-12 14:17:38 +03:00
|
|
|
void allExistingsSelectedChanged();
|
|
|
|
|
|
|
|
void allConflictingSelectedChanged();
|
|
|
|
|
2023-05-02 14:55:17 +03:00
|
|
|
private:
|
|
|
|
void updateConflictsData();
|
|
|
|
|
2023-05-12 14:17:38 +03:00
|
|
|
void setExistingSelected(bool value,
|
|
|
|
const QModelIndex &index,
|
|
|
|
int role);
|
|
|
|
|
|
|
|
void setConflictingSelected(bool value,
|
|
|
|
const QModelIndex &index,
|
|
|
|
int role);
|
|
|
|
|
2023-05-02 14:55:17 +03:00
|
|
|
OCC::ActivityList mData;
|
|
|
|
|
|
|
|
QVector<ConflictInfo> mConflictData;
|
|
|
|
|
|
|
|
QMimeDatabase mMimeDb;
|
|
|
|
|
|
|
|
QLocale mLocale;
|
2023-05-12 14:17:38 +03:00
|
|
|
|
|
|
|
bool mAllExistingsSelected = false;
|
|
|
|
|
|
|
|
bool mAllConflictingsSelected = false;
|
2023-05-02 14:55:17 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // SYNCCONFLICTSMODEL_H
|