Moved some parts to a static lib so both the executable and the tests can link to it.
Written additional tests.
This commit is contained in:
parent
0a809a7288
commit
d0ea9dfa0c
39 changed files with 1767 additions and 493 deletions
|
|
@ -5,11 +5,11 @@
|
|||
#include <memory>
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <QUuid>
|
||||
|
||||
#include "connectionconfig.h"
|
||||
#include "expected.h"
|
||||
|
||||
class ConnectionList;
|
||||
|
||||
/** \brief Model class for the list of connections.
|
||||
*
|
||||
|
|
@ -18,7 +18,9 @@
|
|||
class ConnectionListModel : public QAbstractListModel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConnectionListModel(QObject *parent);
|
||||
ConnectionListModel(ConnectionList *conns, QObject *parent);
|
||||
ConnectionListModel(const ConnectionListModel&) = delete;
|
||||
~ConnectionListModel();
|
||||
|
||||
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
virtual int columnCount(const QModelIndex &/*parent*/) const override;
|
||||
|
|
@ -27,30 +29,16 @@ public:
|
|||
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
|
||||
void add(const ConnectionConfig &cfg);
|
||||
void newItem();
|
||||
Expected<ConnectionConfig> get(int row);
|
||||
virtual bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
|
||||
void load();
|
||||
void save();
|
||||
void save(int index);
|
||||
private:
|
||||
class LijstElem {
|
||||
public:
|
||||
QUuid m_uuid;
|
||||
bool m_dirty = false;
|
||||
ConnectionConfig m_config;
|
||||
|
||||
LijstElem(const QUuid id, const ConnectionConfig &cfg)
|
||||
: m_uuid(id), m_config(cfg)
|
||||
{}
|
||||
};
|
||||
ConnectionList *m_connections;
|
||||
|
||||
using t_Connections = std::vector<LijstElem>;
|
||||
t_Connections m_connections;
|
||||
|
||||
void deleteFromIni(t_Connections::iterator begin, t_Connections::iterator end);
|
||||
static QString iniFileName();
|
||||
|
||||
static QString makeLongDescription(const ConnectionConfig &cfg);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue