diff --git a/src/EditDialog.cpp b/src/EditDialog.cpp
index 42faabd2..b8d6cdc7 100644
--- a/src/EditDialog.cpp
+++ b/src/EditDialog.cpp
@@ -293,6 +293,20 @@ void EditDialog::setNull()
hexEdit->setData(QByteArray());
dataType = Null;
+ // Check if in text editor mode
+ int editMode = ui->editorStack->currentIndex();
+ if (editMode == TextEditor) {
+ // Setting NULL in the text editor switches the data source to it
+ dataSource = TextBuffer;
+
+ // Ensure the text editor is enabled
+ ui->editorText->setEnabled(true);
+
+ // The text editor doesn't know the difference between an empty string
+ // and a NULL, so we need to record NULL outside of that
+ textNullSet = true;
+ }
+
// Update the cell data info in the bottom left of the Edit Cell
updateCellInfo(hexEdit->data());
@@ -305,11 +319,17 @@ void EditDialog::accept()
return;
if (dataSource == TextBuffer) {
- QString oldData = currentIndex.data(Qt::EditRole).toString();
- QString newData = ui->editorText->toPlainText();
- if (oldData != newData)
- // The data is different, so commit it back to the database
- emit recordTextUpdated(currentIndex, newData.toUtf8(), false);
+ // Check if a NULL is set in the text editor
+ if (textNullSet) {
+ emit recordTextUpdated(currentIndex, hexEdit->data(), true);
+ } else {
+ // It's not NULL, so proceed with normal text string checking
+ QString oldData = currentIndex.data(Qt::EditRole).toString();
+ QString newData = ui->editorText->toPlainText();
+ if (oldData != newData)
+ // The data is different, so commit it back to the database
+ emit recordTextUpdated(currentIndex, newData.toUtf8(), false);
+ }
} else {
// The data source is the hex widget buffer, thus binary data
QByteArray oldData = currentIndex.data(Qt::EditRole).toByteArray();
@@ -360,6 +380,22 @@ void EditDialog::editModeChanged(int newMode)
}
}
+// Called for every keystroke in the text editor (only)
+void EditDialog::editTextChanged()
+{
+ if (dataSource == TextBuffer) {
+ // Data has been changed in the text editor, so it can't be a NULL
+ // any more
+ textNullSet = false;
+
+ // Update the cell info in the bottom left manually. This is because
+ // updateCellInfo() only works with QByteArray's (for now)
+ int dataLength = ui->editorText->toPlainText().length();
+ ui->labelType->setText(tr("Type of data currently in cell: Text / Numeric"));
+ ui->labelSize->setText(tr("%n char(s)", "", dataLength));
+ }
+}
+
// Determine the type of data in the cell
int EditDialog::checkDataType(const QByteArray& data)
{
diff --git a/src/EditDialog.h b/src/EditDialog.h
index 38af2d52..b3c0a191 100644
--- a/src/EditDialog.h
+++ b/src/EditDialog.h
@@ -37,6 +37,7 @@ private slots:
virtual void loadData(const QByteArray& data);
virtual void toggleOverwriteMode();
virtual void editModeChanged(int newMode);
+ virtual void editTextChanged();
virtual void updateCellInfo(const QByteArray& data);
virtual QString humanReadableSize(double byteCount);
@@ -49,6 +50,7 @@ private:
QPersistentModelIndex currentIndex;
int dataSource;
int dataType;
+ bool textNullSet;
enum DataSources {
TextBuffer,
diff --git a/src/EditDialog.ui b/src/EditDialog.ui
index 5b124ee0..8f35092b 100644
--- a/src/EditDialog.ui
+++ b/src/EditDialog.ui
@@ -326,6 +326,22 @@
+
+ editorText
+ textChanged()
+ EditDialog
+ editTextChanged()
+
+
+ 279
+ 191
+
+
+ 339
+ 335
+
+
+
importData()