From 0cbd0d16a12bb49170e53bb4d710872e254a5975 Mon Sep 17 00:00:00 2001 From: eelke Date: Sat, 9 Dec 2017 15:46:33 +0100 Subject: [PATCH] Seperated the Param data from the model. This makes saving and loading the parameter data easier to do without cluttering up the model class. --- pglab/ParamListModel.cpp | 10 ++++++++++ pglab/ParamListModel.h | 32 +++++++++++++++++------------- pglab/QueryParamListController.cpp | 2 +- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/pglab/ParamListModel.cpp b/pglab/ParamListModel.cpp index 801e441..931b15c 100644 --- a/pglab/ParamListModel.cpp +++ b/pglab/ParamListModel.cpp @@ -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); +} diff --git a/pglab/ParamListModel.h b/pglab/ParamListModel.h index 7363bde..62449f6 100644 --- a/pglab/ParamListModel.h +++ b/pglab/ParamListModel.h @@ -1,23 +1,26 @@ -#ifndef PARAMLISTMODEL_H +#ifndef PARAMLISTMODEL_H #define PARAMLISTMODEL_H #include #include #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; + + 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; t_ParamList m_paramList; }; diff --git a/pglab/QueryParamListController.cpp b/pglab/QueryParamListController.cpp index 947a0e8..0906c80 100644 --- a/pglab/QueryParamListController.cpp +++ b/pglab/QueryParamListController.cpp @@ -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); }