-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqgitdiffwidget.h
More file actions
65 lines (53 loc) · 1.81 KB
/
qgitdiffwidget.h
File metadata and controls
65 lines (53 loc) · 1.81 KB
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
#pragma once
#include "qgit.h"
#include <QWidget>
#include <QVector>
#include <QString>
#include <QRect>
#include <QList>
class QGitDiffWidgetPrivate;
class QGitDiffWidgetPrivateLine;
class QGitDiffWidget : public QWidget
{
Q_OBJECT
Q_PROPERTY( bool readonly READ readonly WRITE setReadonly DESIGNABLE true )
public:
explicit QGitDiffWidget(QWidget *parent = nullptr);
~QGitDiffWidget() = default;
void setGitDiff(const QString &first, const QString &second, const QList<QString> &files);
void setReadonly(bool readonly = true);
void setIgnoreWhitespace(bool ignore);
void setLinesOfContent(int lines);
void refresh();
bool readonly() const;
int hoverFile() const;
int hoverHunk() const;
int hoverLine() const;
QVector<QGitDiffWidgetLine> linesAt(int fileIdx, int hunkIdx, int lineIdx, QString &fileName) const;
signals:
void requestGitDiff(QString first, QString second, QList<QString> files, uint32_t context_lines, bool ignoreWhitespace);
void select(QString file, QVector<QGitDiffWidgetLine> lines);
public slots:
void responseGitDiff(QString first, QString second, QList<QGitDiffFile> diff, QGitError error);
protected:
void paintEvent(QPaintEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void moveEvent(QMoveEvent *event) override;
private:
void updatePosition();
private:
QGitDiffWidgetPrivate *m_private = nullptr;
QString m_requestedFirst;
QString m_requestedSecond;
QList<QString> m_requestedFiles;
QFont m_font;
int m_fontHeight = 0;
int m_fontAscent = 0;
int m_hoverFile = -1;
int m_hoverHunk = -1;
int m_hoverLine = -1;
bool m_readonly = false;
int m_linesOfContent = 3;
bool m_ignoreWhitespace = false;
};