File indexing completed on 2025-01-19 04:22:44
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 "abstractgititemsmodel.h" 0010 0011 #include <QDateTime> 0012 #include <QMutex> 0013 0014 namespace Git 0015 { 0016 0017 struct DatesRange { 0018 int count = 0; 0019 QDateTime first; 0020 QDateTime last; 0021 0022 void begin(const QDateTime &time); 0023 void increase(const QDateTime &time); 0024 }; 0025 0026 struct Author { 0027 QString email; 0028 QString name; 0029 0030 DatesRange commits; 0031 DatesRange authoredCommits; 0032 DatesRange tags; 0033 }; 0034 0035 class AuthorsModel : public AbstractGitItemsModel 0036 { 0037 Q_OBJECT 0038 0039 public: 0040 enum AuthorsModelsRoles { 0041 Name, 0042 Email, 0043 Commits, 0044 LastColumn, 0045 }; 0046 enum AuthorCreateReason { Commit, AuthoredCommit, Tag }; 0047 0048 Q_ENUM(AuthorsModelsRoles) 0049 explicit AuthorsModel(Manager *git, QObject *parent = nullptr); 0050 0051 int rowCount(const QModelIndex &parent) const override; 0052 int columnCount(const QModelIndex &parent) const override; 0053 QVariant headerData(int section, Qt::Orientation orientation, int role) const override; 0054 QVariant data(const QModelIndex &index, int role) const override; 0055 0056 Author *findOrCreate(const QString &name, const QString &email); 0057 Author *findOrCreate(const QString &name, const QString &email, const QDateTime &time, AuthorCreateReason reason); 0058 void clear(); 0059 0060 protected: 0061 void fill() override; 0062 0063 private: 0064 QList<Author *> mData; 0065 QMutex mDataMutex; 0066 }; 0067 0068 } // namespace Git