forked from qt-creator/qt-creator
BinEditor: Copy data as displayed in hex column.
Instigated-by: hjk
This commit is contained in:
@@ -1121,10 +1121,19 @@ void BinEditor::zoomOut(int range)
|
|||||||
|
|
||||||
void BinEditor::copy()
|
void BinEditor::copy()
|
||||||
{
|
{
|
||||||
int selStart = qMin(m_cursorPosition, m_anchorPosition);
|
const int selStart = selectionStart();
|
||||||
int selEnd = qMax(m_cursorPosition, m_anchorPosition);
|
const int selEnd = selectionEnd();
|
||||||
if (selStart < selEnd)
|
if (selStart < selEnd) {
|
||||||
QApplication::clipboard()->setText(QString::fromLatin1(dataMid(selStart, selEnd - selStart)));
|
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)
|
void BinEditor::highlightSearchResults(const QByteArray &pattern, QTextDocument::FindFlags findFlags)
|
||||||
|
|||||||
Reference in New Issue
Block a user