added copy as C Array
This commit is contained in:
parent
4fb2ef8af8
commit
4d4f264153
|
@ -42,6 +42,14 @@ void DataPrinter::toClipboard(DataPrinter::DumpType type, IDataPrintable * print
|
|||
}
|
||||
clipboard_text += QString("}");
|
||||
break;
|
||||
case DP_CArray:
|
||||
clipboard_text += QString("unsigned char bytes[] = {");
|
||||
for (int i = 0; i < printData.length(); i++) {
|
||||
if (i>0) clipboard_text += ", ";
|
||||
clipboard_text += QString("0x%1").arg((uint8_t) printData[i], 1, 16, QChar('0'));
|
||||
}
|
||||
clipboard_text += QString("};");
|
||||
break;
|
||||
case DP_CString:
|
||||
// Beginning quote
|
||||
clipboard_text += QString("\"");
|
||||
|
@ -265,6 +273,11 @@ QActionGroup * DataPrinter::copyActions(QObject * copyClass, QObject * data)
|
|||
action->setProperty("printertype", DataPrinter::DP_GoLiteral);
|
||||
connect(action, &QAction::triggered, dpi, &DataPrinter::copyIDataBytes);
|
||||
|
||||
action = new QAction(tr("…as C Array"), actions);
|
||||
action->setToolTip(tr("Copy packet bytes as C Array."));
|
||||
action->setProperty("printertype", DataPrinter::DP_CArray);
|
||||
connect(action, &QAction::triggered, dpi, &DataPrinter::copyIDataBytes);
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ public:
|
|||
DP_PrintableText,
|
||||
DP_CString,
|
||||
DP_GoLiteral,
|
||||
DP_CArray,
|
||||
DP_MimeData,
|
||||
DP_Base64
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue