1 /*
2 SPDX-FileCopyrightText: 2007 Andreas Pakulat <apaku@gmx.de>
3 SPDX-FileCopyrightText: 2007 Matthew Woehlke <mw_triad@users.sourceforge.net>
4
5 SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8 #ifndef KDEVPLATFORM_VCSEVENT_H
9 #define KDEVPLATFORM_VCSEVENT_H
10
11 #include <QMetaType>
12 #include <QSharedDataPointer>
13
14 #include "vcsexport.h"
15
16 class QString;
17 class QDateTime;
18 template <typename T> class QList;
19
20 namespace KDevelop
21 {
22 class VcsRevision;
23
24 /**
25 * Small container class that contains information about a history event of a
26 * single repository item.
27 */
28 class KDEVPLATFORMVCS_EXPORT VcsItemEvent
29 {
30 public:
31 /**
32 * Class that tells you what happened to a given repository location in a
33 * specific revision.
34 *
35 * Combinations of some of the flags are possible, for example Add|Modified,
36 * Copy|Modified or Merge|Modified, or when returned from VcsEvent::actions().
37 */
38 enum Action
39 {
40 Added = 1<<0 /**< Item was added. */,
41 Deleted = 1<<1 /**< Item was deleted. */,
42 Modified = 1<<2 /**< Item was modified, for example by editing. */,
43 Copied = 1<<3 /**< Item was copied. */,
44 Merged = 1<<4 /**< Item had changes merged into it. */,
45 ContentsModified = 1<<5 /**< Directory was not changed (only contents changed). */,
46 Replaced = 1<<6 /**< Item was replaced. */
47 };
48 Q_DECLARE_FLAGS( Actions, Action )
49
50 VcsItemEvent();
51 virtual ~VcsItemEvent();
52 VcsItemEvent(const VcsItemEvent& );
53
54 QString repositoryLocation() const;
55 QString repositoryCopySourceLocation() const; // may be empty
56 VcsRevision repositoryCopySourceRevision() const; // may be invalid, even if rCSL is not
57 Actions actions() const;
58
59 void setRepositoryLocation( const QString& );
60 void setRepositoryCopySourceLocation( const QString& );
61 void setRepositoryCopySourceRevision( const KDevelop::VcsRevision& );
62 void setActions( Actions );
63
64 VcsItemEvent& operator=( const VcsItemEvent& rhs);
65
66 private:
67 QSharedDataPointer<class VcsItemEventPrivate> d;
68 };
69
70 #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
Q_DECLARE_OPERATORS_FOR_FLAGS(VcsItemEvent::Actions)71 Q_DECLARE_OPERATORS_FOR_FLAGS(VcsItemEvent::Actions)
72 #endif
73
74 /**
75 * Small container class that contains information about a single revision.
76 *
77 * @note log() only returns information about the specific item that was asked
78 * about. When working with a VCS that supports atomic commits (i.e. where a
79 * revision might affect more than one item), use change() to retrieve
80 * information about all items affected by a particular revision.
81 */
82 class KDEVPLATFORMVCS_EXPORT VcsEvent
83 {
84 public:
85 VcsEvent();
86 virtual ~VcsEvent();
87 VcsEvent( const VcsEvent& );
88
89 VcsRevision revision() const;
90 QString author() const;
91 QDateTime date() const;
92 QString message() const;
93 QList<VcsItemEvent> items() const;
94
95 void setRevision( const VcsRevision& );
96 void setAuthor( const QString& );
97 void setDate( const QDateTime& );
98 void setMessage(const QString& );
99 void setItems( const QList<VcsItemEvent>& );
100 void addItem(const VcsItemEvent& item);
101 VcsEvent& operator=( const VcsEvent& rhs);
102
103 private:
104 QSharedDataPointer<class VcsEventPrivate> d;
105 };
106
107 }
108
109 #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
110 Q_DECLARE_OPERATORS_FOR_FLAGS( KDevelop::VcsItemEvent::Actions )
111 #endif
112 Q_DECLARE_METATYPE( KDevelop::VcsEvent )
113 Q_DECLARE_TYPEINFO( KDevelop::VcsEvent, Q_MOVABLE_TYPE );
114 Q_DECLARE_METATYPE( KDevelop::VcsItemEvent )
115 Q_DECLARE_TYPEINFO( KDevelop::VcsItemEvent, Q_MOVABLE_TYPE );
116
117 #endif
118