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:
parent
3bf1ef4fe0
commit
0cbd0d16a1
3 changed files with 29 additions and 15 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,12 @@
|
|||
#ifndef PARAMLISTMODEL_H
|
||||
#ifndef PARAMLISTMODEL_H
|
||||
#define PARAMLISTMODEL_H
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include <vector>
|
||||
#include "Pgsql_declare.h"
|
||||
|
||||
class ParamListModel : public QAbstractTableModel {
|
||||
Q_OBJECT
|
||||
class Param {
|
||||
public:
|
||||
class Param {
|
||||
public:
|
||||
QString value; ///< the value of the parameter (currently this is passed directly)
|
||||
QString type; ///< the type of the parameter
|
||||
|
||||
|
|
@ -17,7 +14,13 @@ public:
|
|||
Param(const QString &v, const QString t)
|
||||
: value(v), type(t)
|
||||
{}
|
||||
};
|
||||
};
|
||||
using t_ParamList = std::vector<Param>;
|
||||
|
||||
|
||||
class ParamListModel : public QAbstractTableModel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue