annotate.h

Go to the documentation of this file.
00001 /*
00002         Author: Marco Costalba (C) 2005-2006
00003 
00004         Copyright: See COPYING file that comes with this distribution
00005 
00006 */
00007 #ifndef ANNOTATE_H
00008 #define ANNOTATE_H
00009 
00010 #include <qobject.h>
00011 #include <qprocess.h>
00012 #include <qtimer.h>
00013 #include <qpair.h>
00014 #include "exceptionmanager.h"
00015 #include "common.h"
00016 
00017 class Git;
00018 class FileHistory;
00019 
00020 class ReachInfo {
00021 public:
00022         ReachInfo() {}
00023         ReachInfo(SCRef s, int i, int t) : sha(s), id(i), type(t) {}
00024         const QString sha;
00025         int id, type;
00026         QStringList roots;
00027 };
00028 typedef QValueVector<ReachInfo> ReachList;
00029 
00030 class RangeInfo {
00031 public:
00032         RangeInfo() { clear(); }
00033         RangeInfo(int s, int e, bool m) : start(s), end(e), modified(m) {}
00034         void clear() { start = end = 0; modified = false; }
00035         int start, end; // ranges count file lines from 1 like patches diffs
00036         bool modified;
00037 };
00038 
00039 class Annotate : public QObject {
00040 Q_OBJECT
00041 public:
00042         Annotate (Git* parent, QObject* guiObj);
00043         void deleteWhenDone();
00044         const FileAnnotation* lookupAnnotation(SCRef sha, SCRef fileName);
00045         bool start(const FileHistory* fh);
00046         bool isValid() { return valid; }
00047         bool isCanceled() { return canceled; }
00048         int count() { return ah.count(); }
00049         int elapsed() { return processingTime.elapsed(); }
00050         const QString file() { return fileName; }
00051         const QString getAncestor(SCRef sha, SCRef fileName, int* shaIdx);
00052         bool getRange(SCRef sha, RangeInfo* r);
00053         bool seekPosition(int* rangeStart, int* rangeEnd, SCRef fromSha, SCRef toSha);
00054         const QString computeRanges(SCRef sha, int rStart, int rEnd, SCRef target = "");
00055 
00056 private slots:
00057         void on_patchProc_readFromStdout();
00058         void on_patchProc_processExited();
00059         void on_progressTimer_timeout();
00060         void on_deleteWhenDone();
00061         void slotComputeDiffs();
00062 
00063 private:
00064         typedef QMap<QString, FileAnnotation> AnnotateHistory;
00065 
00066         void annotateFileHistory(SCRef fileName, bool buildPatchScript);
00067         void doAnnotate(SCRef fileName, SCRef sha, bool buildPatchScript);
00068         FileAnnotation* getFileAnnotation(SCRef sha);
00069         void setInitialAnnotation(SCRef fileName, SCRef sha, FileAnnotation* fa);
00070         const QString setupAuthor(SCRef origAuthor, int annId);
00071         void setAnnotation(SCRef diff, SCRef aut, SCList pAnn, QStringList& nAnn, int ofs = 0);
00072         bool getNextLine(SCRef d, int& idx, QString& line);
00073         static void unify(SList dst, SCList src);
00074         void updatePatchScript(SCRef sha, SCRef par);
00075         bool startPatchProc(SCRef buf, SCRef fileName);
00076         const QString getNextPatch(QString& patchFile, SCRef fileName, SCRef sha);
00077         bool getNextSection(SCRef d, int& idx, QString& sec, SCRef target);
00078         void updateRange(RangeInfo* r, SCRef diff, bool reverse);
00079         void updateCrossRanges(SCRef cnk, bool rev, int oStart, int oLineCnt, RangeInfo* r);
00080         bool isDescendant(SCRef sha, SCRef target);
00081 
00082         EM_DECLARE(exAnnCanceled);
00083 
00084         Git* git;
00085         QObject* gui;
00086         const FileHistory* fh;
00087         AnnotateHistory ah;
00088         bool cancelingAnnotate;
00089         bool annotateRunning;
00090         bool annotateActivity;
00091         bool isError;
00092         int annNumLen;
00093         int annId;
00094         int annFilesNum;
00095         QString patchScript;
00096         QString fileName;
00097         StrVect histRevOrder; // TODO use reference
00098         QProcess patchProc;
00099         QString patchProcBuf;
00100         QString nextFileSha;
00101         bool valid;
00102         bool canceled;
00103         QTime processingTime;
00104         QTimer progressTimer;
00105 
00106         typedef QPair<QString, uint> Key;
00107         QMap<Key, QString> diffMap; // QPair(sha, parentNr)
00108         QMap<QString, RangeInfo> rangeMap;
00109 };
00110 
00111 #endif

Generated on Fri Dec 7 21:57:36 2007 for QGit by  doxygen 1.5.3