File indexing completed on 2024-05-12 04:38:53
0001 /* 0002 SPDX-FileCopyrightText: 2007 Andreas Pakulat <apaku@gmx.de> 0003 SPDX-FileCopyrightText: 2007 Matthew Woehlke <mw_triad@users.sourceforge.net> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef KDEVPLATFORM_DVCSEVENT_H 0009 #define KDEVPLATFORM_DVCSEVENT_H 0010 0011 #include <QMetaType> 0012 #include <QSharedDataPointer> 0013 0014 #include <vcs/vcsexport.h> 0015 0016 class QStringList; 0017 class QString; 0018 0019 namespace KDevelop 0020 { 0021 /** 0022 * This class is used to store all required Commit(Revision) data: commit (sha string), 0023 * log (log[0] is used as shortlog), author, date (in QString), CommitType, and a special properties mask. 0024 * It's mostly used in CommitViewDelegate. Maybe this class can be merged with 0025 * something like KDevelop::VcsEvent. 0026 * This is also a helper class for the LogView::parseOutput() method. 0027 * 0028 * @note DVcsEvent is used just to store the data, it doesn't change any of it (for example with QString::trimmed()) 0029 * 0030 * @see GitExecutor::getAllCommits() 0031 * @see end of CommitViewDelegate::paintGraph() for details of how properties are used 0032 * @see dvcsEcecutor::parseOutput() 0033 * 0034 * @author Evgeniy Ivanov <powerfox@kde.ru> 0035 * 0036 */ 0037 //TODO: properties should be used instead of type 0038 class KDEVPLATFORMVCS_EXPORT DVcsEvent 0039 { 0040 public: 0041 0042 /** 0043 * The CommitType namespace specifies the type of commit. It's mostly used in CommitViewDelegate to 0044 * choose what to draw in each graph (and for creation of HEADs labels in shortlog). 0045 * Every commit has a properties array of CommitType (which can be called mask), 0046 * which shows its state in every branch. for example: 0047 * if branch has this commit (after merge several branches can have one commit) properties[branch] is set to BRANCH. 0048 */ 0049 enum CommitType { 0050 INITIAL, /**< Initial (first) commit, we shouldn't draw bottom line to connect with parent */ 0051 HEAD, /**< HEAD commit, we should use its for branch label, and shouldn't draw head line to connect with child */ 0052 BRANCH, /**< draw a circle in the branch column */ 0053 MERGE, /**< draw a square (current implementation requires drawing connections */ 0054 CROSS, /**< just draw a cross-line */ 0055 HCROSS, /**< draw horizontal cross (it's used to connect merge with parent/child */ 0056 MERGE_RIGHT, /**< draw connection lines, two lines (like a clock 9-center-12) */ 0057 MERGE_LEFT, /**< draw connection lines, 9-center-6) */ 0058 EMPTY /**< draw nothing */ 0059 }; 0060 0061 DVcsEvent(); 0062 DVcsEvent(const DVcsEvent& rhs); 0063 ~DVcsEvent(); 0064 0065 DVcsEvent& operator=(const DVcsEvent& rhs); 0066 0067 /** Returns sha string of the commit. */ 0068 QString commit() const; 0069 0070 /** Sets sha string. */ 0071 void setCommit(const QString& commit); 0072 0073 /** Returns QStringList with parents (sha strings). */ 0074 QStringList parents() const; 0075 0076 /** Sets parents (sha strings). */ 0077 void setParents(const QStringList& parents); 0078 0079 /** Returns commit date (stored in QString). */ 0080 QString date() const; 0081 0082 /** Sets date. */ 0083 void setDate(const QString& date); 0084 0085 /** Returns author (committer) name. */ 0086 QString author() const; 0087 0088 /** Sets author (committer) name. */ 0089 void setAuthor(const QString& author); 0090 0091 /** Returns full log in one QString. */ 0092 QString log() const; 0093 0094 /** Sets full log in one QString. */ 0095 void setLog(const QString& log); 0096 0097 /** Returns CommitType */ 0098 int type() const; 0099 0100 /** Sets CommitType */ 0101 void setType(CommitType t); 0102 0103 /** Returns list of properties */ 0104 QList<int> properties() const; 0105 0106 /** Sets properties */ 0107 void setProperties(const QList<int>& properties); 0108 0109 /** Sets property 0110 * @param index index in the properties array. 0111 * @param prop value to be set 0112 */ 0113 void setProperty(int index, int prop); 0114 0115 private: 0116 QSharedDataPointer<class DVcsEventPrivate> d; 0117 }; 0118 0119 } 0120 0121 Q_DECLARE_TYPEINFO(KDevelop::DVcsEvent, Q_MOVABLE_TYPE); 0122 0123 #endif