diff options
author | ck <qt-info@nokia.com> | 2010-02-02 11:06:27 +0100 |
---|---|---|
committer | ck <qt-info@nokia.com> | 2010-02-02 11:06:27 +0100 |
commit | 18dd27354786d3c7b4b522a7ddc538ae8700fb80 (patch) | |
tree | c38a0ded6be6073c8340ddb72af10750a4bc3ca7 | |
parent | f52e7cc384f1b013d252c7fa0eab715f26044698 (diff) | |
download | qt-creator-18dd27354786d3c7b4b522a7ddc538ae8700fb80.tar.gz |
BinEditor: Copy data as displayed in hex column.
Instigated-by: hjk
-rw-r--r-- | src/plugins/bineditor/bineditor.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/plugins/bineditor/bineditor.cpp b/src/plugins/bineditor/bineditor.cpp index 5242702709..cc82aac138 100644 --- a/src/plugins/bineditor/bineditor.cpp +++ b/src/plugins/bineditor/bineditor.cpp @@ -1121,10 +1121,19 @@ void BinEditor::zoomOut(int range) void BinEditor::copy() { - int selStart = qMin(m_cursorPosition, m_anchorPosition); - int selEnd = qMax(m_cursorPosition, m_anchorPosition); - if (selStart < selEnd) - QApplication::clipboard()->setText(QString::fromLatin1(dataMid(selStart, selEnd - selStart))); + const int selStart = selectionStart(); + const int selEnd = selectionEnd(); + if (selStart < selEnd) { + const QByteArray &data = dataMid(selStart, selEnd - selStart); + QString hexString; + const char * const hex = "0123456789abcdef"; + for (int i = 0; i < data.size(); ++i) { + const uchar val = static_cast<uchar>(data[i]); + hexString.append(hex[val >> 4]).append(hex[val & 0xf]).append(' '); + } + hexString.chop(1); + QApplication::clipboard()->setText(hexString); + } } void BinEditor::highlightSearchResults(const QByteArray &pattern, QTextDocument::FindFlags findFlags) |