realign contributors addition (waiting for whitespace cleanup)
[qgit4/redivivus.git] / src / annotate.h
blobc866156b9ec8f47d2277c9facf227f8e5a2e0c14
1 /*
2 Author: Marco Costalba (C) 2005-2007
4 Copyright: See COPYING file that comes with this distribution
6 */
7 #ifndef ANNOTATE_H
8 #define ANNOTATE_H
10 #include <QObject>
11 #include <QTime>
12 #include "exceptionmanager.h"
13 #include "common.h"
15 class Git;
16 class FileHistory;
17 class MyProcess;
19 class ReachInfo {
20 public:
21 ReachInfo() {}
22 ReachInfo(SCRef s, int i, int t) : sha(s), id(i), type(t) {}
23 const QString sha;
24 int id, type;
25 QStringList roots;
27 typedef QVector<ReachInfo> ReachList;
29 class RangeInfo {
30 public:
31 RangeInfo() { clear(); }
32 RangeInfo(int s, int e, bool m) : start(s), end(e), modified(m) {}
33 void clear() { start = end = 0; modified = false; }
34 int start, end; // ranges count file lines from 1 like patches diffs
35 bool modified;
37 typedef QHash<QString, RangeInfo> Ranges;
39 class Annotate : public QObject {
40 Q_OBJECT
41 public:
42 Annotate(Git* parent, QObject* guiObj);
43 void deleteWhenDone();
44 const FileAnnotation* lookupAnnotation(SCRef sha);
45 bool start(const FileHistory* fh);
46 bool isCanceled() { return canceled; }
47 const QString getAncestor(SCRef sha, int* shaIdx);
48 bool getRange(SCRef sha, RangeInfo* r);
49 bool seekPosition(int* rangeStart, int* rangeEnd, SCRef fromSha, SCRef toSha);
50 const QString computeRanges(SCRef sha, int paraFrom, int paraTo, SCRef target = "");
52 signals:
53 void annotateReady(Annotate*, bool, const QString&);
55 private slots:
56 void on_deleteWhenDone();
57 void slotComputeDiffs();
59 private:
60 void annotateFileHistory();
61 void doAnnotate(const ShaString& sha);
62 FileAnnotation* getFileAnnotation(SCRef sha);
63 void setInitialAnnotation(SCRef fileSha, FileAnnotation* fa);
64 const QString setupAuthor(SCRef origAuthor, int annId);
65 bool setAnnotation(SCRef diff, SCRef aut, SCList pAnn, SList nAnn, int ofs = 0);
66 bool getNextLine(SCRef d, int& idx, QString& line);
67 static void unify(SList dst, SCList src);
68 const QString getPatch(SCRef sha, int parentNum = 0);
69 bool getNextSection(SCRef d, int& idx, QString& sec, SCRef target);
70 void updateRange(RangeInfo* r, SCRef diff, bool reverse);
71 void updateCrossRanges(SCRef cnk, bool rev, int oStart, int oLineCnt, RangeInfo* r);
72 bool isDescendant(SCRef sha, SCRef target);
74 EM_DECLARE(exAnnCanceled);
76 Git* git;
77 QObject* gui;
78 const FileHistory* fh;
79 AnnotateHistory ah;
80 bool cancelingAnnotate;
81 bool annotateRunning;
82 bool annotateActivity;
83 bool isError;
84 int annNumLen;
85 int annId;
86 int annFilesNum;
87 ShaVect histRevOrder; // TODO use reference
88 bool valid;
89 bool canceled;
90 QTime processingTime;
91 Ranges ranges;
94 #endif