Version 2.6
[qgit4/redivivus.git] / src / patchcontent.h
blobf9f1912ffa3367147f6eaba66f287f1d6b643a88
1 /*
2 Author: Marco Costalba (C) 2005-2007
4 Copyright: See COPYING file that comes with this distribution
6 */
7 #ifndef PATCHCONTENT_H
8 #define PATCHCONTENT_H
10 #include <QPointer>
11 #include <QTextEdit>
12 #include <QSyntaxHighlighter>
13 #include "common.h"
15 class Domain;
16 class Git;
17 class MyProcess;
18 class StateInfo;
20 class DiffHighlighter : public QSyntaxHighlighter {
21 public:
22 DiffHighlighter(QTextEdit* p) : QSyntaxHighlighter(p), cl(0) {}
23 void setCombinedLength(uint c) { cl = c; }
24 virtual void highlightBlock(const QString& text);
25 private:
26 uint cl;
29 class PatchContent: public QTextEdit {
30 Q_OBJECT
31 public:
32 PatchContent(QWidget* parent);
33 void setup(Domain* parent, Git* git);
34 void clear();
35 void centerOnFileHeader(StateInfo& st);
36 void refresh();
37 void update(StateInfo& st);
39 enum PatchFilter {
40 VIEW_ALL,
41 VIEW_ADDED,
42 VIEW_REMOVED
44 PatchFilter curFilter, prevFilter;
46 public slots:
47 void on_highlightPatch(const QString&, bool);
48 void typeWriterFontChanged();
49 void procReadyRead(const QByteArray& data);
50 void procFinished();
52 private:
53 friend class DiffHighlighter;
55 void scrollCursorToTop();
56 void scrollLineToTop(int lineNum);
57 int positionToLineNum(int pos);
58 int topToLineNum();
59 void saveRestoreSizes(bool startup = false);
60 int doSearch(const QString& txt, int pos);
61 bool computeMatches();
62 bool getMatch(int para, int* indexFrom, int* indexTo);
63 void centerMatch(int id = 0);
64 bool centerTarget(SCRef target);
65 void processData(const QByteArray& data, int* prevLineNum = NULL);
67 Git* git;
68 DiffHighlighter* diffHighlighter;
69 QPointer<MyProcess> proc;
70 bool diffLoaded;
71 QByteArray patchRowData;
72 QString halfLine;
73 bool isRegExp;
74 QRegExp pickAxeRE;
75 QString target;
76 bool seekTarget;
78 struct MatchSelection {
79 int paraFrom;
80 int indexFrom;
81 int paraTo;
82 int indexTo;
84 typedef QVector<MatchSelection> Matches;
85 Matches matches;
88 #endif