File indexing completed on 2025-01-05 05:14:39
0001 /* 0002 SPDX-FileCopyrightText: 2021 Hamed Masafi <hamed.masfi@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "gitglobal.h" 0010 #include <QAbstractListModel> 0011 0012 class ChangedFilesModel : public QAbstractListModel 0013 { 0014 Q_OBJECT 0015 0016 public: 0017 explicit ChangedFilesModel(Git::Manager *git, bool checkable = false, QObject *parent = nullptr); 0018 void reload(); 0019 0020 int rowCount(const QModelIndex &parent) const override; 0021 int columnCount(const QModelIndex &parent) const override; 0022 QVariant data(const QModelIndex &index, int role) const override; 0023 bool setData(const QModelIndex &index, const QVariant &value, int role) override; 0024 Qt::ItemFlags flags(const QModelIndex &index) const override; 0025 Q_REQUIRED_RESULT QString filePath(int index) const; 0026 Q_REQUIRED_RESULT int size() const; 0027 Q_REQUIRED_RESULT QStringList checkedFiles() const; 0028 void checkByStatus(Git::ChangeStatus status); 0029 void checkByStatus(const QList<Git::ChangeStatus> &statuses); 0030 void toggleCheckAll(bool checked); 0031 0032 struct Row { 0033 QString filePath; 0034 QString oldFilePath; 0035 Git::ChangeStatus status; 0036 bool checked; 0037 }; 0038 const QList<Row> &data() const; 0039 const Row *data(int index) const; 0040 Q_REQUIRED_RESULT int checkedCount() const; 0041 0042 Q_SIGNALS: 0043 void checkedCountChanged(); 0044 0045 private: 0046 QIcon createIcon(Git::ChangeStatus status); 0047 0048 Git::Manager *mGit{nullptr}; 0049 QList<Row> mData; 0050 QMap<Git::ChangeStatus, QIcon> mIcons; 0051 bool mCheckable = false; 0052 };