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