Seperated the Param data from the model.

This makes saving and loading the parameter data easier to do without cluttering up the model class.
This commit is contained in:
eelke 2017-12-09 15:46:33 +01:00
parent 3bf1ef4fe0
commit 0cbd0d16a1
3 changed files with 29 additions and 15 deletions

View file

@ -135,3 +135,13 @@ bool ParamListModel::removeRows(int row, int count, const QModelIndex &parent)
// // FIXME: Implement me!
// endRemoveColumns();
//}
const t_ParamList& ParamListModel::GetParams() const
{
return m_paramList;
}
void ParamListModel::SetParams(t_ParamList params)
{
m_paramList = std::move(params);
}

View file

@ -1,23 +1,26 @@
#ifndef PARAMLISTMODEL_H
#ifndef PARAMLISTMODEL_H
#define PARAMLISTMODEL_H
#include <QAbstractTableModel>
#include <vector>
#include "Pgsql_declare.h"
class Param {
public:
QString value; ///< the value of the parameter (currently this is passed directly)
QString type; ///< the type of the parameter
Param() = default;
Param(const QString &v, const QString t)
: value(v), type(t)
{}
};
using t_ParamList = std::vector<Param>;
class ParamListModel : public QAbstractTableModel {
Q_OBJECT
public:
class Param {
public:
QString value; ///< the value of the parameter (currently this is passed directly)
QString type; ///< the type of the parameter
Param() = default;
Param(const QString &v, const QString t)
: value(v), type(t)
{}
};
enum e_Column {
ColValue = 0,
@ -46,11 +49,12 @@ public:
bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
auto begin() const { return m_paramList.begin(); }
auto end() const { return m_paramList.end(); }
// auto begin() const { return m_paramList.begin(); }
// auto end() const { return m_paramList.end(); }
const t_ParamList& GetParams() const;
void SetParams(t_ParamList params);
private:
using t_ParamList = std::vector<Param>;
t_ParamList m_paramList;
};

View file

@ -23,7 +23,7 @@ Pgsql::Params QueryParamListController::params() const
{
Pgsql::Params params;
auto types = m_openDatabase->catalogue()->types();
for (auto e : m_paramList) {
for (auto e : m_paramList.GetParams()) {
Oid oid = types->getByName(e.type).oid;
params.add(e.value, oid);
}