Most of functionality for connections in tree works now. Old list largely removed.
This commit is contained in:
parent
8840d3bcbb
commit
b3a98f6dc0
10 changed files with 399 additions and 158 deletions
|
|
@ -8,9 +8,11 @@
|
|||
|
||||
#include "ConnectionConfig.h"
|
||||
#include "Expected.h"
|
||||
#include <optional>
|
||||
#include <variant>
|
||||
#include <QVector>
|
||||
|
||||
//#include <QSqlDatabase>
|
||||
#include <QSqlError>
|
||||
class QSqlDatabase;
|
||||
|
||||
class ConnectionTreeModel : public QAbstractItemModel {
|
||||
|
|
@ -46,13 +48,36 @@ public:
|
|||
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
|
||||
/** Matches cc to the list by looking at its uuid.
|
||||
*
|
||||
* If it is not in the list it is added. If the uuid is in the list that entry is updated.
|
||||
* If the group has been changed it is moved to the right group.
|
||||
* In both cases the data is also directly written to long term storage.
|
||||
*/
|
||||
void save(const QString &group, const ConnectionConfig &cc);
|
||||
/** Save changed config, group is not allowed to change
|
||||
*/
|
||||
void save(const ConnectionConfig &cc);
|
||||
private:
|
||||
using Groups = QVector<std::shared_ptr<ConnectionGroup>>;
|
||||
|
||||
QSqlDatabase &m_db;
|
||||
Groups m_groups;
|
||||
|
||||
/// Finds the connection with the specified uuid and returns
|
||||
/// { group_index, connection_index }
|
||||
std::tuple<int, int> findConfig(const QUuid uuid) const;
|
||||
int findGroup(QString name) const;
|
||||
|
||||
/// Create a new group in the DB and place in the tree
|
||||
/// dataChanged is sent by this function
|
||||
std::variant<int, QSqlError> addGroup(QString group_name);
|
||||
std::optional<QSqlError> saveToDb(const ConnectionConfig &cc);
|
||||
};
|
||||
|
||||
#if false
|
||||
/** \brief Model class for the list of connections.
|
||||
*
|
||||
* This class also allows for the editing of the list.
|
||||
|
|
@ -107,5 +132,6 @@ private:
|
|||
|
||||
QString iniFileName();
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // CONNECTIONLISTMODEL_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue