-
Notifications
You must be signed in to change notification settings - Fork 5
/
hexedit.h
65 lines (49 loc) · 1.78 KB
/
hexedit.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
65
/*
* This application is free software and is released under the terms of
* the BSD license. See LICENSE file for details.
*
* Copyright (c) 2010 Volker Poplawski (volker@openbios.org)
*/
#ifndef HEXEDIT_H
#define HEXEDIT_H
#include <QtWidgets>
class HexEdit : public QAbstractScrollArea
{
Q_OBJECT
public:
HexEdit(QWidget *parent = 0);
~HexEdit();
enum OffsetColumn { NONE, SIZE32, SIZE64 };
void setData( const uchar* data, quint64 size );
qint64 cursorPosition() const { return m_cursorPosition; }
int visibleLines() const;
virtual QSize sizeHint () const;
public Q_SLOTS:
void setHighlight( const uchar* start, qint64 size, bool ensureVisible = false );
void ensureHighlightVisible();
void setCursorPosition( const uchar* pos );
Q_SIGNALS:
void cursorPosition(qint64 pos);
void rescanRequested(qint64 ofs);
protected:
virtual void paintEvent( QPaintEvent * event );
virtual void resizeEvent( QResizeEvent * event );
virtual void scrollContentsBy ( int dx, int dy );
virtual void keyPressEvent( QKeyEvent* event );
virtual void mousePressEvent( QMouseEvent* event );
virtual void contextMenuEvent(QContextMenuEvent *);
void updateScrollbar();
void ensureCursorVisible();
QPair<int,int> calculateHexTextArea(const QString& hexStr, int start, int end) const;
QPair<int,int> calculateAsciiTextArea(const QString& asciiStr, int start, int end) const;
qint64 mousePosToOffset( const QPoint& pos ) const;
const uchar* m_data;
qint64 m_dataSize;
qint64 m_cursorPosition;
const uchar* m_highlightStartAdr; // byte offset
qint64 m_highlightSize; // bytes
int m_lineCount;
OffsetColumn m_offsetColumnMode;
QSize m_sizeHint;
};
#endif