mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-05-23 05:58:24 -05:00
XML mode for the cell editor
The new editor mode shares the same Scintilla widget as the JSON mode. The JsonTextEdit class has been generalised. Future modes supported by Scintilla could be added with the current pattern. As a consequence, the EditMode is not always equal to the current stacked widget. Some code in EditDialog has been refactored, so it is easier to understand and modified with so many modes. textNullSet has been replaced by the use of dataType as Null. SVG is promoted to a new recognised data type, so it can be edited in the XML mode. The XML data is formatted and validated following the pattern established by the JSON mode. New modules are needed by the XML mode: the Qt XML module and some new Scintilla files required by the HTML/XML lexer. The indent_compact was incorrectly named in Setting::getDefaultValue. See issue #1253.
This commit is contained in:
+13
-8
@@ -4,9 +4,8 @@
|
||||
#include <QDialog>
|
||||
#include <QPersistentModelIndex>
|
||||
|
||||
#include "jsontextedit.h"
|
||||
|
||||
class QHexEdit;
|
||||
class DockTextEdit;
|
||||
|
||||
namespace Ui {
|
||||
class EditDialog;
|
||||
@@ -50,38 +49,44 @@ signals:
|
||||
private:
|
||||
Ui::EditDialog* ui;
|
||||
QHexEdit* hexEdit;
|
||||
JsonTextEdit* jsonEdit;
|
||||
DockTextEdit* sciEdit;
|
||||
QPersistentModelIndex currentIndex;
|
||||
int dataSource;
|
||||
int dataType;
|
||||
bool textNullSet;
|
||||
bool isReadOnly;
|
||||
bool mustIndentAndCompact;
|
||||
|
||||
enum DataSources {
|
||||
TextBuffer,
|
||||
HexBuffer,
|
||||
JsonBuffer
|
||||
SciBuffer
|
||||
};
|
||||
|
||||
// SVG is both an Image and an XML document so it is treated separately
|
||||
enum DataTypes {
|
||||
Binary,
|
||||
Image,
|
||||
Null,
|
||||
Text,
|
||||
JSON
|
||||
JSON,
|
||||
SVG
|
||||
};
|
||||
|
||||
// Edit modes and editor stack (this must be aligned with the UI)
|
||||
// Note that JSON and XML share the Scintilla widget.
|
||||
enum EditModes {
|
||||
TextEditor = 0,
|
||||
HexEditor = 1,
|
||||
JsonEditor = 2,
|
||||
ImageViewer = 3
|
||||
ImageViewer = 2,
|
||||
JsonEditor, SciEditor = 3,
|
||||
XmlEditor = 4
|
||||
};
|
||||
|
||||
int checkDataType(const QByteArray& data);
|
||||
QString humanReadableSize(double byteCount) const;
|
||||
bool promptInvalidData(const QString& dataType, const QString& errorString);
|
||||
void setDataInBuffer(const QByteArray& data, DataSources source);
|
||||
void setStackCurrentIndex(int editMode);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user