forked from wtr9987/gvtree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraphwidget.h
284 lines (239 loc) · 7.97 KB
/
graphwidget.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
275
276
277
278
279
280
281
282
283
284
/* --------------------------------------------- */
/* */
/* Copyright (C) 2021 Wolfgang Trummer */
/* Contact: [email protected] */
/* */
/* gvtree V1.8-0 */
/* */
/* git version tree browser */
/* */
/* 28. December 2021 */
/* */
/* This program is licensed under */
/* GNU GENERAL PUBLIC LICENSE */
/* Version 3, 29 June 2007 */
/* */
/* --------------------------------------------- */
#ifndef __GRAPHWIDGET_H__
#define __GRAPHWIDGET_H__
#include <QGraphicsView>
#include <QModelIndex>
#include <QDockWidget>
#include <QTreeView>
#include <QString>
#include <QList>
#include <QRectF>
#include <QTextEdit>
#include "fromtoinfo.h"
#include "comparetree.h"
class Version;
class GraphWidget : public QGraphicsView
{
Q_OBJECT
public:
// Constructor
GraphWidget(class MainWindow* parent = NULL);
// Test tree
void test();
// Test load git log file
void load(const QString& _path);
// Get real git log information of a local repository
void gitlog(bool _dirChanged = false);
Version* gitlogSingle(QString _hash = QString(), bool _create = false);
// Get hashes of one file and markup versions
void setGitLogFileConstraint(const QString& _fileConstraint = QString());
// Create the graph from git log information
void process(QList<QString> _cache);
void forceUpdate();
// Compare or view versions
void compareToSelected(Version* _v, bool _view = false);
void compareToPrevious(Version* _v, bool _view = false);
void compareToLocalHead(Version* _v, bool _view = false);
void compareToBranchBaseline(Version* _v, bool _view = false);
void viewThisVersion(Version* _v);
void compareVersions(Version* _v1, Version* _v2, bool _showDiff = false);
// focus
int matchVersions(const QString& _text, QList<Version*>& _matches, bool _exactMatch = false, QString _keyConstraint = QString());
bool focusElements(const QString& _text, bool _exactMatch = false, QString _keyConstraint = QString());
bool focusElements(const QList<Version*>& _markup);
void displayHits(Version* _v);
void displayHits(const QList<Version*>& _hits, bool _unfold = true);
void clear();
void getMarkedupVersions(QList<Version*>& _markup, bool _selected = true);
void resetMatches();
void setMinSize(bool _resize = true);
// change the position of HEAD
void flipY();
void setGlobalVersionInfo(const QString& _item, bool _value);
void setLocalRepositoryPath(const QString& _dir);
const QString& getLocalRepositoryPath() const;
const class MainWindow* getMainWindow() const;
void commitInfo(const Version* _v, QTextEdit* _tedi);
void setCompareTree(CompareTree* _tree);
void resetCompareTree();
QStringList getFromHashes() const;
QString getToHash() const;
const QString& getFileConstraint() const;
void calculateGraphicsViewPosition();
const QSet<Version*>& getPredecessors() const;
Version* getVersionByHash(const QString& _hash);
Version* getSelectedVersion();
void preferencesUpdated(bool _forceUpdate = false);
/**
* \brief After reload or refresh check if the current
* versions are contained in the new version tree.
* If not false is returned and the compare widget
* can be cleared, too.
*/
bool restoreImportantVersions();
void saveImportantVersions();
float getXFactor() const;
float getYFactor() const;
bool getTopDownView() const;
Version* getLocalHeadVersion() const;
void updateFromToInfo();
// style
const QColor& getBackgroundColor() const
{
return backgroundColor;
}
const QColor& getFromToColor() const
{
return fromToColor;
}
const QColor& getNodeColor() const
{
return nodeColor;
}
const QColor& getSelectedColor() const
{
return selectedColor;
}
const QColor& getSearchColor() const
{
return searchColor;
}
const QColor& getEdgeColor() const
{
return edgeColor;
}
const QColor& getMergeColor() const
{
return mergeColor;
}
const QColor& getFoldedColor() const
{
return foldedColor;
}
const QColor& getUnfoldedColor() const
{
return unfoldedColor;
}
const QColor& getFileConstraintColor() const
{
return fileConstraintColor;
}
int getConnectorStyle() const
{
return connectorStyle;
}
bool isFromToVersion(Version* _v) const;
const QImage* getImage(const QString& _name) const;
public slots:
void diffStagedChanges();
void diffLocalChanges();
void resetDiff();
void resetSelection();
void focusCurrent();
void fitInView();
void foldAll();
void unfoldAll();
void normalizeGraph();
void updateGraphFolding(Version* _v = NULL);
void zoomIn();
void zoomOut();
void updateColors();
void focusFromVersion();
void focusToVersion();
void removeFilter();
void adjustComments();
void adjustAllEdges();
void setBlockItemChanged(bool _val);
protected:
void focusFromTo(const QRectF& _from, const QRectF& _to);
void animatedFocus(const QRectF& _from, const QRectF& _to);
QRectF animatedFocus(const QRectF& _from, const QRectF& _to, double _morph);
void aspectCenter(QRectF& _from, QRectF& _to);
virtual void contextMenuEvent(QContextMenuEvent* _event);
virtual void keyPressEvent(QKeyEvent* event);
virtual void wheelEvent(QWheelEvent* event);
virtual void mousePressEvent(QMouseEvent* event);
virtual void mouseMoveEvent(QMouseEvent* event);
virtual void mouseReleaseEvent(QMouseEvent* event);
void drawBackground(QPainter* painter, const QRectF& rect);
void scaleView(qreal scaleFactor);
void expandTree();
void fillCompareWidgetFromToInfo();
Version* findVersion(const QString& _hash);
// to debug the git log --graph parser...
void debugGraphParser(const QString& _tree, const QVector<Version*>& _slots);
void debugExit(char _c,
int _column,
int _lineNumber,
const QString& _tree,
const QString& _previousTree,
const QString& _line);
private:
// from/to version cursor
QSet<Version*> fromVersions;
Version* toVersion;
FromToInfo* fromToInfo;
// backup the hashes to restore after refresh
QStringList fromHashSave;
QString toHashSave;
// root version node
Version* rootVersion;
Version* localHeadVersion; // local HEAD version
Version* headVersion; // top version element (without --remotes == localHeadVersion)
QStringList globalVersionInfo;
// other widgets
class MainWindow* mwin;
CompareTree* compareTree;
// mouse pan
bool pan;
QPoint mpos;
// argv
QString localRepositoryPath;
QString fileConstraint;
QSet<QString> fileConstraintHashes;
// preferences
QColor backgroundColor;
QColor fromToColor;
QColor nodeColor;
QColor selectedColor;
QColor searchColor;
QColor edgeColor;
QColor mergeColor;
QColor foldedColor;
QColor unfoldedColor;
QColor fileConstraintColor;
int connectorStyle;
int maxLines;
int currentLines;
bool shortHashes;
bool reduceTree;
bool topDownView;
int horizontalSort;
bool remotes;
bool all;
int xfactor;
int yfactor;
int commentColumns;
int commentMaxlen;
Version* selectedVersion;
QString selectedVersionHash;
//
QMap<QString, QMap<QString, QStringList> > keyInformationCache;
QMap<QString, const QImage*> imageDB;
};
#endif