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