-
Notifications
You must be signed in to change notification settings - Fork 1
/
version.h
274 lines (209 loc) · 7.56 KB
/
version.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
/* --------------------------------------------- */
/* */
/* Copyright (C) 2021 Wolfgang Trummer */
/* Contact: [email protected] */
/* */
/* gvtree V1.9-0 */
/* */
/* git version tree browser */
/* */
/* 28. December 2021 */
/* */
/* This program is licensed under */
/* GNU GENERAL PUBLIC LICENSE */
/* Version 3, 29 June 2007 */
/* */
/* --------------------------------------------- */
#ifndef __VERSION_H__
#define __VERSION_H__
#include <QGraphicsItem>
#include <QList>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <QRegularExpression>
#else
#include <QRegExp>
#endif
#include <QSet>
#include <QRectF>
#include <QString>
#include <QStringList>
#include <QWidget>
#include <QDateTime>
#include "node.h"
class Edge;
class GraphWidget;
QT_BEGIN_NAMESPACE
class QGraphicsSceneMouseEvent;
QT_END_NAMESPACE
class Version : public QGraphicsItem,
public Node
{
public:
/**
* \brief Constructor for the verion tree root node
*/
Version(GraphWidget* _graphWidget, QGraphicsItem* _parent = NULL);
/**
* \brief Constructor for a Version.
* The globalVersionInfo contains the keyInformation elements
* which are activated by mainwindows' View menu.
*/
Version(const QStringList& _globalVersionInfo,
const QStringList& _changeableVersionInfo,
GraphWidget* _graphWidget,
QGraphicsItem* _parent = NULL);
enum {Type = UserType + 1};
int type() const
{
return Type;
}
bool isMain() const;
bool isRoot() const;
bool isFolder() const;
bool isFolded() const;
bool isFoldable() const;
void setIsMain(bool _val);
void setIsFoldable(bool _val);
const Version* lookupFoldedFolderVersion() const;
Version* lookupFolderVersion();
Version* lookupBranchBaseline();
const QMap<QString, QStringList>& getKeyInformation() const;
void setKeyInformation(const QMap<QString, QStringList>& _data);
QString getCommitDateString() const;
/**
* \brief The git log information _input is checked against
* rawInput. If changed the new tokens of _parts
* are proessed.
* _parts contains dummy, hash, commit date, user name and
* tag information.
*
* \return If changed true is returned
*/
bool processGitLogInfo(const QString& _input, const QStringList& _parts);
/**
* \brief The %d information of the git log output is analyzed for
* certain tag patterns.
*/
void processGitLogTagInformation(const QString& _tagInfo);
void processGitLogCommentInformation(const QString& _tagInfo);
void updateCommentInformation(int _columns, int _maxlen);
//!> Edges
virtual void addInEdge(Edge* edge);
virtual void addOutEdge(Edge* edge);
//!> QGraphicsItems
virtual QRectF boundingRect() const;
virtual QPainterPath shape() const;
virtual void paint(QPainter* _painter, const QStyleOptionGraphicsItem* _option, QWidget* _widget);
virtual void setSelected(bool _val);
virtual bool isSelected() const;
const QString& getHash() const;
QList<Version*> getNeighbourBox();
void calculateCoordinates(float _scaleX, float _scaleY);
void linkTreenodes(Version* _parent);
void setMatched(bool _val);
bool getMatched() const;
void addLocalVersionInfo(const QString& _val);
void setUpdateBoundingRect(bool _val);
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
bool findMatch(QRegularExpression& _pattern, const QString& _text, bool _exactMatch = false, QString _keyConstraint = QString());
#else
bool findMatch(QRegExp& _pattern, const QString& _text, bool _exactMatch = false, QString _keyConstraint = QString());
#endif
void collectFolderVersions(Version* _rootNode, Version* _parent);
void flattenFoldersRecurse();
void updateFoldableRecurse();
void foldRecurse(bool _val);
int numEdges() const;
const QList<Version*>& getFolderVersions() const;
void clearFolderVersions();
void updateFolderBox();
void applyHorizontalSort(int _sort);
int calculateWeightRecurse();
int getWeight() const;
long getCommitDate() const;
int getPredecessors(QSet<Version*>& _result);
int getPredecessorHashes(QStringList& _result);
void calculateLocalBoundingBox();
bool getSubtreeHidden() const;
void setSubtreeVisible(bool _value);
void compareToSelected(bool _view = false);
void compareToPrevious(bool _view = false);
void compareToLocalHead(bool _view = false);
void compareToBranchBaseline(bool _view = false);
void viewThisVersion();
void focusNeighbourBox();
// all elements in linear will then get Node::height = 0
void foldAction();
void setBlockItemChanged(bool _val);
bool getBlockItemChanged() const;
void setFileConstraint(bool _val);
bool getFileConstraint() const;
void reduceToFileConstraint(Version* _parent, bool _merge = false);
void clearFileConstraintEdgeList();
QList<Edge*>& getFileConstraintInEdgeList();
QList<Edge*>& getFileConstraintOutEdgeList();
/**
* \brief If version is folded away, ensure its visibility.
*
* \return true, if folding has changed
*/
bool ensureUnfolded();
int getDotRadius() const;
protected:
bool hasBranch() const;
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* _event);
bool getTextBoundingBox(const QString& _key, const QStringList& _values, int& _height, QRectF& _updatedBox) const;
bool drawTextBox(const QString& _key, const QStringList& _values, int& _height, const qreal& _lod, QPainter* _painter, bool _frame = true);
QVariant itemChange(GraphicsItemChange change, const QVariant& value);
void adjustEdges();
void adjustEdgesRecurse();
void setFolded(bool _val);
private:
QList<Edge*> edgeList;
QList<Edge*> fileConstraintInEdgeList;
QList<Edge*> fileConstraintOutEdgeList;
// QString hash;
QStringList tags;
QStringList branchTags;
GraphWidget* graph;
QString commit_sse;
const QStringList& globalVersionInfo;
const QStringList& changeableVersionInfo;
static QStringList dummy;
bool matched;
QMap<QString, QStringList> keyInformation;
QSet<QString> localVersionInfo;
QRectF localBoundingBox;
QRectF folderBox;
QString treeInfo;
QString hash;
QDateTime commitTimestamp;
// Versions with no fork or merge are collected in the following list.
// They can be folded or unfolded, then.
QList<Version*> linear;
void addToFolder(Version* _v);
// fold/unfold action:
// if the versions in linear are folded, the flag of the list owner
// 'folded' is set. Initial value is true.
bool folded;
// flag to control if the version can be folded away
bool foldable;
// rootnode
bool rootnode;
// hidden subtree?
bool subtreeHidden;
// foldedHeight
// Node::foldedHeight := 0 for all
bool blockItemChanged;
//
QString rawInput;
bool updateBoundingRect;
bool main;
bool fileConstraint;
bool selected;
int weight;
long commitDate;
};
typedef struct Version* VersionPointer;
Q_DECLARE_METATYPE(VersionPointer)
#endif