Change the internal data type for cell contents to a binary type

Store the data of a DB cell in a QByteArray, i.e. a binary data type,
instead of putting it in a QString, thus converting it to a UTF8 string.

Rewrite the reading and writing of DB cells to correctly handle binary
data containing 0x00 bytes.

Change the edit dialog to actually do all the data checks etc. on a
currently invisible QHexEdit widget instead of a QTextEdit.

All these changes combined make it possible to actually store binary
data without it being corrupted. You can for example import pictures
now, export them and actually open the exported file. So this is an
improvement.
This commit is contained in:
Martin Kleusberg
2013-03-17 01:38:48 +01:00
parent 0cf9ecd158
commit 6c8712d804
7 changed files with 104 additions and 86 deletions

View File

@@ -2,6 +2,7 @@
#define __EDITDIALOG_H__
#include <QDialog>
class QHexEdit;
namespace Ui {
class EditDialog;
@@ -23,7 +24,7 @@ public:
public slots:
virtual void reset();
virtual void loadText(const QString& text, int row, int col);
virtual void loadText(const QByteArray& data, int row, int col);
private slots:
virtual void enableExport(bool enabled);
@@ -37,10 +38,11 @@ private slots:
signals:
void goingAway();
void updateRecordText(int, int, const QString&);
void updateRecordText(int, int, const QByteArray&);
private:
Ui::EditDialog* ui;
QHexEdit* hexEdit;
int dataType;
int dataSize;
int curCol;