EditDialog: Show warning when editing binary data in text mode

This commit is contained in:
Martin Kleusberg
2014-05-25 17:30:57 +02:00
parent 41296e3ac0
commit ae4d04f9b1
2 changed files with 24 additions and 8 deletions

View File

@@ -144,12 +144,14 @@ void EditDialog::hexDataChanged()
void EditDialog::checkDataType()
{
// Check if data is text only
ui->comboEditor->setVisible(true);
// Check if data is text only
if(QString(hexEdit->data()).toUtf8() == hexEdit->data()) // Any proper way??
{
ui->editorStack->setCurrentIndex(0);
ui->labelBinayWarning->setVisible(false);
ui->labelType->setText(tr("Type of data currently in cell: Text / Numeric"));
ui->labelSize->setText(tr("%n char(s)", "", hexEdit->data().length()));
} else {
@@ -168,6 +170,7 @@ void EditDialog::checkDataType()
} else {
// It's not. So it's probably some random binary data.
ui->labelBinayWarning->setVisible(true);
ui->labelType->setText(tr("Type of data currently in cell: Binary"));
ui->labelSize->setText(tr("%n byte(s)", "", hexEdit->data().length()));
}

View File

@@ -89,13 +89,26 @@
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QTextEdit" name="editorText">
<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 class="QWidget" name="verticalLayout_4">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="labelBinayWarning">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600; color:#c00000;&quot;&gt;Warning: Editing binary content in text mode may result in corrupted data!&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="editorText">
<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>
</item>
</layout>
</widget>
<widget class="QWidget" name="editorBinary"/>
<widget class="QScrollArea" name="editorImageScrollArea">