Commit 18dd2735 authored by ck's avatar ck
Browse files

BinEditor: Copy data as displayed in hex column.

Instigated-by: hjk
parent f52e7cc3
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment