00001
00002
00003
00004
00005
00006
00007 #ifndef FILECONTENT_H
00008 #define FILECONTENT_H
00009
00010 #include <qobject.h>
00011 #include <qguardedptr.h>
00012 #include "common.h"
00013
00014 class QTextEdit;
00015 class QListView;
00016 class FileHighlighter;
00017 class Domain;
00018 class StateInfo;
00019 class Annotate;
00020 class Git;
00021 class MyProcess;
00022 class RangeInfo;
00023 class FileHistory;
00024
00025 class FileContent: public QObject {
00026 Q_OBJECT
00027 public:
00028 FileContent(Domain* parent, Git* git, QTextEdit* f);
00029 ~FileContent();
00030 void update(bool force = false);
00031 bool annotateAvailable() { return curAnn != NULL; }
00032 void clear();
00033 void copySelection();
00034 void goToAnnotation(int id);
00035 bool goToRangeStart();
00036 bool rangeFilter(bool b);
00037 bool getRange(SCRef sha, RangeInfo* r);
00038 void startAnnotate(FileHistory* fh);
00039 void setShowAnnotate(bool b);
00040 void setHighlightSource(bool b);
00041
00042 signals:
00043 void annotationAvailable(bool);
00044 void fileAvailable(bool);
00045 void revIdSelected(int);
00046
00047 public slots:
00048 void on_doubleClicked(int, int);
00049 void on_annotateReady(Annotate*, const QString&, bool, const QString&);
00050 void on_procDataReady(const QByteArray&);
00051 void on_eof(bool emitSignal = true);
00052
00053 private:
00054 friend class FileHighlighter;
00055
00056 void clearAnnotate();
00057 void clearText(bool emitSignal = true);
00058 void findInFile(SCRef str);
00059 bool lookupAnnotation();
00060 uint annotateLength(const FileAnnotation* curAnn);
00061 void saveScreenState();
00062 void restoreScreenState();
00063 uint processData(const QByteArray& fileChunk);
00064
00065 Domain* d;
00066 Git* git;
00067 QTextEdit* ft;
00068 StateInfo* st;
00069 RangeInfo* rangeInfo;
00070 FileHighlighter* fileHighlighter;
00071 QGuardedPtr<Annotate> annotateObj;
00072 QGuardedPtr<MyProcess> proc;
00073 const FileAnnotation* curAnn;
00074 QByteArray fileRowData;
00075 QString fileProcessedData;
00076 QString halfLine;
00077 uint curLine;
00078 QStringList::const_iterator curAnnIt;
00079 uint annoLen;
00080 bool isFileAvailable;
00081 bool isAnnotationAvailable;
00082 bool isAnnotationAppended;
00083 bool isRangeFilterActive;
00084 bool isShowAnnotate;
00085 bool isHtmlSource;
00086
00087 struct ScreenState {
00088 bool isValid, hasSelectedText, isAnnotationAppended;
00089 int topPara, paraFrom, indexFrom, paraTo, indexTo, annoLen;
00090 };
00091 ScreenState ss;
00092
00093 static const QString HTML_HEAD;
00094 static const QString HTML_TAIL;
00095 static const QString HTML_FILE_START;
00096 static const QString HTML_FILE_END;
00097 };
00098
00099 #endif