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! // // FIXME: Implement me!
// endRemoveColumns(); // endRemoveColumns();
//} //}
const t_ParamList& ParamListModel::GetParams() const
{
return m_paramList;
}
void ParamListModel::SetParams(t_ParamList params)
{
m_paramList = std::move(params);
}

View file

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

View file

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