File indexing completed on 2024-04-21 05:46:29

0001 // SPDX-FileCopyrightText: 2020 Simon Persson <simon.persson@mykolab.com>
0002 //
0003 // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004 
0005 #ifndef VERSIONLISTMODEL_H
0006 #define VERSIONLISTMODEL_H
0007 
0008 #include <QAbstractListModel>
0009 #include "mergedvfs.h"
0010 
0011 struct BupSourceInfo {
0012     QUrl mBupKioPath;
0013     QString mRepoPath;
0014     QString mBranchName;
0015     QString mPathInRepo;
0016     qint64 mCommitTime;
0017     quint64 mSize;
0018     bool mIsDirectory;
0019 };
0020 
0021 Q_DECLARE_METATYPE(BupSourceInfo)
0022 
0023 class VersionListModel : public QAbstractListModel
0024 {
0025     Q_OBJECT
0026 public:
0027     explicit VersionListModel(QObject *parent = nullptr);
0028     void setNode(const MergedNode *pNode);
0029     int rowCount(const QModelIndex &pParent) const override;
0030     QVariant data(const QModelIndex &pIndex, int pRole) const override;
0031 
0032 protected:
0033     const VersionList *mVersionList;
0034     const MergedNode *mNode{};
0035 };
0036 
0037 enum VersionDataRole {
0038     VersionBupUrlRole = Qt::UserRole + 1, // QUrl
0039     VersionMimeTypeRole, // QString
0040     VersionSizeRole, // quint64
0041     VersionSourceInfoRole, // PathInfo
0042     VersionIsDirectoryRole // bool
0043 };
0044 
0045 #endif // VERSIONLISTMODEL_H