Store connection configuration as key value pairs
Add migration for the sqlite database. Because the Qt SQL library is a bit hard to work with use sqlite through custom wrapper.
This commit is contained in:
parent
4caccf1000
commit
aac55b0ed1
17 changed files with 276439 additions and 384 deletions
|
|
@ -11,8 +11,7 @@
|
|||
#include <variant>
|
||||
#include <QVector>
|
||||
|
||||
#include <QSqlError>
|
||||
class QSqlDatabase;
|
||||
#include "sqlite/SQLiteConnection.h"
|
||||
|
||||
class ConnectionTreeModel : public QAbstractItemModel {
|
||||
Q_OBJECT
|
||||
|
|
@ -27,7 +26,7 @@ public:
|
|||
ColCount
|
||||
};
|
||||
|
||||
ConnectionTreeModel(QObject *parent, QSqlDatabase &db);
|
||||
ConnectionTreeModel(QObject *parent, SQLiteConnection &db);
|
||||
|
||||
void load();
|
||||
|
||||
|
|
@ -61,8 +60,8 @@ public:
|
|||
void save(const ConnectionConfig &cc);
|
||||
void clearAllPasswords();
|
||||
/// Create a new group in the DB and place in the tree
|
||||
std::variant<int, QSqlError> addGroup(const QString &group_name);
|
||||
std::optional<QSqlError> removeGroup(int row);
|
||||
int addGroup(const QString &group_name);
|
||||
void removeGroup(int row);
|
||||
int findGroup(int conngroup_id) const;
|
||||
|
||||
static ConnectionConfig* getConfigFromModelIndex(QModelIndex index);
|
||||
|
|
@ -71,7 +70,7 @@ public:
|
|||
private:
|
||||
using Groups = QVector<std::shared_ptr<ConnectionGroup>>;
|
||||
|
||||
QSqlDatabase &m_db;
|
||||
SQLiteConnection &m_db;
|
||||
Groups m_groups;
|
||||
|
||||
/// Finds the connection with the specified uuid and returns
|
||||
|
|
@ -79,8 +78,11 @@ private:
|
|||
std::tuple<int, int> findConfig(const QUuid uuid) const;
|
||||
int findGroup(const QString &name) const;
|
||||
|
||||
std::optional<QSqlError> saveToDb(const ConnectionConfig &cc);
|
||||
void saveToDb(const ConnectionConfig &cc);
|
||||
|
||||
void loadGroups();
|
||||
void loadConnections();
|
||||
void loadConnectionParameters(ConnectionConfig &cc);
|
||||
// QAbstractItemModel interface
|
||||
public:
|
||||
virtual Qt::DropActions supportedDropActions() const override;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue