summaryrefslogtreecommitdiff
path: root/externals/qhexedit/qhexedit.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--externals/qhexedit/qhexedit.h240
1 files changed, 0 insertions, 240 deletions
diff --git a/externals/qhexedit/qhexedit.h b/externals/qhexedit/qhexedit.h
deleted file mode 100644
index 15b6d7603..000000000
--- a/externals/qhexedit/qhexedit.h
+++ /dev/null
@@ -1,240 +0,0 @@
1// Original author: Winfried Simon
2// See http://code.google.com/p/qhexedit2/
3// Huge thanks!
4
5#ifndef QHEXEDIT_H
6#define QHEXEDIT_H
7
8#include <QtGui>
9#include "qhexedit_p.h"
10
11/** \mainpage
12QHexEdit is a binary editor widget for Qt.
13
14\version Version 0.6.3
15\image html hexedit.png
16*/
17
18
19/*! QHexEdit is a hex editor widget written in C++ for the Qt (Qt4) framework.
20It is a simple editor for binary data, just like QPlainTextEdit is for text
21data. There are sip configuration files included, so it is easy to create
22bindings for PyQt and you can use this widget also in python.
23
24QHexEdit takes the data of a QByteArray (setData()) and shows it. You can use
25the mouse or the keyboard to navigate inside the widget. If you hit the keys
26(0..9, a..f) you will change the data. Changed data is highlighted and can be
27accessed via data().
28
29Normaly QHexEdit works in the overwrite Mode. You can set overwriteMode(false)
30and insert data. In this case the size of data() increases. It is also possible
31to delete bytes (del or backspace), here the size of data decreases.
32
33You can select data with keyboard hits or mouse movements. The copy-key will
34copy the selected data into the clipboard. The cut-key copies also but delets
35it afterwards. In overwrite mode, the paste function overwrites the content of
36the (does not change the length) data. In insert mode, clipboard data will be
37inserted. The clipboard content is expected in ASCII Hex notation. Unknown
38characters will be ignored.
39
40QHexEdit comes with undo/redo functionality. All changes can be undone, by
41pressing the undo-key (usually ctr-z). They can also be redone afterwards.
42The undo/redo framework is cleared, when setData() sets up a new
43content for the editor. You can search data inside the content with indexOf()
44and lastIndexOf(). The replace() function is to change located subdata. This
45'replaced' data can also be undone by the undo/redo framework.
46
47This widget can only handle small amounts of data. The size has to be below 10
48megabytes, otherwise the scroll sliders ard not shown and you can't scroll any
49more.
50*/
51 class QHexEdit : public QScrollArea
52{
53 Q_OBJECT
54 /*! Property data holds the content of QHexEdit. Call setData() to set the
55 content of QHexEdit, data() returns the actual content.
56 */
57 Q_PROPERTY(QByteArray data READ data WRITE setData)
58
59 /*! Property addressOffset is added to the Numbers of the Address Area.
60 A offset in the address area (left side) is sometimes usefull, whe you show
61 only a segment of a complete memory picture. With setAddressOffset() you set
62 this property - with addressOffset() you get the actual value.
63 */
64 Q_PROPERTY(int addressOffset READ addressOffset WRITE setAddressOffset)
65
66 /*! Property address area color sets (setAddressAreaColor()) the backgorund
67 color of address areas. You can also read the color (addressaAreaColor()).
68 */
69 Q_PROPERTY(QColor addressAreaColor READ addressAreaColor WRITE setAddressAreaColor)
70
71 /*! Porperty cursorPosition sets or gets the position of the editor cursor
72 in QHexEdit.
73 */
74 Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition)
75
76 /*! Property highlighting color sets (setHighlightingColor()) the backgorund
77 color of highlighted text areas. You can also read the color
78 (highlightingColor()).
79 */
80 Q_PROPERTY(QColor highlightingColor READ highlightingColor WRITE setHighlightingColor)
81
82 /*! Property selection color sets (setSelectionColor()) the backgorund
83 color of selected text areas. You can also read the color
84 (selectionColor()).
85 */
86 Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor)
87
88 /*! Porperty overwrite mode sets (setOverwriteMode()) or gets (overwriteMode()) the mode
89 in which the editor works. In overwrite mode the user will overwrite existing data. The
90 size of data will be constant. In insert mode the size will grow, when inserting
91 new data.
92 */
93 Q_PROPERTY(bool overwriteMode READ overwriteMode WRITE setOverwriteMode)
94
95 /*! Porperty readOnly sets (setReadOnly()) or gets (isReadOnly) the mode
96 in which the editor works. In readonly mode the the user can only navigate
97 through the data and select data; modifying is not possible. This
98 property's default is false.
99 */
100 Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
101
102 /*! Set the font of the widget. Please use fixed width fonts like Mono or Courier.*/
103 Q_PROPERTY(QFont font READ font WRITE setFont)
104
105
106public:
107 /*! Creates an instance of QHexEdit.
108 \param parent Parent widget of QHexEdit.
109 */
110 QHexEdit(QWidget *parent = 0);
111
112 /*! Returns the index position of the first occurrence
113 of the byte array ba in this byte array, searching forward from index position
114 from. Returns -1 if ba could not be found. In addition to this functionality
115 of QByteArray the cursorposition is set to the end of found bytearray and
116 it will be selected.
117
118 */
119 int indexOf(const QByteArray & ba, int from = 0) const;
120
121 /*! Inserts a byte array.
122 \param i Index position, where to insert
123 \param ba byte array, which is to insert
124 In overwrite mode, the existing data will be overwritten, in insertmode ba will be
125 inserted and size of data grows.
126 */
127 void insert(int i, const QByteArray & ba);
128
129 /*! Inserts a char.
130 \param i Index position, where to insert
131 \param ch Char, which is to insert
132 In overwrite mode, the existing data will be overwritten, in insertmode ba will be
133 inserted and size of data grows.
134 */
135 void insert(int i, char ch);
136
137 /*! Returns the index position of the last occurrence
138 of the byte array ba in this byte array, searching backwards from index position
139 from. Returns -1 if ba could not be found. In addition to this functionality
140 of QByteArray the cursorposition is set to the beginning of found bytearray and
141 it will be selected.
142
143 */
144 int lastIndexOf(const QByteArray & ba, int from = 0) const;
145
146 /*! Removes len bytes from the content.
147 \param pos Index position, where to remove
148 \param len Amount of bytes to remove
149 In overwrite mode, the existing bytes will be overwriten with 0x00.
150 */
151 void remove(int pos, int len=1);
152
153 /*! Replaces len bytes from index position pos with the byte array after.
154 */
155 void replace( int pos, int len, const QByteArray & after);
156
157 /*! Gives back a formatted image of the content of QHexEdit
158 */
159 QString toReadableString();
160
161 /*! Gives back a formatted image of the selected content of QHexEdit
162 */
163 QString selectionToReadableString();
164
165 /*! \cond docNever */
166 void setAddressOffset(int offset);
167 int addressOffset();
168 void setCursorPosition(int cusorPos);
169 int cursorPosition();
170 void setData(QByteArray const &data);
171 QByteArray data();
172 void setAddressAreaColor(QColor const &color);
173 QColor addressAreaColor();
174 void setHighlightingColor(QColor const &color);
175 QColor highlightingColor();
176 void setSelectionColor(QColor const &color);
177 QColor selectionColor();
178 void setOverwriteMode(bool);
179 bool overwriteMode();
180 void setReadOnly(bool);
181 bool isReadOnly();
182 const QFont &font() const;
183 void setFont(const QFont &);
184 /*! \endcond docNever */
185
186public slots:
187 /*! Redoes the last operation. If there is no operation to redo, i.e.
188 there is no redo step in the undo/redo history, nothing happens.
189 */
190 void redo();
191
192 /*! Set the minimum width of the address area.
193 \param addressWidth Width in characters.
194 */
195 void setAddressWidth(int addressWidth);
196
197 /*! Switch the address area on or off.
198 \param addressArea true (show it), false (hide it).
199 */
200 void setAddressArea(bool addressArea);
201
202 /*! Switch the ascii area on or off.
203 \param asciiArea true (show it), false (hide it).
204 */
205 void setAsciiArea(bool asciiArea);
206
207 /*! Switch the highlighting feature on or of.
208 \param mode true (show it), false (hide it).
209 */
210 void setHighlighting(bool mode);
211
212 /*! Undoes the last operation. If there is no operation to undo, i.e.
213 there is no undo step in the undo/redo history, nothing happens.
214 */
215 void undo();
216
217signals:
218
219 /*! Contains the address, where the cursor is located. */
220 void currentAddressChanged(int address);
221
222 /*! Contains the size of the data to edit. */
223 void currentSizeChanged(int size);
224
225 /*! The signal is emited every time, the data is changed. */
226 void dataChanged();
227
228 /*! The signal is emited every time, the overwrite mode is changed. */
229 void overwriteModeChanged(bool state);
230
231private:
232 /*! \cond docNever */
233 QHexEditPrivate *qHexEdit_p;
234 QHBoxLayout *layout;
235 QScrollArea *scrollArea;
236 /*! \endcond docNever */
237};
238
239#endif
240