00001
00002
00003
00004
00005
00006
00007 #ifndef PATCHVIEW_H
00008 #define PATCHVIEW_H
00009
00010 #include <qobject.h>
00011 #include <qguardedptr.h>
00012 #include <qregexp.h>
00013 #include <qvaluevector.h>
00014 #include "patchbase.h"
00015 #include "domain.h"
00016
00017 class QTextEdit;
00018 class QLineEdit;
00019 class QRadioButton;
00020 class DiffHighlighter;
00021 class Git;
00022 class MyProcess;
00023 class StateInfo;
00024 class Domain;
00025 class DiffHighlighter;
00026 class ListBoxFiles;
00027 class TabPatch;
00028 class RevFile;
00029
00030 class PatchView :public Domain {
00031 Q_OBJECT
00032 public:
00033 PatchView() {}
00034 PatchView(MainImpl* mi, Git* g);
00035 ~PatchView();
00036 void clear(bool complete = true);
00037 virtual TabPatch* tab() { return patchTab; }
00038
00039 signals:
00040 void diffTo(const QString&);
00041 void diffViewerDocked();
00042
00043 public slots:
00044 void on_lineEditDiff_returnPressed();
00045 void on_buttonGroupDiff_clicked(int);
00046 void on_buttonFilterPatch_clicked();
00047 void on_procDataReady(const QByteArray&);
00048 void on_eof();
00049 void on_highlightPatch(const QString&, bool);
00050 void on_updateRevDesc();
00051
00052 protected slots:
00053 virtual void on_contextMenu(const QString&, int);
00054
00055 protected:
00056 virtual bool doUpdate(bool force);
00057
00058 private:
00059 friend class DiffHighlighter;
00060
00061 void updatePatch();
00062 void centerOnFileHeader(const QString& fileName);
00063 void centerTarget();
00064 void saveRestoreSizes(bool startup = false);
00065 int doSearch(const QString& txt, int pos);
00066 void computeMatches();
00067 bool getMatch(int para, int* indexFrom, int* indexTo);
00068 void centerMatch(uint id = 0);
00069 const QString processData(const QByteArray& fileChunk, int* prevLineNum = NULL);
00070
00071 TabPatch* patchTab;
00072 DiffHighlighter* diffHighlighter;
00073 ListBoxFiles* listBoxFiles;
00074 QGuardedPtr<MyProcess> proc;
00075 QByteArray patchRowData;
00076 QString target;
00077 QString partialParagraphs;
00078 QString normalizedSha;
00079 bool seekTarget;
00080 bool diffLoaded;
00081 bool isRegExp;
00082 QRegExp pickAxeRE;
00083
00084 enum ButtonId {
00085 DIFF_TO_PARENT = 0,
00086 DIFF_TO_HEAD = 1,
00087 DIFF_TO_SHA = 2
00088 };
00089
00090 enum PatchFilter {
00091 VIEW_ALL,
00092 VIEW_ADDED,
00093 VIEW_REMOVED
00094 };
00095 PatchFilter curFilter, prevFilter;
00096
00097 struct MatchSelection {
00098 int paraFrom;
00099 int indexFrom;
00100 int paraTo;
00101 int indexTo;
00102 };
00103 typedef QValueVector<MatchSelection> Matches;
00104 Matches matches;
00105 };
00106
00107 #endif