mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
Support text in different encoding in Browse Data tab
When browsing and editing a table in the Browse Data tab allow the user to change the assumed encoding of the text in the table. We'll then try to convert from this encoding to Unicode for display purposes and to convert from Unicode to this encoding for editing purposes. This way the UI and all tools will keep using Unicode while the database format is still respected. I hope the amount conversions generated this way won't affect the performance too much. See issue #414.
This commit is contained in:
@@ -12,7 +12,7 @@ class SqliteTableModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SqliteTableModel(QObject *parent = 0, DBBrowserDB* db = 0, size_t chunkSize = 50000);
|
||||
explicit SqliteTableModel(QObject *parent = 0, DBBrowserDB* db = 0, size_t chunkSize = 50000, const QString& encoding = QString());
|
||||
void reset();
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
@@ -40,12 +40,13 @@ public:
|
||||
|
||||
bool isBinary(const QModelIndex& index) const;
|
||||
|
||||
void setEncoding(QString encoding) { m_encoding = encoding; }
|
||||
QString encoding() const { return m_encoding; }
|
||||
|
||||
typedef QList<QByteArray> QByteArrayList;
|
||||
|
||||
sqlb::ForeignKeyClause getForeignKeyClause(int column) const;
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void updateFilter(int column, const QString& value);
|
||||
|
||||
@@ -57,6 +58,9 @@ private:
|
||||
QStringList getColumns(const QString& sQuery, QVector<int>& fieldsTypes);
|
||||
int getQueryRowCount();
|
||||
|
||||
QByteArray encode(const QByteArray& str) const;
|
||||
QByteArray decode(const QByteArray& str) const;
|
||||
|
||||
DBBrowserDB* m_db;
|
||||
int m_rowCount;
|
||||
QStringList m_headers;
|
||||
@@ -82,6 +86,8 @@ private:
|
||||
size_t m_chunkSize;
|
||||
|
||||
bool m_valid; //! tells if the current query is valid.
|
||||
|
||||
QString m_encoding;
|
||||
};
|
||||
|
||||
#endif // SQLITETABLEMODEL_H
|
||||
|
||||
Reference in New Issue
Block a user