forked from Dax89/QHexView
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqhexview.h
64 lines (52 loc) · 1.83 KB
/
qhexview.h
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
#ifndef QHEXVIEW_H
#define QHEXVIEW_H
#define QHEXVIEW_VERSION 3.0
#include <QAbstractScrollArea>
#include <QTimer>
#include "document/qhexrenderer.h"
#include "document/qhexdocument.h"
class QHexView : public QAbstractScrollArea
{
Q_OBJECT
public:
explicit QHexView(QWidget *parent = nullptr);
QHexDocument* document();
void setDocument(QHexDocument* document);
void setReadOnly(bool b);
protected:
virtual bool event(QEvent* e);
virtual void keyPressEvent(QKeyEvent *e);
virtual void mousePressEvent(QMouseEvent* e);
virtual void mouseMoveEvent(QMouseEvent* e);
virtual void mouseReleaseEvent(QMouseEvent* e);
virtual void focusInEvent(QFocusEvent* e);
virtual void focusOutEvent(QFocusEvent* e);
virtual void wheelEvent(QWheelEvent* e);
virtual void resizeEvent(QResizeEvent* e);
virtual void paintEvent(QPaintEvent* e);
private slots:
void renderCurrentLine();
void moveToSelection();
void blinkCursor();
private:
void moveNext(bool select = false);
void movePrevious(bool select = false);
private:
bool processMove(QHexCursor* cur, QKeyEvent* e);
bool processTextInput(QHexCursor* cur, QKeyEvent* e);
bool processAction(QHexCursor* cur, QKeyEvent* e);
void adjustScrollBars();
void renderLine(quint64 line);
quint64 firstVisibleLine() const;
quint64 lastVisibleLine() const;
quint64 visibleLines() const;
bool isLineVisible(quint64 line) const;
int documentSizeFactor() const;
QPoint absolutePosition(const QPoint & pos) const;
private:
QHexDocument* m_document;
QHexRenderer* m_renderer;
QTimer* m_blinktimer;
bool m_readonly;
};
#endif // QHEXVIEW_H