File indexing completed on 2025-01-05 05:14:51

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 "libkommitwidgets_export.h"
0010 #include "ui_commitdetails.h"
0011 
0012 namespace Git
0013 {
0014 class Commit;
0015 class LogsModel;
0016 }
0017 
0018 class LIBKOMMITWIDGETS_EXPORT CommitDetails : public QWidget, private Ui::CommitDetails
0019 {
0020     Q_OBJECT
0021 
0022     Q_PROPERTY(bool enableCommitsLinks READ enableCommitsLinks WRITE setEnableCommitsLinks NOTIFY enableCommitsLinksChanged FINAL)
0023     Q_PROPERTY(bool enableEmailsLinks READ enableEmailsLinks WRITE setEnableEmailsLinks NOTIFY enableEmailsLinksChanged FINAL)
0024     Q_PROPERTY(bool enableFilesLinks READ enableFilesLinks WRITE setEnableFilesLinks NOTIFY enableFilesLinksChanged FINAL)
0025 
0026 public:
0027     explicit CommitDetails(QWidget *parent = nullptr);
0028 
0029     Q_REQUIRED_RESULT Git::Commit *commit() const;
0030     void setCommit(Git::Commit *commit);
0031 
0032     Q_REQUIRED_RESULT bool enableCommitsLinks() const;
0033     void setEnableCommitsLinks(bool enableCommitsLinks);
0034     Q_REQUIRED_RESULT bool enableEmailsLinks() const;
0035     void setEnableEmailsLinks(bool enableEmailsLinks);
0036     Q_REQUIRED_RESULT bool enableFilesLinks() const;
0037     void setEnableFilesLinks(bool enableFilesLinks);
0038 
0039 Q_SIGNALS:
0040     void hashClicked(const QString &hash);
0041     void fileClicked(const QString &file);
0042 
0043     void enableCommitsLinksChanged();
0044     void enableEmailsLinksChanged();
0045     void enableFilesLinksChanged();
0046 
0047 private:
0048     void mSlotEmailLinkClicked(const QString &link);
0049 
0050     QString createChangedFiles();
0051     QString generateCommitLink(const QString &hash);
0052     QString generateCommitsLink(const QStringList &hashes);
0053 
0054     Git::LogsModel *mLogsModel{nullptr};
0055 
0056     Git::Commit *mCommit{nullptr};
0057     bool mEnableCommitsLinks{true};
0058     bool mEnableEmailsLinks{true};
0059     bool mEnableFilesLinks{true};
0060 };