Skip to content

Commit

Permalink
EditDialog: Show warning when editing binary data in text mode
Browse files Browse the repository at this point in the history
  • Loading branch information
MKleusberg committed May 25, 2014
1 parent 41296e3 commit ae4d04f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/EditDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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()));
}
Expand Down
27 changes: 20 additions & 7 deletions src/EditDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down

0 comments on commit ae4d04f

Please sign in to comment.