EditDialog: Improve handling of binary data in text mode

Make the EditDialog a bit more user friendly when editing binary data in
text mode:

Don't change back to the hex editor after changing any character.

Show the full binary data even if it contains a NULL byte.

Also (though a bit unrelated) disable rich text input for the text widget.

This partially fixes issue #19.
This commit is contained in:
Martin Kleusberg
2014-05-25 11:53:31 +02:00
parent 516d71f146
commit 7b9a120d42
2 changed files with 9 additions and 2 deletions

View File

@@ -54,10 +54,15 @@ void EditDialog::loadText(const QByteArray& data, int row, int col)
curCol = col;
oldData = data;
ui->editorText->setPlainText(data);
QString textData = QString::fromUtf8(data.constData(), data.size());
ui->editorText->setPlainText(textData);
ui->editorText->setFocus();
ui->editorText->selectAll();
hexEdit->setData(data);
// Assume it's binary data and only call checkDatyType afterwards. This means the correct input widget is selected here in all cases
// but once the user changed it to text input it will stay there.
ui->editorStack->setCurrentIndex(1);
checkDataType();
}
@@ -162,7 +167,6 @@ void EditDialog::checkDataType()
ui->comboEditor->setVisible(false);
} else {
// It's not. So it's probably some random binary data.
ui->editorStack->setCurrentIndex(1);
ui->labelType->setText(tr("Type of data currently in cell: Binary"));
ui->labelSize->setText(tr("%n byte(s)", "", hexEdit->data().length()));

View File

@@ -93,6 +93,9 @@
<property name="whatsThis">
<string>This area displays information about the data present in this database cell</string>
</property>
<property name="acceptRichText">
<bool>false</bool>
</property>
</widget>
<widget class="QWidget" name="editorBinary"/>
<widget class="QScrollArea" name="editorImageScrollArea">