MCPcopy Create free account
hub / github.com/Neverous/efibooteditor / dataFormatChanged

Method dataFormatChanged

src/filepathdialog.cpp:1536–1576  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1534}
1535
1536void FilePathDialog::dataFormatChanged(int &index, int new_index, QPlainTextEdit &_data, QComboBox &format)
1537{
1538 bool success = false;
1539 QByteArray input = getData(_data, index);
1540 QString output;
1541 switch(static_cast<DataFormat>(new_index))
1542 {
1543 case DataFormat::Base64:
1544 output = input.toBase64();
1545 success = true;
1546 break;
1547
1548 case DataFormat::Utf16:
1549 if(static_cast<uint>(input.size()) % sizeof(char16_t) == 0)
1550 success = toUnicode(output, input, "UTF-16");
1551
1552 break;
1553
1554 case DataFormat::Utf8:
1555 success = toUnicode(output, input, "UTF-8");
1556 break;
1557
1558 case DataFormat::Hex:
1559 output = input.toHex();
1560 success = true;
1561 break;
1562 }
1563
1564 if(output.contains(QChar(0)))
1565 success = false;
1566
1567 if(!success)
1568 {
1569 QMessageBox::critical(this, qApp->applicationName(), tr("Couldn't change data format!"));
1570 format.setCurrentIndex(index);
1571 return;
1572 }
1573
1574 _data.setPlainText(output);
1575 index = new_index;
1576}
1577
1578void FilePathDialog::resetDiskCombo()
1579{

Callers

nothing calls this directly

Calls 1

toUnicodeFunction · 0.85

Tested by

no test coverage detected