[go: up one dir, main page]

File: annotate.h

package info (click to toggle)
qgit 2.3-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 1,152 kB
  • ctags: 1,477
  • sloc: cpp: 11,857; makefile: 51; sh: 39
file content (94 lines) | stat: -rw-r--r-- 2,521 bytes parent folder | download | duplicates (2)
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
/*
	Author: Marco Costalba (C) 2005-2007

	Copyright: See COPYING file that comes with this distribution

*/
#ifndef ANNOTATE_H
#define ANNOTATE_H

#include <QObject>
#include <QTime>
#include "exceptionmanager.h"
#include "common.h"

class Git;
class FileHistory;
class MyProcess;

class ReachInfo {
public:
	ReachInfo() {}
	ReachInfo(SCRef s, int i, int t) : sha(s), id(i), type(t) {}
	const QString sha;
	int id, type;
	QStringList roots;
};
typedef QVector<ReachInfo> ReachList;

class RangeInfo {
public:
	RangeInfo() { clear(); }
	RangeInfo(int s, int e, bool m) : start(s), end(e), modified(m) {}
	void clear() { start = end = 0; modified = false; }
	int start, end; // ranges count file lines from 1 like patches diffs
	bool modified;
};
typedef QHash<QString, RangeInfo> Ranges;

class Annotate : public QObject {
Q_OBJECT
public:
	Annotate(Git* parent, QObject* guiObj);
	void deleteWhenDone();
	const FileAnnotation* lookupAnnotation(SCRef sha);
	bool start(const FileHistory* fh);
	bool isCanceled() { return canceled; }
	const QString getAncestor(SCRef sha, int* shaIdx);
	bool getRange(SCRef sha, RangeInfo* r);
	bool seekPosition(int* rangeStart, int* rangeEnd, SCRef fromSha, SCRef toSha);
	const QString computeRanges(SCRef sha, int paraFrom, int paraTo, SCRef target = "");

signals:
	void annotateReady(Annotate*, bool, const QString&);

private slots:
	void on_deleteWhenDone();
	void slotComputeDiffs();

private:
	void annotateFileHistory();
	void doAnnotate(const ShaString& sha);
	FileAnnotation* getFileAnnotation(SCRef sha);
	void setInitialAnnotation(SCRef fileSha, FileAnnotation* fa);
	const QString setupAuthor(SCRef origAuthor, int annId);
	bool setAnnotation(SCRef diff, SCRef aut, SCList pAnn, SList nAnn, int ofs = 0);
	bool getNextLine(SCRef d, int& idx, QString& line);
	static void unify(SList dst, SCList src);
	const QString getPatch(SCRef sha, int parentNum = 0);
	bool getNextSection(SCRef d, int& idx, QString& sec, SCRef target);
	void updateRange(RangeInfo* r, SCRef diff, bool reverse);
	void updateCrossRanges(SCRef cnk, bool rev, int oStart, int oLineCnt, RangeInfo* r);
	bool isDescendant(SCRef sha, SCRef target);

	EM_DECLARE(exAnnCanceled);

	Git* git;
	QObject* gui;
	const FileHistory* fh;
	AnnotateHistory ah;
	bool cancelingAnnotate;
	bool annotateRunning;
	bool annotateActivity;
	bool isError;
	int annNumLen;
	int annId;
	int annFilesNum;
	ShaVect histRevOrder; // TODO use reference
	bool valid;
	bool canceled;
	QTime processingTime;
	Ranges ranges;
};

#endif