Double clicking a table now opens a CRUD page for that table however data cannot be changed yet thought it will display an editbox.
This commit is contained in:
parent
abd4020ddf
commit
2ba27178a2
13 changed files with 288 additions and 33 deletions
|
|
@ -4,13 +4,15 @@
|
|||
#include "BaseTableModel.h"
|
||||
#include "ASyncDBConnection.h"
|
||||
#include "PgClass.h"
|
||||
#include "PgConstraint.h"
|
||||
#include "Pgsql_Connection.h"
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
class PgConstraint;
|
||||
class OpenDatase;
|
||||
class OpenDatabase;
|
||||
class ASyncWindow;
|
||||
|
||||
/**
|
||||
* @brief The CrudModel class
|
||||
|
|
@ -33,35 +35,55 @@ class OpenDatase;
|
|||
class CrudModel: public BaseTableModel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
CrudModel();
|
||||
explicit CrudModel(ASyncWindow *async_win);
|
||||
~CrudModel();
|
||||
|
||||
void setConfig(std::shared_ptr<OpenDatabase> db, const PgClass &table);
|
||||
|
||||
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
void setData(std::shared_ptr<OpenDatabase> db, const PgClass &table);
|
||||
|
||||
|
||||
// Basic functionality:
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
virtual QVariant data(const QModelIndex &index, int role) const override;
|
||||
virtual Qt::ItemFlags flags(const QModelIndex &) const override;
|
||||
protected:
|
||||
virtual Oid getType(int column) const override;
|
||||
virtual QVariant getData(const QModelIndex &index) const override;
|
||||
|
||||
private:
|
||||
ASyncWindow * m_asyncWindow;
|
||||
std::shared_ptr<OpenDatabase> m_database;
|
||||
PgClass m_table;
|
||||
boost::optional<PgConstraint> m_primaryKey;
|
||||
ASyncDBConnection m_dbConn;
|
||||
bool callLoadData = false;
|
||||
|
||||
|
||||
using RowData = std::vector<std::string>;
|
||||
using RowDataPtr = std::unique_ptr<RowData>;
|
||||
/** Choosen for a vector of pointers while vector is relatively slow with insertion and removal in the middle
|
||||
* I hope the small size of the elements will make this not much of an issue while the simple linear and sequential
|
||||
* nature of a vector will keep memory allocation fairly efficient.
|
||||
using RowList = std::vector<RowDataPtr>;
|
||||
// using RowData = std::vector<std::string>;
|
||||
// using RowDataPtr = std::unique_ptr<RowData>;
|
||||
// /** Choosen for a vector of pointers while vector is relatively slow with insertion and removal in the middle
|
||||
// * I hope the small size of the elements will make this not much of an issue while the simple linear and sequential
|
||||
// * nature of a vector will keep memory allocation fairly efficient.
|
||||
// */
|
||||
// using RowList = std::vector<RowDataPtr>;
|
||||
|
||||
std::shared_ptr<Pgsql::Result> m_roData;
|
||||
void loadData();
|
||||
void loadIntoModel(std::shared_ptr<Pgsql::Result> data);
|
||||
|
||||
// std::shared_ptr<RowList> resultToRowList(std::shared_ptr<Pgsql::Result> result);
|
||||
|
||||
private slots:
|
||||
|
||||
void connectionStateChanged(ASyncDBConnection::State state);
|
||||
// void queryResult(std::shared_ptr<Pgsql::Result> result);
|
||||
// void queryError();
|
||||
|
||||
// void dataProcessingFutureFinished();
|
||||
};
|
||||
|
||||
#endif // CRUDMODEL_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue