@@ -1,206 +1,206 | |||||
1 | #include <QtGui> |
|
1 | #include <QtGui> | |
2 |
|
2 | |||
3 | #include "qhexedit.h" |
|
3 | #include "qhexedit.h" | |
4 |
|
4 | #include <QScrollBar> | ||
5 |
|
5 | |||
6 | QHexEdit::QHexEdit(QWidget *parent) : QScrollArea(parent) |
|
6 | QHexEdit::QHexEdit(QWidget *parent) : QScrollArea(parent) | |
7 | { |
|
7 | { | |
8 | qHexEdit_p = new QHexEditPrivate(this); |
|
8 | qHexEdit_p = new QHexEditPrivate(this); | |
9 | setWidget(qHexEdit_p); |
|
9 | setWidget(qHexEdit_p); | |
10 | setWidgetResizable(true); |
|
10 | setWidgetResizable(true); | |
11 |
|
11 | |||
12 | connect(qHexEdit_p, SIGNAL(currentAddressChanged(int)), this, SIGNAL(currentAddressChanged(int))); |
|
12 | connect(qHexEdit_p, SIGNAL(currentAddressChanged(int)), this, SIGNAL(currentAddressChanged(int))); | |
13 | connect(qHexEdit_p, SIGNAL(currentSizeChanged(int)), this, SIGNAL(currentSizeChanged(int))); |
|
13 | connect(qHexEdit_p, SIGNAL(currentSizeChanged(int)), this, SIGNAL(currentSizeChanged(int))); | |
14 | connect(qHexEdit_p, SIGNAL(dataChanged()), this, SIGNAL(dataChanged())); |
|
14 | connect(qHexEdit_p, SIGNAL(dataChanged()), this, SIGNAL(dataChanged())); | |
15 | connect(qHexEdit_p, SIGNAL(overwriteModeChanged(bool)), this, SIGNAL(overwriteModeChanged(bool))); |
|
15 | connect(qHexEdit_p, SIGNAL(overwriteModeChanged(bool)), this, SIGNAL(overwriteModeChanged(bool))); | |
16 | setFocusPolicy(Qt::NoFocus); |
|
16 | setFocusPolicy(Qt::NoFocus); | |
17 | } |
|
17 | } | |
18 |
|
18 | |||
19 | int QHexEdit::indexOf(const QByteArray & ba, int from) const |
|
19 | int QHexEdit::indexOf(const QByteArray & ba, int from) const | |
20 | { |
|
20 | { | |
21 | return qHexEdit_p->indexOf(ba, from); |
|
21 | return qHexEdit_p->indexOf(ba, from); | |
22 | } |
|
22 | } | |
23 |
|
23 | |||
24 | void QHexEdit::insert(int i, const QByteArray & ba) |
|
24 | void QHexEdit::insert(int i, const QByteArray & ba) | |
25 | { |
|
25 | { | |
26 | qHexEdit_p->insert(i, ba); |
|
26 | qHexEdit_p->insert(i, ba); | |
27 | } |
|
27 | } | |
28 |
|
28 | |||
29 | void QHexEdit::insert(int i, char ch) |
|
29 | void QHexEdit::insert(int i, char ch) | |
30 | { |
|
30 | { | |
31 | qHexEdit_p->insert(i, ch); |
|
31 | qHexEdit_p->insert(i, ch); | |
32 | } |
|
32 | } | |
33 |
|
33 | |||
34 | int QHexEdit::lastIndexOf(const QByteArray & ba, int from) const |
|
34 | int QHexEdit::lastIndexOf(const QByteArray & ba, int from) const | |
35 | { |
|
35 | { | |
36 | return qHexEdit_p->lastIndexOf(ba, from); |
|
36 | return qHexEdit_p->lastIndexOf(ba, from); | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | void QHexEdit::remove(int pos, int len) |
|
39 | void QHexEdit::remove(int pos, int len) | |
40 | { |
|
40 | { | |
41 | qHexEdit_p->remove(pos, len); |
|
41 | qHexEdit_p->remove(pos, len); | |
42 | } |
|
42 | } | |
43 |
|
43 | |||
44 | void QHexEdit::replace( int pos, int len, const QByteArray & after) |
|
44 | void QHexEdit::replace( int pos, int len, const QByteArray & after) | |
45 | { |
|
45 | { | |
46 | qHexEdit_p->replace(pos, len, after); |
|
46 | qHexEdit_p->replace(pos, len, after); | |
47 | } |
|
47 | } | |
48 |
|
48 | |||
49 | QString QHexEdit::toReadableString() |
|
49 | QString QHexEdit::toReadableString() | |
50 | { |
|
50 | { | |
51 | return qHexEdit_p->toRedableString(); |
|
51 | return qHexEdit_p->toRedableString(); | |
52 | } |
|
52 | } | |
53 |
|
53 | |||
54 | QString QHexEdit::selectionToReadableString() |
|
54 | QString QHexEdit::selectionToReadableString() | |
55 | { |
|
55 | { | |
56 | return qHexEdit_p->selectionToReadableString(); |
|
56 | return qHexEdit_p->selectionToReadableString(); | |
57 | } |
|
57 | } | |
58 |
|
58 | |||
59 | void QHexEdit::setAddressArea(bool addressArea) |
|
59 | void QHexEdit::setAddressArea(bool addressArea) | |
60 | { |
|
60 | { | |
61 | qHexEdit_p->setAddressArea(addressArea); |
|
61 | qHexEdit_p->setAddressArea(addressArea); | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | void QHexEdit::redo() |
|
64 | void QHexEdit::redo() | |
65 | { |
|
65 | { | |
66 | qHexEdit_p->redo(); |
|
66 | qHexEdit_p->redo(); | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 | void QHexEdit::undo() |
|
69 | void QHexEdit::undo() | |
70 | { |
|
70 | { | |
71 | qHexEdit_p->undo(); |
|
71 | qHexEdit_p->undo(); | |
72 | } |
|
72 | } | |
73 |
|
73 | |||
74 | void QHexEdit::setAddressWidth(int addressWidth) |
|
74 | void QHexEdit::setAddressWidth(int addressWidth) | |
75 | { |
|
75 | { | |
76 | qHexEdit_p->setAddressWidth(addressWidth); |
|
76 | qHexEdit_p->setAddressWidth(addressWidth); | |
77 | } |
|
77 | } | |
78 |
|
78 | |||
79 | void QHexEdit::setAsciiArea(bool asciiArea) |
|
79 | void QHexEdit::setAsciiArea(bool asciiArea) | |
80 | { |
|
80 | { | |
81 | qHexEdit_p->setAsciiArea(asciiArea); |
|
81 | qHexEdit_p->setAsciiArea(asciiArea); | |
82 | } |
|
82 | } | |
83 |
|
83 | |||
84 | void QHexEdit::setHighlighting(bool mode) |
|
84 | void QHexEdit::setHighlighting(bool mode) | |
85 | { |
|
85 | { | |
86 | qHexEdit_p->setHighlighting(mode); |
|
86 | qHexEdit_p->setHighlighting(mode); | |
87 | } |
|
87 | } | |
88 |
|
88 | |||
89 | void QHexEdit::setAddressOffset(int offset) |
|
89 | void QHexEdit::setAddressOffset(int offset) | |
90 | { |
|
90 | { | |
91 | qHexEdit_p->setAddressOffset(offset); |
|
91 | qHexEdit_p->setAddressOffset(offset); | |
92 | } |
|
92 | } | |
93 |
|
93 | |||
94 | int QHexEdit::addressOffset() |
|
94 | int QHexEdit::addressOffset() | |
95 | { |
|
95 | { | |
96 | return qHexEdit_p->addressOffset(); |
|
96 | return qHexEdit_p->addressOffset(); | |
97 | } |
|
97 | } | |
98 |
|
98 | |||
99 | void QHexEdit::setCursorPosition(int cursorPos) |
|
99 | void QHexEdit::setCursorPosition(int cursorPos) | |
100 | { |
|
100 | { | |
101 | // cursorPos in QHexEditPrivate is the position of the textcoursor without |
|
101 | // cursorPos in QHexEditPrivate is the position of the textcoursor without | |
102 | // blanks, means bytePos*2 |
|
102 | // blanks, means bytePos*2 | |
103 | qHexEdit_p->setCursorPos(cursorPos*2); |
|
103 | qHexEdit_p->setCursorPos(cursorPos*2); | |
104 | } |
|
104 | } | |
105 |
|
105 | |||
106 | int QHexEdit::cursorPosition() |
|
106 | int QHexEdit::cursorPosition() | |
107 | { |
|
107 | { | |
108 | return qHexEdit_p->cursorPos() / 2; |
|
108 | return qHexEdit_p->cursorPos() / 2; | |
109 | } |
|
109 | } | |
110 |
|
110 | |||
111 |
|
111 | |||
112 | void QHexEdit::setData(const QByteArray &data) |
|
112 | void QHexEdit::setData(const QByteArray &data) | |
113 | { |
|
113 | { | |
114 | verticalScrollBar()->setSliderPosition(verticalScrollBar()->minimum()); |
|
114 | verticalScrollBar()->setSliderPosition(verticalScrollBar()->minimum()); | |
115 | qHexEdit_p->setData(data); |
|
115 | qHexEdit_p->setData(data); | |
116 | } |
|
116 | } | |
117 |
|
117 | |||
118 | QByteArray QHexEdit::data() |
|
118 | QByteArray QHexEdit::data() | |
119 | { |
|
119 | { | |
120 | return qHexEdit_p->data(); |
|
120 | return qHexEdit_p->data(); | |
121 | } |
|
121 | } | |
122 |
|
122 | |||
123 | void QHexEdit::setAddressAreaColor(const QColor &color) |
|
123 | void QHexEdit::setAddressAreaColor(const QColor &color) | |
124 | { |
|
124 | { | |
125 | qHexEdit_p->setAddressAreaColor(color); |
|
125 | qHexEdit_p->setAddressAreaColor(color); | |
126 | } |
|
126 | } | |
127 |
|
127 | |||
128 | QColor QHexEdit::addressAreaColor() |
|
128 | QColor QHexEdit::addressAreaColor() | |
129 | { |
|
129 | { | |
130 | return qHexEdit_p->addressAreaColor(); |
|
130 | return qHexEdit_p->addressAreaColor(); | |
131 | } |
|
131 | } | |
132 |
|
132 | |||
133 | void QHexEdit::setHighlightingColor(const QColor &color) |
|
133 | void QHexEdit::setHighlightingColor(const QColor &color) | |
134 | { |
|
134 | { | |
135 | qHexEdit_p->setHighlightingColor(color); |
|
135 | qHexEdit_p->setHighlightingColor(color); | |
136 | } |
|
136 | } | |
137 |
|
137 | |||
138 | QColor QHexEdit::highlightingColor() |
|
138 | QColor QHexEdit::highlightingColor() | |
139 | { |
|
139 | { | |
140 | return qHexEdit_p->highlightingColor(); |
|
140 | return qHexEdit_p->highlightingColor(); | |
141 | } |
|
141 | } | |
142 |
|
142 | |||
143 | void QHexEdit::setSelectionColor(const QColor &color) |
|
143 | void QHexEdit::setSelectionColor(const QColor &color) | |
144 | { |
|
144 | { | |
145 | qHexEdit_p->setSelectionColor(color); |
|
145 | qHexEdit_p->setSelectionColor(color); | |
146 | } |
|
146 | } | |
147 |
|
147 | |||
148 | QColor QHexEdit::selectionColor() |
|
148 | QColor QHexEdit::selectionColor() | |
149 | { |
|
149 | { | |
150 | return qHexEdit_p->selectionColor(); |
|
150 | return qHexEdit_p->selectionColor(); | |
151 | } |
|
151 | } | |
152 |
|
152 | |||
153 | void QHexEdit::setOverwriteMode(bool overwriteMode) |
|
153 | void QHexEdit::setOverwriteMode(bool overwriteMode) | |
154 | { |
|
154 | { | |
155 | qHexEdit_p->setOverwriteMode(overwriteMode); |
|
155 | qHexEdit_p->setOverwriteMode(overwriteMode); | |
156 | } |
|
156 | } | |
157 |
|
157 | |||
158 | bool QHexEdit::overwriteMode() |
|
158 | bool QHexEdit::overwriteMode() | |
159 | { |
|
159 | { | |
160 | return qHexEdit_p->overwriteMode(); |
|
160 | return qHexEdit_p->overwriteMode(); | |
161 | } |
|
161 | } | |
162 |
|
162 | |||
163 | void QHexEdit::setReadOnly(bool readOnly) |
|
163 | void QHexEdit::setReadOnly(bool readOnly) | |
164 | { |
|
164 | { | |
165 | qHexEdit_p->setReadOnly(readOnly); |
|
165 | qHexEdit_p->setReadOnly(readOnly); | |
166 | } |
|
166 | } | |
167 |
|
167 | |||
168 | bool QHexEdit::isReadOnly() |
|
168 | bool QHexEdit::isReadOnly() | |
169 | { |
|
169 | { | |
170 | return qHexEdit_p->isReadOnly(); |
|
170 | return qHexEdit_p->isReadOnly(); | |
171 | } |
|
171 | } | |
172 |
|
172 | |||
173 | void QHexEdit::setFont(const QFont &font) |
|
173 | void QHexEdit::setFont(const QFont &font) | |
174 | { |
|
174 | { | |
175 | qHexEdit_p->setFont(font); |
|
175 | qHexEdit_p->setFont(font); | |
176 | } |
|
176 | } | |
177 |
|
177 | |||
178 | void QHexEdit::resetSelection(int pos) |
|
178 | void QHexEdit::resetSelection(int pos) | |
179 | { |
|
179 | { | |
180 | qHexEdit_p->resetSelection(pos); |
|
180 | qHexEdit_p->resetSelection(pos); | |
181 | } |
|
181 | } | |
182 |
|
182 | |||
183 | void QHexEdit::resetSelection() |
|
183 | void QHexEdit::resetSelection() | |
184 | { |
|
184 | { | |
185 | qHexEdit_p->resetSelection(); |
|
185 | qHexEdit_p->resetSelection(); | |
186 | } |
|
186 | } | |
187 |
|
187 | |||
188 | void QHexEdit::setSelection(int pos) |
|
188 | void QHexEdit::setSelection(int pos) | |
189 | { |
|
189 | { | |
190 | qHexEdit_p->setSelection(pos); |
|
190 | qHexEdit_p->setSelection(pos); | |
191 | } |
|
191 | } | |
192 |
|
192 | |||
193 | int QHexEdit::getSelectionBegin() |
|
193 | int QHexEdit::getSelectionBegin() | |
194 | { |
|
194 | { | |
195 | return qHexEdit_p->getSelectionBegin(); |
|
195 | return qHexEdit_p->getSelectionBegin(); | |
196 | } |
|
196 | } | |
197 |
|
197 | |||
198 | int QHexEdit::getSelectionEnd() |
|
198 | int QHexEdit::getSelectionEnd() | |
199 | { |
|
199 | { | |
200 | return qHexEdit_p->getSelectionEnd(); |
|
200 | return qHexEdit_p->getSelectionEnd(); | |
201 | } |
|
201 | } | |
202 |
|
202 | |||
203 | const QFont & QHexEdit::font() const |
|
203 | const QFont & QHexEdit::font() const | |
204 | { |
|
204 | { | |
205 | return qHexEdit_p->font(); |
|
205 | return qHexEdit_p->font(); | |
206 | } |
|
206 | } |
General Comments 0
You need to be logged in to leave comments.
Login now