Made a list model for displaying them in a list. Also added controles to edit the most important properties.
35 lines
928 B
C++
35 lines
928 B
C++
#ifndef CONNECTIONLISTMODEL_H
|
|
#define CONNECTIONLISTMODEL_H
|
|
|
|
#include <vector>
|
|
#include <memory>
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
#include "connectionconfig.h"
|
|
|
|
|
|
class ConnectionListModel : public QAbstractListModel {
|
|
Q_OBJECT
|
|
public:
|
|
ConnectionListModel(QObject *parent);
|
|
|
|
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
|
// virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
|
|
|
void add(const ConnectionConfig &cfg)
|
|
{
|
|
m_connections.push_back(cfg);
|
|
auto idx = createIndex(m_connections.size()-1, 0);
|
|
emit dataChanged(idx, idx);
|
|
}
|
|
|
|
private:
|
|
using t_Connections = std::vector<ConnectionConfig>;
|
|
t_Connections m_connections;
|
|
|
|
static QString makeLongDescription(const ConnectionConfig &cfg);
|
|
};
|
|
|
|
#endif // CONNECTIONLISTMODEL_H
|