qhexedit2/0000700000175000017500000000000014212406715012623 5ustar carstencarstenqhexedit2/src/0000700000175000017500000000000013716244704013420 5ustar carstencarstenqhexedit2/src/QHexEditPlugin.h0000644000175000017500000000164213716244704016440 0ustar carstencarsten#ifndef QHEXEDITPLUGIN_H #define QHEXEDITPLUGIN_H #include #if QT_VERSION < QT_VERSION_CHECK(5,0,0) #include #else #include #endif class QHexEditPlugin : public QObject, public QDesignerCustomWidgetInterface { Q_OBJECT Q_INTERFACES(QDesignerCustomWidgetInterface) #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) Q_PLUGIN_METADATA(IID "com.qt-project.Qt.QHexEditPlugin") #endif public: QHexEditPlugin(QObject * parent = 0); bool isContainer() const; bool isInitialized() const; QIcon icon() const; QString domXml() const; QString group() const; QString includeFile() const; QString name() const; QString toolTip() const; QString whatsThis() const; QWidget *createWidget(QWidget *parent); void initialize(QDesignerFormEditorInterface *core); private: bool initialized; }; #endif qhexedit2/src/commands.cpp0000644000175000017500000001007713716244704015744 0ustar carstencarsten#include "commands.h" #include // Helper class to store single byte commands class CharCommand : public QUndoCommand { public: enum CCmd {insert, removeAt, overwrite}; CharCommand(Chunks * chunks, CCmd cmd, qint64 charPos, char newChar, QUndoCommand *parent=0); void undo(); void redo(); bool mergeWith(const QUndoCommand *command); int id() const { return 1234; } private: Chunks * _chunks; qint64 _charPos; bool _wasChanged; char _newChar; char _oldChar; CCmd _cmd; }; CharCommand::CharCommand(Chunks * chunks, CCmd cmd, qint64 charPos, char newChar, QUndoCommand *parent) : QUndoCommand(parent) { _chunks = chunks; _charPos = charPos; _newChar = newChar; _cmd = cmd; } bool CharCommand::mergeWith(const QUndoCommand *command) { const CharCommand *nextCommand = static_cast(command); bool result = false; if (_cmd != CharCommand::removeAt) { if (nextCommand->_cmd == overwrite) if (nextCommand->_charPos == _charPos) { _newChar = nextCommand->_newChar; result = true; } } return result; } void CharCommand::undo() { switch (_cmd) { case insert: _chunks->removeAt(_charPos); break; case overwrite: _chunks->overwrite(_charPos, _oldChar); _chunks->setDataChanged(_charPos, _wasChanged); break; case removeAt: _chunks->insert(_charPos, _oldChar); _chunks->setDataChanged(_charPos, _wasChanged); break; } } void CharCommand::redo() { switch (_cmd) { case insert: _chunks->insert(_charPos, _newChar); break; case overwrite: _oldChar = (*_chunks)[_charPos]; _wasChanged = _chunks->dataChanged(_charPos); _chunks->overwrite(_charPos, _newChar); break; case removeAt: _oldChar = (*_chunks)[_charPos]; _wasChanged = _chunks->dataChanged(_charPos); _chunks->removeAt(_charPos); break; } } UndoStack::UndoStack(Chunks * chunks, QObject * parent) : QUndoStack(parent) { _chunks = chunks; _parent = parent; this->setUndoLimit(1000); } void UndoStack::insert(qint64 pos, char c) { if ((pos >= 0) && (pos <= _chunks->size())) { QUndoCommand *cc = new CharCommand(_chunks, CharCommand::insert, pos, c); this->push(cc); } } void UndoStack::insert(qint64 pos, const QByteArray &ba) { if ((pos >= 0) && (pos <= _chunks->size())) { QString txt = QString(tr("Inserting %1 bytes")).arg(ba.size()); beginMacro(txt); for (int idx=0; idx < ba.size(); idx++) { QUndoCommand *cc = new CharCommand(_chunks, CharCommand::insert, pos + idx, ba.at(idx)); this->push(cc); } endMacro(); } } void UndoStack::removeAt(qint64 pos, qint64 len) { if ((pos >= 0) && (pos < _chunks->size())) { if (len==1) { QUndoCommand *cc = new CharCommand(_chunks, CharCommand::removeAt, pos, char(0)); this->push(cc); } else { QString txt = QString(tr("Delete %1 chars")).arg(len); beginMacro(txt); for (qint64 cnt=0; cnt= 0) && (pos < _chunks->size())) { QUndoCommand *cc = new CharCommand(_chunks, CharCommand::overwrite, pos, c); this->push(cc); } } void UndoStack::overwrite(qint64 pos, int len, const QByteArray &ba) { if ((pos >= 0) && (pos < _chunks->size())) { QString txt = QString(tr("Overwrite %1 chars")).arg(len); beginMacro(txt); removeAt(pos, len); insert(pos, ba); endMacro(); } } qhexedit2/src/commands.h0000644000175000017500000000263313716244704015410 0ustar carstencarsten#ifndef COMMANDS_H #define COMMANDS_H /** \cond docNever */ #include #include "chunks.h" /*! CharCommand is a class to provid undo/redo functionality in QHexEdit. A QUndoCommand represents a single editing action on a document. CharCommand is responsable for manipulations on single chars. It can insert. overwrite and remove characters. A manipulation stores allways two actions 1. redo (or do) action 2. undo action. CharCommand also supports command compression via mergeWidht(). This enables the user to perform an undo command e.g. 3 steps in a single command. If you for example insert a new byt "34" this means for the editor doing 3 steps: insert a "00", overwrite it with "03" and the overwrite it with "34". These 3 steps are combined into a single step, insert a "34". The byte array oriented commands are just put into a set of single byte commands, which are pooled together with the macroBegin() and macroEnd() functionality of Qt's QUndoStack. */ class UndoStack : public QUndoStack { Q_OBJECT public: UndoStack(Chunks *chunks, QObject * parent=0); void insert(qint64 pos, char c); void insert(qint64 pos, const QByteArray &ba); void removeAt(qint64 pos, qint64 len=1); void overwrite(qint64 pos, char c); void overwrite(qint64 pos, int len, const QByteArray &ba); private: Chunks * _chunks; QObject * _parent; }; /** \endcond docNever */ #endif // COMMANDS_H qhexedit2/src/qhexedit.cpp0000644000175000017500000010427113716244704015756 0ustar carstencarsten#include #include #include #include #include #include "qhexedit.h" #include // ********************************************************************** Constructor, destructor QHexEdit::QHexEdit(QWidget *parent) : QAbstractScrollArea(parent) { _addressArea = true; _addressWidth = 4; _asciiArea = true; _overwriteMode = true; _highlighting = true; _readOnly = false; _cursorPosition = 0; _lastEventSize = 0; _hexCharsInLine = 47; _bytesPerLine = 16; _editAreaIsAscii = false; _hexCaps = false; _dynamicBytesPerLine = false; _chunks = new Chunks(this); _undoStack = new UndoStack(_chunks, this); #ifdef Q_OS_WIN32 setFont(QFont("Courier", 10)); #else setFont(QFont("Monospace", 10)); #endif setAddressAreaColor(this->palette().alternateBase().color()); setAddressFontColor(QPalette::WindowText); setAsciiAreaColor(this->palette().alternateBase().color()); setAsciiFontColor(QPalette::WindowText); setHighlightingColor(QColor(0xff, 0xff, 0x99, 0xff)); setSelectionColor(this->palette().highlight().color()); connect(&_cursorTimer, SIGNAL(timeout()), this, SLOT(updateCursor())); connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(adjust())); connect(horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(adjust())); connect(_undoStack, SIGNAL(indexChanged(int)), this, SLOT(dataChangedPrivate(int))); _cursorTimer.setInterval(500); _cursorTimer.start(); setAddressWidth(4); setAddressArea(true); setAsciiArea(true); setOverwriteMode(true); setHighlighting(true); setReadOnly(false); init(); } QHexEdit::~QHexEdit() { } // ********************************************************************** Properties void QHexEdit::setAddressArea(bool addressArea) { _addressArea = addressArea; adjust(); setCursorPosition(_cursorPosition); viewport()->update(); } bool QHexEdit::addressArea() { return _addressArea; } QColor QHexEdit::addressAreaColor() { return _addressAreaColor; } void QHexEdit::setAddressAreaColor(const QColor &color) { _addressAreaColor = color; viewport()->update(); } QColor QHexEdit::addressFontColor() { return _addressFontColor; } void QHexEdit::setAddressFontColor(const QColor &color) { _addressFontColor = color; viewport()->update(); } QColor QHexEdit::asciiAreaColor() { return _asciiAreaColor; } void QHexEdit::setAsciiAreaColor(const QColor &color) { _asciiAreaColor = color; viewport()->update(); } QColor QHexEdit::asciiFontColor() { return _asciiFontColor; } void QHexEdit::setAsciiFontColor(const QColor &color) { _asciiFontColor = color; viewport()->update(); } QColor QHexEdit::hexFontColor() { return _hexFontColor; } void QHexEdit::setHexFontColor(const QColor &color) { _hexFontColor = color; viewport()->update(); } void QHexEdit::setAddressOffset(qint64 addressOffset) { _addressOffset = addressOffset; adjust(); setCursorPosition(_cursorPosition); viewport()->update(); } qint64 QHexEdit::addressOffset() { return _addressOffset; } void QHexEdit::setAddressWidth(int addressWidth) { _addressWidth = addressWidth; adjust(); setCursorPosition(_cursorPosition); viewport()->update(); } int QHexEdit::addressWidth() { qint64 size = _chunks->size(); int n = 1; if (size > Q_INT64_C(0x100000000)){ n += 8; size /= Q_INT64_C(0x100000000);} if (size > 0x10000){ n += 4; size /= 0x10000;} if (size > 0x100){ n += 2; size /= 0x100;} if (size > 0x10){ n += 1;} if (n > _addressWidth) return n; else return _addressWidth; } void QHexEdit::setAsciiArea(bool asciiArea) { if (!asciiArea) _editAreaIsAscii = false; _asciiArea = asciiArea; adjust(); setCursorPosition(_cursorPosition); viewport()->update(); } bool QHexEdit::asciiArea() { return _asciiArea; } void QHexEdit::setBytesPerLine(int count) { _bytesPerLine = count; _hexCharsInLine = count * 3 - 1; adjust(); setCursorPosition(_cursorPosition); viewport()->update(); } int QHexEdit::bytesPerLine() { return _bytesPerLine; } void QHexEdit::setCursorPosition(qint64 position) { // 1. delete old cursor _blink = false; viewport()->update(_cursorRect); // 2. Check, if cursor in range? if (position > (_chunks->size() * 2 - 1)) position = _chunks->size() * 2 - (_overwriteMode ? 1 : 0); if (position < 0) position = 0; // 3. Calc new position of cursor _bPosCurrent = position / 2; _pxCursorY = ((position / 2 - _bPosFirst) / _bytesPerLine + 1) * _pxCharHeight; int x = (position % (2 * _bytesPerLine)); if (_editAreaIsAscii) { _pxCursorX = x / 2 * _pxCharWidth + _pxPosAsciiX; _cursorPosition = position & 0xFFFFFFFFFFFFFFFE; } else { _pxCursorX = (((x / 2) * 3) + (x % 2)) * _pxCharWidth + _pxPosHexX; _cursorPosition = position; } if (_overwriteMode) _cursorRect = QRect(_pxCursorX - horizontalScrollBar()->value(), _pxCursorY + _pxCursorWidth, _pxCharWidth, _pxCursorWidth); else _cursorRect = QRect(_pxCursorX - horizontalScrollBar()->value(), _pxCursorY - _pxCharHeight + 4, _pxCursorWidth, _pxCharHeight); // 4. Immediately draw new cursor _blink = true; viewport()->update(_cursorRect); emit currentAddressChanged(_bPosCurrent); } qint64 QHexEdit::cursorPosition(QPoint pos) { // Calc cursor position depending on a graphical position qint64 result = -1; int posX = pos.x() + horizontalScrollBar()->value(); int posY = pos.y() - 3; if ((posX >= _pxPosHexX) && (posX < (_pxPosHexX + (1 + _hexCharsInLine) * _pxCharWidth))) { _editAreaIsAscii = false; int x = (posX - _pxPosHexX) / _pxCharWidth; x = (x / 3) * 2 + x % 3; int y = (posY / _pxCharHeight) * 2 * _bytesPerLine; result = _bPosFirst * 2 + x + y; } else if (_asciiArea && (posX >= _pxPosAsciiX) && (posX < (_pxPosAsciiX + (1 + _bytesPerLine) * _pxCharWidth))) { _editAreaIsAscii = true; int x = 2 * (posX - _pxPosAsciiX) / _pxCharWidth; int y = (posY / _pxCharHeight) * 2 * _bytesPerLine; result = _bPosFirst * 2 + x + y; } return result; } qint64 QHexEdit::cursorPosition() { return _cursorPosition; } void QHexEdit::setData(const QByteArray &ba) { _data = ba; _bData.setData(_data); setData(_bData); } QByteArray QHexEdit::data() { return _chunks->data(0, -1); } void QHexEdit::setHighlighting(bool highlighting) { _highlighting = highlighting; viewport()->update(); } bool QHexEdit::highlighting() { return _highlighting; } void QHexEdit::setHighlightingColor(const QColor &color) { _brushHighlighted = QBrush(color); _penHighlighted = QPen(viewport()->palette().color(QPalette::WindowText)); viewport()->update(); } QColor QHexEdit::highlightingColor() { return _brushHighlighted.color(); } void QHexEdit::setOverwriteMode(bool overwriteMode) { _overwriteMode = overwriteMode; emit overwriteModeChanged(overwriteMode); } bool QHexEdit::overwriteMode() { return _overwriteMode; } void QHexEdit::setSelectionColor(const QColor &color) { _brushSelection = QBrush(color); _penSelection = QPen(Qt::white); viewport()->update(); } QColor QHexEdit::selectionColor() { return _brushSelection.color(); } bool QHexEdit::isReadOnly() { return _readOnly; } void QHexEdit::setReadOnly(bool readOnly) { _readOnly = readOnly; } void QHexEdit::setHexCaps(const bool isCaps) { if (_hexCaps != isCaps) { _hexCaps = isCaps; viewport()->update(); } } bool QHexEdit::hexCaps() { return _hexCaps; } void QHexEdit::setDynamicBytesPerLine(const bool isDynamic) { _dynamicBytesPerLine = isDynamic; resizeEvent(NULL); } bool QHexEdit::dynamicBytesPerLine() { return _dynamicBytesPerLine; } // ********************************************************************** Access to data of qhexedit bool QHexEdit::setData(QIODevice &iODevice) { bool ok = _chunks->setIODevice(iODevice); init(); dataChangedPrivate(); return ok; } QByteArray QHexEdit::dataAt(qint64 pos, qint64 count) { return _chunks->data(pos, count); } bool QHexEdit::write(QIODevice &iODevice, qint64 pos, qint64 count) { return _chunks->write(iODevice, pos, count); } // ********************************************************************** Char handling void QHexEdit::insert(qint64 index, char ch) { _undoStack->insert(index, ch); refresh(); } void QHexEdit::remove(qint64 index, qint64 len) { _undoStack->removeAt(index, len); refresh(); } void QHexEdit::replace(qint64 index, char ch) { _undoStack->overwrite(index, ch); refresh(); } // ********************************************************************** ByteArray handling void QHexEdit::insert(qint64 pos, const QByteArray &ba) { _undoStack->insert(pos, ba); refresh(); } void QHexEdit::replace(qint64 pos, qint64 len, const QByteArray &ba) { _undoStack->overwrite(pos, len, ba); refresh(); } // ********************************************************************** Utility functions void QHexEdit::ensureVisible() { if (_cursorPosition < (_bPosFirst * 2)) verticalScrollBar()->setValue((int)(_cursorPosition / 2 / _bytesPerLine)); if (_cursorPosition > ((_bPosFirst + (_rowsShown - 1)*_bytesPerLine) * 2)) verticalScrollBar()->setValue((int)(_cursorPosition / 2 / _bytesPerLine) - _rowsShown + 1); if (_pxCursorX < horizontalScrollBar()->value()) horizontalScrollBar()->setValue(_pxCursorX); if ((_pxCursorX + _pxCharWidth) > (horizontalScrollBar()->value() + viewport()->width())) horizontalScrollBar()->setValue(_pxCursorX + _pxCharWidth - viewport()->width()); viewport()->update(); } qint64 QHexEdit::indexOf(const QByteArray &ba, qint64 from) { qint64 pos = _chunks->indexOf(ba, from); if (pos > -1) { qint64 curPos = pos*2; setCursorPosition(curPos + ba.length()*2); resetSelection(curPos); setSelection(curPos + ba.length()*2); ensureVisible(); } return pos; } bool QHexEdit::isModified() { return _modified; } qint64 QHexEdit::lastIndexOf(const QByteArray &ba, qint64 from) { qint64 pos = _chunks->lastIndexOf(ba, from); if (pos > -1) { qint64 curPos = pos*2; setCursorPosition(curPos - 1); resetSelection(curPos); setSelection(curPos + ba.length()*2); ensureVisible(); } return pos; } void QHexEdit::redo() { _undoStack->redo(); setCursorPosition(_chunks->pos()*(_editAreaIsAscii ? 1 : 2)); refresh(); } QString QHexEdit::selectionToReadableString() { QByteArray ba = _chunks->data(getSelectionBegin(), getSelectionEnd() - getSelectionBegin()); return toReadable(ba); } QString QHexEdit::selectedData() { QByteArray ba = _chunks->data(getSelectionBegin(), getSelectionEnd() - getSelectionBegin()).toHex(); return ba; } void QHexEdit::setFont(const QFont &font) { QFont theFont(font); theFont.setStyleHint(QFont::Monospace); QWidget::setFont(theFont); QFontMetrics metrics = fontMetrics(); #if QT_VERSION > QT_VERSION_CHECK(5, 11, 0) _pxCharWidth = metrics.horizontalAdvance(QLatin1Char('2')); #else _pxCharWidth = metrics.width(QLatin1Char('2')); #endif _pxCharHeight = metrics.height(); _pxGapAdr = _pxCharWidth / 2; _pxGapAdrHex = _pxCharWidth; _pxGapHexAscii = 2 * _pxCharWidth; _pxCursorWidth = _pxCharHeight / 7; _pxSelectionSub = _pxCharHeight / 5; viewport()->update(); } QString QHexEdit::toReadableString() { QByteArray ba = _chunks->data(); return toReadable(ba); } void QHexEdit::undo() { _undoStack->undo(); setCursorPosition(_chunks->pos()*(_editAreaIsAscii ? 1 : 2)); refresh(); } // ********************************************************************** Handle events void QHexEdit::keyPressEvent(QKeyEvent *event) { // Cursor movements if (event->matches(QKeySequence::MoveToNextChar)) { qint64 pos = _cursorPosition + 1; if (_editAreaIsAscii) pos += 1; setCursorPosition(pos); resetSelection(pos); } if (event->matches(QKeySequence::MoveToPreviousChar)) { qint64 pos = _cursorPosition - 1; if (_editAreaIsAscii) pos -= 1; setCursorPosition(pos); resetSelection(pos); } if (event->matches(QKeySequence::MoveToEndOfLine)) { qint64 pos = _cursorPosition - (_cursorPosition % (2 * _bytesPerLine)) + (2 * _bytesPerLine) - 1; setCursorPosition(pos); resetSelection(_cursorPosition); } if (event->matches(QKeySequence::MoveToStartOfLine)) { qint64 pos = _cursorPosition - (_cursorPosition % (2 * _bytesPerLine)); setCursorPosition(pos); resetSelection(_cursorPosition); } if (event->matches(QKeySequence::MoveToPreviousLine)) { setCursorPosition(_cursorPosition - (2 * _bytesPerLine)); resetSelection(_cursorPosition); } if (event->matches(QKeySequence::MoveToNextLine)) { setCursorPosition(_cursorPosition + (2 * _bytesPerLine)); resetSelection(_cursorPosition); } if (event->matches(QKeySequence::MoveToNextPage)) { setCursorPosition(_cursorPosition + (((_rowsShown - 1) * 2 * _bytesPerLine))); resetSelection(_cursorPosition); } if (event->matches(QKeySequence::MoveToPreviousPage)) { setCursorPosition(_cursorPosition - (((_rowsShown - 1) * 2 * _bytesPerLine))); resetSelection(_cursorPosition); } if (event->matches(QKeySequence::MoveToEndOfDocument)) { setCursorPosition(_chunks->size() * 2 ); resetSelection(_cursorPosition); } if (event->matches(QKeySequence::MoveToStartOfDocument)) { setCursorPosition(0); resetSelection(_cursorPosition); } // Select commands if (event->matches(QKeySequence::SelectAll)) { resetSelection(0); setSelection(2 * _chunks->size() + 1); } if (event->matches(QKeySequence::SelectNextChar)) { qint64 pos = _cursorPosition + 1; if (_editAreaIsAscii) pos += 1; setCursorPosition(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectPreviousChar)) { qint64 pos = _cursorPosition - 1; if (_editAreaIsAscii) pos -= 1; setSelection(pos); setCursorPosition(pos); } if (event->matches(QKeySequence::SelectEndOfLine)) { qint64 pos = _cursorPosition - (_cursorPosition % (2 * _bytesPerLine)) + (2 * _bytesPerLine) - 1; setCursorPosition(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectStartOfLine)) { qint64 pos = _cursorPosition - (_cursorPosition % (2 * _bytesPerLine)); setCursorPosition(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectPreviousLine)) { qint64 pos = _cursorPosition - (2 * _bytesPerLine); setCursorPosition(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectNextLine)) { qint64 pos = _cursorPosition + (2 * _bytesPerLine); setCursorPosition(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectNextPage)) { qint64 pos = _cursorPosition + (((viewport()->height() / _pxCharHeight) - 1) * 2 * _bytesPerLine); setCursorPosition(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectPreviousPage)) { qint64 pos = _cursorPosition - (((viewport()->height() / _pxCharHeight) - 1) * 2 * _bytesPerLine); setCursorPosition(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectEndOfDocument)) { qint64 pos = _chunks->size() * 2; setCursorPosition(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectStartOfDocument)) { qint64 pos = 0; setCursorPosition(pos); setSelection(pos); } // Edit Commands if (!_readOnly) { /* Cut */ if (event->matches(QKeySequence::Cut)) { QByteArray ba = _chunks->data(getSelectionBegin(), getSelectionEnd() - getSelectionBegin()).toHex(); for (qint64 idx = 32; idx < ba.size(); idx +=33) ba.insert(idx, "\n"); QClipboard *clipboard = QApplication::clipboard(); clipboard->setText(ba); if (_overwriteMode) { qint64 len = getSelectionEnd() - getSelectionBegin(); replace(getSelectionBegin(), (int)len, QByteArray((int)len, char(0))); } else { remove(getSelectionBegin(), getSelectionEnd() - getSelectionBegin()); } setCursorPosition(2 * getSelectionBegin()); resetSelection(2 * getSelectionBegin()); } else /* Paste */ if (event->matches(QKeySequence::Paste)) { QClipboard *clipboard = QApplication::clipboard(); QByteArray ba = QByteArray().fromHex(clipboard->text().toLatin1()); if (_overwriteMode) { ba = ba.left(std::min(ba.size(), (_chunks->size() - _bPosCurrent))); replace(_bPosCurrent, ba.size(), ba); } else insert(_bPosCurrent, ba); setCursorPosition(_cursorPosition + 2 * ba.size()); resetSelection(getSelectionBegin()); } else /* Delete char */ if (event->matches(QKeySequence::Delete)) { if (getSelectionBegin() != getSelectionEnd()) { _bPosCurrent = getSelectionBegin(); if (_overwriteMode) { QByteArray ba = QByteArray(getSelectionEnd() - getSelectionBegin(), char(0)); replace(_bPosCurrent, ba.size(), ba); } else { remove(_bPosCurrent, getSelectionEnd() - getSelectionBegin()); } } else { if (_overwriteMode) replace(_bPosCurrent, char(0)); else remove(_bPosCurrent, 1); } setCursorPosition(2 * _bPosCurrent); resetSelection(2 * _bPosCurrent); } else /* Backspace */ if ((event->key() == Qt::Key_Backspace) && (event->modifiers() == Qt::NoModifier)) { if (getSelectionBegin() != getSelectionEnd()) { _bPosCurrent = getSelectionBegin(); setCursorPosition(2 * _bPosCurrent); if (_overwriteMode) { QByteArray ba = QByteArray(getSelectionEnd() - getSelectionBegin(), char(0)); replace(_bPosCurrent, ba.size(), ba); } else { remove(_bPosCurrent, getSelectionEnd() - getSelectionBegin()); } resetSelection(2 * _bPosCurrent); } else { bool behindLastByte = false; if ((_cursorPosition / 2) == _chunks->size()) behindLastByte = true; _bPosCurrent -= 1; if (_overwriteMode) replace(_bPosCurrent, char(0)); else remove(_bPosCurrent, 1); if (!behindLastByte) _bPosCurrent -= 1; setCursorPosition(2 * _bPosCurrent); resetSelection(2 * _bPosCurrent); } } else /* undo */ if (event->matches(QKeySequence::Undo)) { undo(); } else /* redo */ if (event->matches(QKeySequence::Redo)) { redo(); } else if ((QApplication::keyboardModifiers() == Qt::NoModifier) || (QApplication::keyboardModifiers() == Qt::KeypadModifier) || (QApplication::keyboardModifiers() == Qt::ShiftModifier) || (QApplication::keyboardModifiers() == (Qt::AltModifier | Qt::ControlModifier)) || (QApplication::keyboardModifiers() == Qt::GroupSwitchModifier)) { /* Hex and ascii input */ int key; if (_editAreaIsAscii) key = (uchar)event->text()[0].toLatin1(); else key = int(event->text()[0].toLower().toLatin1()); if ((((key >= '0' && key <= '9') || (key >= 'a' && key <= 'f')) && _editAreaIsAscii == false) || (key >= ' ' && _editAreaIsAscii)) { if (getSelectionBegin() != getSelectionEnd()) { if (_overwriteMode) { qint64 len = getSelectionEnd() - getSelectionBegin(); replace(getSelectionBegin(), (int)len, QByteArray((int)len, char(0))); } else { remove(getSelectionBegin(), getSelectionEnd() - getSelectionBegin()); _bPosCurrent = getSelectionBegin(); } setCursorPosition(2 * _bPosCurrent); resetSelection(2 * _bPosCurrent); } // If insert mode, then insert a byte if (_overwriteMode == false) if ((_cursorPosition % 2) == 0) insert(_bPosCurrent, char(0)); // Change content if (_chunks->size() > 0) { char ch = key; if (!_editAreaIsAscii){ QByteArray hexValue = _chunks->data(_bPosCurrent, 1).toHex(); if ((_cursorPosition % 2) == 0) hexValue[0] = key; else hexValue[1] = key; ch = QByteArray().fromHex(hexValue)[0]; } replace(_bPosCurrent, ch); if (_editAreaIsAscii) setCursorPosition(_cursorPosition + 2); else setCursorPosition(_cursorPosition + 1); resetSelection(_cursorPosition); } } } } /* Copy */ if (event->matches(QKeySequence::Copy)) { QByteArray ba = _chunks->data(getSelectionBegin(), getSelectionEnd() - getSelectionBegin()).toHex(); for (qint64 idx = 32; idx < ba.size(); idx +=33) ba.insert(idx, "\n"); QClipboard *clipboard = QApplication::clipboard(); clipboard->setText(ba); } // Switch between insert/overwrite mode if ((event->key() == Qt::Key_Insert) && (event->modifiers() == Qt::NoModifier)) { setOverwriteMode(!overwriteMode()); setCursorPosition(_cursorPosition); } // switch from hex to ascii edit if (event->key() == Qt::Key_Tab && !_editAreaIsAscii){ _editAreaIsAscii = true; setCursorPosition(_cursorPosition); } // switch from ascii to hex edit if (event->key() == Qt::Key_Backtab && _editAreaIsAscii){ _editAreaIsAscii = false; setCursorPosition(_cursorPosition); } refresh(); QAbstractScrollArea::keyPressEvent(event); } void QHexEdit::mouseMoveEvent(QMouseEvent * event) { _blink = false; viewport()->update(); qint64 actPos = cursorPosition(event->pos()); if (actPos >= 0) { setCursorPosition(actPos); setSelection(actPos); } } void QHexEdit::mousePressEvent(QMouseEvent * event) { _blink = false; viewport()->update(); qint64 cPos = cursorPosition(event->pos()); if (cPos >= 0) { if (event->button() != Qt::RightButton) resetSelection(cPos); setCursorPosition(cPos); } } void QHexEdit::paintEvent(QPaintEvent *event) { QPainter painter(viewport()); int pxOfsX = horizontalScrollBar()->value(); if (event->rect() != _cursorRect) { int pxPosStartY = _pxCharHeight; // draw some patterns if needed painter.fillRect(event->rect(), viewport()->palette().color(QPalette::Base)); if (_addressArea) painter.fillRect(QRect(-pxOfsX, event->rect().top(), _pxPosHexX - _pxGapAdrHex/2, height()), _addressAreaColor); if (_asciiArea) { int linePos = _pxPosAsciiX - (_pxGapHexAscii / 2); painter.setPen(Qt::gray); painter.drawLine(linePos - pxOfsX, event->rect().top(), linePos - pxOfsX, height()); } painter.setPen(viewport()->palette().color(QPalette::WindowText)); // paint address area if (_addressArea) { QString address; for (int row=0, pxPosY = _pxCharHeight; row < (_dataShown.size()/_bytesPerLine); row++, pxPosY +=_pxCharHeight) { address = QString("%1").arg(_bPosFirst + row*_bytesPerLine + _addressOffset, _addrDigits, 16, QChar('0')); painter.setPen(QPen(_addressFontColor)); painter.drawText(_pxPosAdrX - pxOfsX, pxPosY, _hexCaps ? address.toUpper() : address); } } // paint hex and ascii area painter.setBackgroundMode(Qt::TransparentMode); for (int row = 0, pxPosY = pxPosStartY; row <= _rowsShown; row++, pxPosY +=_pxCharHeight) { QByteArray hex; int pxPosX = _pxPosHexX - pxOfsX; int pxPosAsciiX2 = _pxPosAsciiX - pxOfsX; qint64 bPosLine = row * _bytesPerLine; for (int colIdx = 0; ((bPosLine + colIdx) < _dataShown.size() && (colIdx < _bytesPerLine)); colIdx++) { QColor c = viewport()->palette().color(QPalette::Base); painter.setPen(QPen(_hexFontColor)); qint64 posBa = _bPosFirst + bPosLine + colIdx; if ((getSelectionBegin() <= posBa) && (getSelectionEnd() > posBa)) { c = _brushSelection.color(); painter.setPen(_penSelection); } else { if (_highlighting) if (_markedShown.at((int)(posBa - _bPosFirst))) { c = _brushHighlighted.color(); painter.setPen(_penHighlighted); } } // render hex value QRect r; if (colIdx == 0) r.setRect(pxPosX, pxPosY - _pxCharHeight + _pxSelectionSub, 2*_pxCharWidth, _pxCharHeight); else r.setRect(pxPosX - _pxCharWidth, pxPosY - _pxCharHeight + _pxSelectionSub, 3*_pxCharWidth, _pxCharHeight); painter.fillRect(r, c); hex = _hexDataShown.mid((bPosLine + colIdx) * 2, 2); painter.drawText(pxPosX, pxPosY, _hexCaps ? hex.toUpper() : hex); pxPosX += 3*_pxCharWidth; // render ascii value if (_asciiArea) { int ch = (uchar)_dataShown.at(bPosLine + colIdx); if (ch < ' ' || ch > '~') ch = '.'; r.setRect(pxPosAsciiX2, pxPosY - _pxCharHeight + _pxSelectionSub, _pxCharWidth, _pxCharHeight); painter.fillRect(r, (c == _brushSelection.color() || c == _brushHighlighted.color()) ? c : _asciiAreaColor); painter.setPen(QPen(_asciiFontColor)); painter.drawText(pxPosAsciiX2, pxPosY, QChar(ch)); pxPosAsciiX2 += _pxCharWidth; } } } painter.setBackgroundMode(Qt::TransparentMode); painter.setPen(viewport()->palette().color(QPalette::WindowText)); } // _cursorPosition counts in 2, _bPosFirst counts in 1 int hexPositionInShowData = _cursorPosition - 2 * _bPosFirst; // due to scrolling the cursor can go out of the currently displayed data if ((hexPositionInShowData >= 0) && (hexPositionInShowData < _hexDataShown.size())) { // paint cursor if (!_readOnly) { QColor color; if (_blink && hasFocus()) { color = viewport()->palette().color(QPalette::WindowText); } else { if (_editAreaIsAscii) color = _asciiAreaColor; else color = viewport()->palette().color(QPalette::Base); } painter.fillRect(_cursorRect, color); } else { painter.fillRect(QRect(_pxCursorX - pxOfsX, _pxCursorY - _pxCharHeight + _pxSelectionSub, _pxCharWidth, _pxCharHeight), viewport()->palette().dark().color()); if (_editAreaIsAscii) { // every 2 hex there is 1 ascii int asciiPositionInShowData = hexPositionInShowData / 2; int ch = (uchar)_dataShown.at(asciiPositionInShowData); if (ch < ' ' || ch > '~') ch = '.'; painter.drawText(_pxCursorX - pxOfsX, _pxCursorY, QChar(ch)); } else { QByteArray hex = _hexDataShown.mid(hexPositionInShowData, 1); painter.drawText(_pxCursorX - pxOfsX, _pxCursorY, _hexCaps ? hex.toUpper() : hex); } } } // emit event, if size has changed if (_lastEventSize != _chunks->size()) { _lastEventSize = _chunks->size(); emit currentSizeChanged(_lastEventSize); } } void QHexEdit::resizeEvent(QResizeEvent *) { if (_dynamicBytesPerLine) { int pxFixGaps = 0; if (_addressArea) pxFixGaps = addressWidth() * _pxCharWidth + _pxGapAdr; pxFixGaps += _pxGapAdrHex; if (_asciiArea) pxFixGaps += _pxGapHexAscii; // +1 because the last hex value do not have space. so it is effective one char more int charWidth = (viewport()->width() - pxFixGaps ) / _pxCharWidth + 1; // 2 hex alfa-digits 1 space 1 ascii per byte = 4; if ascii is disabled then 3 // to prevent devision by zero use the min value 1 setBytesPerLine(std::max(charWidth / (_asciiArea ? 4 : 3),1)); } adjust(); } bool QHexEdit::focusNextPrevChild(bool next) { if (_addressArea) { if ( (next && _editAreaIsAscii) || (!next && !_editAreaIsAscii )) return QWidget::focusNextPrevChild(next); else return false; } else { return QWidget::focusNextPrevChild(next); } } // ********************************************************************** Handle selections void QHexEdit::resetSelection() { _bSelectionBegin = _bSelectionInit; _bSelectionEnd = _bSelectionInit; } void QHexEdit::resetSelection(qint64 pos) { pos = pos / 2 ; if (pos < 0) pos = 0; if (pos > _chunks->size()) pos = _chunks->size(); _bSelectionInit = pos; _bSelectionBegin = pos; _bSelectionEnd = pos; } void QHexEdit::setSelection(qint64 pos) { pos = pos / 2; if (pos < 0) pos = 0; if (pos > _chunks->size()) pos = _chunks->size(); if (pos >= _bSelectionInit) { _bSelectionEnd = pos; _bSelectionBegin = _bSelectionInit; } else { _bSelectionBegin = pos; _bSelectionEnd = _bSelectionInit; } } qint64 QHexEdit::getSelectionBegin() { return _bSelectionBegin; } qint64 QHexEdit::getSelectionEnd() { return _bSelectionEnd; } // ********************************************************************** Private utility functions void QHexEdit::init() { _undoStack->clear(); setAddressOffset(0); resetSelection(0); setCursorPosition(0); verticalScrollBar()->setValue(0); _modified = false; } void QHexEdit::adjust() { // recalc Graphics if (_addressArea) { _addrDigits = addressWidth(); _pxPosHexX = _pxGapAdr + _addrDigits*_pxCharWidth + _pxGapAdrHex; } else _pxPosHexX = _pxGapAdrHex; _pxPosAdrX = _pxGapAdr; _pxPosAsciiX = _pxPosHexX + _hexCharsInLine * _pxCharWidth + _pxGapHexAscii; // set horizontalScrollBar() int pxWidth = _pxPosAsciiX; if (_asciiArea) pxWidth += _bytesPerLine*_pxCharWidth; horizontalScrollBar()->setRange(0, pxWidth - viewport()->width()); horizontalScrollBar()->setPageStep(viewport()->width()); // set verticalScrollbar() _rowsShown = ((viewport()->height()-4)/_pxCharHeight); int lineCount = (int)(_chunks->size() / (qint64)_bytesPerLine) + 1; verticalScrollBar()->setRange(0, lineCount - _rowsShown); verticalScrollBar()->setPageStep(_rowsShown); int value = verticalScrollBar()->value(); _bPosFirst = (qint64)value * _bytesPerLine; _bPosLast = _bPosFirst + (qint64)(_rowsShown * _bytesPerLine) - 1; if (_bPosLast >= _chunks->size()) _bPosLast = _chunks->size() - 1; readBuffers(); setCursorPosition(_cursorPosition); } void QHexEdit::dataChangedPrivate(int) { _modified = _undoStack->index() != 0; adjust(); emit dataChanged(); } void QHexEdit::refresh() { ensureVisible(); readBuffers(); } void QHexEdit::readBuffers() { _dataShown = _chunks->data(_bPosFirst, _bPosLast - _bPosFirst + _bytesPerLine + 1, &_markedShown); _hexDataShown = QByteArray(_dataShown.toHex()); } QString QHexEdit::toReadable(const QByteArray &ba) { QString result; for (int i=0; i < ba.size(); i += 16) { QString addrStr = QString("%1").arg(_addressOffset + i, addressWidth(), 16, QChar('0')); QString hexStr; QString ascStr; for (int j=0; j<16; j++) { if ((i + j) < ba.size()) { hexStr.append(" ").append(ba.mid(i+j, 1).toHex()); char ch = ba[i + j]; if ((ch < 0x20) || (ch > 0x7e)) ch = '.'; ascStr.append(QChar(ch)); } } result += addrStr + " " + QString("%1").arg(hexStr, -48) + " " + QString("%1").arg(ascStr, -17) + "\n"; } return result; } void QHexEdit::updateCursor() { if (_blink) _blink = false; else _blink = true; viewport()->update(_cursorRect); } qhexedit2/src/qhexeditplugin.pro0000644000175000017500000000135413716244704017211 0ustar carstencarsten#! [0] #! [1] greaterThan(QT_MAJOR_VERSION, 4) { QT += widgets uiplugin } lessThan(QT_MAJOR_VERSION, 5) { CONFIG += designer } CONFIG += plugin #! [0] TARGET = $$qtLibraryTarget($$TARGET) #! [2] TEMPLATE = lib #! [1] #! [2] QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/designer #! [3] HEADERS = \ qhexedit.h \ chunks.h \ commands.h \ QHexEditPlugin.h SOURCES = \ qhexedit.cpp \ chunks.cpp \ commands.cpp \ QHexEditPlugin.cpp #! [3] # install target.path = $$[QT_INSTALL_PLUGINS]/designer sources.files = $$SOURCES $$HEADERS *.pro sources.path = $$[QT_INSTALL_EXAMPLES]/designer/QHexEditPlugin INSTALLS += target symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) qhexedit2/src/CMakeLists.txt0000644000175000017500000000134713716244704016177 0ustar carstencarsten#CMakeLists.txt SET(HEX_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/commands.cpp ${CMAKE_CURRENT_SOURCE_DIR}/chunks.cpp ${CMAKE_CURRENT_SOURCE_DIR}/qhexedit.cpp) SET(HEX_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/commands.h ${CMAKE_CURRENT_SOURCE_DIR}/chunks.h ${CMAKE_CURRENT_SOURCE_DIR}/qhexedit.h) SET(HEX_SOURCES ${HEX_SOURCES} PARENT_SCOPE) SET(HEX_HEADERS ${HEX_HEADERS} PARENT_SCOPE) # SET(FILES_TO_TRANSLATE ${FILES_TO_TRANSLATE} ${MAIN_SOURCES} ${MAIN_FORMS} ${MAIN_HEADERS} # PARENT_SCOPE) # cleanup $build/*.cpp~ on "make clean" SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*~") qhexedit2/src/chunks.h0000644000175000017500000000374513716244704015107 0ustar carstencarsten#ifndef CHUNKS_H #define CHUNKS_H /** \cond docNever */ /*! The Chunks class is the storage backend for QHexEdit. * * When QHexEdit loads data, Chunks access them using a QIODevice interface. When the app uses * a QByteArray interface, QBuffer is used to provide again a QIODevice like interface. No data * will be changed, therefore Chunks opens the QIODevice in QIODevice::ReadOnly mode. After every * access Chunks closes the QIODevice, that's why external applications can overwrite files while * QHexEdit shows them. * * When the the user starts to edit the data, Chunks creates a local copy of a chunk of data (4 * kilobytes) and notes all changes there. Parallel to that chunk, there is a second chunk, * which keep track of which bytes are changed and which not. * */ #include struct Chunk { QByteArray data; QByteArray dataChanged; qint64 absPos; }; class Chunks: public QObject { Q_OBJECT public: // Constructors and file settings Chunks(QObject *parent); Chunks(QIODevice &ioDevice, QObject *parent); bool setIODevice(QIODevice &ioDevice); // Getting data out of Chunks QByteArray data(qint64 pos=0, qint64 count=-1, QByteArray *highlighted=0); bool write(QIODevice &iODevice, qint64 pos=0, qint64 count=-1); // Set and get highlighting infos void setDataChanged(qint64 pos, bool dataChanged); bool dataChanged(qint64 pos); // Search API qint64 indexOf(const QByteArray &ba, qint64 from); qint64 lastIndexOf(const QByteArray &ba, qint64 from); // Char manipulations bool insert(qint64 pos, char b); bool overwrite(qint64 pos, char b); bool removeAt(qint64 pos); // Utility functions char operator[](qint64 pos); qint64 pos(); qint64 size(); private: int getChunkIndex(qint64 absPos); QIODevice * _ioDevice; qint64 _pos; qint64 _size; QList _chunks; #ifdef MODUL_TEST public: int chunkSize(); #endif }; /** \endcond docNever */ #endif // CHUNKS_H qhexedit2/src/qhexedit.pro0000644000175000017500000000054213716244704015770 0ustar carstencarsten greaterThan(QT_MAJOR_VERSION, 4): QT += widgets QT += core gui TEMPLATE = lib VERSION = 4.1.0 DEFINES += QHEXEDIT_EXPORTS HEADERS = \ qhexedit.h \ chunks.h \ commands.h SOURCES = \ qhexedit.cpp \ chunks.cpp \ commands.cpp Release:TARGET = qhexedit Debug:TARGET = qhexeditd unix:DESTDIR = /usr/lib win32:DESTDIR = ../lib qhexedit2/src/qhexedit.sip0000644000175000017500000000356713716244704015775 0ustar carstencarsten%Module(name=qhexedit, version=1) %Import QtCore/QtCoremod.sip %Import QtGui/QtGuimod.sip %If (Qt_5_0_0 -) %Import QtWidgets/QtWidgetsmod.sip %End class QHexEdit : QAbstractScrollArea { %TypeHeaderCode #include "../src/qhexedit.h" %End public: explicit QHexEdit(QWidget *parent /TransferThis/ = 0); virtual ~QHexEdit(); bool setData(QIODevice &); QByteArray dataAt(qint64, qint64=-1); bool write(QIODevice &iODevice, qint64=0, qint64=-1); void insert(qint64, char); void remove(qint64, qint64); void replace(qint64, char); void insert(qint64, QByteArray &); void replace(qint64, qint64, QByteArray &); bool addressArea(); bool addressWidth(); bool asciiArea(); qint64 cursorPosition(QPoint); void ensureVisible(); qint64 indexOf(QByteArray &, qint64); bool isModified(); bool highlighting(); qint64 lastIndexOf(QByteArray &, qint64); QString selectionToReadableString(); QString selectedData(); void setFont(const QFont &); QString toReadableString(); QColor addressAreaColor(); void setAddressAreaColor(const QColor &); qint64 addressOffset(); void setAddressOffset(qint64); qint64 cursorPosition(); void setCursorPosition(qint64); QByteArray data(); void setData(const QByteArray &); QColor highlightingColor(); void setHighlightingColor(const QColor &); bool overwriteMode(); void setOverwriteMode(bool); bool isReadOnly(); void setReadOnly(bool); QColor selectionColor(); void setSelectionColor(const QColor &); public slots: void redo(); void setAddressArea(bool); void setAddressWidth(int); void setAsciiArea(bool); void setHighlighting(bool); void undo(); signals: void currentAddressChanged(qint64); void currentSizeChanged(qint64); void dataChanged(); void overwriteModeChanged(bool); }; qhexedit2/src/chunks.cpp0000644000175000017500000002044413716244704015435 0ustar carstencarsten#include "chunks.h" #include #define NORMAL 0 #define HIGHLIGHTED 1 #define BUFFER_SIZE 0x10000 #define CHUNK_SIZE 0x1000 #define READ_CHUNK_MASK Q_INT64_C(0xfffffffffffff000) // ***************************************** Constructors and file settings Chunks::Chunks(QObject *parent): QObject(parent) { QBuffer *buf = new QBuffer(this); setIODevice(*buf); } Chunks::Chunks(QIODevice &ioDevice, QObject *parent): QObject(parent) { setIODevice(ioDevice); } bool Chunks::setIODevice(QIODevice &ioDevice) { _ioDevice = &ioDevice; bool ok = _ioDevice->open(QIODevice::ReadOnly); if (ok) // Try to open IODevice { _size = _ioDevice->size(); _ioDevice->close(); } else // Fallback is an empty buffer { QBuffer *buf = new QBuffer(this); _ioDevice = buf; _size = 0; } _chunks.clear(); _pos = 0; return ok; } // ***************************************** Getting data out of Chunks QByteArray Chunks::data(qint64 pos, qint64 maxSize, QByteArray *highlighted) { qint64 ioDelta = 0; int chunkIdx = 0; Chunk chunk; QByteArray buffer; // Do some checks and some arrangements if (highlighted) highlighted->clear(); if (pos >= _size) return buffer; if (maxSize < 0) maxSize = _size; else if ((pos + maxSize) > _size) maxSize = _size - pos; _ioDevice->open(QIODevice::ReadOnly); while (maxSize > 0) { chunk.absPos = LLONG_MAX; bool chunksLoopOngoing = true; while ((chunkIdx < _chunks.count()) && chunksLoopOngoing) { // In this section, we track changes before our required data and // we take the editdet data, if availible. ioDelta is a difference // counter to justify the read pointer to the original data, if // data in between was deleted or inserted. chunk = _chunks[chunkIdx]; if (chunk.absPos > pos) chunksLoopOngoing = false; else { chunkIdx += 1; qint64 count; qint64 chunkOfs = pos - chunk.absPos; if (maxSize > ((qint64)chunk.data.size() - chunkOfs)) { count = (qint64)chunk.data.size() - chunkOfs; ioDelta += CHUNK_SIZE - chunk.data.size(); } else count = maxSize; if (count > 0) { buffer += chunk.data.mid(chunkOfs, (int)count); maxSize -= count; pos += count; if (highlighted) *highlighted += chunk.dataChanged.mid(chunkOfs, (int)count); } } } if ((maxSize > 0) && (pos < chunk.absPos)) { // In this section, we read data from the original source. This only will // happen, whe no copied data is available qint64 byteCount; QByteArray readBuffer; if ((chunk.absPos - pos) > maxSize) byteCount = maxSize; else byteCount = chunk.absPos - pos; maxSize -= byteCount; _ioDevice->seek(pos + ioDelta); readBuffer = _ioDevice->read(byteCount); buffer += readBuffer; if (highlighted) *highlighted += QByteArray(readBuffer.size(), NORMAL); pos += readBuffer.size(); } } _ioDevice->close(); return buffer; } bool Chunks::write(QIODevice &iODevice, qint64 pos, qint64 count) { if (count == -1) count = _size; bool ok = iODevice.open(QIODevice::WriteOnly); if (ok) { for (qint64 idx=pos; idx < count; idx += BUFFER_SIZE) { QByteArray ba = data(idx, BUFFER_SIZE); iODevice.write(ba); } iODevice.close(); } return ok; } // ***************************************** Set and get highlighting infos void Chunks::setDataChanged(qint64 pos, bool dataChanged) { if ((pos < 0) || (pos >= _size)) return; int chunkIdx = getChunkIndex(pos); qint64 posInBa = pos - _chunks[chunkIdx].absPos; _chunks[chunkIdx].dataChanged[(int)posInBa] = char(dataChanged); } bool Chunks::dataChanged(qint64 pos) { QByteArray highlighted; data(pos, 1, &highlighted); return bool(highlighted.at(0)); } // ***************************************** Search API qint64 Chunks::indexOf(const QByteArray &ba, qint64 from) { qint64 result = -1; QByteArray buffer; for (qint64 pos=from; (pos < _size) && (result < 0); pos += BUFFER_SIZE) { buffer = data(pos, BUFFER_SIZE + ba.size() - 1); int findPos = buffer.indexOf(ba); if (findPos >= 0) result = pos + (qint64)findPos; } return result; } qint64 Chunks::lastIndexOf(const QByteArray &ba, qint64 from) { qint64 result = -1; QByteArray buffer; for (qint64 pos=from; (pos > 0) && (result < 0); pos -= BUFFER_SIZE) { qint64 sPos = pos - BUFFER_SIZE - (qint64)ba.size() + 1; if (sPos < 0) sPos = 0; buffer = data(sPos, pos - sPos); int findPos = buffer.lastIndexOf(ba); if (findPos >= 0) result = sPos + (qint64)findPos; } return result; } // ***************************************** Char manipulations bool Chunks::insert(qint64 pos, char b) { if ((pos < 0) || (pos > _size)) return false; int chunkIdx; if (pos == _size) chunkIdx = getChunkIndex(pos-1); else chunkIdx = getChunkIndex(pos); qint64 posInBa = pos - _chunks[chunkIdx].absPos; _chunks[chunkIdx].data.insert(posInBa, b); _chunks[chunkIdx].dataChanged.insert(posInBa, char(1)); for (int idx=chunkIdx+1; idx < _chunks.size(); idx++) _chunks[idx].absPos += 1; _size += 1; _pos = pos; return true; } bool Chunks::overwrite(qint64 pos, char b) { if ((pos < 0) || (pos >= _size)) return false; int chunkIdx = getChunkIndex(pos); qint64 posInBa = pos - _chunks[chunkIdx].absPos; _chunks[chunkIdx].data[(int)posInBa] = b; _chunks[chunkIdx].dataChanged[(int)posInBa] = char(1); _pos = pos; return true; } bool Chunks::removeAt(qint64 pos) { if ((pos < 0) || (pos >= _size)) return false; int chunkIdx = getChunkIndex(pos); qint64 posInBa = pos - _chunks[chunkIdx].absPos; _chunks[chunkIdx].data.remove(posInBa, 1); _chunks[chunkIdx].dataChanged.remove(posInBa, 1); for (int idx=chunkIdx+1; idx < _chunks.size(); idx++) _chunks[idx].absPos -= 1; _size -= 1; _pos = pos; return true; } // ***************************************** Utility functions char Chunks::operator[](qint64 pos) { return data(pos, 1)[0]; } qint64 Chunks::pos() { return _pos; } qint64 Chunks::size() { return _size; } int Chunks::getChunkIndex(qint64 absPos) { // This routine checks, if there is already a copied chunk available. If os, it // returns a reference to it. If there is no copied chunk available, original // data will be copied into a new chunk. int foundIdx = -1; int insertIdx = 0; qint64 ioDelta = 0; for (int idx=0; idx < _chunks.size(); idx++) { Chunk chunk = _chunks[idx]; if ((absPos >= chunk.absPos) && (absPos < (chunk.absPos + chunk.data.size()))) { foundIdx = idx; break; } if (absPos < chunk.absPos) { insertIdx = idx; break; } ioDelta += chunk.data.size() - CHUNK_SIZE; insertIdx = idx + 1; } if (foundIdx == -1) { Chunk newChunk; qint64 readAbsPos = absPos - ioDelta; qint64 readPos = (readAbsPos & READ_CHUNK_MASK); _ioDevice->open(QIODevice::ReadOnly); _ioDevice->seek(readPos); newChunk.data = _ioDevice->read(CHUNK_SIZE); _ioDevice->close(); newChunk.absPos = absPos - (readAbsPos - readPos); newChunk.dataChanged = QByteArray(newChunk.data.size(), char(0)); _chunks.insert(insertIdx, newChunk); foundIdx = insertIdx; } return foundIdx; } #ifdef MODUL_TEST int Chunks::chunkSize() { return _chunks.size(); } #endif qhexedit2/src/qhexedit.h0000644000175000017500000004174713716244704015433 0ustar carstencarsten#ifndef QHEXEDIT_H #define QHEXEDIT_H #include #include #include #include "chunks.h" #include "commands.h" #ifdef QHEXEDIT_EXPORTS #define QHEXEDIT_API Q_DECL_EXPORT #elif QHEXEDIT_IMPORTS #define QHEXEDIT_API Q_DECL_IMPORT #else #define QHEXEDIT_API #endif /** \mainpage QHexEdit is a binary editor widget for Qt. \version Version 0.8.8 \image html qhexedit.png */ /** QHexEdit is a hex editor widget written in C++ for the Qt (Qt4, Qt5) framework. It is a simple editor for binary data, just like QPlainTextEdit is for text data. There are sip configuration files included, so it is easy to create bindings for PyQt and you can use this widget also in python 2 and 3. QHexEdit takes the data of a QByteArray (setData()) and shows it. You can use the mouse or the keyboard to navigate inside the widget. If you hit the keys (0..9, a..f) you will change the data. Changed data is highlighted and can be accessed via data(). Normally QHexEdit works in the overwrite mode. You can set overwrite mode(false) and insert data. In this case the size of data() increases. It is also possible to delete bytes (del or backspace), here the size of data decreases. You can select data with keyboard hits or mouse movements. The copy-key will copy the selected data into the clipboard. The cut-key copies also but deletes it afterwards. In overwrite mode, the paste function overwrites the content of the (does not change the length) data. In insert mode, clipboard data will be inserted. The clipboard content is expected in ASCII Hex notation. Unknown characters will be ignored. QHexEdit comes with undo/redo functionality. All changes can be undone, by pressing the undo-key (usually ctr-z). They can also be redone afterwards. The undo/redo framework is cleared, when setData() sets up a new content for the editor. You can search data inside the content with indexOf() and lastIndexOf(). The replace() function is to change located subdata. This 'replaced' data can also be undone by the undo/redo framework. QHexEdit is based on QIODevice, that's why QHexEdit can handle big amounts of data. The size of edited data can be more then two gigabytes without any restrictions. */ class QHEXEDIT_API QHexEdit : public QAbstractScrollArea { Q_OBJECT /*! Property address area switch the address area on or off. Set addressArea true (show it), false (hide it). */ Q_PROPERTY(bool addressArea READ addressArea WRITE setAddressArea) /*! Property address area color sets (setAddressAreaColor()) the background color of address areas. You can also read the color (addressAreaColor()). */ Q_PROPERTY(QColor addressAreaColor READ addressAreaColor WRITE setAddressAreaColor) /*! Property address font color sets (setAddressFontColor()) the text color of address areas. You can also read the color (addressFontColor()). */ Q_PROPERTY(QColor addressFontColor READ addressFontColor WRITE setAddressFontColor) /*! Property ascii area color sets (setAsciiAreaColor()) the backgorund color of ascii areas. You can also read the color (asciiAreaColor()). */ Q_PROPERTY(QColor asciiAreaColor READ asciiAreaColor WRITE setAsciiAreaColor) /*! Property ascii font color sets (setAsciiFontColor()) the text color of ascii areas. You can also read the color (asciiFontColor()). */ Q_PROPERTY(QColor asciiFontColor READ asciiFontColor WRITE setAsciiFontColor) /*! Property hex font color sets (setHexFontColor()) the text color of hex areas. You can also read the color (hexFontColor()). */ Q_PROPERTY(QColor hexFontColor READ hexFontColor WRITE setHexFontColor) /*! Property addressOffset is added to the Numbers of the Address Area. A offset in the address area (left side) is sometimes useful, whe you show only a segment of a complete memory picture. With setAddressOffset() you set this property - with addressOffset() you get the current value. */ Q_PROPERTY(qint64 addressOffset READ addressOffset WRITE setAddressOffset) /*! Set and get the minimum width of the address area, width in characters. */ Q_PROPERTY(int addressWidth READ addressWidth WRITE setAddressWidth) /*! Switch the ascii area on (true, show it) or off (false, hide it). */ Q_PROPERTY(bool asciiArea READ asciiArea WRITE setAsciiArea) /*! Set and get bytes number per line.*/ Q_PROPERTY(int bytesPerLine READ bytesPerLine WRITE setBytesPerLine) /*! Property cursorPosition sets or gets the position of the editor cursor in QHexEdit. Every byte in data has two cursor positions: the lower and upper Nibble. Maximum cursor position is factor two of data.size(). */ Q_PROPERTY(qint64 cursorPosition READ cursorPosition WRITE setCursorPosition) /*! Property data holds the content of QHexEdit. Call setData() to set the content of QHexEdit, data() returns the actual content. When calling setData() with a QByteArray as argument, QHexEdit creates a internal copy of the data If you want to edit big files please use setData(), based on QIODevice. */ Q_PROPERTY(QByteArray data READ data WRITE setData NOTIFY dataChanged) /*! That property defines if the hex values looks as a-f if the value is false(default) or A-F if value is true. */ Q_PROPERTY(bool hexCaps READ hexCaps WRITE setHexCaps) /*! Property defines the dynamic calculation of bytesPerLine parameter depends of width of widget. set this property true to avoid horizontal scrollbars and show the maximal possible data. defalut value is false*/ Q_PROPERTY(bool dynamicBytesPerLine READ dynamicBytesPerLine WRITE setDynamicBytesPerLine) /*! Switch the highlighting feature on or of: true (show it), false (hide it). */ Q_PROPERTY(bool highlighting READ highlighting WRITE setHighlighting) /*! Property highlighting color sets (setHighlightingColor()) the background color of highlighted text areas. You can also read the color (highlightingColor()). */ Q_PROPERTY(QColor highlightingColor READ highlightingColor WRITE setHighlightingColor) /*! Property overwrite mode sets (setOverwriteMode()) or gets (overwriteMode()) the mode in which the editor works. In overwrite mode the user will overwrite existing data. The size of data will be constant. In insert mode the size will grow, when inserting new data. */ Q_PROPERTY(bool overwriteMode READ overwriteMode WRITE setOverwriteMode) /*! Property selection color sets (setSelectionColor()) the background color of selected text areas. You can also read the color (selectionColor()). */ Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor) /*! Property readOnly sets (setReadOnly()) or gets (isReadOnly) the mode in which the editor works. In readonly mode the the user can only navigate through the data and select data; modifying is not possible. This property's default is false. */ Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly) /*! Set the font of the widget. Please use fixed width fonts like Mono or Courier.*/ Q_PROPERTY(QFont font READ font WRITE setFont) public: /*! Creates an instance of QHexEdit. \param parent Parent widget of QHexEdit. */ QHexEdit(QWidget *parent=0); // Access to data of qhexedit /*! Sets the data of QHexEdit. The QIODevice will be opened just before reading and closed immediately afterwards. This is to allow other programs to rewrite the file while editing it. */ bool setData(QIODevice &iODevice); /*! Gives back the data as a QByteArray starting at position \param pos and delivering \param count bytes. */ QByteArray dataAt(qint64 pos, qint64 count=-1); /*! Gives back the data into a \param iODevice starting at position \param pos and delivering \param count bytes. */ bool write(QIODevice &iODevice, qint64 pos=0, qint64 count=-1); // Char handling /*! Inserts a char. \param pos Index position, where to insert \param ch Char, which is to insert The char will be inserted and size of data grows. */ void insert(qint64 pos, char ch); /*! Removes len bytes from the content. \param pos Index position, where to remove \param len Amount of bytes to remove */ void remove(qint64 pos, qint64 len=1); /*! Replaces a char. \param pos Index position, where to overwrite \param ch Char, which is to insert The char will be overwritten and size remains constant. */ void replace(qint64 pos, char ch); // ByteArray handling /*! Inserts a byte array. \param pos Index position, where to insert \param ba QByteArray, which is to insert The QByteArray will be inserted and size of data grows. */ void insert(qint64 pos, const QByteArray &ba); /*! Replaces \param len bytes with a byte array \param ba \param pos Index position, where to overwrite \param ba QByteArray, which is inserted \param len count of bytes to overwrite The data is overwritten and size of data may change. */ void replace(qint64 pos, qint64 len, const QByteArray &ba); // Utility functions /*! Calc cursor position from graphics position * \param point from where the cursor position should be calculated * \return Cursor position */ qint64 cursorPosition(QPoint point); /*! Ensure the cursor to be visbile */ void ensureVisible(); /*! Find first occurrence of ba in QHexEdit data * \param ba Data to find * \param from Point where the search starts * \return pos if fond, else -1 */ qint64 indexOf(const QByteArray &ba, qint64 from); /*! Returns if any changes where done on document * \return true when document is modified else false */ bool isModified(); /*! Find last occurrence of ba in QHexEdit data * \param ba Data to find * \param from Point where the search starts * \return pos if fond, else -1 */ qint64 lastIndexOf(const QByteArray &ba, qint64 from); /*! Gives back a formatted image of the selected content of QHexEdit */ QString selectionToReadableString(); /*! Return the selected content of QHexEdit as QByteArray */ QString selectedData(); /*! Set Font of QHexEdit * \param font */ void setFont(const QFont &font); /*! Gives back a formatted image of the content of QHexEdit */ QString toReadableString(); public slots: /*! Redoes the last operation. If there is no operation to redo, i.e. there is no redo step in the undo/redo history, nothing happens. */ void redo(); /*! Undoes the last operation. If there is no operation to undo, i.e. there is no undo step in the undo/redo history, nothing happens. */ void undo(); signals: /*! Contains the address, where the cursor is located. */ void currentAddressChanged(qint64 address); /*! Contains the size of the data to edit. */ void currentSizeChanged(qint64 size); /*! The signal is emitted every time, the data is changed. */ void dataChanged(); /*! The signal is emitted every time, the overwrite mode is changed. */ void overwriteModeChanged(bool state); /*! \cond docNever */ public: ~QHexEdit(); // Properties bool addressArea(); void setAddressArea(bool addressArea); QColor addressAreaColor(); void setAddressAreaColor(const QColor &color); QColor addressFontColor(); void setAddressFontColor(const QColor &color); QColor asciiAreaColor(); void setAsciiAreaColor(const QColor &color); QColor asciiFontColor(); void setAsciiFontColor(const QColor &color); QColor hexFontColor(); void setHexFontColor(const QColor &color); qint64 addressOffset(); void setAddressOffset(qint64 addressArea); int addressWidth(); void setAddressWidth(int addressWidth); bool asciiArea(); void setAsciiArea(bool asciiArea); int bytesPerLine(); void setBytesPerLine(int count); qint64 cursorPosition(); void setCursorPosition(qint64 position); QByteArray data(); void setData(const QByteArray &ba); void setHexCaps(const bool isCaps); bool hexCaps(); void setDynamicBytesPerLine(const bool isDynamic); bool dynamicBytesPerLine(); bool highlighting(); void setHighlighting(bool mode); QColor highlightingColor(); void setHighlightingColor(const QColor &color); bool overwriteMode(); void setOverwriteMode(bool overwriteMode); bool isReadOnly(); void setReadOnly(bool readOnly); QColor selectionColor(); void setSelectionColor(const QColor &color); protected: // Handle events void keyPressEvent(QKeyEvent *event); void mouseMoveEvent(QMouseEvent * event); void mousePressEvent(QMouseEvent * event); void paintEvent(QPaintEvent *event); void resizeEvent(QResizeEvent *); virtual bool focusNextPrevChild(bool next); private: // Handle selections void resetSelection(qint64 pos); // set selectionStart and selectionEnd to pos void resetSelection(); // set selectionEnd to selectionStart void setSelection(qint64 pos); // set min (if below init) or max (if greater init) qint64 getSelectionBegin(); qint64 getSelectionEnd(); // Private utility functions void init(); void readBuffers(); QString toReadable(const QByteArray &ba); private slots: void adjust(); // recalc pixel positions void dataChangedPrivate(int idx=0); // emit dataChanged() signal void refresh(); // ensureVisible() and readBuffers() void updateCursor(); // update blinking cursor private: // Name convention: pixel positions start with _px int _pxCharWidth, _pxCharHeight; // char dimensions (dependend on font) int _pxPosHexX; // X-Pos of HeaxArea int _pxPosAdrX; // X-Pos of Address Area int _pxPosAsciiX; // X-Pos of Ascii Area int _pxGapAdr; // gap left from AddressArea int _pxGapAdrHex; // gap between AddressArea and HexAerea int _pxGapHexAscii; // gap between HexArea and AsciiArea int _pxCursorWidth; // cursor width int _pxSelectionSub; // offset selection rect int _pxCursorX; // current cursor pos int _pxCursorY; // current cursor pos // Name convention: absolute byte positions in chunks start with _b qint64 _bSelectionBegin; // first position of Selection qint64 _bSelectionEnd; // end of Selection qint64 _bSelectionInit; // memory position of Selection qint64 _bPosFirst; // position of first byte shown qint64 _bPosLast; // position of last byte shown qint64 _bPosCurrent; // current position // variables to store the property values bool _addressArea; // left area of QHexEdit QColor _addressAreaColor; QColor _asciiAreaColor; QColor _addressFontColor; QColor _asciiFontColor; QColor _hexFontColor; int _addressWidth; bool _asciiArea; qint64 _addressOffset; int _bytesPerLine; int _hexCharsInLine; bool _highlighting; bool _overwriteMode; QBrush _brushSelection; QPen _penSelection; QBrush _brushHighlighted; QPen _penHighlighted; bool _readOnly; bool _hexCaps; bool _dynamicBytesPerLine; // other variables bool _editAreaIsAscii; // flag about the ascii mode edited int _addrDigits; // real no of addressdigits, may be > addressWidth bool _blink; // help get cursor blinking QBuffer _bData; // buffer, when setup with QByteArray Chunks *_chunks; // IODevice based access to data QTimer _cursorTimer; // for blinking cursor qint64 _cursorPosition; // absolute position of cursor, 1 Byte == 2 tics QRect _cursorRect; // physical dimensions of cursor QByteArray _data; // QHexEdit's data, when setup with QByteArray QByteArray _dataShown; // data in the current View QByteArray _hexDataShown; // data in view, transformed to hex qint64 _lastEventSize; // size, which was emitted last time QByteArray _markedShown; // marked data in view bool _modified; // Is any data in editor modified? int _rowsShown; // lines of text shown UndoStack * _undoStack; // Stack to store edit actions for undo/redo /*! \endcond docNever */ }; #endif // QHEXEDIT_H qhexedit2/src/QHexEditPlugin.cpp0000644000175000017500000000326513716244704016776 0ustar carstencarsten#include "QHexEditPlugin.h" #include "qhexedit.h" #include QHexEditPlugin::QHexEditPlugin(QObject * parent) : QObject(parent) { initialized = false; } bool QHexEditPlugin::isContainer() const { return false; } bool QHexEditPlugin::isInitialized() const { return initialized; } QIcon QHexEditPlugin::icon() const { return QIcon(); } QString QHexEditPlugin::domXml() const { return "\n" " \n" " \n" " \n" " 0\n" " 0\n" " 100\n" " 100\n" " \n" " \n" " \n" " QHexEditWidget\n" " \n" " \n" " QHexEdit widget allow to edit the data in hex view.\n" " \n" " \n" "\n"; } QString QHexEditPlugin::group() const { return "Input Widgets"; } QString QHexEditPlugin::includeFile() const { return "qhexedit.h"; } QString QHexEditPlugin::name() const { return "QHexEdit"; } QString QHexEditPlugin::toolTip() const { return ""; } QString QHexEditPlugin::whatsThis() const { return ""; } QWidget * QHexEditPlugin::createWidget(QWidget *parent) { return new QHexEdit(parent); } void QHexEditPlugin::initialize(QDesignerFormEditorInterface * /*core*/) { if (initialized) return; initialized = true; } #if QT_VERSION < QT_VERSION_CHECK(5,0,0) Q_EXPORT_PLUGIN2(QHexEditPlugin, QHexEditPlugin) #endif qhexedit2/src/license.txt0000644000175000017500000006364113716244704015627 0ustar carstencarsten GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it!qhexedit2/setup.py0000644000175000017500000000744613716244704014370 0ustar carstencarsten#!/usr/bin/env python from distutils.core import setup, Extension from distutils import log import os import subprocess import sipdistutils import sipconfig cfg = sipconfig.Configuration() pyqt_sip_dir = cfg.default_sip_dir try: import PyQt5 PyQt_Version = 'PyQt5' except: PyQt_Version = 'PyQt4' include_dirs = ['src'] class build_pyqt_ext(sipdistutils.build_ext): description = "Build a qhexedit PyQt extension." user_options = sipdistutils.build_ext.user_options + [( "required", None, "qhexedit is required (failure to build will raise an error)" )] boolean_options = sipdistutils.build_ext.boolean_options + ["required"] def initialize_options(self): sipdistutils.build_ext.initialize_options(self) self.required = False def finalize_options(self): if PyQt_Version == 'PyQt5': from PyQt5.QtCore import PYQT_CONFIGURATION else: from PyQt4.QtCore import PYQT_CONFIGURATION sipdistutils.build_ext.finalize_options(self) self.sip_opts = self.sip_opts + PYQT_CONFIGURATION['sip_flags'].split() self.sip_opts.append('-I%s/%s' % (pyqt_sip_dir, PyQt_Version)) if self.required is not None: self.required = True def build_extension(self, ext): cppsources = (s for s in ext.sources if s.endswith(".cpp")) if not os.path.exists(self.build_temp): os.makedirs(self.build_temp) for source in cppsources: header = source.replace(".cpp", ".h") if os.path.exists(header): moc_file = os.path.basename(header).replace(".h", ".moc") call_arg = ( "moc", "-o", os.path.join(self.build_temp, moc_file), header ) log.info("Calling: " + " ".join(call_arg)) try: subprocess.call(call_arg) except OSError: raise OSError( "Could not locate 'moc' executable." ) sipdistutils.build_ext.build_extension(self, ext) def run(self): try: sipdistutils.build_ext.run(self) except Exception as ex: if self.required: raise else: log.info("Could not build qhexedit extension (%r)\n" "Skipping." % ex) # For sipdistutils to find PyQt's .sip files def _sip_sipfiles_dir(self): return pyqt_sip_dir # Used Qt libs if PyQt_Version == 'PyQt5': qt_libs = ["QtCore", "QtGui", "QtWidgets"] else: qt_libs = ["QtCore", "QtGui"] if cfg.qt_framework: for lib in qt_libs: include_dirs += [os.path.join(cfg.qt_lib_dir, lib + ".framework", "Headers")] else: if PyQt_Version == 'PyQt5': for qt_inc_dir in ('/usr/include/qt', '/usr/include/x86_64-linux-gnu/qt5'): include_dirs.append(qt_inc_dir) include_dirs += [os.path.join(qt_inc_dir, lib) for lib in qt_libs] libraries = ["Qt5" + lib[2:] for lib in qt_libs] else: for qt_inc_dir in ('/usr/include/qt', '/usr/include/qt4'): include_dirs.append(qt_inc_dir) include_dirs += [os.path.join(qt_inc_dir, lib) for lib in qt_libs] libraries = ["Qt" + lib[2:] for lib in qt_libs] libraries.append("qhexedit") dirname = os.path.dirname(__file__) setup( name='QHexEdit', version='0.8.8', ext_modules=[ Extension( "qhexedit", sources=[ os.path.join(dirname, "src/qhexedit.sip"), ], include_dirs=include_dirs, libraries=libraries, ) ], cmdclass={"build_ext": build_pyqt_ext}, ) qhexedit2/python/0000700000175000017500000000000013716244704014152 5ustar carstencarstenqhexedit2/python/python2_pyqt4/0000700000175000017500000000000013716244704016716 5ustar carstencarstenqhexedit2/python/python2_pyqt4/searchdialog.py0000644000175000017500000000571213716244704021734 0ustar carstencarsten#!/usr/bin/env python from PyQt4 import QtCore, QtGui from Ui_searchdialog import Ui_SearchDialog class SearchDialog(QtGui.QDialog): def __init__(self, parent, hexEdit): super(SearchDialog, self).__init__() self.ui = Ui_SearchDialog() self.ui.setupUi(self) self._hexEdit = hexEdit def findNext(self): startIdx = self._hexEdit.cursorPosition() findBa = self.getContent(self.ui.cbFindFormat.currentIndex(), self.ui.cbFind.currentText()) idx = -1 if findBa.length() > 0: if self.ui.cbBackwards.isChecked(): idx = self._hexEdit.lastIndexOf(findBa, startIdx) else: idx = self._hexEdit.indexOf(findBa, startIdx) return idx @QtCore.pyqtSlot() def on_pbFind_clicked(self): self.findNext() @QtCore.pyqtSlot() def on_pbReplace_clicked(self): idx = self.findNext() if idx >= 0: replaceBa = self.getContent(self.ui.cbReplaceFormat.currentIndex(), self.ui.cbReplace.currentText()) self.replaceOccurrence(idx, replaceBa) @QtCore.pyqtSlot() def on_pbReplaceAll_clicked(self): replaceCounter = 0 idx = 0 goOn = QtGui.QMessageBox.Yes while (idx >= 0) and (goOn == QtGui.QMessageBox.Yes): idx = self.findNext() if idx >= 0: replaceBa = self.getContent(self.ui.cbReplaceFormat.currentIndex(), self.ui.cbReplace.currentText()) result = self.replaceOccurrence(idx, replaceBa) if result == QtGui.QMessageBox.Yes: replaceCounter += 1 if result == QtGui.QMessageBox.Cancel: goOn = QtGui.QMessageBox.Cancel if replaceCounter > 0: QtGui.QMessageBox.information(self, "QHexEdit", "%s occurrences replaced" % replaceCounter) def getContent(self, comboIndex, inputStr): if comboIndex == 0: # hex findBa = QtCore.QByteArray.fromHex(inputStr.toAscii()) elif comboIndex == 1: # text findBa = inputStr.toUtf8() return findBa def replaceOccurrence(self, idx, replaceBa): result = QtGui.QMessageBox.Yes if replaceBa.length() >= 0: if self.ui.cbPrompt.isChecked(): result = QtGui.QMessageBox.question(self, "QHexEdit", "Replace occurrence?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No | QtGui.QMessageBox.Cancel) if result == QtGui.QMessageBox.Yes: self._hexEdit.replace(idx, replaceBa.length(), replaceBa) self._hexEdit.update() else: self._hexEdit.replace(idx, replaceBa.length(), replaceBa) return result qhexedit2/python/python2_pyqt4/optionsdialog.py0000644000175000017500000001215513716244704022161 0ustar carstencarsten#!/usr/bin/env python import sys from PyQt4 import QtCore, QtGui from Ui_optionsdialog import Ui_OptionsDialog class OptionsDialog(QtGui.QDialog): accepted = QtCore.pyqtSignal() def __init__(self, fileName=None): super(OptionsDialog, self).__init__() self.ui = Ui_OptionsDialog() self.ui.setupUi(self) self.readSettings() self.writeSettings() def show(self): self.readSettings() super(OptionsDialog, self).show() def accept(self): self.writeSettings() self.accepted.emit() super(OptionsDialog, self).hide() def readSettings(self): settings = QtCore.QSettings() self.setColor(self.ui.lbHighlightingColor, QtGui.QColor(settings.value("HighlightingColor", QtGui.QColor(0xff, 0xff, 0x99, 0xff)))) self.setColor(self.ui.lbAddressAreaColor, QtGui.QColor(settings.value("AddressAreaColor", QtGui.QColor(0xd4, 0xd4, 0xd4, 0xff)))) self.setColor(self.ui.lbSelectionColor, QtGui.QColor(settings.value("SelectionColor", QtGui.QColor(0x6d, 0x9e, 0xff, 0xff)))) self.ui.leWidgetFont.setFont(QtGui.QFont(settings.value("WidgetFont", QtGui.QFont(QtGui.QFont("Courier New", 10))))) if sys.version_info >= (3, 0): self.ui.sbAddressAreaWidth.setValue(int(settings.value("AddressAreaWidth", 4))) self.ui.cbAddressArea.setChecked(settings.value("AddressArea", 'true')=='true') self.ui.cbAsciiArea.setChecked(settings.value("AsciiArea", 'true')=='true') self.ui.cbHighlighting.setChecked(settings.value("Highlighting", 'true')=='true') self.ui.cbOverwriteMode.setChecked(settings.value("OverwriteMode", 'true')=='true') self.ui.cbReadOnly.setChecked(settings.value("ReadOnly", 'false')=='true') else: self.ui.sbAddressAreaWidth.setValue(settings.value("AddressAreaWidth", 4).toInt()[0]) self.ui.cbAddressArea.setChecked(settings.value("AddressArea", True).toBool()) self.ui.cbAsciiArea.setChecked(settings.value("AsciiArea", True).toBool()) self.ui.cbHighlighting.setChecked(settings.value("Highlighting", True).toBool()) self.ui.cbOverwriteMode.setChecked(settings.value("OverwriteMode", True).toBool()) self.ui.cbReadOnly.setChecked(settings.value("ReadOnly", False).toBool()) def writeSettings(self): settings = QtCore.QSettings() if sys.version_info >= (3, 0): def b(b): if b: return 'true' else: return 'false' settings.setValue("AddressArea", b(self.ui.cbAddressArea.isChecked())) settings.setValue("AsciiArea", b(self.ui.cbAsciiArea.isChecked())) settings.setValue("Highlighting", b(self.ui.cbHighlighting.isChecked())) settings.setValue("OverwriteMode", b(self.ui.cbOverwriteMode.isChecked())) settings.setValue("ReadOnly", b(self.ui.cbReadOnly.isChecked())) else: settings.setValue("AddressArea", self.ui.cbAddressArea.isChecked()) settings.setValue("AsciiArea", self.ui.cbAsciiArea.isChecked()) settings.setValue("Highlighting", self.ui.cbHighlighting.isChecked()) settings.setValue("OverwriteMode", self.ui.cbOverwriteMode.isChecked()) settings.setValue("ReadOnly", self.ui.cbReadOnly.isChecked()) settings.setValue("HighlightingColor", self.ui.lbHighlightingColor.palette().color(QtGui.QPalette.Background)) settings.setValue("AddressAreaColor", self.ui.lbAddressAreaColor.palette().color(QtGui.QPalette.Background)) settings.setValue("SelectionColor", self.ui.lbSelectionColor.palette().color(QtGui.QPalette.Background)) settings.setValue("WidgetFont", self.ui.leWidgetFont.font()) settings.setValue("AddressAreaWidth", self.ui.sbAddressAreaWidth.value()) def reject(self): super(OptionsDialog, self).hide() def setColor(self, label, color): palette = label.palette() palette.setColor(QtGui.QPalette.Background, color) label.setPalette(palette) label.setAutoFillBackground(True) def on_pbHighlightingColor_pressed(self): print("hier") color = QtGui.QColorDialog.getColor(self.ui.lbHighlightingColor.palette().color(QtGui.QPalette.Background), self) if color.isValid(): self.setColor(self.ui.lbHighlightingColor, color) def on_pbAddressAreaColor_pressed(self): color = QtGui.QColorDialog.getColor(self.ui.lbAddressAreaColor.palette().color(QtGui.QPalette.Background), self) if color.isValid(): self.setColor(self.ui.lbAddressAreaColor, color) def on_pbSelectionColor_pressed(self): color = QtGui.QColorDialog.getColor(self.ui.lbSelectionColor.palette().color(QtGui.QPalette.Background), self) if color.isValid(): self.setColor(self.ui.lbSelectioncColor, color) def on_pbWidgetFont_pressed(self): font, ok = QtGui.QFontDialog().getFont(self.ui.leWidgetFont.font(), self) if ok: self.ui.leWidgetFont.setFont(font) qhexedit2/python/python2_pyqt4/mainwindow.py0000644000175000017500000002741013716244704021462 0ustar carstencarsten#!/usr/bin/env python import sys from PyQt4 import QtCore, QtGui from qhexedit import QHexEdit from optionsdialog import OptionsDialog from searchdialog import SearchDialog import qhexedit_rc class MainWindow(QtGui.QMainWindow): def __init__(self, fileName=None): super(MainWindow, self).__init__() self.init() self.setCurrentFile('') def about(self): QtGui.QMessageBox.about(self, "About HexEdit", "The HexEdit example is a short Demo of the QHexEdit Widget."); def closeEvent(self, event): self.writeSettings() del self.optionsDialog self.close() def createActions(self): self.openAct = QtGui.QAction(QtGui.QIcon(':/images/open.png'), "&Open...", self, shortcut=QtGui.QKeySequence.Open, statusTip="Open an existing file", triggered=self.open) self.saveAct = QtGui.QAction(QtGui.QIcon(':/images/save.png'), "&Save", self, shortcut=QtGui.QKeySequence.Save, statusTip="Save the document to disk", triggered=self.save) self.saveAsAct = QtGui.QAction("Save &As...", self, shortcut=QtGui.QKeySequence.SaveAs, statusTip="Save the document under a new name", triggered=self.saveAs) self.saveReadable = QtGui.QAction("Save as &Readable...", self, statusTip="Save in a readable format", triggered=self.saveToReadableFile) self.exitAct = QtGui.QAction("E&xit", self, shortcut="Ctrl+Q", statusTip="Exit the application", triggered=self.close) self.undoAct = QtGui.QAction("&Undo", self, shortcut=QtGui.QKeySequence.Undo, triggered=self.hexEdit.undo) self.redoAct = QtGui.QAction("&Redo", self, shortcut=QtGui.QKeySequence.Redo, triggered=self.hexEdit.redo) self.saveSelectionReadable = QtGui.QAction("Save Selection Readable...", self, statusTip="Save selection in a readable format", triggered=self.saveSelectionToReadableFile) self.aboutAct = QtGui.QAction("&About", self, statusTip="Show the application's About box", triggered=self.about) self.findAct = QtGui.QAction("&Find/Replace", self, shortcut=QtGui.QKeySequence.Find, statusTip="Show the Dialog for finding and replacing", triggered=self.showSearchDialog) self.findNextAct = QtGui.QAction("Find &next", self, shortcut=QtGui.QKeySequence.FindNext, statusTip="Find next occurrence of the searched pattern", triggered=self.findNext) self.optionsAct = QtGui.QAction("&Options", self, statusTip="Show the options dialog", triggered=self.showOptionsDialog) def createMenus(self): self.fileMenu = self.menuBar().addMenu("&File") self.fileMenu.addAction(self.openAct) self.fileMenu.addAction(self.saveAct) self.fileMenu.addAction(self.saveAsAct) self.fileMenu.addAction(self.saveReadable) self.fileMenu.addSeparator() self.fileMenu.addAction(self.exitAct) self.editMenu = self.menuBar().addMenu("&Edit") self.editMenu.addAction(self.undoAct) self.editMenu.addAction(self.redoAct) self.editMenu.addAction(self.saveSelectionReadable) self.editMenu.addSeparator() self.editMenu.addAction(self.findAct) self.editMenu.addAction(self.findNextAct) self.editMenu.addSeparator() self.editMenu.addAction(self.optionsAct) self.helpMenu = self.menuBar().addMenu("&Help") self.helpMenu.addAction(self.aboutAct) def createStatusBar(self): # Address Label self.lbAddressName = QtGui.QLabel() self.lbAddressName.setText("Address:") self.statusBar().addPermanentWidget(self.lbAddressName) self.lbAddress = QtGui.QLabel() self.lbAddress.setFrameShape(QtGui.QFrame.Panel) self.lbAddress.setFrameShadow(QtGui.QFrame.Sunken) self.lbAddress.setMinimumWidth(70) self.statusBar().addPermanentWidget(self.lbAddress) self.hexEdit.currentAddressChanged.connect(self.setAddress) # Address Size self.lbSizeName = QtGui.QLabel() self.lbSizeName.setText("Size:") self.statusBar().addPermanentWidget(self.lbSizeName) self.lbSize = QtGui.QLabel() self.lbSize.setFrameShape(QtGui.QFrame.Panel) self.lbSize.setFrameShadow(QtGui.QFrame.Sunken) self.lbSize.setMinimumWidth(70) self.statusBar().addPermanentWidget(self.lbSize) self.hexEdit.currentSizeChanged.connect(self.setSize) # Overwrite Mode label self.lbOverwriteModeName = QtGui.QLabel() self.lbOverwriteModeName.setText("Mode:") self.statusBar().addPermanentWidget(self.lbOverwriteModeName) self.lbOverwriteMode = QtGui.QLabel() self.lbOverwriteMode.setFrameShape(QtGui.QFrame.Panel) self.lbOverwriteMode.setFrameShadow(QtGui.QFrame.Sunken) self.lbOverwriteMode.setMinimumWidth(70) self.statusBar().addPermanentWidget(self.lbOverwriteMode) self.setOverwriteMode(self.hexEdit.overwriteMode()) self.statusBar().showMessage("Ready") def createToolBars(self): self.fileToolBar = self.addToolBar("File") self.fileToolBar.addAction(self.openAct) self.fileToolBar.addAction(self.saveAct) def init(self): self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.isUntitled = True self.hexEdit = QHexEdit() self.setCentralWidget(self.hexEdit) self.hexEdit.overwriteModeChanged.connect(self.setOverwriteMode) self.optionsDialog = OptionsDialog(self) self.optionsDialog.accepted.connect(self.optionsAccepted) self.searchDialog = SearchDialog(self, self.hexEdit) self.createActions() self.createMenus() self.createToolBars() self.createStatusBar() self.readSettings() def loadFile(self, fileName): file = QtCore.QFile(fileName) if not file.open( QtCore.QFile.ReadOnly | QtCore.QFile.Text): QtGui.QMessageBox.warning(self, "QHexEdit", "Cannot read file %s:\n%s." % (fileName, file.errorString())) return QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor) self.hexEdit.setData(file.readAll()) QtGui.QApplication.restoreOverrideCursor() self.setCurrentFile(fileName) self.statusBar().showMessage("File loaded", 2000) def open(self): fileName = QtGui.QFileDialog.getOpenFileName(self) if fileName: self.loadFile(fileName) def optionsAccepted(self): self.writeSettings() self.readSettings() def findNext(self): self.searchDialog.findNext() def readSettings(self): settings = QtCore.QSettings() if sys.version_info >= (3, 0): pos = settings.value('pos', QtCore.QPoint(200, 200)) size = settings.value('size', QtCore.QSize(610, 460)) self.hexEdit.setAddressArea(settings.value("AddressArea")=='true') self.hexEdit.setAsciiArea(settings.value("AsciiArea")=='true') self.hexEdit.setHighlighting(settings.value("Highlighting")=='true') self.hexEdit.setOverwriteMode(settings.value("OverwriteMode")=='true') self.hexEdit.setReadOnly(settings.value("ReadOnly")=='true') self.hexEdit.setHighlightingColor(QtGui.QColor(settings.value("HighlightingColor"))) self.hexEdit.setAddressAreaColor(QtGui.QColor(settings.value("AddressAreaColor"))) self.hexEdit.setSelectionColor(QtGui.QColor(settings.value("SelectionColor"))) self.hexEdit.setFont(QtGui.QFont(settings.value("WidgetFont", QtGui.QFont(QtGui.QFont("Courier New", 10))))) self.hexEdit.setAddressWidth(int(settings.value("AddressAreaWidth"))); else: pos = settings.value('pos', QtCore.QPoint(200, 200)).toPoint() size = settings.value('size', QtCore.QSize(610, 460)).toSize() self.hexEdit.setAddressArea(settings.value("AddressArea").toBool()) self.hexEdit.setAsciiArea(settings.value("AsciiArea").toBool()) self.hexEdit.setHighlighting(settings.value("Highlighting").toBool()) self.hexEdit.setOverwriteMode(settings.value("OverwriteMode").toBool()) self.hexEdit.setReadOnly(settings.value("ReadOnly").toBool()) self.hexEdit.setHighlightingColor(QtGui.QColor(settings.value("HighlightingColor"))) self.hexEdit.setAddressAreaColor(QtGui.QColor(settings.value("AddressAreaColor"))) self.hexEdit.setSelectionColor(QtGui.QColor(settings.value("SelectionColor"))) self.hexEdit.setFont(QtGui.QFont(settings.value("WidgetFont", QtGui.QFont(QtGui.QFont("Courier New", 10))))) self.hexEdit.setAddressWidth(settings.value("AddressAreaWidth").toInt()[0]); self.move(pos) self.resize(size) def save(self): if self.isUntitled: return self.saveAs() else: return self.saveFile(self.curFile) def saveAs(self): fileName = QtGui.QFileDialog.getSaveFileName(self, "Save As", self.curFile) if not fileName: return False return self.saveFile(fileName) def showOptionsDialog(self): self.optionsDialog.show() def showSearchDialog(self): self.searchDialog.show() def setAddress(self, address): self.lbAddress.setText('%x' % address) def setOverwriteMode(self, mode): settings = QtCore.QSettings() settings.setValue("OverwriteMode", mode) if mode: self.lbOverwriteMode.setText("Overwrite") else: self.lbOverwriteMode.setText("Insert") def setSize(self, size): self.lbSize.setText('%d' % size) def saveFile(self, fileName): file = QtCore.QFile(fileName) if not file.open( QtCore.QFile.WriteOnly | QtCore.QFile.Truncate): QtGui.QMessageBox.warning(self, "HexEdit", "Cannot write file %s:\n%s." % (fileName, file.errorString())) return False file.write(self.hexEdit.data()) self.setCurrentFile(fileName) self.statusBar().showMessage("File saved", 2000) return True def saveToReadableFile(self): fileName = QtGui.QFileDialog.getSaveFileName(self, "Save To Readable File") if not fileName.isEmpty(): file = open(str(fileName), "wb") file.write(str(self.hexEdit.toReadableString())) self.statusBar().showMessage("File saved", 2000); def saveSelectionToReadableFile(self): fileName = QtGui.QFileDialog.getSaveFileName(self, "Save To Readable File") if not fileName.isEmpty(): file = open(str(fileName), "wb") file.write(str(self.hexEdit.selectionToReadableString())) self.statusBar().showMessage("File saved", 2000); def setCurrentFile(self, fileName): self.curFile = fileName self.isUntitled = (fileName == "") self.setWindowModified(False) self.setWindowTitle("%s[*] - QHexEdit" % self.strippedName(self.curFile)) def strippedName(self, fullFileName): return QtCore.QFileInfo(fullFileName).fileName() def writeSettings(self): settings = QtCore.QSettings() settings.setValue('pos', self.pos()) settings.setValue('size', self.size()) if __name__ == '__main__': app = QtGui.QApplication(sys.argv) app.setApplicationName("QHexEdit"); app.setOrganizationName("QHexEdit"); mainWin = MainWindow() mainWin.show() sys.exit(app.exec_()) qhexedit2/python/python2_pyqt4/optionsdialog.ui0000644000175000017500000001706113716244704022147 0ustar carstencarsten OptionsDialog 0 0 395 351 Dialog Flags ReadOnly Higlighting Overwrite Mode Address Area Ascii Area Colors and Fonts Highlighting Color 100 0 16777215 16777215 QFrame::Panel QFrame::Sunken Address Area Color 100 0 16777215 16777215 QFrame::Panel QFrame::Sunken 100 0 16777215 16777215 QFrame::Panel QFrame::Sunken Selection Color Widget Font 0 0 Courier New 10 01 23 45 67 89 ab cd ef Address Area Address Area Width 1 6 4 Qt::Vertical 20 28 Qt::Horizontal QDialogButtonBox::Cancel|QDialogButtonBox::Ok pbHighlightingColor pbAddressAreaColor buttonBox buttonBox accepted() OptionsDialog accept() 222 154 157 168 buttonBox rejected() OptionsDialog reject() 290 160 286 168 qhexedit2/python/python2_pyqt4/qhexedit_rc.py0000644000175000017500000003433413716244704021610 0ustar carstencarsten# -*- coding: utf-8 -*- # Resource object code # # Created: Do. Apr 16 20:55:39 2015 # by: The Resource Compiler for PyQt (Qt v4.8.6) # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore qt_resource_data = b"\ \x00\x00\x04\xa3\ \x89\ \x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\ \x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\ \x00\x00\x00\x04\x67\x41\x4d\x41\x00\x00\xd6\xd8\xd4\x4f\x58\x32\ \x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\ \x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\ \x79\x71\xc9\x65\x3c\x00\x00\x04\x35\x49\x44\x41\x54\x58\xc3\xe5\ \x97\xcd\x8f\x54\x45\x14\xc5\x7f\xb7\xea\xd6\x7b\xaf\xdb\x6e\xc7\ \xf9\x40\x9d\x89\x46\x4d\x34\x99\x44\x8d\x1a\x48\x98\xc4\x8c\x1f\ \x1b\xfe\x02\x4c\x5c\xf1\x07\x18\x16\x2e\x4d\x5c\x6b\x58\xc3\x8e\ \xc4\x8d\x1b\x17\xce\x82\x68\x74\x41\x5c\x18\x0d\xe2\xc4\xc6\x00\ \x3d\x60\x50\x51\x19\x60\x02\xa2\x0e\x0c\x83\xd3\xfd\x5e\xf7\x94\ \x8b\xaa\xee\xf9\x60\xe6\x0d\x84\x51\x16\x56\x52\xa9\xce\x7b\xb7\ \xeb\x9e\x3a\xf7\xd4\xa9\x7a\xea\xbd\xe7\x7e\x36\xe5\x3e\xb7\x3e\ \x80\x5d\xbb\x76\xbd\x03\xec\xfd\x8f\xf2\x4e\x35\x1a\x8d\x03\xeb\ \x19\xd8\xbb\xef\xbd\xa3\x3b\x1f\x1f\x76\x00\x9c\x3c\x3a\xcf\xcc\ \x97\x37\x58\x9c\xef\xdc\x53\xa6\xda\xa0\xf2\xdc\x6b\x03\xbc\xb8\ \x67\x10\x80\x8b\x7f\x16\x7c\xf8\xee\x1e\x80\xdb\x00\x70\xfc\xec\ \x1c\xdf\x3f\x30\x04\x78\x2e\xfd\xb8\xc0\xfe\xb7\xce\x6f\xcb\x72\ \x0f\x1d\x79\x9a\x0b\x23\x96\xd3\x9f\x1f\x64\xfc\xd5\x7d\x9b\x6b\ \x40\x45\xb0\x16\x40\x78\x70\x2c\x23\xcb\xb2\x6d\x01\x30\x30\x96\ \x61\x8d\x50\x1b\x7c\x14\x23\x25\x22\x14\x2b\xd8\x18\x91\xd5\x95\ \x73\xe7\xce\x83\x2a\xb8\x04\xd2\x14\xb2\x0c\xd2\x2c\x8c\x49\x0a\ \x49\x12\xde\x77\x3a\x90\xe7\x90\xb7\xa1\xd5\x82\x76\x2b\x8e\x6d\ \x28\x72\xb2\xfa\x38\xd6\x0a\xe3\xaf\xbc\x49\x6b\xf1\xfa\xe6\x00\ \xac\x15\xac\x15\x04\xb0\x46\xd8\xbd\x7b\xe7\x16\x6b\xeb\x86\xae\ \x80\x5a\xa8\x56\x81\xea\x6d\x51\x8d\xaf\x04\xb5\x82\xf7\xa0\xa6\ \x84\x01\x67\x05\x35\x82\x08\xa8\x0a\x95\x2c\xc3\x23\x20\x1e\x08\ \xc0\xf0\x1e\x2f\x02\xde\x23\x12\x26\x15\x7c\x88\x23\xc4\x21\x1e\ \x3c\x21\x5e\x40\x4d\x58\x18\x40\xd7\x4a\x89\x06\xac\xa0\xda\x63\ \x00\x9a\x33\xbf\x05\x8a\x53\x07\x69\x02\x95\x04\xb2\x34\xf6\x04\ \x12\x07\x4e\xa1\xe8\x40\x5e\x40\x2b\x8f\xbd\x05\x4b\x39\xb4\x73\ \xc8\x0b\x54\x87\x71\x3d\x00\x2a\xe5\x25\x70\x31\x40\xd5\x30\x39\ \xf9\xd2\xd6\x0a\xf3\x3e\xd0\xaf\x16\xaa\x1b\x8b\xf6\xd8\x27\x61\ \x61\xbd\x1c\x25\x25\x20\x00\xf0\x81\x8d\x34\x4d\xa3\x3a\xc3\xb3\ \x98\x11\x89\x6c\x07\xda\x63\x09\x56\x98\x5f\x29\x46\xfc\x61\xcd\ \x72\x7f\x61\x1d\x2d\xd1\x80\x3a\x09\x54\x49\x18\x4f\x34\x2f\xe0\ \x9d\x85\xc4\x21\x89\xc3\x67\x09\x92\x69\xd8\x11\x89\xe2\x13\x87\ \x58\x8b\xef\x76\x91\xbc\x80\xbc\x03\xed\x02\xdf\x6a\x23\xed\x02\ \xf2\x02\x9f\x77\x50\x1d\x45\xd5\x20\x78\x3a\xeb\x54\x78\x9b\x06\ \x9c\x33\x78\x0f\x03\x8f\x24\xbc\xfe\xf2\xf3\x77\x68\xe8\x36\x68\ \xa4\xbe\xf1\xeb\xc6\xfc\xdf\xb1\x04\x52\x5e\x82\x44\x4d\x5f\x84\ \x8f\x0d\xa5\x38\xe7\xb6\xc5\x88\x9e\x18\x4b\xb9\x76\xb3\x03\x08\ \x9d\x52\x11\xaa\x90\xb8\x50\xef\x5a\xc5\x30\x7d\xb1\xcb\x40\xc5\ \xb0\x0e\xf4\x26\xad\x57\xf9\x55\x2e\xe1\xe1\xc6\xd2\x32\xf5\xcc\ \x70\x7d\xc9\x84\x2d\xe9\x4a\x19\x10\x9c\x1a\xc0\x73\xe5\x66\x97\ \x2b\x37\xbb\xac\x51\x57\x3f\xd7\xaa\x64\x7e\xc5\x27\xa2\x29\xac\ \x05\x15\xc3\x9c\x0b\xb5\x77\xa6\x6c\x17\xa8\xc1\xa9\x20\xc8\x1a\ \x35\xaf\x9b\x35\x1a\x8f\x59\x31\x9e\xfe\x7b\xe9\xef\x14\x00\xf1\ \x82\xef\x9b\x58\x30\x2b\x57\x56\x02\x55\x21\xd1\x90\xfc\xe7\x53\ \xdf\xf2\xeb\x99\x13\x2c\x2d\xde\xb8\xa7\xfa\x57\x6a\x03\x3c\xf5\ \xec\x4e\x9e\x79\x61\x02\x0f\xa8\x33\x5b\x31\x10\x03\x7c\x87\xf7\ \xf7\xbf\xc1\xc2\xc2\x02\xb7\x6e\xdd\xa2\x28\x0a\x44\x04\x6b\x2d\ \xd6\x5a\x54\x15\x55\xc5\x39\x87\xaa\x62\xad\xc5\x98\xf0\xdf\xe5\ \xe5\x65\xf2\x3c\xef\xf7\x23\xcd\xf9\xb8\xf2\x2d\x18\x70\x56\x50\ \x17\x18\xdc\x31\x3a\xb6\x72\x4f\x38\x7e\x9c\xe9\xe9\x69\x8c\x31\ \x78\xef\x99\x98\x98\x60\x72\x72\xf2\x8e\x59\xd8\x31\x3a\xd6\xdf\ \x86\xae\xd4\x09\x55\x70\x36\xac\xa2\x56\xaf\xf7\x6b\x39\x33\x33\ \xc3\xd0\xd0\x10\xd6\x5a\xbc\xf7\x34\x9b\xcd\xbb\x02\x50\xab\xd7\ \x70\xd1\x88\xb4\xd4\x88\x14\x9c\x0b\x27\x5c\xa0\x2a\x00\xa8\x56\ \xab\x64\x59\xd6\xa7\xb8\x37\xde\x69\x73\x1a\xa9\x17\x41\x4b\xad\ \x38\x1e\xc7\xbd\x23\xb4\xd7\x8c\x31\x88\x44\xdf\x8f\x3a\xb8\xab\ \x9b\xaf\x35\xa8\x0d\xf3\xf6\x18\x2e\x3d\x8e\x83\x29\x6d\xe3\xd5\ \xdb\x12\xa9\xf7\xe5\x56\x6c\xad\xf4\x91\x0e\x8e\x0c\xc3\xf2\xef\ \xdb\x02\xe0\xa1\x91\x61\xd4\xc2\xb5\x2b\x97\x59\x9c\xbf\xbe\x05\ \x03\x36\xf8\xc0\x60\xad\x02\x0b\xdb\xc3\xc0\x50\xad\xc2\xec\xc5\ \x4b\x9c\xfd\xee\x1b\xce\x9f\x9c\x9e\x03\xa6\x36\x04\x60\x24\x5e\ \x4a\x05\x12\x0b\xed\x91\x27\xa9\x3d\x0c\x6f\x1f\x38\xc8\x66\xc7\ \x81\x27\x3a\xf1\x2a\xe7\x35\x1e\x32\x81\x14\x28\xba\x70\xf9\xea\ \x55\xce\x34\x8e\xd1\xfc\xfa\x8b\xb9\xd9\x1f\x4e\x1d\x02\x0e\x6f\ \x08\xe0\xb3\x8f\x3e\xe0\xa7\xd3\x27\x57\x99\xe9\xda\xa3\x86\x55\ \xe6\xbb\x1e\x04\x1b\x3c\x5f\x1d\x6f\x7c\x77\xee\x8f\xd9\x5f\x0e\ \x01\x87\x1b\x8d\xc6\x5f\x1b\x01\x98\x9a\xfe\xf4\xe3\x7f\xf5\x73\ \x6c\x7d\xf2\x35\x00\xe2\xb7\xda\x81\xff\xdd\xd7\xf1\x3f\x4d\xf0\ \x4b\xb9\xe8\x46\x89\xaf\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\ \x60\x82\ \x00\x00\x08\x19\ \x89\ \x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\ \x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\ \x00\x00\x00\x04\x67\x41\x4d\x41\x00\x00\xd6\xd8\xd4\x4f\x58\x32\ \x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\x74\x77\x61\x72\x65\ \x00\x41\x64\x6f\x62\x65\x20\x49\x6d\x61\x67\x65\x52\x65\x61\x64\ \x79\x71\xc9\x65\x3c\x00\x00\x07\xab\x49\x44\x41\x54\x58\xc3\xad\ \x57\x5b\x50\x93\x67\x1a\xf6\xca\xce\xec\xcc\xf6\x62\x2f\xbc\xd9\ \xe9\xce\xec\x6e\xbd\xda\xd9\x9b\xb5\xce\xba\x3b\x7b\xb0\xad\xcc\ \x7a\xb1\xce\xce\x3a\xb3\x76\x54\x70\x75\xdb\xe2\x81\xd6\xb6\x54\ \x04\xbb\xa5\x20\x6d\xc1\x82\x06\x08\x07\x51\x42\x80\x80\x80\x02\ \x21\x81\x10\x92\x40\x48\x10\x73\x24\x21\x67\x72\x80\x04\x42\x20\ \x9c\x09\x47\xb5\x54\x78\xf6\xfb\x7e\x13\x16\x30\x58\x8b\x7d\x67\ \x9e\xf9\x2f\x92\xfc\xcf\xfb\x3e\xcf\xfb\xbe\xdf\x97\x5d\x00\x76\ \xfd\x98\x20\xf1\x0b\x82\x14\x02\x03\xc1\x75\x82\x03\xcf\xfd\xfe\ \x8f\x48\xbc\x9b\x20\xe1\x57\xaf\xef\xb5\x2a\x8c\xd6\x65\xdb\x02\ \x60\x19\x1e\x5b\x09\x27\xf1\x33\xfa\x19\x81\x22\xfc\xdc\x3e\x76\ \x48\x7e\x8a\xa0\xb9\xb6\x59\x1c\x32\xcf\xad\x42\x39\xfe\x1d\x44\ \xf6\x51\xd8\xc7\xe6\xe8\x87\x86\x3d\x7b\xf6\x58\x53\x52\xae\x2c\ \xca\x3a\x3a\x10\x4e\xe2\xe5\x49\xc3\xc4\x31\x04\xb7\x3e\x49\xf9\ \x2c\x60\x9b\x5d\x59\x53\x4d\x03\x4d\xb6\x11\x34\xeb\xfb\x20\x31\ \x79\x60\x19\x9d\xc5\xbb\xef\xbe\x3f\xc5\xab\xbe\x83\xf1\x89\x29\ \x4c\x4f\xcf\xae\x92\xef\xd7\xbc\x74\x02\x11\x9f\x0f\xbe\x1d\xe3\ \xb2\x04\x43\x4f\xb4\x33\x40\x8b\x7b\x06\xcd\x3d\x2e\x34\xeb\xec\ \xa8\x57\xf6\x20\x87\x53\x85\x32\x5e\x35\x43\xbc\xb0\xf4\x90\x81\ \xc1\x60\x5c\x26\xbf\x4b\x7c\xe1\x04\x48\x1c\x24\x38\x41\xfd\xdd\ \xea\x73\x27\xf1\xb9\x27\x04\x48\x87\x97\xc1\xd7\xbb\x20\x22\x55\ \x37\xdc\x37\xa2\xb8\x4e\x88\x2c\x56\x3e\xcc\x56\xdb\x3a\x71\x04\ \x2c\x16\x6b\x2c\xfc\xce\xe7\x27\x10\x91\x36\x93\x95\x3f\x46\x7d\ \xa5\xfe\x12\xc4\x6f\xf4\x59\x31\xb6\x02\x7e\xef\x20\x5a\x7b\x9c\ \xe0\x3f\x30\xa1\x4c\x28\x43\x46\x0e\x1b\xb2\x0e\xf9\x26\xd2\xf9\ \xc5\x65\xcc\x2d\x2c\x21\x34\xbf\x88\xbd\x7b\xf7\x5a\xc9\x3b\x7e\ \xba\x6d\x02\x24\x7e\x43\x90\x46\x3d\x35\x13\x69\x75\xb3\x80\xd2\ \x3f\x0f\xcb\xc4\xe2\x9a\x50\xa1\x5a\xb4\x6c\xf1\x59\xa0\xb6\xa0\ \xa6\x5d\x8d\x2f\xb2\x73\x71\xb7\x9e\xff\x0c\x31\x25\x9d\x09\xcd\ \x63\x62\x6a\x06\x83\x43\x81\x27\xe4\xdd\xbc\x2d\xd3\xb0\x3b\x92\ \x03\x33\x26\xd4\x53\xb5\xd3\xfb\x58\x4f\x88\xc5\x03\x21\x88\x2c\ \x43\x50\xba\x46\xd0\xed\x09\x42\xe5\x9b\x42\x9b\x73\xfc\xa9\xcf\ \x5a\x1b\xee\x2a\x74\xc8\xbc\xc9\x45\x09\xa7\x6c\x93\xcf\x9b\x88\ \x27\xa7\x11\x18\x1d\xc3\x80\x6f\x08\xa2\xd6\xd6\x25\xc2\x51\xdb\ \x28\x12\x87\xc6\x1f\xaf\x82\x2f\x62\x94\x4d\x89\x24\x90\x22\xea\ \x52\x2d\x9a\x42\xab\xe8\x18\x79\x04\xa1\xc5\xcf\x10\x53\x74\xf6\ \x0d\xa3\xd3\xe1\x87\xd4\x3c\x80\x16\xbd\x03\x0d\x5d\x06\x14\xd5\ \x0a\x90\x91\x95\x0d\x2f\x79\xf1\xc6\xaa\xa9\xd4\xb3\x73\x0b\x4c\ \xc5\x94\xd8\xdd\xef\x85\xc9\x62\x05\xb7\xbc\x12\xa5\xe5\x95\x4b\ \x13\xf3\xcb\xab\x23\x0f\x01\x37\xd9\x11\xe6\xd9\x15\x84\x97\x15\ \x13\x06\xcb\x3c\xd0\x68\xf2\xa3\xdd\xee\x5f\x27\x96\x3b\x86\x20\ \xb3\x78\xd7\x7d\xe6\x08\xa4\xf8\x3c\x33\x1b\x2a\x8d\x36\xaa\xdc\ \x53\x33\x21\x8c\x8e\x8d\x33\x15\xd3\x26\xe4\x37\x09\xf1\xc1\xc5\ \x8f\x51\x73\xaf\x01\xbe\x65\x60\xfc\x11\xa0\x23\x13\x23\xf2\xce\ \xa1\xbe\x5d\xb9\xb8\x51\x01\x83\x81\x74\x74\x4d\xa7\x1e\x0a\x67\ \x80\xa9\xb8\xdd\xea\x83\xd8\xe8\x42\x93\xca\xcc\xf8\x7c\xe5\xcb\ \x2c\x88\xda\x24\x51\x89\xa7\x67\xe7\x18\x1b\x86\x86\x47\x60\x77\ \x38\x49\x82\x3a\x24\x7c\xf8\x21\xae\xb3\x0b\xe1\x99\x5c\x80\x6f\ \x09\xd0\x90\xde\xe1\x0f\x2c\x81\xab\x1f\xc4\x7d\xef\x04\xdd\x07\ \x1d\x61\xeb\xff\x9f\xc0\x1d\xb9\x16\x1d\xf6\x21\x48\xcc\xfd\x4f\ \x7d\xee\xd4\x22\x9d\x55\x84\xaa\x9a\xba\x4d\x3e\x47\xe4\x8e\xf8\ \x3c\x3c\x12\x84\xd3\xdd\x0f\xbd\xc1\x88\xc2\xe2\x62\x9c\x7e\x2f\ \x1e\x3d\x03\x01\xf4\x2f\x02\x83\x84\xbc\xc5\xff\x2d\xee\x3a\x43\ \x28\x51\x91\xf7\xf6\x05\xf1\x4e\xdc\xbf\x7d\x84\x33\x69\xe3\x20\ \x18\xf4\x33\xab\xe0\xc9\x54\x68\x35\x38\xd1\xd8\xdd\x0b\x9e\x58\ \x89\xac\x5c\xf6\x33\x3e\x47\xaa\x9e\x9c\x9e\x65\xe4\xee\xf7\x0e\ \xa2\xd7\x6c\x41\x43\x03\x1f\x27\x62\xe3\x20\xe9\xd6\xc0\x45\xcf\ \x01\x52\x90\x24\xb8\x86\xb2\x9e\x00\x6e\xb4\xdb\x50\xd1\x1b\x44\ \x85\xce\x8b\x4a\x7e\x0b\x6d\xbe\x9b\x5b\x27\xd1\xa0\x99\xf8\x16\ \x65\x22\x05\xee\x29\xf4\x28\x13\xc8\x90\x78\x35\x0b\x1a\xad\x3e\ \xaa\xdc\x63\x13\x93\xf0\x0d\x0d\xc3\x66\xef\x83\xb4\x5d\x8e\xc4\ \x4b\x97\x90\xc3\xca\xc3\xd4\x63\xc0\x4e\x7a\x49\x31\x4e\xfa\x89\ \x94\x7f\x5b\x3b\x84\x7c\x85\x13\x25\x6a\x1f\x4a\xd5\x03\xe8\xf2\ \x30\xa3\x28\x22\xf8\xf9\x33\x09\x74\x8f\x2e\xa1\xa8\xbe\x15\xa5\ \x7c\x09\xb2\x4a\x2a\xf0\xcf\xe3\x71\x51\xe5\xf6\x07\x46\xd1\xe7\ \xf2\x40\xab\x37\x20\xfd\x6a\x06\x92\xbf\x48\x83\xcd\x37\x02\x27\ \xa9\xda\x40\x1a\x4c\xe0\x7b\x88\x52\x9d\x1f\x45\xdd\xfd\x0c\x71\ \x41\x97\x1b\xc5\xdd\x1e\x88\x9c\x41\xfc\xf9\xcd\xb7\x5d\x84\xeb\ \x6c\xb4\x43\xd0\x28\xf7\x4e\x23\xa7\xfc\x1e\xb2\x4b\xab\xf1\x51\ \xea\x57\x48\xfe\x6f\xea\xfa\x58\x51\xb9\x47\x82\xe3\xf0\x0c\xf8\ \x60\x34\x99\x51\xc9\xab\xc2\xfb\x67\xcf\x41\xfe\x40\x03\x3f\xe9\ \x6e\xb2\x8d\x19\xb9\x6f\x69\x06\x19\xd2\x9b\x2a\x2f\x72\xe5\x0e\ \xe4\x75\xf6\xa1\xf0\xbe\x1b\x1c\x95\x1b\xf9\x9c\xca\x29\xc2\x53\ \xb8\xdd\x29\xdc\x2b\x76\x04\x90\x51\xc8\xc5\x95\x6b\x79\x38\x11\ \x9f\x80\x9b\xb7\x6e\x33\x63\x15\x91\xdb\x6a\x73\x40\x22\x6d\xc7\ \x85\x84\x0f\x50\x74\xbb\x0c\xf3\x2b\x80\x9f\x34\x58\xf7\x24\x20\ \x1c\x7c\x84\x4a\xd3\x18\x38\xfa\x61\x86\x9c\x56\xfd\x55\xb3\x1e\ \xac\x0e\x3b\xb8\x3a\x1f\xd9\x21\x1e\x7a\x2f\xe0\x13\xbc\xba\x5d\ \x02\x26\xbe\xc1\x83\x94\x6f\xd8\x38\x9f\x9c\x8a\x03\x7f\x3d\x04\ \x63\xaf\x99\xe9\x6e\x2a\xb7\x46\xd7\x83\xa4\xcb\xc9\x48\xff\x3a\ \x8b\x8c\xd5\x3c\x53\xb5\x71\xf6\xa9\xdc\x35\xf6\x69\x5c\x97\x59\ \x19\xd9\xbf\x6e\x21\xa7\xa0\xd4\x82\x74\xbe\x1a\x57\x9b\x34\x60\ \xc9\xcc\x10\xbb\x82\xf8\xe5\xaf\x5f\xa7\x67\xc0\x3b\xe1\x75\x1f\ \x35\xcc\x35\xdd\x66\x7c\x94\x96\x85\xb8\x73\x17\xf1\x97\x43\x31\ \x4c\xd5\x74\x99\xf0\xaa\xaa\x71\xfa\xf4\x19\x68\xcc\x0e\x8c\x92\ \x2d\x36\x14\x1e\xab\x5a\xc7\x0c\x78\xe6\x71\x70\x0d\x23\x4c\xa3\ \x65\x8a\x0c\x8c\xec\xb4\xfa\x9c\xb6\x5e\x94\x74\x39\xd0\x66\xf7\ \xaf\x1e\x3d\x11\x4b\x47\x2e\x6f\xc3\x79\x13\x35\x2c\x5c\x99\x1a\ \xf1\x97\x3e\xc7\xd1\xd8\x33\xf8\x38\x31\x09\x86\x5e\x13\x1a\x9b\ \x04\xf8\xdd\x1b\xfb\x51\x4f\xd4\xf1\x90\x99\xee\x9a\x00\xaa\xad\ \x93\x60\x2b\x5d\x0c\x39\xf5\xbc\xf0\xbe\x67\xbd\xea\xcc\x16\x3d\ \x4a\x55\x1e\x08\x6d\x01\x94\xd4\xf1\x43\xe1\x65\x53\x40\xf0\xca\ \xf7\x25\x60\x2b\x6e\x6a\xc7\xa9\x84\x44\xc4\x1c\x39\x8a\xdc\x7c\ \x36\x5a\x5a\xc5\x38\x14\x13\x83\x2f\x39\x35\xc8\x14\x6a\x98\xe6\ \xa2\xd5\xd2\x27\xf5\x9a\x7a\x4c\x13\xa1\x49\x64\xb7\x99\x90\xdb\ \x6e\x46\xb9\xda\x8d\x06\xa5\x76\x39\x2c\x39\x3d\xf9\x4e\x13\xec\ \xd9\x72\xd4\x47\x0d\x3b\xab\x46\x88\x63\xff\x39\x8f\xdf\xee\xfb\ \x3d\x1a\xf9\x02\x9c\xbf\x90\x80\x93\xf1\x17\x70\xa3\xad\x07\x19\ \xc4\x4f\x4a\x14\xe9\x6e\xba\x58\xa8\xef\x2c\xfa\x94\x98\x50\x28\ \xb7\x40\xe9\x0e\x3c\xf9\x57\xec\x29\x2a\x77\x2d\xc1\x67\x04\xfb\ \xb6\xb9\xe4\x44\x8d\xbe\xcc\xb2\x5a\xfc\xe3\xe4\x19\x1c\x3c\xf4\ \x37\xb0\x72\xf3\xb0\xef\xc0\x1f\x50\x20\xd1\x21\x89\x27\x65\x2a\ \xa6\x4b\x85\x3e\xbf\x21\xd5\x46\xe4\x2e\x90\x5b\x21\xb0\x0c\xae\ \xe5\xdc\xe2\xd2\x11\x13\x13\xe4\x87\x6f\x3c\xaf\x3c\xe7\x96\x15\ \x35\x9c\x69\x45\xe5\xf8\xfb\xb1\x58\x1c\x3f\x19\x87\x37\xf6\xef\ \xc7\x8d\x3a\x11\x92\xab\xa4\x0c\x21\xed\x70\xea\x35\x55\x21\x8b\ \x34\x5b\xc9\x03\x37\x2a\x34\x6e\xd4\x49\x3a\x17\xc3\x72\x73\x08\ \x8e\x6d\x95\xfb\x87\x24\xe0\x4a\x65\x73\x70\xe4\xf8\x29\x1c\x3e\ \x7c\x98\x8c\x63\x2e\x32\x05\x2a\x5c\x22\xd5\xd3\x5d\x7e\x4d\xdc\ \x0b\x36\xe9\x74\x76\xa7\x1d\x77\x8c\xe4\x88\xb6\xf9\x9e\x84\xb7\ \x1a\x95\xfb\x22\xbd\x49\xfd\x80\x0b\x6d\xf4\x04\x32\x4a\x78\x4c\ \x0f\x9c\x4b\x49\xc3\xb5\xa6\x2e\x7c\xc2\x6d\x65\x36\x59\xf1\x83\ \x01\x5c\x97\x9a\xc1\x51\x7b\x20\xf3\x04\xd7\xce\x25\x26\x05\x36\ \xc8\xfd\xc7\x9d\xc8\x1d\xd5\x82\xdc\x1a\x01\xce\x5e\x4e\x45\x81\ \x58\x85\x78\xf6\x5d\x5c\xa9\x55\x90\xaa\xfb\xc0\x96\xdb\x50\xad\ \x75\xe3\xae\x54\x41\x2f\x10\xca\x0d\x72\xbf\xba\xd3\x6a\xa3\x05\ \xb7\xa2\x51\xf8\x1d\xaf\x43\x8d\x4f\xb9\x2d\x88\xcb\xe6\xe1\x9a\ \x48\x8f\xaa\x1e\x2f\x9a\x35\xe6\xc7\x7f\x7a\xf3\x2d\x57\x78\xac\ \xa8\xdc\xaf\xbd\xac\xdc\xd1\xe2\x08\xdd\x05\x5c\x75\x1f\xde\xcb\ \xaf\x45\xb9\x76\x00\x32\x67\x60\xf5\xc2\xa7\x97\xa9\xdc\xf7\x08\ \xd2\xa9\xdc\x3b\xf8\x03\xf3\xc2\xf1\x13\x82\xca\x1c\xee\x9d\x50\ \x0b\x39\x94\xb8\x0d\xc2\xc8\x16\xa3\x17\x87\xc3\x2f\x22\xf7\x0e\ \xff\xda\x6d\x8a\xdd\x61\x99\xd5\x1b\xb6\xd8\x6b\xbb\x5e\x32\xbe\ \x2f\x89\xff\x01\x66\xb9\x5f\xfc\x11\x80\x3d\xcf\x00\x00\x00\x00\ \x49\x45\x4e\x44\xae\x42\x60\x82\ " qt_resource_name = b"\ \x00\x06\ \x07\x03\x7d\xc3\ \x00\x69\ \x00\x6d\x00\x61\x00\x67\x00\x65\x00\x73\ \x00\x08\ \x08\xc8\x58\x67\ \x00\x73\ \x00\x61\x00\x76\x00\x65\x00\x2e\x00\x70\x00\x6e\x00\x67\ \x00\x08\ \x06\xc1\x59\x87\ \x00\x6f\ \x00\x70\x00\x65\x00\x6e\x00\x2e\x00\x70\x00\x6e\x00\x67\ " qt_resource_struct = b"\ \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ \x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x02\ \x00\x00\x00\x28\x00\x00\x00\x00\x00\x01\x00\x00\x04\xa7\ \x00\x00\x00\x12\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ " def qInitResources(): QtCore.qRegisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data) def qCleanupResources(): QtCore.qUnregisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data) qInitResources() qhexedit2/python/python2_pyqt4/Ui_optionsdialog.py0000644000175000017500000002141613716244704022616 0ustar carstencarsten# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'optionsdialog.ui' # # Created: Thu May 28 21:45:32 2015 # by: PyQt4 UI code generator 4.10.4 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: def _fromUtf8(s): return s try: _encoding = QtGui.QApplication.UnicodeUTF8 def _translate(context, text, disambig): return QtGui.QApplication.translate(context, text, disambig, _encoding) except AttributeError: def _translate(context, text, disambig): return QtGui.QApplication.translate(context, text, disambig) class Ui_OptionsDialog(object): def setupUi(self, OptionsDialog): OptionsDialog.setObjectName(_fromUtf8("OptionsDialog")) OptionsDialog.resize(395, 351) self.verticalLayout = QtGui.QVBoxLayout(OptionsDialog) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.gbFlags = QtGui.QGroupBox(OptionsDialog) self.gbFlags.setObjectName(_fromUtf8("gbFlags")) self.gridLayout_2 = QtGui.QGridLayout(self.gbFlags) self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2")) self.cbReadOnly = QtGui.QCheckBox(self.gbFlags) self.cbReadOnly.setObjectName(_fromUtf8("cbReadOnly")) self.gridLayout_2.addWidget(self.cbReadOnly, 3, 0, 1, 1) self.cbHighlighting = QtGui.QCheckBox(self.gbFlags) self.cbHighlighting.setObjectName(_fromUtf8("cbHighlighting")) self.gridLayout_2.addWidget(self.cbHighlighting, 2, 0, 1, 1) self.cbOverwriteMode = QtGui.QCheckBox(self.gbFlags) self.cbOverwriteMode.setObjectName(_fromUtf8("cbOverwriteMode")) self.gridLayout_2.addWidget(self.cbOverwriteMode, 1, 0, 1, 1) self.cbAddressArea = QtGui.QCheckBox(self.gbFlags) self.cbAddressArea.setObjectName(_fromUtf8("cbAddressArea")) self.gridLayout_2.addWidget(self.cbAddressArea, 1, 1, 1, 1) self.cbAsciiArea = QtGui.QCheckBox(self.gbFlags) self.cbAsciiArea.setObjectName(_fromUtf8("cbAsciiArea")) self.gridLayout_2.addWidget(self.cbAsciiArea, 2, 1, 1, 1) self.verticalLayout.addWidget(self.gbFlags) self.gbColors = QtGui.QGroupBox(OptionsDialog) self.gbColors.setObjectName(_fromUtf8("gbColors")) self.gridLayout = QtGui.QGridLayout(self.gbColors) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) self.pbHighlightingColor = QtGui.QPushButton(self.gbColors) self.pbHighlightingColor.setObjectName(_fromUtf8("pbHighlightingColor")) self.gridLayout.addWidget(self.pbHighlightingColor, 0, 0, 1, 1) self.lbHighlightingColor = QtGui.QLabel(self.gbColors) self.lbHighlightingColor.setMinimumSize(QtCore.QSize(100, 0)) self.lbHighlightingColor.setMaximumSize(QtCore.QSize(16777215, 16777215)) self.lbHighlightingColor.setFrameShape(QtGui.QFrame.Panel) self.lbHighlightingColor.setFrameShadow(QtGui.QFrame.Sunken) self.lbHighlightingColor.setText(_fromUtf8("")) self.lbHighlightingColor.setObjectName(_fromUtf8("lbHighlightingColor")) self.gridLayout.addWidget(self.lbHighlightingColor, 0, 1, 1, 1) self.pbAddressAreaColor = QtGui.QPushButton(self.gbColors) self.pbAddressAreaColor.setObjectName(_fromUtf8("pbAddressAreaColor")) self.gridLayout.addWidget(self.pbAddressAreaColor, 1, 0, 2, 1) self.lbAddressAreaColor = QtGui.QLabel(self.gbColors) self.lbAddressAreaColor.setMinimumSize(QtCore.QSize(100, 0)) self.lbAddressAreaColor.setMaximumSize(QtCore.QSize(16777215, 16777215)) self.lbAddressAreaColor.setFrameShape(QtGui.QFrame.Panel) self.lbAddressAreaColor.setFrameShadow(QtGui.QFrame.Sunken) self.lbAddressAreaColor.setText(_fromUtf8("")) self.lbAddressAreaColor.setObjectName(_fromUtf8("lbAddressAreaColor")) self.gridLayout.addWidget(self.lbAddressAreaColor, 1, 1, 2, 1) self.lbSelectionColor = QtGui.QLabel(self.gbColors) self.lbSelectionColor.setMinimumSize(QtCore.QSize(100, 0)) self.lbSelectionColor.setMaximumSize(QtCore.QSize(16777215, 16777215)) self.lbSelectionColor.setFrameShape(QtGui.QFrame.Panel) self.lbSelectionColor.setFrameShadow(QtGui.QFrame.Sunken) self.lbSelectionColor.setText(_fromUtf8("")) self.lbSelectionColor.setObjectName(_fromUtf8("lbSelectionColor")) self.gridLayout.addWidget(self.lbSelectionColor, 3, 1, 1, 1) self.pbSelectionColor = QtGui.QPushButton(self.gbColors) self.pbSelectionColor.setObjectName(_fromUtf8("pbSelectionColor")) self.gridLayout.addWidget(self.pbSelectionColor, 3, 0, 1, 1) self.pbWidgetFont = QtGui.QPushButton(self.gbColors) self.pbWidgetFont.setObjectName(_fromUtf8("pbWidgetFont")) self.gridLayout.addWidget(self.pbWidgetFont, 4, 0, 1, 1) self.leWidgetFont = QtGui.QLineEdit(self.gbColors) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.leWidgetFont.sizePolicy().hasHeightForWidth()) self.leWidgetFont.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setFamily(_fromUtf8("Courier New")) font.setPointSize(10) self.leWidgetFont.setFont(font) self.leWidgetFont.setObjectName(_fromUtf8("leWidgetFont")) self.gridLayout.addWidget(self.leWidgetFont, 4, 1, 1, 1) self.verticalLayout.addWidget(self.gbColors) self.gbAddressAreaWidth = QtGui.QGroupBox(OptionsDialog) self.gbAddressAreaWidth.setObjectName(_fromUtf8("gbAddressAreaWidth")) self.gridLayout_3 = QtGui.QGridLayout(self.gbAddressAreaWidth) self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3")) self.lbAddressAreaWidth = QtGui.QLabel(self.gbAddressAreaWidth) self.lbAddressAreaWidth.setObjectName(_fromUtf8("lbAddressAreaWidth")) self.gridLayout_3.addWidget(self.lbAddressAreaWidth, 0, 0, 1, 1) self.sbAddressAreaWidth = QtGui.QSpinBox(self.gbAddressAreaWidth) self.sbAddressAreaWidth.setMinimum(1) self.sbAddressAreaWidth.setMaximum(6) self.sbAddressAreaWidth.setProperty("value", 4) self.sbAddressAreaWidth.setObjectName(_fromUtf8("sbAddressAreaWidth")) self.gridLayout_3.addWidget(self.sbAddressAreaWidth, 0, 1, 1, 1) self.verticalLayout.addWidget(self.gbAddressAreaWidth) spacerItem = QtGui.QSpacerItem(20, 28, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem) self.buttonBox = QtGui.QDialogButtonBox(OptionsDialog) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) self.buttonBox.setObjectName(_fromUtf8("buttonBox")) self.verticalLayout.addWidget(self.buttonBox) self.retranslateUi(OptionsDialog) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), OptionsDialog.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), OptionsDialog.reject) QtCore.QMetaObject.connectSlotsByName(OptionsDialog) OptionsDialog.setTabOrder(self.pbHighlightingColor, self.pbAddressAreaColor) OptionsDialog.setTabOrder(self.pbAddressAreaColor, self.buttonBox) def retranslateUi(self, OptionsDialog): OptionsDialog.setWindowTitle(_translate("OptionsDialog", "Dialog", None)) self.gbFlags.setTitle(_translate("OptionsDialog", "Flags", None)) self.cbReadOnly.setText(_translate("OptionsDialog", "ReadOnly", None)) self.cbHighlighting.setText(_translate("OptionsDialog", "Higlighting", None)) self.cbOverwriteMode.setText(_translate("OptionsDialog", "Overwrite Mode", None)) self.cbAddressArea.setText(_translate("OptionsDialog", "Address Area", None)) self.cbAsciiArea.setText(_translate("OptionsDialog", "Ascii Area", None)) self.gbColors.setTitle(_translate("OptionsDialog", "Colors and Fonts", None)) self.pbHighlightingColor.setText(_translate("OptionsDialog", "Highlighting Color", None)) self.pbAddressAreaColor.setText(_translate("OptionsDialog", "Address Area Color", None)) self.pbSelectionColor.setText(_translate("OptionsDialog", "Selection Color", None)) self.pbWidgetFont.setText(_translate("OptionsDialog", "Widget Font", None)) self.leWidgetFont.setText(_translate("OptionsDialog", "01 23 45 67 89 ab cd ef", None)) self.gbAddressAreaWidth.setTitle(_translate("OptionsDialog", "Address Area", None)) self.lbAddressAreaWidth.setText(_translate("OptionsDialog", "Address Area Width", None)) qhexedit2/python/python2_pyqt4/qhexedit.qrc0000644000175000017500000000020413716244704021246 0ustar carstencarsten images/open.png images/save.png qhexedit2/python/python2_pyqt4/searchdialog.ui0000644000175000017500000001220313716244704021712 0ustar carstencarsten SearchDialog 0 0 436 223 QHexEdit - Find/Replace Find Hex UTF-8 0 0 true Replace Hex UTF-8 0 0 true Options &Backwards &Prompt on replace &Find F3 true &Replace Replace &All &Close Qt::Vertical 20 40 cbFind cbReplace cbFindFormat cbReplaceFormat cbBackwards cbPrompt pbFind pbReplace pbReplaceAll pbCancel pbCancel clicked() SearchDialog hide() 360 134 364 162 qhexedit2/python/python2_pyqt4/Ui_searchdialog.py0000644000175000017500000001604713716244704022374 0ustar carstencarsten# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'searchdialog.ui' # # Created: Thu May 28 21:45:19 2015 # by: PyQt4 UI code generator 4.10.4 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: def _fromUtf8(s): return s try: _encoding = QtGui.QApplication.UnicodeUTF8 def _translate(context, text, disambig): return QtGui.QApplication.translate(context, text, disambig, _encoding) except AttributeError: def _translate(context, text, disambig): return QtGui.QApplication.translate(context, text, disambig) class Ui_SearchDialog(object): def setupUi(self, SearchDialog): SearchDialog.setObjectName(_fromUtf8("SearchDialog")) SearchDialog.resize(436, 223) self.horizontalLayout_3 = QtGui.QHBoxLayout(SearchDialog) self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3")) self.verticalLayout_2 = QtGui.QVBoxLayout() self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) self.gbFind = QtGui.QGroupBox(SearchDialog) self.gbFind.setObjectName(_fromUtf8("gbFind")) self.horizontalLayout = QtGui.QHBoxLayout(self.gbFind) self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.cbFindFormat = QtGui.QComboBox(self.gbFind) self.cbFindFormat.setObjectName(_fromUtf8("cbFindFormat")) self.cbFindFormat.addItem(_fromUtf8("")) self.cbFindFormat.addItem(_fromUtf8("")) self.horizontalLayout.addWidget(self.cbFindFormat) self.cbFind = QtGui.QComboBox(self.gbFind) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.cbFind.sizePolicy().hasHeightForWidth()) self.cbFind.setSizePolicy(sizePolicy) self.cbFind.setEditable(True) self.cbFind.setObjectName(_fromUtf8("cbFind")) self.horizontalLayout.addWidget(self.cbFind) self.verticalLayout_2.addWidget(self.gbFind) self.gbReplace = QtGui.QGroupBox(SearchDialog) self.gbReplace.setObjectName(_fromUtf8("gbReplace")) self.horizontalLayout_2 = QtGui.QHBoxLayout(self.gbReplace) self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) self.cbReplaceFormat = QtGui.QComboBox(self.gbReplace) self.cbReplaceFormat.setObjectName(_fromUtf8("cbReplaceFormat")) self.cbReplaceFormat.addItem(_fromUtf8("")) self.cbReplaceFormat.addItem(_fromUtf8("")) self.horizontalLayout_2.addWidget(self.cbReplaceFormat) self.cbReplace = QtGui.QComboBox(self.gbReplace) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.cbReplace.sizePolicy().hasHeightForWidth()) self.cbReplace.setSizePolicy(sizePolicy) self.cbReplace.setEditable(True) self.cbReplace.setObjectName(_fromUtf8("cbReplace")) self.horizontalLayout_2.addWidget(self.cbReplace) self.verticalLayout_2.addWidget(self.gbReplace) self.gbOptions = QtGui.QGroupBox(SearchDialog) self.gbOptions.setObjectName(_fromUtf8("gbOptions")) self.verticalLayout_3 = QtGui.QVBoxLayout(self.gbOptions) self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3")) self.cbBackwards = QtGui.QCheckBox(self.gbOptions) self.cbBackwards.setObjectName(_fromUtf8("cbBackwards")) self.verticalLayout_3.addWidget(self.cbBackwards) self.cbPrompt = QtGui.QCheckBox(self.gbOptions) self.cbPrompt.setObjectName(_fromUtf8("cbPrompt")) self.verticalLayout_3.addWidget(self.cbPrompt) self.verticalLayout_2.addWidget(self.gbOptions) self.horizontalLayout_3.addLayout(self.verticalLayout_2) self.verticalLayout = QtGui.QVBoxLayout() self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.pbFind = QtGui.QPushButton(SearchDialog) self.pbFind.setDefault(True) self.pbFind.setObjectName(_fromUtf8("pbFind")) self.verticalLayout.addWidget(self.pbFind) self.pbReplace = QtGui.QPushButton(SearchDialog) self.pbReplace.setObjectName(_fromUtf8("pbReplace")) self.verticalLayout.addWidget(self.pbReplace) self.pbReplaceAll = QtGui.QPushButton(SearchDialog) self.pbReplaceAll.setObjectName(_fromUtf8("pbReplaceAll")) self.verticalLayout.addWidget(self.pbReplaceAll) self.pbCancel = QtGui.QPushButton(SearchDialog) self.pbCancel.setObjectName(_fromUtf8("pbCancel")) self.verticalLayout.addWidget(self.pbCancel) spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem) self.horizontalLayout_3.addLayout(self.verticalLayout) self.retranslateUi(SearchDialog) QtCore.QObject.connect(self.pbCancel, QtCore.SIGNAL(_fromUtf8("clicked()")), SearchDialog.hide) QtCore.QMetaObject.connectSlotsByName(SearchDialog) SearchDialog.setTabOrder(self.cbFind, self.cbReplace) SearchDialog.setTabOrder(self.cbReplace, self.cbFindFormat) SearchDialog.setTabOrder(self.cbFindFormat, self.cbReplaceFormat) SearchDialog.setTabOrder(self.cbReplaceFormat, self.cbBackwards) SearchDialog.setTabOrder(self.cbBackwards, self.cbPrompt) SearchDialog.setTabOrder(self.cbPrompt, self.pbFind) SearchDialog.setTabOrder(self.pbFind, self.pbReplace) SearchDialog.setTabOrder(self.pbReplace, self.pbReplaceAll) SearchDialog.setTabOrder(self.pbReplaceAll, self.pbCancel) def retranslateUi(self, SearchDialog): SearchDialog.setWindowTitle(_translate("SearchDialog", "QHexEdit - Find/Replace", None)) self.gbFind.setTitle(_translate("SearchDialog", "Find", None)) self.cbFindFormat.setItemText(0, _translate("SearchDialog", "Hex", None)) self.cbFindFormat.setItemText(1, _translate("SearchDialog", "UTF-8", None)) self.gbReplace.setTitle(_translate("SearchDialog", "Replace", None)) self.cbReplaceFormat.setItemText(0, _translate("SearchDialog", "Hex", None)) self.cbReplaceFormat.setItemText(1, _translate("SearchDialog", "UTF-8", None)) self.gbOptions.setTitle(_translate("SearchDialog", "Options", None)) self.cbBackwards.setText(_translate("SearchDialog", "&Backwards", None)) self.cbPrompt.setText(_translate("SearchDialog", "&Prompt on replace", None)) self.pbFind.setText(_translate("SearchDialog", "&Find", None)) self.pbFind.setShortcut(_translate("SearchDialog", "F3", None)) self.pbReplace.setText(_translate("SearchDialog", "&Replace", None)) self.pbReplaceAll.setText(_translate("SearchDialog", "Replace &All", None)) self.pbCancel.setText(_translate("SearchDialog", "&Close", None)) qhexedit2/python/python2_pyqt4/images/0000700000175000017500000000000013716244704020163 5ustar carstencarstenqhexedit2/python/python2_pyqt4/images/open.png0000644000175000017500000000403113716244704021642 0ustar carstencarstenPNG  IHDR szzgAMAOX2tEXtSoftwareAdobe ImageReadyqe<IDATXíW[Pgb/nٛκ;{z:vTpuֶT mQB!@Hs$!grB GTx~0X}g/>ߗ]v uH W*e`[ '3">vH~Y2ϭB9DQ臆={XSR,::NI1>I,`]YSMM4 1y`Ż?ū)LOϮ׼tCO3@{=.4W S2^5C`\&K|H$8As''H׻ "U77N,V>V:q,k,'6?F}oY1~ Z{?0L(CF&e-,!4{Z;~m$~CF=5iu?PZlY]/sq 1% cbjC'ݼ-Ӱ;3&SXO!,CPF BBsZ*tȼE lϛ'Ào%Q(/bM$"R-BySt < ] /yƪԳs LŔbK˫#7G<<b~/=/-:C(QNܿ}3i 3Th58 X\3>GelAC'b ER$nPD΋J~ m['Ѡe")(Ȑx5 >c f]KcNzI1N[;|%jJ0("3 t.| J*qQF@7 jH7'@L{RE qAAͷ]lC(N#KQWHoXQG `4QɫgA@?noiқ*/ru)S)+vQŕky8n3cjs@"mDžPt +4X$ |J8aVU;:!z/]&o8=cn*F׃H:381 ^QO`+] 9g=JUmCeS@%`+njǩD9|6ZZ8/95j'zLIdnFڍv9,9=NrG ;Fc9=pOJnX,P(@!F.[! o<<5iEX?7Ǎ: !p5U!4[7*4nI:rsm$Jesp)>|c.2*\"]~M 6tvw䈶"I m2JxLKIõ.|me6Y\Q{ %&6ǝՂ^NEXx]\UPuTA/ rjQCO-H/5z-Wxܯ\u˯Ev2g`§ҩ;P 9 /"mak^2/f_=IENDB`qhexedit2/python/python2_pyqt4/images/save.png0000644000175000017500000000224313716244704021642 0ustar carstencarstenPNG  IHDR szzgAMAOX2tEXtSoftwareAdobe ImageReadyqe<5IDATX͏TE{n@FM4DHČL\.M\kXÎč΂htA\ =`PQ` ^` QVR{:ԩz~6>>]vN5ػ」;v<:̗7XSڠkg|p?0x.ory #ӟd}k@E@xp,#˲m00aP|#%"+Օs΃* ,I Iw:琷Ղv+m(r8 㯼IkFؽ{k놮ZVmQg5 ,# /#&|#!Я'aa%% 4M:ólc V_)Fara-р: TIO4/!g iXvj#wPE x:Tx3x$wh6h߱R^DM_ 8ňKvRPZ0}@Ű&WU.2p}Ʉ-Jsf+7QW?תd~')Ü wl 55Y1{X0+WVU!ѐS,-޸Wj'WڣU<_o|w__sl}5ځ?MKFIENDB`qhexedit2/python/python3_pyqt5/0000700000175000017500000000000013716244704016720 5ustar carstencarstenqhexedit2/python/python3_pyqt5/mainwindow.py0000644000175000017500000000100713716244704021456 0ustar carstencarstenimport sys from PyQt5 import QtWidgets from qhexedit import QHexEdit class HexEdit(QHexEdit): def __init__(self, fileName=None): super(HexEdit, self).__init__() file = open(fileName, 'rb') data = file.read() self.setData(data) self.setReadOnly(False) if __name__ == '__main__': app = QtWidgets.QApplication(sys.argv) mainWin = HexEdit('mainwindow.py') mainWin.resize(600, 400) mainWin.move(300, 300) mainWin.show() sys.exit(app.exec_()) qhexedit2/delete.sh0000755000175000017500000000054713716244704014452 0ustar carstencarstensudo rm -f /usr/lib/libqhexedit* # Python 2 sudo rm -f /usr/local/lib/python2.7/dist-packages/qhexedit* sudo rm -f /usr/local/lib/python2.7/dist-packages/QHexEdit* # Python 3 sudo rm -f /usr/local/lib/python3.4/dist-packages/qhexedit.cpython-34m.so sudo rm -f /usr/local/lib/python3.4/dist-packages/QHexEdit-0.7.2.egg-info sudo rm -f -R build mkdir build qhexedit2/build-python-bindings.sh0000755000175000017500000000057613716244704017423 0ustar carstencarstenif [ ! -d build ];then mkdir build else rm -rf build/* fi cd build # for Qt4 use qt4-qmake # /usr/share/qt4/bin/qmake ../src/qhexedit.pro # for Qt5 use qt5-qmake /usr/lib/x86_64-linux-gnu/qt5/bin/qmake ../src/qhexedit.pro sudo make cd .. # for PyQt4 use python2 and PyQt4 # sudo python2 setup.py install # for PyQt5 use python3 and PyQt5 sudo python3 setup.py install qhexedit2/deploy.nsi0000644000175000017500000001301413716244704014651 0ustar carstencarsten#!define VERSION "0.0.1" !define QT "C:\Qt\5.5\mingw492_32\bin\" !define BUILD_DIR "C:\dev\qhexedit\build\release\" !define TRANS_DIR "C:\dev\qhexedit\example\translations\" !define OUTFILE_NAME "C:\dev\qhexedit\build\QHexEdit.exe" !define INSTALLATIONNAME "QHexEdit" ;-------------------------------- ;Include Modern UI !include "MUI2.nsh" ;-------------------------------- ;General ;Name and file Name ${INSTALLATIONNAME} OutFile ${OUTFILE_NAME} SetCompressor lzma ;Default installation folder InstallDir "$PROGRAMFILES\QHexEdit" ;Get installation folder from registry if available InstallDirRegKey HKCU "Software\${INSTALLATIONNAME}" "" ;Request application privileges for Windows Vista !define MULTIUSER_EXECUTIONLEVEL Highest !define MULTIUSER_MUI !define MULTIUSER_INSTALLMODE_COMMANDLINE !include MultiUser.nsh ;-------------------------------- ;Interface Settings # !define MUI_HEADERIMAGE # !define MUI_HEADERIMAGE_BITMAP "cm_header.bmp" # !define MUI_HEADERIMAGE_UNBITMAP "cm_un-header.bmp" # !define MUI_WELCOMEFINISHPAGE_BITMAP "cm_wizard.bmp" # !define MUI_UNWELCOMEFINISHPAGE_BITMAP "cm_un-wizard.bmp" # !define MUI_ICON "myIcons.ico" # !define MUI_UNICON "unicon.ico" !define MUI_ABORTWARNING ;Show all languages, despite user's codepage # !define MUI_LANGDLL_ALLLANGUAGES ;-------------------------------- ;Language Selection Dialog Settings ;Remember the installer language !define MUI_LANGDLL_REGISTRY_ROOT "SHCTX" !define MUI_LANGDLL_REGISTRY_KEY "Software\${INSTALLATIONNAME}" !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language" ;Start Menu Folder Page Configuration !define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX" !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\${INSTALLATIONNAME}" !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" ;-------------------------------- ;Pages !insertmacro MUI_PAGE_WELCOME # !insertmacro MUI_PAGE_LICENSE $(license) !insertmacro MUI_PAGE_COMPONENTS !insertmacro MULTIUSER_PAGE_INSTALLMODE !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH !insertmacro MUI_UNPAGE_WELCOME !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_UNPAGE_FINISH ;-------------------------------- ;Languages !insertmacro MUI_LANGUAGE "English" ;first language is the default Language !insertmacro MUI_LANGUAGE "German" ;-------------------------------- ;Reserve Files ;If you are using solid compression, files that are required before ;the actual installation should be stored first in the data block, ;because this will make your installer start faster. !insertmacro MUI_RESERVEFILE_LANGDLL ;-------------------------------- ;Installer Sections Section "" SetOutPath $INSTDIR File ${BUILD_DIR}qhexedit.exe File /r ${BUILD_DIR}*.dll File ${TRANS_DIR}*.qm WriteUninstaller $INSTDIR\uninstall.exe WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${INSTALLATIONNAME}" "DisplayName" "QHexEdit Installer" WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${INSTALLATIONNAME}" "UninstallString" '"$INSTDIR\uninstall.exe"' WriteRegDWORD SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${INSTALLATIONNAME}" "NoModify" 1 WriteRegDWORD SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${INSTALLATIONNAME}" "NoRepair" 1 WriteRegStr SHCTX "Software\${INSTALLATIONNAME}" "" $INSTDIR SectionEnd Section $(startmenu) Startmenu CreateDirectory "$SMPROGRAMS\${INSTALLATIONNAME}" CreateShortCut "$SMPROGRAMS\${INSTALLATIONNAME}\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 CreateShortCut "$SMPROGRAMS\${INSTALLATIONNAME}\QHexEdit.lnk" "$INSTDIR\qhexedit.exe" "" "$INSTDIR\qhexedit.exe" 0 SectionEnd Section /o $(desktop) Desktop CreateShortCut "$DESKTOP\QHexEdit.lnk" "$INSTDIR\qhexedit.exe" "" "$INSTDIR\qhexedit.exe" 0 SectionEnd ;-------------------------------- ;Installer Functions Function .onInit !insertmacro MULTIUSER_INIT !insertmacro MUI_LANGDLL_DISPLAY FunctionEnd ;-------------------------------- ;Descriptions #LicenseLangString license ${LANG_ENGLISH} license.rtf #LicenseLangString license ${LANG_GERMAN} license_de.rtf LangString startmenu ${LANG_ENGLISH} "Add to Start Menu" LangString startmenu ${LANG_GERMAN} "Eintrag ins Startmenü" LangString DESC_Startmenu ${LANG_ENGLISH} "Add an Entry to the Start Menu" LangString DESC_Startmenu ${LANG_GERMAN} "Einen Eintrag ins Startmenü hinzufügen" LangString desktop ${LANG_ENGLISH} "Add a Desktop Icon" LangString desktop ${LANG_GERMAN} "Zum Desktop hinzufügen" LangString DESC_Desktop ${LANG_ENGLISH} "Add an Icon to the Desktop" LangString DESC_Desktop ${LANG_GERMAN} "Einen Eintrag zum Desktop hinzufügen" !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${Startmenu} $(DESC_Startmenu) !insertmacro MUI_DESCRIPTION_TEXT ${Desktop} $(DESC_Desktop) !insertmacro MUI_FUNCTION_DESCRIPTION_END ;-------------------------------- ;Uninstaller Section Section "Uninstall" DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${INSTALLATIONNAME}" DeleteRegKey SHCTX "Software\${INSTALLATIONNAME}" RMDir /r $INSTDIR Delete "$SMPROGRAMS\${INSTALLATIONNAME}\Uninstall.lnk" Delete "$SMPROGRAMS\${INSTALLATIONNAME}\QHexEdit.lnk" Delete "$DESKTOP\QHexEdit.lnk" RMDir "$SMPROGRAMS\${INSTALLATIONNAME}" SectionEnd ;-------------------------------- ;Uninstaller Functions Function un.onInit !insertmacro MULTIUSER_UNINIT !insertmacro MUI_UNGETLANGUAGE FunctionEnd qhexedit2/readme.md0000644000175000017500000000624013716244704014424 0ustar carstencarstenQHexEdit2 ========= ![Application QHexEdit2 in Action](http://simsys.github.io/qhexedit.png) QHexEdit is a hex editor widget written in C++ for the Qt (Qt4, Qt5) framework. It is a simple editor for binary data, just like QPlainTextEdit is for text data. There are sip configuration files included, so it is easy to create bindings for PyQt and you can use this widget also in python 2 and 3. QHexEdit takes the data of a QByteArray (setData()) and shows it. You can use the mouse or the keyboard to navigate inside the widget. If you hit the keys (0..9, a..f) you will change the data. Changed data is highlighted and can be accessed via data(). Normally QHexEdit works in the overwrite mode. You can set overwrite mode(false) and insert data. In this case the size of data() increases. It is also possible to delete bytes (del or backspace), here the size of data decreases. You can select data with keyboard hits or mouse movements. The copy-key will copy the selected data into the clipboard. The cut-key copies also but deletes it afterwards. In overwrite mode, the paste function overwrites the content of the (does not change the length) data. In insert mode, clipboard data will be inserted. The clipboard content is expected in ASCII Hex notation. Unknown characters will be ignored. QHexEdit comes with undo/redo functionality. All changes can be undone, by pressing the undo-key (usually ctr-z). They can also be redone afterwards. The undo/redo framework is cleared, when setData() sets up a new content for the editor. You can search data inside the content with indexOf() and lastIndexOf(). The replace() function is to change located subdata. This 'replaced' data can also be undone by the undo/redo framework. QHexEdit is based on QIODevice, that's why QHexEdit can handle big amounts of data. The size of edited data can be more then two gigabytes without any restrictions. ## Using QHexEdit You can read the documentation of the project [here](http://simsys.github.io/). You find in the sources a [C++ example](https://github.com/Simsys/qhexedit2/tree/master/example), that shows how tu use the QHexedit widget. There is also a [python example](https://github.com/Simsys/qhexedit2/tree/master/python/python3_pyqt5) available. ## Contributing to QHexEdit We love to receive contributions. You can submit bug reports [here](https://github.com/Simsys/qhexedit2/issues). If you are a developer, you can pick up a work item and start to realize super exciting features or fix bugs. We also like to receive enhancement proposals or translation support. ## License ``` Copyright (C) 2015-2016 Winfried Simon This software may be used under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation and appearing in the file license.txt included in the packaging of this file. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ``` qhexedit2/example/0000700000175000017500000000000013716244704014264 5ustar carstencarstenqhexedit2/example/searchdialog.h0000644000175000017500000000126313716244704017076 0ustar carstencarsten#ifndef SEARCHDIALOG_H #define SEARCHDIALOG_H #include #include #include "../src/qhexedit.h" namespace Ui { class SearchDialog; } class SearchDialog : public QDialog { Q_OBJECT public: explicit SearchDialog(QHexEdit *hexEdit, QWidget *parent = 0); ~SearchDialog(); qint64 findNext(); Ui::SearchDialog *ui; private slots: void on_pbFind_clicked(); void on_pbReplace_clicked(); void on_pbReplaceAll_clicked(); private: QByteArray getContent(int comboIndex, const QString &input); qint64 replaceOccurrence(qint64 idx, const QByteArray &replaceBa); QHexEdit *_hexEdit; QByteArray _findBa; }; #endif // SEARCHDIALOG_H qhexedit2/example/translations/0000700000175000017500000000000013716244704017005 5ustar carstencarstenqhexedit2/example/translations/qhexedit_de.qm0000644000175000017500000001622713716244704021651 0ustar carstencarstenbu`?W z4{p6^~ > i2`S%s\ "'):Ol{{RaE @6lxx}\[$^V!Y~%%8'$ t /  H yb 1 9Pq z n em QS }d \ S  ^~( `lM 5 hs l< B s *.0qZTT)e Rg!$i &ber&About MainWindow&Beearbeiten&Edit MainWindow &Datei&File MainWindow &Suchen/Ersetzen &Find/Replace MainWindow &Hilfe&Help MainWindowf&fnen...&Open... MainWindow&Optionen&Options MainWindow&Rckgngig&Redo MainWindow&Speichern&Save MainWindowL&Auswahl in lesbarer Form speichern...&Save Selection Readable... MainWindow"&Wiederherstellen&Undo MainWindowber &Qt About &Qt MainWindowber QHexEditAbout QHexEdit MainWindowAdresse:Address: MainWindow<Kann Datei %1 nicht lesen: %2.Cannot read file %1: %2. MainWindow<Kann Datei %1 nicht schreiben.Cannot write file %1. MainWindowDKann Detei %1 nicht schreiben: %2.Cannot write file %1: %2. MainWindowDatei erhalten: Drop File:  MainWindow&BeendenE&xit MainWindowBearbeitenEdit MainWindow&Applikation beendenExit the application MainWindow DateiFile MainWindowDatei geladen File loaded MainWindow"Datei gespeichert File saved MainWindow&Weitersuchen Find &next MainWindowpZeige die nchste Fundstelle mit dem gleichen Suchmuster,Find next occurrence of the searched pattern MainWindowEinfgenInsert MainWindow Mode:Mode: MainWindow2Existierende Datei ffnenOpen an existing file MainWindowberschreiben Overwrite MainWindowQHexEditQHexEdit MainWindow FertigReady MainWindowSDISDI MainWindow&Speichern &unter... Save &As... MainWindow>Als &lesbare Datei speichern...Save &Readable... MainWindowSpeichern unterSave As MainWindow6Als lesbare Datei speichernSave To Readable File MainWindowNDas Dokument in lesbarer From speichernSave document in readable form MainWindowLSpeichere die Auswahl in lesbarer FormSave selection in readable form MainWindow:Dokument auf Platte speichernSave the document to disk MainWindowHDokument unter neuem Namen speichern"Save the document under a new name MainWindow@Zeige den Suchen/Ersetzen Dialog)Show the Dialog for finding and replacing MainWindowrZeige den Dialog, um Optionen der Anwendunge einzustellen.Show the Dialog to select applications options MainWindow6Zeige Informationen ber QtShow the Qt library's About box MainWindowDZeige Informationen zur Anwendungj Show the application's About box MainWindow Gre:Size: MainWindowDas QHexEdit Beispiel ist eine einfache Demo Anwendung fr das QHexEdit Widget. MainWindow About HexEdit O HexEdit The HexEdit example is a short Demo of the QHexEdit Widget. Příklad HexEdit je krátká ukázka doplňku QHexEdit. Save As Uložit jako Save To Readable File Uložit do čitelného souboru HexEdit HexEdit About QHexEdit The QHexEdit example is a short Demo of the QHexEdit Widget. QHexEdit Cannot write file %1: %2. Nelze zapsat soubor %1: %2. File saved Soubor uložen Overwrite Přepsat Insert Vložit &Open... &Otevřít... Open an existing file Otevřít stávající soubor &Save &Uložit Save the document to disk Uložit dokument na disk Save &As... Uložit &jako... Save the document under a new name Uložit dokument pod novým názvem Save &Readable... Uložit Č&itelné... Save document in readable form Uložit dokument v čitelné podobě E&xit &Ukončit Exit the application Ukončit program &Undo &Zpět &Redo &Znovu &Save Selection Readable... &Uložit výběr čitelný... Save selection in readable form Uložit výběr v čitelné podobě &About &O programu Show the application's About box Ukázat informace o programu About &Qt O &Qt Show the Qt library's About box Ukázat informace oknihovně Qt Find next occurrence of the searched pattern &Options &Volby Show the Dialog to select applications options Ukázat dialog pro výběr voleb programu Edit Cannot write file %1. &Find/Replace Drop File: Show the Dialog for finding and replacing Find &next &File &Soubor &Edit Ú&pravy &Help &Nápověda Address: Adresa: Size: Velikost: Mode: Režim: Ready Připraven File Soubor SDI SDI Cannot read file %1: %2. Nelze číst soubor %1: %2. File loaded Soubor nahrán OptionsDialog Dialog Dialog QHexEdit - Options Flags Příznaky ReadOnly PouzeProČtení Higlighting Zvýraznění Overwrite Mode Režim přepisu Address Area Oblast s adresou Ascii Area Oblast ASCII Colors and Fonts Barvy a písma Highlighting Color Barva pro zvýraznění Address Area Color Barva pro oblast s adresou Selection Color Barva výběru Widget Font Písmo doplňku 01 23 45 67 89 ab cd ef 01 23 45 67 89 ab cd ef Address Area Width Šířka oblasti s adresou Hex Area Bytes per Line SearchDialog Dialog Dialog QHexEdit - Find/Replace Find Hex UTF-8 Replace Options &Backwards &Prompt on replace &Find F3 &Replace Replace &All &Close QHexEdit %1 occurrences replaced. Replace occurrence? UndoStack Inserting %1 bytes Delete %1 chars Overwrite %1 chars qhexedit2/example/translations/qhexedit_cs.qm0000644000175000017500000001024113716244704021654 0ustar carstencarsten @z4 1~\`S%s\Yl{aE l?xx1}\u^V Y $H t q yb  9P z n e} `lM hs l< / s  *.0q ReSRg ! ji&O programu&About MainWindow&pravy&Edit MainWindow&Soubor&File MainWindow&Npovda&Help MainWindow&OtevYt...&Open... MainWindow &Volby&Options MainWindow &Znovu&Redo MainWindow&Ulo~it&Save MainWindow0&Ulo~it vbr  iteln...&Save Selection Readable... MainWindow &Zpt&Undo MainWindow O &Qt About &Qt MainWindowAdresa:Address: MainWindow2Nelze  st soubor %1: %2.Cannot read file %1: %2. MainWindow6Nelze zapsat soubor %1: %2.Cannot write file %1: %2. MainWindow&Ukon itE&xit MainWindowUkon it programExit the application MainWindow SouborFile MainWindowSoubor nahrn File loaded MainWindowSoubor ulo~en File saved MainWindow Vlo~itInsert MainWindow Re~im:Mode: MainWindow0OtevYt stvajc souborOpen an existing file MainWindowPYepsat Overwrite MainWindowPYipravenReady MainWindowSDISDI MainWindowUlo~it &jako... Save &As... MainWindow$Ulo~it  &iteln...Save &Readable... MainWindowUlo~it jakoSave As MainWindow6Ulo~it do  itelnho souboruSave To Readable File MainWindow@Ulo~it dokument v  iteln podobSave document in readable form MainWindow:Ulo~it vbr v  iteln podobSave selection in readable form MainWindow.Ulo~it dokument na diskSave the document to disk MainWindow@Ulo~it dokument pod novm nzvem"Save the document under a new name MainWindowLUkzat dialog pro vbr voleb programu.Show the Dialog to select applications options MainWindow:Ukzat informace oknihovn QtShow the Qt library's About box MainWindow6Ukzat informace o programu Show the application's About box MainWindowVelikost:Size: MainWindow.01 23 45 67 89 ab cd ef01 23 45 67 89 ab cd ef OptionsDialog Oblast s adresou Address Area OptionsDialog4Barva pro oblast s adresouAddress Area Color OptionsDialog.`Yka oblasti s adresouAddress Area Width OptionsDialogOblast ASCII Ascii Area OptionsDialogBarvy a psmaColors and Fonts OptionsDialogPYznakyFlags OptionsDialog(Barva pro zvraznnHighlighting Color OptionsDialogZvraznn Higlighting OptionsDialogRe~im pYepisuOverwrite Mode OptionsDialogPouzePro tenReadOnly OptionsDialogBarva vbruSelection Color OptionsDialogPsmo doplHku Widget Font OptionsDialogqhexedit2/example/translations/qhexedit_ru.qm0000644000175000017500000001613013716244704021700 0ustar carstencarstenF `?W z4E{p6F~i`S%{s\"',)2:)l%{{baE rlxx}\$^'VeY 3~%%'$ t 2 /  : yb ] 9P/ z nm e Q } \ ST  ^~ `lM e hs l< sx *.0qTTe Rg!i& ?@>3@0<<5&About MainWindow& 540:B8@>20=85&Edit MainWindow &$09;&File MainWindow&>8A:/0<5=0 &Find/Replace MainWindow&><>IL&Help MainWindow&B:@KBL...&Open... MainWindow&0AB@>9:8&Options MainWindow&>2B>@5=85&Redo MainWindow&!>E@0=8BL&Save MainWindowD&!>E@0=8BL 2K45;5=>5 G8B015;L=>...&Save Selection Readable... MainWindow&B<5=0&Undo MainWindow@> &QT About &Qt MainWindow@> QHexEditAbout QHexEdit MainWindow 4@5A:Address: MainWindow<5 <>3C ?@>G8B0BL D09; %1: %2.Cannot read file %1: %2. MainWindow25 <>3C 70?8A0BL D09; %1.Cannot write file %1. MainWindow:5 <>3C 70?8A0BL D09; %1: %2.Cannot write file %1: %2. MainWindow &KE>4E&xit MainWindow 540:B8@>20=85Edit MainWindow&KE>4 87 ?@8;>65=8OExit the application MainWindow$09;File MainWindow$09; 703@C65= File loaded MainWindow$09; A>E@0=5= File saved MainWindow 09B8 &A;54CNI89 Find &next MainWindowX09B8 A;54CNI85 2E>645=85 ?>8A:>2>3> H01;>=0,Find next occurrence of the searched pattern MainWindowAB02:0Insert MainWindow  568<:Mode: MainWindow2B:@KBL ACI5AB2CNI89 D09;Open an existing file MainWindow 0<5=0 Overwrite MainWindowQHexEditQHexEdit MainWindow >B>2>Ready MainWindow"!>E@0=8BL &:0:... Save &As... MainWindow4!>E@0=8BL :0: &G8B05<K9...Save &Readable... MainWindow!>E@0=8BL :0:Save As MainWindow6!>E@0=8BL :0: G8B05<K9 D09;Save To Readable File MainWindowL!>E@0=8BL 4>:C<5=B 2 G8B015;L=>9 D>@<5Save document in readable form MainWindowN!>E@0=8BL 2K45;5=>5 2 G8B015;L=>9 D>@<5Save selection in readable form MainWindow4!>E@0=8BL 4>:C<5=B =0 48A:Save the document to disk MainWindowF!>E@0=8BL 4>:C<5=B ?>4 =>2K< 8<5=5<"Save the document under a new name MainWindowX>:070BL 480;>3>2>5 >:=> 4;O ?>8A:0 8 70<5=K)Show the Dialog for finding and replacing MainWindowb>:070BL 480;>3>2>5 >:=> 4;O CAB0=>2>: ?@8;>65=8O.Show the Dialog to select applications options MainWindowD>:070BL A>>1I5=85 > 181;8>B5:5 QTShow the Qt library's About box MainWindowZ>:070BL A>>1I5=85 @0AA:07K20NI55 > ?@>3@0<<5 Show the application's About box MainWindow 07<5@:Size: MainWindowQHexEdit ?@8<5@ MB> :>@>B:0O 45<>=AB@0F8O @01>BK QHexEdit :><?>=5=BK.1;0ABL Address Area OptionsDialog*&25B 04@5A=>9 >1;0AB8Address Area Color OptionsDialog.(8@8=0 04@5A=>9 >1;0AB8Address Area Width OptionsDialog1;0ABL ASCII Ascii Area OptionsDialog09B 2 AB@>:5Bytes per Line OptionsDialog&25B0 8 (@8DBKColors and Fonts OptionsDialog $;038Flags OptionsDialog2(5AB=04F0B8@8G=0O >1;0ABLHex Area OptionsDialog$&25B ?>4A25G820=8OHighlighting Color OptionsDialog>4A25G820=85 Higlighting OptionsDialog 568< 70<5=KOverwrite Mode OptionsDialog(QHexEdit - 0AB@>9:8QHexEdit - Options OptionsDialog">;L:> GB5=85ReadOnly OptionsDialog2&25B 4;O 2K1@0=>9 >1;0AB8Selection Color OptionsDialog((@8DB 4;O :><?>=5=BK Widget Font OptionsDialog@%1 =0945=KE D@03<5=B>2 70<5=5=>.%1 occurrences replaced. SearchDialog&1@0B=K9 ?>8A: &Backwards SearchDialog&0:@KBL&Close SearchDialog &09B8&Find SearchDialog8&@54C?@5640BL ?5@54 70<5=>9&Prompt on replace SearchDialog0&<5=8BL&Replace SearchDialogF3F3 SearchDialog 09B8Find SearchDialogHexHex SearchDialog0AB@>9:8Options SearchDialogQHexEditQHexEdit SearchDialog.QHExEdit - >8A:/0<5=0QHexEdit - Find/Replace SearchDialog 0<5=0Replace SearchDialog0<5=8BL &2AQ Replace &All SearchDialog$70<5=8BL =0945=>5?Replace occurrence? SearchDialog UTF-8UTF-8 SearchDialog&#40;8BL %1 A8<2>;>2Delete %1 chars UndoStack AB028BL %1 109BInserting %1 bytes UndoStack(0<5=8BL %1 A8<2>;>2Overwrite %1 chars UndoStack ) , qhexedit2/example/translations/qhexedit_ru.ts0000644000175000017500000004130113716244704021707 0ustar carstencarsten MainWindow About QHexEdit Про QHexEdit The QHexEdit example is a short Demo of the QHexEdit Widget. QHexEdit пример это короткая демонстрация работы QHexEdit компоненты. Save As Сохранить как Save To Readable File i hope it is text file with hex dump Сохранить как читаемый файл QHexEdit QHexEdit Cannot write file %1: %2. Не могу записать файл %1: %2. File saved Файл сохранен Overwrite Замена Insert Вставка &Open... &Открыть... Open an existing file Открыть существующий файл &Save &Сохранить Save the document to disk Сохранить документ на диск Save &As... Сохранить &как... Save the document under a new name Сохранить документ под новым именем Save &Readable... Сохранить как &читаемый... Save document in readable form Сохранить документ в читабельной форме E&xit В&ыход Exit the application Выход из приложения &Undo &Отмена &Redo &Повторение &Save Selection Readable... &Сохранить выделеное читабельно... Save selection in readable form Сохранить выделеное в читабельной форме &About &О программе Show the application's About box Показать сообщение рассказывающее о программе About &Qt Про &QT Show the Qt library's About box Показать сообщение о библиотеке QT &Find/Replace &Поиск/Замена Show the Dialog for finding and replacing Показать диалоговое окно для поиска и замены Find &next Найти &следующий Find next occurrence of the searched pattern Найти следующие вхождение поискового шаблона &Options &Настройки Show the Dialog to select applications options Показать диалоговое окно для установок приложения &File &Файл &Edit &Редактирование &Help &Помощь Address: Адрес: Size: Размер: Mode: Режим: Ready Готово File Файл Edit Редактирование Cannot read file %1: %2. Не могу прочитать файл %1: %2. File loaded Файл загружен Cannot write file %1. Не могу записать файл %1. OptionsDialog QHexEdit - Options QHexEdit - Настройки Flags Флаги ReadOnly Только чтение Higlighting Подсвечивание Overwrite Mode Режим замены Address Area Адресная область Ascii Area Область ASCII Colors and Fonts Цвета и Шрифты Highlighting Color Цвет подсвечивания Address Area Color Цвет адресной области Selection Color Цвет для выбраной области Widget Font Шрифт для компоненты 01 23 45 67 89 ab cd ef 01 23 45 67 89 ab cd ef Address Area Width Ширина адресной области Hex Area Шестнадцатиричная область Bytes per Line Байт в строке SearchDialog QHexEdit - Find/Replace QHExEdit - Поиск/Замена Find Найти Hex Hex UTF-8 UTF-8 Replace Замена Options Настройки &Backwards &Обратный поиск &Prompt on replace &Предупреждать перед заменой &Find &Найти F3 F3 &Replace За&менить Replace &All Заменить &всё &Close &Закрыть QHexEdit QHexEdit %1 occurrences replaced. %1 найденых фрагментов заменено. Replace occurrence? заменить найденое? UndoStack Inserting %1 bytes Вставить %1 байт Delete %1 chars Удалить %1 символов Overwrite %1 chars Заменить %1 символов qhexedit2/example/translations/qhexedit_de.ts0000644000175000017500000004175313716244704021664 0ustar carstencarsten MainWindow About HexEdit Über HexEdit The HexEdit example is a short Demo of the QHexEdit Widget. Das HexEdit Beispiel ist eine einfache Demo Anwendung für das QHexEdit Widget. Save As Speichern unter Save To Readable File Als lesbare Datei speichern HexEdit HexEdit About QHexEdit Über QHexEdit The QHexEdit example is a short Demo of the QHexEdit Widget. Das QHexEdit Beispiel ist eine einfache Demo Anwendung für das QHexEdit Widget. QHexEdit QHexEdit Cannot write file %1: %2. Kann Detei %1 nicht schreiben: %2. File saved Datei gespeichert Overwrite Überschreiben Insert Einfügen &Open... Öf&fnen... Open an existing file Existierende Datei öffnen &Save &Speichern Save the document to disk Dokument auf Platte speichern Save &As... Speichern &unter... Save the document under a new name Dokument unter neuem Namen speichern Save &Readable... Als &lesbare Datei speichern... Save document in readable form Das Dokument in lesbarer From speichern E&xit &Beenden Exit the application Applikation beenden &Undo &Wiederherstellen &Redo &Rückgängig &Save Selection Readable... &Auswahl in lesbarer Form speichern... Save selection in readable form Speichere die Auswahl in lesbarer Form &About Ü&ber Show the application's About box Zeige Informationen zur Anwendungj About &Qt Über &Qt Show the Qt library's About box Zeige Informationen über Qt Find next occurrence of the searched pattern Zeige die nächste Fundstelle mit dem gleichen Suchmuster &Options &Optionen Show the Dialog to select applications options Zeige den Dialog, um Optionen der Anwendunge einzustellen Edit Bearbeiten Cannot write file %1. Kann Datei %1 nicht schreiben. &Find/Replace &Suchen/Ersetzen Drop File: Datei erhalten: Show the Dialog for finding and replacing Zeige den Suchen/Ersetzen Dialog Find &next &Weitersuchen Find next occurance of the sarched pattern Zeige die nächste Fundstelle mit dem gleichen Suchmuster &File &Datei &Edit &Beearbeiten &Help &Hilfe Address: Adresse: Size: Größe: Mode: Mode: Ready Fertig File Datei SDI SDI Cannot read file %1: %2. Kann Datei %1 nicht lesen: %2. File loaded Datei geladen OptionsDialog Dialog Optionen QHexEdit - Options QHexEdit - Optionen Flags Eigenschaften ReadOnly Nur lesen Higlighting Hervorheben Overwrite Mode Überschreibe Modus Address Area Adressfeld Ascii Area Ascii-Feld Colors and Fonts Farben und Schriftarten Highlighting Color Farbe Hervorhebung Address Area Color Farbe Adressfeld Selection Color Farbe Markierung Widget Font Font-Auswahl 01 23 45 67 89 ab cd ef Address Area Width Hex Area Hexadezimalfeld Bytes per Line Bytes pro Zeile SearchDialog Dialog Optionen QHexEdit - Find/Replace QHexEdit - Suchen/Ersetzen Find Suchen Hex Hex UTF-8 UTF-8 Replace Ersetzen Options Optionen &Backwards &Rückwärts &Prompt on replace Vor dem Ersetzen &nachfragen &Find &Suchen F3 &Replace &Ersetzen Replace &All &Alle ersetzen &Close &Schließen QHexEdit QHexEdit %1 occurrences replaced. %1 Vorkommnisse ersetzt. Replace occurrence? Vorkommnis ersetzen? Replace occurrance? Vorkommnis ersetzen? UndoStack Inserting %1 bytes %1 Bytes eingefügt Delete %1 chars %1 Zeiche(n) gelöscht Overwrite %1 chars %1 Zeichen überschrieben qhexedit2/example/optionsdialog.cpp0000644000175000017500000001264213716244704017662 0ustar carstencarsten #include #include #include "optionsdialog.h" #include "ui_optionsdialog.h" OptionsDialog::OptionsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::OptionsDialog) { ui->setupUi(this); readSettings(); writeSettings(); } OptionsDialog::~OptionsDialog() { delete ui; } void OptionsDialog::show() { readSettings(); QWidget::show(); } void OptionsDialog::accept() { writeSettings(); emit accepted(); QDialog::hide(); } void OptionsDialog::readSettings() { QSettings settings; ui->cbAddressArea->setChecked(settings.value("AddressArea", true).toBool()); ui->cbAsciiArea->setChecked(settings.value("AsciiArea", true).toBool()); ui->cbHighlighting->setChecked(settings.value("Highlighting", true).toBool()); ui->cbOverwriteMode->setChecked(settings.value("OverwriteMode", true).toBool()); ui->cbReadOnly->setChecked(settings.value("ReadOnly").toBool()); setColor(ui->lbHighlightingColor, settings.value("HighlightingColor", QColor(0xff, 0xff, 0x99, 0xff)).value()); setColor(ui->lbSelectionColor, settings.value("SelectionColor", this->palette().highlight().color()).value()); setColor(ui->lbAddressAreaColor, settings.value("AddressAreaColor", this->palette().alternateBase().color()).value()); setColor(ui->lbAddressFontColor, settings.value("AddressFontColor", QPalette::WindowText).value()); setColor(ui->lbAsciiAreaColor, settings.value("AsciiAreaColor", this->palette().alternateBase().color()).value()); setColor(ui->lbAsciiFontColor, settings.value("AsciiFontColor", QPalette::WindowText).value()); setColor(ui->lbHexFontColor, settings.value("HexFontColor", QPalette::WindowText).value()); #ifdef Q_OS_WIN32 ui->leWidgetFont->setFont(settings.value("WidgetFont", QFont("Courier", 10)).value()); #else ui->leWidgetFont->setFont(settings.value("WidgetFont", QFont("Monospace", 10)).value()); #endif ui->sbAddressAreaWidth->setValue(settings.value("AddressAreaWidth", 4).toInt()); ui->sbBytesPerLine->setValue(settings.value("BytesPerLine", 16).toInt()); } void OptionsDialog::writeSettings() { QSettings settings; settings.setValue("AddressArea", ui->cbAddressArea->isChecked()); settings.setValue("AsciiArea", ui->cbAsciiArea->isChecked()); settings.setValue("Highlighting", ui->cbHighlighting->isChecked()); settings.setValue("OverwriteMode", ui->cbOverwriteMode->isChecked()); settings.setValue("ReadOnly", ui->cbReadOnly->isChecked()); settings.setValue("HighlightingColor", ui->lbHighlightingColor->palette().color(QPalette::Background)); settings.setValue("SelectionColor", ui->lbSelectionColor->palette().color(QPalette::Background)); settings.setValue("AddressAreaColor", ui->lbAddressAreaColor->palette().color(QPalette::Background)); settings.setValue("AddressFontColor", ui->lbAddressFontColor->palette().color(QPalette::Background)); settings.setValue("AsciiAreaColor", ui->lbAsciiAreaColor->palette().color(QPalette::Background)); settings.setValue("AsciiFontColor", ui->lbAsciiFontColor->palette().color(QPalette::Background)); settings.setValue("HexFontColor", ui->lbHexFontColor->palette().color(QPalette::Background)); settings.setValue("WidgetFont", ui->leWidgetFont->font()); settings.setValue("AddressAreaWidth", ui->sbAddressAreaWidth->value()); settings.setValue("BytesPerLine", ui->sbBytesPerLine->value()); } void OptionsDialog::setColor(QWidget *widget, QColor color) { QPalette palette = widget->palette(); palette.setColor(QPalette::Background, color); widget->setPalette(palette); widget->setAutoFillBackground(true); } void OptionsDialog::on_pbHighlightingColor_clicked() { QColor color = QColorDialog::getColor(ui->lbHighlightingColor->palette().color(QPalette::Background), this); if (color.isValid()) setColor(ui->lbHighlightingColor, color); } void OptionsDialog::on_pbAddressAreaColor_clicked() { QColor color = QColorDialog::getColor(ui->lbAddressAreaColor->palette().color(QPalette::Background), this); if (color.isValid()) setColor(ui->lbAddressAreaColor, color); } void OptionsDialog::on_pbAddressFontColor_clicked() { QColor color = QColorDialog::getColor(ui->lbAddressFontColor->palette().color(QPalette::WindowText), this); if (color.isValid()) setColor(ui->lbAddressFontColor, color); } void OptionsDialog::on_pbAsciiAreaColor_clicked() { QColor color = QColorDialog::getColor(ui->lbAsciiAreaColor->palette().color(QPalette::Background), this); if (color.isValid()) setColor(ui->lbAsciiAreaColor, color); } void OptionsDialog::on_pbAsciiFontColor_clicked() { QColor color = QColorDialog::getColor(ui->lbAsciiFontColor->palette().color(QPalette::WindowText), this); if (color.isValid()) setColor(ui->lbAsciiFontColor, color); } void OptionsDialog::on_pbHexFontColor_clicked() { QColor color = QColorDialog::getColor(ui->lbHexFontColor->palette().color(QPalette::WindowText), this); if (color.isValid()) setColor(ui->lbHexFontColor, color); } void OptionsDialog::on_pbSelectionColor_clicked() { QColor color = QColorDialog::getColor(ui->lbSelectionColor->palette().color(QPalette::Background), this); if (color.isValid()) setColor(ui->lbSelectionColor, color); } void OptionsDialog::on_pbWidgetFont_clicked() { bool ok; QFont font = QFontDialog::getFont(&ok, ui->leWidgetFont->font(), this); if (ok) ui->leWidgetFont->setFont(font); } qhexedit2/example/mainwindow.cpp0000644000175000017500000003305413716244704017163 0ustar carstencarsten#include #include #include #include #include #include #include #include #include #include #include #include #include "mainwindow.h" /*****************************************************************************/ /* Public methods */ /*****************************************************************************/ MainWindow::MainWindow() { setAcceptDrops( true ); init(); setCurrentFile(""); } /*****************************************************************************/ /* Protected methods */ /*****************************************************************************/ void MainWindow::closeEvent(QCloseEvent *) { writeSettings(); } void MainWindow::dragEnterEvent(QDragEnterEvent *event) { if (event->mimeData()->hasUrls()) event->accept(); } void MainWindow::dropEvent(QDropEvent *event) { if (event->mimeData()->hasUrls()) { QList urls = event->mimeData()->urls(); QString filePath = urls.at(0).toLocalFile(); loadFile(filePath); event->accept(); } } /*****************************************************************************/ /* Private Slots */ /*****************************************************************************/ void MainWindow::about() { QMessageBox::about(this, tr("About QHexEdit"), tr("The QHexEdit example is a short Demo of the QHexEdit Widget.")); } void MainWindow::dataChanged() { setWindowModified(hexEdit->isModified()); } void MainWindow::open() { QString fileName = QFileDialog::getOpenFileName(this); if (!fileName.isEmpty()) { loadFile(fileName); } } void MainWindow::optionsAccepted() { writeSettings(); readSettings(); } void MainWindow::findNext() { searchDialog->findNext(); } bool MainWindow::save() { if (isUntitled) { return saveAs(); } else { return saveFile(curFile); } } bool MainWindow::saveAs() { QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), curFile); if (fileName.isEmpty()) return false; return saveFile(fileName); } void MainWindow::saveSelectionToReadableFile() { QString fileName = QFileDialog::getSaveFileName(this, tr("Save To Readable File")); if (!fileName.isEmpty()) { QFile file(fileName); if (!file.open(QFile::WriteOnly | QFile::Text)) { QMessageBox::warning(this, tr("QHexEdit"), tr("Cannot write file %1:\n%2.") .arg(fileName) .arg(file.errorString())); return; } QApplication::setOverrideCursor(Qt::WaitCursor); file.write(hexEdit->selectionToReadableString().toLatin1()); QApplication::restoreOverrideCursor(); statusBar()->showMessage(tr("File saved"), 2000); } } void MainWindow::saveToReadableFile() { QString fileName = QFileDialog::getSaveFileName(this, tr("Save To Readable File")); if (!fileName.isEmpty()) { QFile file(fileName); if (!file.open(QFile::WriteOnly | QFile::Text)) { QMessageBox::warning(this, tr("QHexEdit"), tr("Cannot write file %1:\n%2.") .arg(fileName) .arg(file.errorString())); return; } QApplication::setOverrideCursor(Qt::WaitCursor); file.write(hexEdit->toReadableString().toLatin1()); QApplication::restoreOverrideCursor(); statusBar()->showMessage(tr("File saved"), 2000); } } void MainWindow::setAddress(qint64 address) { lbAddress->setText(QString("%1").arg(address, 1, 16)); } void MainWindow::setOverwriteMode(bool mode) { QSettings settings; settings.setValue("OverwriteMode", mode); if (mode) lbOverwriteMode->setText(tr("Overwrite")); else lbOverwriteMode->setText(tr("Insert")); } void MainWindow::setSize(qint64 size) { lbSize->setText(QString("%1").arg(size)); } void MainWindow::showOptionsDialog() { optionsDialog->show(); } void MainWindow::showSearchDialog() { searchDialog->show(); } /*****************************************************************************/ /* Private Methods */ /*****************************************************************************/ void MainWindow::init() { setAttribute(Qt::WA_DeleteOnClose); optionsDialog = new OptionsDialog(this); connect(optionsDialog, SIGNAL(accepted()), this, SLOT(optionsAccepted())); isUntitled = true; hexEdit = new QHexEdit; setCentralWidget(hexEdit); connect(hexEdit, SIGNAL(overwriteModeChanged(bool)), this, SLOT(setOverwriteMode(bool))); connect(hexEdit, SIGNAL(dataChanged()), this, SLOT(dataChanged())); searchDialog = new SearchDialog(hexEdit, this); createActions(); createMenus(); createToolBars(); createStatusBar(); readSettings(); setUnifiedTitleAndToolBarOnMac(true); } void MainWindow::createActions() { openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this); openAct->setShortcuts(QKeySequence::Open); openAct->setStatusTip(tr("Open an existing file")); connect(openAct, SIGNAL(triggered()), this, SLOT(open())); saveAct = new QAction(QIcon(":/images/save.png"), tr("&Save"), this); saveAct->setShortcuts(QKeySequence::Save); saveAct->setStatusTip(tr("Save the document to disk")); connect(saveAct, SIGNAL(triggered()), this, SLOT(save())); saveAsAct = new QAction(tr("Save &As..."), this); saveAsAct->setShortcuts(QKeySequence::SaveAs); saveAsAct->setStatusTip(tr("Save the document under a new name")); connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs())); saveReadable = new QAction(tr("Save &Readable..."), this); saveReadable->setStatusTip(tr("Save document in readable form")); connect(saveReadable, SIGNAL(triggered()), this, SLOT(saveToReadableFile())); exitAct = new QAction(tr("E&xit"), this); exitAct->setShortcuts(QKeySequence::Quit); exitAct->setStatusTip(tr("Exit the application")); connect(exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows())); undoAct = new QAction(QIcon(":/images/undo.png"), tr("&Undo"), this); undoAct->setShortcuts(QKeySequence::Undo); connect(undoAct, SIGNAL(triggered()), hexEdit, SLOT(undo())); redoAct = new QAction(QIcon(":/images/redo.png"), tr("&Redo"), this); redoAct->setShortcuts(QKeySequence::Redo); connect(redoAct, SIGNAL(triggered()), hexEdit, SLOT(redo())); saveSelectionReadable = new QAction(tr("&Save Selection Readable..."), this); saveSelectionReadable->setStatusTip(tr("Save selection in readable form")); connect(saveSelectionReadable, SIGNAL(triggered()), this, SLOT(saveSelectionToReadableFile())); aboutAct = new QAction(tr("&About"), this); aboutAct->setStatusTip(tr("Show the application's About box")); connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); aboutQtAct = new QAction(tr("About &Qt"), this); aboutQtAct->setStatusTip(tr("Show the Qt library's About box")); connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt())); findAct = new QAction(QIcon(":/images/find.png"), tr("&Find/Replace"), this); findAct->setShortcuts(QKeySequence::Find); findAct->setStatusTip(tr("Show the Dialog for finding and replacing")); connect(findAct, SIGNAL(triggered()), this, SLOT(showSearchDialog())); findNextAct = new QAction(tr("Find &next"), this); findNextAct->setShortcuts(QKeySequence::FindNext); findNextAct->setStatusTip(tr("Find next occurrence of the searched pattern")); connect(findNextAct, SIGNAL(triggered()), this, SLOT(findNext())); optionsAct = new QAction(tr("&Options"), this); optionsAct->setStatusTip(tr("Show the Dialog to select applications options")); connect(optionsAct, SIGNAL(triggered()), this, SLOT(showOptionsDialog())); } void MainWindow::createMenus() { fileMenu = menuBar()->addMenu(tr("&File")); fileMenu->addAction(openAct); fileMenu->addAction(saveAct); fileMenu->addAction(saveAsAct); fileMenu->addAction(saveReadable); fileMenu->addSeparator(); fileMenu->addAction(exitAct); editMenu = menuBar()->addMenu(tr("&Edit")); editMenu->addAction(undoAct); editMenu->addAction(redoAct); editMenu->addAction(saveSelectionReadable); editMenu->addSeparator(); editMenu->addAction(findAct); editMenu->addAction(findNextAct); editMenu->addSeparator(); editMenu->addAction(optionsAct); helpMenu = menuBar()->addMenu(tr("&Help")); helpMenu->addAction(aboutAct); helpMenu->addAction(aboutQtAct); } void MainWindow::createStatusBar() { // Address Label lbAddressName = new QLabel(); lbAddressName->setText(tr("Address:")); statusBar()->addPermanentWidget(lbAddressName); lbAddress = new QLabel(); lbAddress->setFrameShape(QFrame::Panel); lbAddress->setFrameShadow(QFrame::Sunken); lbAddress->setMinimumWidth(70); statusBar()->addPermanentWidget(lbAddress); connect(hexEdit, SIGNAL(currentAddressChanged(qint64)), this, SLOT(setAddress(qint64))); // Size Label lbSizeName = new QLabel(); lbSizeName->setText(tr("Size:")); statusBar()->addPermanentWidget(lbSizeName); lbSize = new QLabel(); lbSize->setFrameShape(QFrame::Panel); lbSize->setFrameShadow(QFrame::Sunken); lbSize->setMinimumWidth(70); statusBar()->addPermanentWidget(lbSize); connect(hexEdit, SIGNAL(currentSizeChanged(qint64)), this, SLOT(setSize(qint64))); // Overwrite Mode Label lbOverwriteModeName = new QLabel(); lbOverwriteModeName->setText(tr("Mode:")); statusBar()->addPermanentWidget(lbOverwriteModeName); lbOverwriteMode = new QLabel(); lbOverwriteMode->setFrameShape(QFrame::Panel); lbOverwriteMode->setFrameShadow(QFrame::Sunken); lbOverwriteMode->setMinimumWidth(70); statusBar()->addPermanentWidget(lbOverwriteMode); setOverwriteMode(hexEdit->overwriteMode()); statusBar()->showMessage(tr("Ready"), 2000); } void MainWindow::createToolBars() { fileToolBar = addToolBar(tr("File")); fileToolBar->addAction(openAct); fileToolBar->addAction(saveAct); editToolBar = addToolBar(tr("Edit")); editToolBar->addAction(undoAct); editToolBar->addAction(redoAct); editToolBar->addAction(findAct); } void MainWindow::loadFile(const QString &fileName) { file.setFileName(fileName); if (!hexEdit->setData(file)) { QMessageBox::warning(this, tr("QHexEdit"), tr("Cannot read file %1:\n%2.") .arg(fileName) .arg(file.errorString())); return; } setCurrentFile(fileName); statusBar()->showMessage(tr("File loaded"), 2000); } void MainWindow::readSettings() { QSettings settings; QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint(); QSize size = settings.value("size", QSize(610, 460)).toSize(); move(pos); resize(size); hexEdit->setAddressArea(settings.value("AddressArea").toBool()); hexEdit->setAsciiArea(settings.value("AsciiArea").toBool()); hexEdit->setHighlighting(settings.value("Highlighting").toBool()); hexEdit->setOverwriteMode(settings.value("OverwriteMode").toBool()); hexEdit->setReadOnly(settings.value("ReadOnly").toBool()); hexEdit->setHighlightingColor(settings.value("HighlightingColor").value()); hexEdit->setSelectionColor(settings.value("SelectionColor").value()); hexEdit->setAddressAreaColor(settings.value("AddressAreaColor").value()); hexEdit->setAddressFontColor(settings.value("AddressFontColor").value()); hexEdit->setAsciiAreaColor(settings.value("AsciiAreaColor").value()); hexEdit->setAsciiFontColor(settings.value("AsciiFontColor").value()); hexEdit->setHexFontColor(settings.value("HexFontColor").value()); hexEdit->setFont(settings.value("WidgetFont").value()); hexEdit->setAddressWidth(settings.value("AddressAreaWidth").toInt()); hexEdit->setBytesPerLine(settings.value("BytesPerLine").toInt()); hexEdit->setHexCaps(settings.value("HexCaps", true).toBool()); } bool MainWindow::saveFile(const QString &fileName) { QString tmpFileName = fileName + ".~tmp"; QApplication::setOverrideCursor(Qt::WaitCursor); QFile file(tmpFileName); bool ok = hexEdit->write(file); if (QFile::exists(fileName)) ok = QFile::remove(fileName); if (ok) { file.setFileName(tmpFileName); ok = file.copy(fileName); if (ok) ok = QFile::remove(tmpFileName); } QApplication::restoreOverrideCursor(); if (!ok) { QMessageBox::warning(this, tr("QHexEdit"), tr("Cannot write file %1.") .arg(fileName)); return false; } setCurrentFile(fileName); statusBar()->showMessage(tr("File saved"), 2000); return true; } void MainWindow::setCurrentFile(const QString &fileName) { curFile = QFileInfo(fileName).canonicalFilePath(); isUntitled = fileName.isEmpty(); setWindowModified(false); if (fileName.isEmpty()) setWindowFilePath("QHexEdit"); else setWindowFilePath(curFile + " - QHexEdit"); } QString MainWindow::strippedName(const QString &fullFileName) { return QFileInfo(fullFileName).fileName(); } void MainWindow::writeSettings() { QSettings settings; settings.setValue("pos", pos()); settings.setValue("size", size()); } qhexedit2/example/mainwindow.h0000644000175000017500000000375313716244704016633 0ustar carstencarsten#ifndef MAINWINDOW_H #define MAINWINDOW_H #include #include "../src/qhexedit.h" #include "optionsdialog.h" #include "searchdialog.h" QT_BEGIN_NAMESPACE class QAction; class QMenu; class QUndoStack; class QLabel; class QDragEnterEvent; class QDropEvent; QT_END_NAMESPACE class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(); protected: void closeEvent(QCloseEvent *event); void dragEnterEvent(QDragEnterEvent *event); void dropEvent(QDropEvent *event); private slots: void about(); void dataChanged(); void open(); void optionsAccepted(); void findNext(); bool save(); bool saveAs(); void saveSelectionToReadableFile(); void saveToReadableFile(); void setAddress(qint64 address); void setOverwriteMode(bool mode); void setSize(qint64 size); void showOptionsDialog(); void showSearchDialog(); private: void init(); void createActions(); void createMenus(); void createStatusBar(); void createToolBars(); void loadFile(const QString &fileName); void readSettings(); bool saveFile(const QString &fileName); void setCurrentFile(const QString &fileName); QString strippedName(const QString &fullFileName); void writeSettings(); QString curFile; QFile file; bool isUntitled; QMenu *fileMenu; QMenu *editMenu; QMenu *helpMenu; QToolBar *fileToolBar; QToolBar *editToolBar; QAction *openAct; QAction *saveAct; QAction *saveAsAct; QAction *saveReadable; QAction *closeAct; QAction *exitAct; QAction *undoAct; QAction *redoAct; QAction *saveSelectionReadable; QAction *aboutAct; QAction *aboutQtAct; QAction *optionsAct; QAction *findAct; QAction *findNextAct; QHexEdit *hexEdit; OptionsDialog *optionsDialog; SearchDialog *searchDialog; QLabel *lbAddress, *lbAddressName; QLabel *lbOverwriteMode, *lbOverwriteModeName; QLabel *lbSize, *lbSizeName; }; #endif qhexedit2/example/qhexedit.pro0000644000175000017500000000153513716244704016637 0ustar carstencarstengreaterThan(QT_MAJOR_VERSION, 4): QT += widgets HEADERS = \ mainwindow.h \ optionsdialog.h \ ../src/qhexedit.h \ ../src/chunks.h \ ../src/commands.h \ searchdialog.h SOURCES = \ main.cpp \ mainwindow.cpp \ optionsdialog.cpp \ ../src/qhexedit.cpp \ ../src/chunks.cpp \ ../src/commands.cpp \ searchdialog.cpp RESOURCES = \ qhexedit.qrc FORMS += \ optionsdialog.ui \ searchdialog.ui OTHER_FILES += \ ../build-example.bat \ ../build-python-bindings.bat \ ../build-example.sh \ ../build-python-bindings.sh \ ../deploy.nsi \ ../doc/release.txt \ ../doc/howtorelease.txt \ ../appveyor.yml \ ../readme.md \ ../setup.py \ ../src/qhexedit.sip TRANSLATIONS += \ translations/qhexedit_cs.ts \ translations/qhexedit_de.ts DEFINES += QHEXEDIT_EXPORTS qhexedit2/example/optionsdialog.ui0000644000175000017500000003005513716244704017513 0ustar carstencarsten OptionsDialog 0 0 374 754 QHexEdit - Options Flags Address Area Overwrite Mode Higlighting Ascii Area ReadOnly 0 0 Colors and Fonts Highlighting Color 100 0 16777215 16777215 QFrame::Panel QFrame::Sunken Selection Color 100 0 16777215 16777215 QFrame::Panel QFrame::Sunken Address Area Color 100 0 16777215 16777215 QFrame::Panel QFrame::Sunken Address Font Color 100 0 16777215 16777215 QFrame::Panel QFrame::Sunken ASCII Area Color 100 0 16777215 16777215 QFrame::Panel QFrame::Sunken ASCII Font Color 100 0 16777215 16777215 QFrame::Panel QFrame::Sunken Hex Font Color 100 0 16777215 16777215 QFrame::Panel QFrame::Sunken Widget Font 0 0 Courier New 10 01 23 45 67 89 ab cd ef Address Area Address Area Width 1 6 4 Hex Area Bytes per Line 1 32 16 Qt::Vertical 20 40 Qt::Horizontal QDialogButtonBox::Cancel|QDialogButtonBox::Ok pbHighlightingColor pbAddressAreaColor buttonBox buttonBox accepted() OptionsDialog accept() 222 154 157 168 buttonBox rejected() OptionsDialog reject() 290 160 286 168 qhexedit2/example/qhexedit.qrc0000644000175000017500000000043313716244704016620 0ustar carstencarsten images/open.png images/save.png images/undo.png images/redo.png images/find.png images/qhexedit.ico qhexedit2/example/optionsdialog.h0000644000175000017500000000145313716244704017325 0ustar carstencarsten#ifndef OPTIONSDIALOG_H #define OPTIONSDIALOG_H #include #include namespace Ui { class OptionsDialog; } class OptionsDialog : public QDialog { Q_OBJECT public: explicit OptionsDialog(QWidget *parent = 0); ~OptionsDialog(); Ui::OptionsDialog *ui; void show(); public slots: virtual void accept(); private slots: void on_pbHighlightingColor_clicked(); void on_pbAddressAreaColor_clicked(); void on_pbAddressFontColor_clicked(); void on_pbAsciiAreaColor_clicked(); void on_pbAsciiFontColor_clicked(); void on_pbHexFontColor_clicked(); void on_pbSelectionColor_clicked(); void on_pbWidgetFont_clicked(); private: void readSettings(); void writeSettings(); void setColor(QWidget *widget, QColor color); }; #endif // OPTIONSDIALOG_H qhexedit2/example/searchdialog.ui0000644000175000017500000001220313716244704017260 0ustar carstencarsten SearchDialog 0 0 436 223 QHexEdit - Find/Replace Find Hex UTF-8 0 0 true Replace Hex UTF-8 0 0 true Options &Backwards &Prompt on replace &Find F3 true &Replace Replace &All &Close Qt::Vertical 20 40 cbFind cbReplace cbFindFormat cbReplaceFormat cbBackwards cbPrompt pbFind pbReplace pbReplaceAll pbCancel pbCancel clicked() SearchDialog hide() 360 134 364 162 qhexedit2/example/images/0000700000175000017500000000000013716244704015531 5ustar carstencarstenqhexedit2/example/images/redo.png0000644000175000017500000000173113716244704017204 0ustar carstencarstenPNG  IHDR szz pHYs  ~tIME 3-T>6bKGDfIDATXmLaJHN:5̲YkYhˑLikaژՇPPDCY#FZ,Eb%EOO[//}뾞#d\O6 CHUϣ k l ~DK2]pu(݆f U8^/vΩ,i"~6}ҿLԵv9EBGcMW NIH;w#ftضPƜjK? = R+_!pBk]({\Ê~!J&'RN t'A$kB\l!FfQo"y=ĺ%?ZOl000u%ğ,$DXmUI[_qJaFtΧxk/Eawu_[I\X&A4d:q#dwTŦBr?nl[>gY Ds|Zx 9ZP.YڰRf!96 h6wY'Z5u1h0 "D\{g/gʜjhgKZVo+;6&XB^9,XWPG4<68J^@`ȑBּpB0{5|@xN1Ϊj7kETS%iQ Ec%l 0ld+.<L.o,""*Y s8 EHIr(Ll0=F8&`,"P7Dp6Kf"8/&ETꔵ !_n&-0_IENDB`qhexedit2/example/images/open.png0000644000175000017500000000403113716244704017210 0ustar carstencarstenPNG  IHDR szzgAMAOX2tEXtSoftwareAdobe ImageReadyqe<IDATXíW[Pgb/nٛκ;{z:vTpuֶT mQB!@Hs$!grB GTx~0X}g/>ߗ]v uH W*e`[ '3">vH~Y2ϭB9DQ臆={XSR,::NI1>I,`]YSMM4 1y`Ż?ū)LOϮ׼tCO3@{=.4W S2^5C`\&K|H$8As''H׻ "U77N,V>V:q,k,'6?F}oY1~ Z{?0L(CF&e-,!4{Z;~m$~CF=5iu?PZlY]/sq 1% cbjC'ݼ-Ӱ;3&SXO!,CPF BBsZ*tȼE lϛ'Ào%Q(/bM$"R-BySt < ] /yƪԳs LŔbK˫#7G<<b~/=/-:C(QNܿ}3i 3Th58 X\3>GelAC'b ER$nPD΋J~ m['Ѡe")(Ȑx5 >c f]KcNzI1N[;|%jJ0("3 t.| J*qQF@7 jH7'@L{RE qAAͷ]lC(N#KQWHoXQG `4QɫgA@?noiқ*/ru)S)+vQŕky8n3cjs@"mDžPt +4X$ |J8aVU;:!z/]&o8=cn*F׃H:381 ^QO`+] 9g=JUmCeS@%`+njǩD9|6ZZ8/95j'zLIdnFڍv9,9=NrG ;Fc9=pOJnX,P(@!F.[! o<<5iEX?7Ǎ: !p5U!4[7*4nI:rsm$Jesp)>|c.2*\"]~M 6tvw䈶"I m2JxLKIõ.|me6Y\Q{ %&6ǝՂ^NEXx]\UPuTA/ rjQCO-H/5z-Wxܯ\u˯Ev2g`§ҩ;P 9 /"mak^2/f_=IENDB`qhexedit2/example/images/undo.png0000644000175000017500000000170213716244704017216 0ustar carstencarstenPNG  IHDR szz pHYs  ~tIME 6*-WbKGDOIDATX[HTQ4^2InCt"5pP&O:ZVjIʒ¬({DDBHj)"Vf&""%_g63:7eֿ{FKOO P)\/zW6aPD'ڈu*=|7E8|Kj`>Qv2HTx,rBJ{X7@6  `b_.>Xs1|`c!Q:9'Wc |m]]= "YDx!iB>]vN5ػ」;v<:̗7XSڠkg|p?0x.ory #ӟd}k@E@xp,#˲m00aP|#%"+Օs΃* ,I Iw:琷Ղv+m(r8 㯼IkFؽ{k놮ZVmQg5 ,# /#&|#!Я'aa%% 4M:ólc V_)Fara-р: TIO4/!g iXvj#wPE x:Tx3x$wh6h߱R^DM_ 8ňKvRPZ0}@Ű&WU.2p}Ʉ-Jsf+7QW?תd~')Ü wl 55Y1{X0+WVU!ѐS,-޸Wj'WڣU<_o|w__sl}5ځ?MKFIENDB`qhexedit2/example/images/qhexedit64.png0000644000175000017500000001133613716244704020242 0ustar carstencarstenPNG  IHDR@@iqsBIT|d pHYsJJ)mѩtEXtSoftwarewww.inkscape.org<[IDATx}E3KB &@P0!qQY!""֫eqr*PtȂWPAޝ;=|{}nlTMݏ>ӧ xWJ0w}OLd,H `btp,"[2q)L >s@bP8֥ Z \q|A F!c/Rr@EJ48($ݓ<; ?d=.&@ȿw D}S^ |@ֆPAGmc_`=%1k!_Ay>0ՋdXx0'76C^ x|~S"yXStHs]b-ZgIސ3 ё@gEIv˜ (%g\DHx2|DwJF||Z\4)E(=# )ܰ|T:Q>/*T` WORZF /_ETgQc#>qGdU>d 5i.';GEbq?.zrf>|kB ZS)wwLMSNx0ŠQ&>oL᳂Yq YQ r%:$aҒ.+MCUC`/l[+am뱬{hPO (aYxǡ Lt,?/ۅFǦn*IY* =HSMijwz~he{*N)"kNmYӞPKH+xlov(jAb){b?+0ψqsex|xUG>9Cb*Czu!փ8˜0֢\I G[OSsX0:3q 5̤J@SD/'.ws38o 7(|J Z8@OGaqNht&Ql Ss))~׻s$]=OpP\?;29q.KZ,3vMFͬv ~BHs`ry'&lX#DasU"6+08%^3HP9&<42ׇ)X o KWAh~BH]QAfbs?Q $e@%M(#'(qu3OsUɉ AGH.4bb뒔XJJ\I$fF]l;AEAmSp\6y _,piZ$\U _IHD"H\p֜GiHDL%HHm5P+;S>́ ZV~^-=7H s#7#ΘQf\tQH .MCЌچ ~>fOh{8#! ˦/bQTbt0^AA9 ]๡ uk;eXgsa9,mIгSlA?F4_aA[ QZ &(%e\yOE,[]d[ӳe8#{8ooh}r8f8B%,(Q7a/}X"]wZfS$50znbO|\Dxײm IXPڈ{CŪO(adx0ⰚIc>򽳘8ˬh sG`î0W %z@Vpx95{˭ך)^+/?g~o<&,5DtNX'4{501U߱bkYQUZ ۹\)A׾^ Y"08{[7=({U.70(<،)Axmq:Ɔ/wR-0;,i0#EJl&O^"q3Dx۹aWWMثߓEjm=, 4ե(##/hd[* ٳ;4k4\|kf5>c8i\0u y$Nn*KEpoN8Xət?Z_d0XkgOQK-̵TXr=ެQ9 v.`] v.%Xbak2ZZιpr;ܓgi6s F@l;_ cEaYG YGdd ރaD"hm맲E(';]X4t{Jqf JT - /7,r7;{t";u ߷'џ0;t=s=d(+Vr[:iV{ȿ9A>m>OPf.c$~;qiBS">;'}ˣD {n?/'ށԅԁ.dn 29WF8ebSX<61AWx\ DEnyX՚ޏ?<8MRm:0dN}<:gv.v{=x>\ʦpKz08]:W)j/7cCb&= v͉lqs#kV}7} 0n&b7(`,د>LMG(&Ru #=~c΀S.:ŦGDTH&/#<$Nb-=*3)4щ]hB-m~uAZ,fHDu7ыOjd,>=:m0='<--EF8.ZNiRCE{`(Jp}~ øu :`]O5jr)p!>8 '# sǙ*΋4#>^)fv*fRσ|̍ٚH;K΅4m@ t+p _3`*TQ#-#'HDZ#&Euʲ'Wozk@'A(r&4jXW0gYO],྾KtZ.%"M0n2lwtr%nSj Hn--.2mq8OY\ET f#/N@PG|V"]3Z%EUiQ.rjuk[kGMW}]|c$x dF?D0ݜȪJ I%Bt`^+f4* fPЁvg kJ|Un?., - 29!fK?^f8ffEy]b? b@͕.ִ1I&_lvj& YDy+C67 %H#X>ÝCu 0L=#ugߏe{ځLu͊.<7obt&8oOؚٝGu+iDF.owRTȀ52LOߐ́ߘǨ!/KtlC2Fم,εl'>)$Kd=v`ՃGK a"N/\ܟ \<G@;߳X,t+'N@yE~&d0 lpկ/BsP;8g1B~0D ?Tuz+R/ zցn2%o]Y OWWSimO Kڽ6z2yQZ]nTXrn"C*x2niu1VXpuyFl)}}%S=OF<@kxާ6u  jʤFSk1aܚ֍}^ħԫ_P<&px7c[TLO%Ɉs 4Ex`ZM/pMg@\_$c[Ŧ;z6Q6-V>VKr>|q'&ጎfeٻ֏kn!&z+ cZ"XpGN;pT 01000010 image/svg+xml qhexedit2/example/images/qhexedit32.png0000644000175000017500000000374413716244704020241 0ustar carstencarstenPNG  IHDR szzsBIT|d pHYs%%fYtEXtSoftwarewww.inkscape.org<aIDATXm]E3羜s "@xm ME /-D H?C()`RlLEhj`Iwٻ̙{wޭ-Q dr2g3?d!?<_0w܏bE9W$V䘾^@/j_$'nv`}Iq;Աi:-ܷ(DKI6r:Y' йMA3+AcIT['`xLk M5e2^` fc< 0Y<sfk}H&D81=h'\C"a*1ӔXq(VXSrexQ5(YKX$͗dC#֙">od9b D 󒸃1b (1@P 嵥G׼ (+r9H$P9$0%`2{qӳ,PT&[ue)0K֩)+7 PC)Y_r:cqe)+iFɷ4b2 \Lv,'q2E%D̓'f\#A( c@P5Pm $I Nb3%the(V5oM\~y&oSae(*jIay c#=E9,Xsbb_ P =m?@<ʑypY=ժE<=~K,X;ZgkF^!'fgd Yz=o P% F14ପ)<ozn9\R5e9jX]ghŅ,>) JbS"%e琰cɳ [`I T-+᪹ {?jnpdr +\̜]Y\0BNe q-Jl^y) UÛgT+<<1aG\_faHY̖-34+"h1Pcbm ~ka:բ %O˔;: ]Xw8t]TĔCmO((M950npɆ7 m7_"z4CBqffAŲ$Mh0Mҙj@ՀRW5-eA@+ftyfN$F yO JwTSK;E>uJӧ 7fE>.= jg@mQ TT&eW]^aW@mWT'+"U$@Kp22vL5i0&) v`a)\{҅Bd3ZK:ą^͗pm;r <%2_XWȪfd]<NZjҊ?) GkYtw ߌV":>Top #D[L[B )f$+pҌ(C+5lS[ٹlefehM9]x??ppn w p7.DlV i-L C /IENDB`qhexedit2/example/images/find.png0000644000175000017500000000363013716244704017173 0ustar carstencarstenPNG  IHDR szz_IDATx^mLTϽw^aE"X_QYmnt7h)Zf7M?4lӦ~6*IjwQX[qw]pQ^Da}`/OxCΐI~y&{~3ffTf1£9$ Gq<>8{,q5|`>߸w|qJʅ۾k ;!Y7”hOG'{g.\5/E68GFG_ϧ{>y6w*9N@SexdK^_cxj%+!O_XAI2`{1_=G I pP$5z %ņ-LK[^oEXDdBN( 07b>A`p8l @61MDlA1hP !F ) ,#$҂E.qrr]3cr$(b0= 6 ڀ׎Jwymmm7o -XL(օ~i'6055e*:|pwmomm!If!Y?BwĥzEO~- Qprt{!rJ{{q} tD_ y%۳P2'aޱyn:H`Aԙ姵'Ǐy```&$9:4 X#h /ńC+\Ԭ X<7Fs1ӝ'ծ沦}|DP'p@#ǃcHIF$B䗖 Ýb5EF^A[Fԡ x<%0&l5-nƦQB K 7p1+eh!徰?H8uń-zֶ)0@B$(v;`ocr 2CCi>t°"ơq̃|(H "$z MF===za&D$6p} ۨ >0Ɛo}z* r3zx(:|m$Y86g8^ 8Hp,\PYΠA{ BP+7\[ 01|!- b8MQVW_SsL/+tmᱨаO'-дĮ"L}rHC%YC^, ^v˲]T---bsfff1""1&,q{+"|SA|{`¾j(`q׮][/NzgT?䶄x'z< L0@,;8zUT\?{9}曠DJMMҹsܹ3;==pbbbpnn.BX~7UWU|I"$D![`I iD#DьG*-͌A,K&@ ^J,^pA}mGgRD`Կz@=I=Y JI (wP}Q {G?1 }¤/OQbФ?fm XN\N[I, LiSV's'Fs.Q"/d^2|[vR9ce߽w"ޠD=XR#h+<;MVv;,CV!#oZ3mجo5IÄUx胖N|icEOj3 .1iD^PRIK8ͩB04 i^fDd%~4#Oc|@ MN y]Yoc"?9#IENDB`qhexedit2/example/images/qhexedit16.png0000644000175000017500000000137013716244704020234 0ustar carstencarstenPNG  IHDRasBIT|d pHYsNtEXtSoftwarewww.inkscape.org<uIDAT8MKat@˝٭s5_ Ju 8_]azL¸X4.ibsՊbn#)YiuvV ?HB $1ؿZ]NWviP  D ?l $uK#R>L-`8 A#E([3! II:y逬닸=eqC g2I't$هuaU\L#;'/|!A"6##Gwy*G? D^KضG[oKm1,$A9ztr(gyUtܮCsH[OI&NZ+a ⷣ^ (Br6A%B3G\O&8KXzhǣ(]֕@]S1`.R6$ȰD1VdjiO6e . [:t`@3:l T#Jb3r/&RSҞE%^S4_(]&Fgum\cO4VzIENDB`qhexedit2/example/images/qhexedit.ico0000644000175000017500000005355613716244704020070 0ustar carstencarsten h6  @@ (BF(  FױZ"+}i(\:7NI>\.oS4۱լ+|Sb%}\q )Z>:LL9^/o 'GIӨyeMwzi',ZQ:9a+s> KJϛТhvyF{v'h>F:Q7c*Cty/-~`͝o^GL w,XAFS5"e'\K~%ƲƜi"=1TCDT4X%KLlo ժ0P"zX7!/ -$P`r MPҎӧwK"I3K J1XTyk_:ϞrCDZDG1IX7y}j\9ȡΘ>mlX4D/+$ry^LR&ɔFjW.Ci3 b-ݾS ( @ %%@ٳΜ<+} uW0Vz9NBGK>T6]/f& }m? װU?'| u=(\1U:MCEL=U5^-Ux ԊҊ{p v ۱׮?iR7$c{d)(^91S;LEEL:9U7*i$?qz yt3jpǓN}f<" )Zc3SV'i} vj1TC:MDE@@T5y^-e&yZ%k}֮˖DTw<%}j3f2T;LDDM<U4`)%[Lm'eg*Qx9# [-Y(3SN`qGD޾faK4|%6z-$y  C+=*O*bs8*V߷ ƍCv_30zy?6+0g sSdxP΢sĊsfD1.I?6K CUi mcٴΞĈIUB,RH?E3)Q4EZXetɖٲ͚QlGU?ZQH@=0O(%6KSesݕرN˘AjTdZM<L1'&<q ~naJŗ~hlcZ3Cj:/q-oNpiӧ4ȓ|wvl`U MC9?^_q`? ޽ҧƐu vj`UMU$O=as޻ϧ ~As޴i_X +H! SYdu @㈈㈈(@ @JJrֳ߿صӧ@.!  ~z w/.W24Qq8Oq=JqAFqFAqJ=qO;qS6qX2q]-qa+qf&qk$9B}uqs+߾ٳҧ}AC5)} y v],X]0U4Q9M=IBEFAK=O9T5X1]-a)e$j~ ԊԎԌԄ|um* ߽ٱӧ]UJ?3(}y u?)]]-Y1U5Q:M?IBEGAK=Q9T5Y1]-c)jy_}ԁ ԆԊԏԌԃ{tpqݺװ؝ _TI=3(| x$`]([-X1T6Q:L?HCEH@L<Q9U4Y0^+jm$ty}Ԃ Ԇ ҋʏԊԂysqiܼ֮ܺ^qj^SFΝȒ†{j 6+  &^+Z/U4RY1?[.a*e&i#0 ԉԎԍ$Sݻҧ̜ƐÅ@5*0"b&]+Y0UU4TX1].a*g%|%Ԇ ԊԎ9[޼ٱҦ̚ǏxQm`jJ?4(9e#a&],YP:\T5Y1]-b*@j!nt7{}ԁ ԆԊF~cݺװѥ̙wkc$TI?3(@hd$`(\M=dQ9U4Y1]-~a(Gg%k qxy}Ԃ Ԇ M~d ֮ܺѣѢ Ōug*`SH</Alg d$_I?eL<Q9U4Z1}]+Mc(g$l iuy~ԃ J\ܹ֭˗gċj]RF:9okgcEB]I?M;Q9V3`@_,c(i#Ilquy~"T۷sg[QD1rokgAGVECI?N;R7j#$mqvz,A }qfZM vrmj>IBAFEBK?N:d'.i#mrwyK%߿(Ǝ ‡{pdfz vrn;N'=KAFFBI>`+Me&j"mrpryuRϚ0ƒ†yn}y ur9U 9M=IBFFBN; ^.ua*f&j"oqg>qyC`Ԉҧe̛ƏxD5W$}y u5P9M?IBEFBBY1]-a)f%m!=] jr{M i$0ۿֱҥ̙ƎFL?3(y|x1Ui5Q:L?ICE@@ P9PU5Y1^-b)f c|ks|ѭܺ׮Ѥ˘UH<1&|1U1T6Q:L?HBDH@L<Q9U4Z0^-}Ybls}q.ܹ֭ѣN^RG;0$ .Wo3S6O;L?HEEH@M<Q9U4U5\=dmu~X۷yf]QE:.# @@.W3S7O%sm$I3M$ % [W&\enw_Jٷ57],  ~|%!= O:U^gpxy߿ٳW@MA6+~ {<+$ qF:NU_gqyN޾ٳ/aqWK@5)~ u/})$  >:FOX`iryݼtlaUK?3(|}. 2-(#O h7?UHUQUZUajs|iUUU9G3ܸ$ivk_UN 2Q& >>73-'CZaks|!e`čui_C0%=Ar;61,u R[dlt!/Rϔƪ ˖Ċsb ;u/#qE@;6/L %JS[el! +ٴت'Ϡɔĉ}EN9."IE?:4, ADKT]d! ٷCԪΞɓÉN.C9- NIE?<"  T:ELU]!3޾VٴҨΞȒW#MB6,RMHC=9L5/ $\2<ENU!:f]߾ٲҧΜƎ xlIbWL@6WRMG<=93.M)}$d,4=FM!B+ eݽٱҥ}˚NƏyiaUK?[UQLKC=92G-~(#c$-6?F!A$cݺװ~ХG̙ƍxk`TJ`[UQLD8A<U3-("[%.7>!}9kP\۹Ф˗Ë7uj^Sd_ZUN$71-&"S&/6!u2~TŐ%sg]hd_YQ/;61+%> &.!mv >Λʕ0ĉ~rhmߑgc^XQ?:50.! '!Unw /$ؽ͟RɓÈ|qqlmga\zGE?:4+!fox4WөzΞȒ†|kt7qlgbLMHC?8v@ !_|gpyoYLٳҧ̜Ɛ„6mvpkfagURMHB>_ !U<`iqz-I_j߽ٱҦ͚{pupkf`[UQLHI# !Xajs{ ݺװҥqv yݺsoje`[UQJ](#!Q9Yaks|!\ܺϯ}+ysoid_ZU~-r'"!S_Zclu}C~+xss޴midaB$ O|  S1\emw~"Cr?AA@???@  ?qhexedit2/example/main.cpp0000644000175000017500000000115113716244704015724 0ustar carstencarsten#include #include #include "mainwindow.h" int main(int argc, char *argv[]) { Q_INIT_RESOURCE(qhexedit); QApplication app(argc, argv); app.setApplicationName("QHexEdit"); app.setOrganizationName("QHexEdit"); app.setWindowIcon(QIcon(":images/qhexedit.ico")); // Identify locale and load translation if available QString locale = QLocale::system().name(); QTranslator translator; translator.load(QString("qhexedit_") + locale); app.installTranslator(&translator); MainWindow *mainWin = new MainWindow; mainWin->show(); return app.exec(); } qhexedit2/example/searchdialog.cpp0000644000175000017500000000541413716244704017433 0ustar carstencarsten#include "searchdialog.h" #include "ui_searchdialog.h" #include SearchDialog::SearchDialog(QHexEdit *hexEdit, QWidget *parent) : QDialog(parent), ui(new Ui::SearchDialog) { ui->setupUi(this); _hexEdit = hexEdit; } SearchDialog::~SearchDialog() { delete ui; } qint64 SearchDialog::findNext() { qint64 from = _hexEdit->cursorPosition() / 2; _findBa = getContent(ui->cbFindFormat->currentIndex(), ui->cbFind->currentText()); qint64 idx = -1; if (_findBa.length() > 0) { if (ui->cbBackwards->isChecked()) idx = _hexEdit->lastIndexOf(_findBa, from); else idx = _hexEdit->indexOf(_findBa, from); } return idx; } void SearchDialog::on_pbFind_clicked() { findNext(); } void SearchDialog::on_pbReplace_clicked() { int idx = findNext(); if (idx >= 0) { QByteArray replaceBa = getContent(ui->cbReplaceFormat->currentIndex(), ui->cbReplace->currentText()); replaceOccurrence(idx, replaceBa); } } void SearchDialog::on_pbReplaceAll_clicked() { int replaceCounter = 0; int idx = 0; int goOn = QMessageBox::Yes; while ((idx >= 0) && (goOn == QMessageBox::Yes)) { idx = findNext(); if (idx >= 0) { QByteArray replaceBa = getContent(ui->cbReplaceFormat->currentIndex(), ui->cbReplace->currentText()); int result = replaceOccurrence(idx, replaceBa); if (result == QMessageBox::Yes) replaceCounter += 1; if (result == QMessageBox::Cancel) goOn = result; } } if (replaceCounter > 0) QMessageBox::information(this, tr("QHexEdit"), QString(tr("%1 occurrences replaced.")).arg(replaceCounter)); } QByteArray SearchDialog::getContent(int comboIndex, const QString &input) { QByteArray findBa; switch (comboIndex) { case 0: // hex findBa = QByteArray::fromHex(input.toLatin1()); break; case 1: // text findBa = input.toUtf8(); break; } return findBa; } qint64 SearchDialog::replaceOccurrence(qint64 idx, const QByteArray &replaceBa) { int result = QMessageBox::Yes; if (replaceBa.length() >= 0) { if (ui->cbPrompt->isChecked()) { result = QMessageBox::question(this, tr("QHexEdit"), tr("Replace occurrence?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel); if (result == QMessageBox::Yes) { _hexEdit->replace(idx, replaceBa.length(), replaceBa); _hexEdit->update(); } } else { _hexEdit->replace(idx, _findBa.length(), replaceBa); } } return result; } qhexedit2/appveyor.yml0000644000175000017500000000255413716244704015241 0ustar carstencarstenversion: build{build} environment: matrix: - QT: C:\Qt\5.11\msvc2015 GENERATOR: Visual Studio 14 2015 PLATFORM: X86 - QT: C:\Qt\5.11\msvc2015_64 GENERATOR: Visual Studio 14 2015 Win64 PLATFORM: X64 clone_folder: c:\dev\qhexedit clone_depth: 5 install: - set PATH=%QT%\bin\;C:\Qt\Tools\QtCreator\bin\;%PATH% before_build: - call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %PLATFORM% - qmake --version - echo %PLATFORM% - cd c:\dev\qhexedit - md build - cd build - if "%PLATFORM%" EQU "X64" (qmake -r -spec win32-msvc CONFIG+=x86_64 CONFIG-=debug CONFIG+=release ..\example\qhexedit.pro) - if "%PLATFORM%" EQU "X86" (qmake -r -spec win32-msvc CONFIG+=Win32 CONFIG-=debug CONFIG+=release ..\example\qhexedit.pro) build_script: - nmake - windeployqt.exe release\qhexedit.exe - makensis ..\deploy.nsi - copy QHexEdit.exe ..\QHexEdit_%PLATFORM%.exe artifacts: - path: QHexEdit_%PLATFORM%.exe deploy: description: 'Latest QHexEdit Release' provider: GitHub auth_token: secure: WEV9mRJC/pC2HFqJMXbLzEfBXAHu8aGDFIR8ARSip9n6jDJyCz3KstjSPM4VsgKc draft: false prerelease: false force_update: true on: branch: master # release from master branch only appveyor_repo_tag: true # deploy on tag push only qhexedit2/test/0000700000175000017500000000000013716244704013610 5ustar carstencarstenqhexedit2/test/testchunks.h0000644000175000017500000000121513716244704016165 0ustar carstencarsten#ifndef TESTASBYTEARRAY_H #define TESTASBYTEARRAY_H #include #include #include #include #include "../src/chunks.h" class TestChunks { public: TestChunks(QTextStream &log, QString tName, int size, bool random=true, int saveFile=0x7fffffff); void insert(qint64 pos, char b); void overwrite(qint64 pos, char b); void removeAt(qint64 pos); void random(int count); void compare(); private: QByteArray _data, _highlighted, _copy; QBuffer _cData; Chunks _chunks; int _tCnt; QString _tName; int _saveFile; QTextStream *_log; }; #endif // TESTASBYTEARRAY_H qhexedit2/test/testdata/0000700000175000017500000000000013716244704015421 5ustar carstencarstenqhexedit2/test/testdata/16.bin0000644000175000017500000000002013716244704016343 0ustar carstencarsten qhexedit2/test/testdata/4.bin0000644000175000017500000000000413716244704016262 0ustar carstencarstenqhexedit2/test/testdata/32.bin0000644000175000017500000000004013716244704016343 0ustar carstencarsten qhexedit2/test/testdata/1.bin0000644000175000017500000000000113716244704016254 0ustar carstencarstenqhexedit2/test/testdata/33.bin0000644000175000017500000000004113716244704016345 0ustar carstencarsten  qhexedit2/test/testchunks.cpp0000644000175000017500000000530113716244704016520 0ustar carstencarsten#include "testchunks.h" #include TestChunks::TestChunks(QTextStream &log, QString tName, int size, bool random, int saveFile) : _chunks(nullptr) { char hex[] = "0123456789abcdef"; srand(0); for (int idx=0; idx < size; idx++) { if (random) _data += char(rand() % 0x100); else _data += hex[idx & 0x0f]; _highlighted += char(0); } _copy = _data; _cData.setData(_copy); _chunks.setIODevice(_cData); _tCnt = 0; _log = &log; _tName = tName; _saveFile = saveFile; compare(); } void TestChunks::random(int count) { for (int idx=1; idx < count; idx++) { int action = rand() % 3; int pos = rand() % _data.size(); char b = char(rand() % 0x100); switch (action) { case 0: removeAt(pos); break; case 1: insert(pos, b); break; case 2: overwrite(pos, b); break; } } } void TestChunks::insert(qint64 pos, char b) { _data.insert((int)pos, b); _copy.insert((int)pos, char(0)); _highlighted.insert((int)pos, 1); _chunks.insert(pos, b); compare(); } void TestChunks::overwrite(qint64 pos, char b) { _data[(int)pos] = b; _highlighted[(int)pos] = 1; _chunks.overwrite(pos, b); compare(); } void TestChunks::removeAt(qint64 pos) { _data.remove((int)pos, 1); _highlighted.remove((int)pos, 1); _chunks.removeAt(pos); compare(); } void TestChunks::compare() { QByteArray rHighLighted; QByteArray rData = _chunks.data(0, -1, &rHighLighted); bool error = false; if (rData != _data) error = true; if (rHighLighted != _highlighted) error = true; _tCnt += 1; int chunkSize = _chunks.chunkSize(); QString tName = QString("logs/%1_%2_%3").arg(_tName).arg(_tCnt).arg(chunkSize); if (error || (_tCnt >= _saveFile)) { QFile file1(tName + "_data.txt"); file1.open(QIODevice::WriteOnly); file1.write(_data); file1.close(); QFile file2(tName + "_highlighted.txt"); file2.open(QIODevice::WriteOnly); file2.write(_highlighted); file2.close(); QFile file3(tName + "_rData.txt"); file3.open(QIODevice::WriteOnly); file3.write(rData); file3.close(); QFile file4(tName + "_rHighlighted.txt"); file4.open(QIODevice::WriteOnly); file4.write(rHighLighted); file4.close(); } if (error) { qDebug() << "NOK " << tName; *_log << "NOK " << tName << "\n"; } else { qDebug() << "OK " << tName; *_log << "OK " << tName << "\n"; } } qhexedit2/test/chunks.pro0000644000175000017500000000054313716244704015641 0ustar carstencarsten#------------------------------------------------- # # Project created by QtCreator 2015-04-20T13:35:52 # #------------------------------------------------- #greaterThan(QT_MAJOR_VERSION, 4): QT += widgets DEFINES += MODUL_TEST SOURCES += \ main.cpp \ ../src/chunks.cpp \ testchunks.cpp HEADERS += \ ../src/chunks.h \ testchunks.h qhexedit2/test/main.cpp0000644000175000017500000000335613716244704015261 0ustar carstencarsten#include #include #include #include "testchunks.h" int main() { QDir dir("logs"); dir.setNameFilters(QStringList() << "*.*"); dir.setFilter(QDir::Files); foreach(QString dirFile, dir.entryList()) dir.remove(dirFile); QString logFilename = "logs/Summary.log"; QFile outFile(logFilename); outFile.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream sumLog(&outFile); TestChunks tc(sumLog, "overwrite", 0x4000, true); tc.overwrite(4379, 25); tc.overwrite(0, '.'); tc.overwrite(0x50, '.'); tc.overwrite(0x100, '.'); tc.overwrite(0xfff, '.'); tc.overwrite(0x1000, '.'); tc.overwrite(0x1fff, '.'); tc.overwrite(0x3000, '.'); tc.overwrite(0x3fff, '.'); tc.overwrite(0x2000, '.'); tc.overwrite(0x2fff, '.'); TestChunks tc2(sumLog, "insert", 0x4000, true); tc2.insert(0, 'E'); // 0 tc2.insert(0x50, 'x'); // 1 tc2.insert(0x100, 'x'); // 2 tc2.insert(0x1002, 'L'); // 3 tc2.insert(0x1004, 'E'); // 4 tc2.insert(0x2004, 'L'); // 5 tc2.insert(0x4005, 'L'); // 6 tc2.insert(0x3007, 'E'); // 7 tc2.insert(0x2008, 'E'); // 8 tc2.insert(0x3008, 'L'); // 9 TestChunks tc3(sumLog, "remove", 0x4000, true); tc3.removeAt(0); // 0 tc3.removeAt(0x50); // f tc3.removeAt(0x100); // e tc3.removeAt(0xffc); // d tc3.removeAt(0xffc); // c tc3.removeAt(0x1ffa); // b tc3.removeAt(0x3ff9); // a tc3.removeAt(0x2ffa); // 9 tc3.removeAt(0x2ff7); // 8 tc3.removeAt(0x1ff7); // 7 TestChunks tc4(sumLog, "random", 0x40000, true); tc4.random(1000); outFile.close(); return 0; } qhexedit2/.gitignore0000644000175000017500000000522713716244704014641 0ustar carstencarsten################# ## Eclipse ################# *.pydevproject .project .metadata bin/ tmp/ *.tmp *.bak *.swp *~.nib local.properties .classpath .settings/ .loadpath # External tool builders .externalToolBuilders/ # Locally stored "Eclipse launch configurations" *.launch # CDT-specific .cproject # PDT-specific .buildpath ################# ## Visual Studio ################# ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. # User-specific files *.suo *.user *.sln.docstates # Build results [Dd]ebug/ [Rr]elease/ x64/ build/ [Bb]in/ [Oo]bj/ # MSTest test Results [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* *_i.c *_p.c *.ilk *.meta *.obj *.pch *.pdb *.pgc *.pgd *.rsp *.sbr *.tlb *.tli *.tlh *.tmp_proj *.log *.vspscc *.vssscc .builds *.pidb *.scc # Visual C++ cache files ipch/ *.aps *.ncb *.opensdf *.sdf *.cachefile # Visual Studio profiler *.psess *.vsp *.vspx # Guidance Automation Toolkit *.gpState # ReSharper is a .NET coding add-in _ReSharper*/ *.[Rr]e[Ss]harper # TeamCity is a build add-in _TeamCity* # DotCover is a Code Coverage Tool *.dotCover # NCrunch *.ncrunch* .*crunch*.local.xml # Installshield output folder [Ee]xpress/ # DocProject is a documentation generator add-in DocProject/buildhelp/ DocProject/Help/*.HxT DocProject/Help/*.HxC DocProject/Help/*.hhc DocProject/Help/*.hhk DocProject/Help/*.hhp DocProject/Help/Html2 DocProject/Help/html # Click-Once directory publish/ # Publish Web Output *.Publish.xml *.pubxml *.publishproj # NuGet Packages Directory ## TODO: If you have NuGet Package Restore enabled, uncomment the next line #packages/ # Windows Azure Build Output csx *.build.csdef # Windows Store app package directory AppPackages/ # Others sql/ *.Cache ClientBin/ [Ss]tyle[Cc]op.* ~$* *~ *.dbmdl *.[Pp]ublish.xml *.pfx *.publishsettings # RIA/Silverlight projects Generated_Code/ # Backup & report files from converting an old project file to a newer # Visual Studio version. Backup files are not needed, because we have git ;-) _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML UpgradeLog*.htm # SQL Server files App_Data/*.mdf App_Data/*.ldf ############# ## Windows detritus ############# # Windows image file caches Thumbs.db ehthumbs.db # Folder config file Desktop.ini # Recycle Bin used on file shares $RECYCLE.BIN/ # Mac crap .DS_Store ############# ## Python ############# # PyCharm .idea/ *.py[cod] # Packages *.egg *.egg-info dist/ eggs/ parts/ var/ sdist/ develop-eggs/ .installed.cfg # Installer logs pip-log.txt # Unit test / coverage reports .coverage .tox #Translations *.mo #Mr Developer .mr.developer.cfg # QtCreator *.pro.user /build-qhexedit-*/ .directory qhexedit2/build-example.sh0000755000175000017500000000016513716244704015734 0ustar carstencarstenif [ ! -d build ];then mkdir build else rm -rf build/* fi cd build qmake ../example/qhexedit.pro make cd ..