2017-12-12 20:13:53 +01:00
|
|
|
|
#ifndef COLUMNTABLEMODEL_H
|
|
|
|
|
|
#define COLUMNTABLEMODEL_H
|
|
|
|
|
|
|
|
|
|
|
|
#include "BaseTableModel.h"
|
2018-11-29 20:21:36 +01:00
|
|
|
|
#include "PgAttribute.h"
|
2017-12-17 19:54:23 +01:00
|
|
|
|
#include "PgClass.h"
|
2017-12-17 19:34:28 +01:00
|
|
|
|
#include "PgIndex.h"
|
2017-12-12 20:13:53 +01:00
|
|
|
|
#include <memory>
|
2018-11-18 20:24:27 +01:00
|
|
|
|
#include <optional>
|
2017-12-17 19:34:28 +01:00
|
|
|
|
#include <vector>
|
2017-12-12 20:13:53 +01:00
|
|
|
|
|
|
|
|
|
|
class PgDatabaseCatalog;
|
|
|
|
|
|
class PgAttribute;
|
|
|
|
|
|
|
|
|
|
|
|
class ColumnTableModel: public BaseTableModel {
|
|
|
|
|
|
public:
|
|
|
|
|
|
enum e_Columns : int {
|
2018-08-05 09:05:56 +02:00
|
|
|
|
AttnumCol,
|
2017-12-12 20:13:53 +01:00
|
|
|
|
NameCol, ///
|
|
|
|
|
|
TypeCol,
|
|
|
|
|
|
NullCol,
|
|
|
|
|
|
DefaultCol,
|
2017-12-25 10:31:58 +01:00
|
|
|
|
ForeignKeyCol,
|
2017-12-12 20:13:53 +01:00
|
|
|
|
CollationCol,
|
|
|
|
|
|
|
|
|
|
|
|
colCount };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using BaseTableModel::BaseTableModel;
|
2018-11-18 20:24:27 +01:00
|
|
|
|
void setData(std::shared_ptr<const PgDatabaseCatalog> cat, const std::optional<PgClass> &table);
|
2017-12-12 20:13:53 +01:00
|
|
|
|
|
|
|
|
|
|
// Header:
|
|
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
|
|
|
|
|
|
|
|
|
|
|
// Basic functionality:
|
|
|
|
|
|
int rowCount(const QModelIndex &parent) const override;
|
|
|
|
|
|
int columnCount(const QModelIndex &parent) const override;
|
|
|
|
|
|
|
|
|
|
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
2018-11-29 20:21:36 +01:00
|
|
|
|
const PgAttribute& column(int row) const;
|
2017-12-12 20:13:53 +01:00
|
|
|
|
protected:
|
|
|
|
|
|
virtual Oid getType(int column) const override;
|
|
|
|
|
|
virtual QVariant getData(const QModelIndex &index) const override;
|
|
|
|
|
|
|
|
|
|
|
|
using t_Columns = std::vector<PgAttribute>;
|
|
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<const PgDatabaseCatalog> m_catalog;
|
2018-11-18 20:24:27 +01:00
|
|
|
|
std::optional<PgClass> m_table;
|
2017-12-12 20:13:53 +01:00
|
|
|
|
t_Columns m_columns;
|
2017-12-17 19:34:28 +01:00
|
|
|
|
std::vector<PgIndex> m_indexes;
|
2017-12-12 20:13:53 +01:00
|
|
|
|
|
2017-12-25 10:31:58 +01:00
|
|
|
|
QString getFKey(const PgAttribute &column) const;
|
|
|
|
|
|
|
2017-12-12 20:13:53 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // COLUMNTABLEMODEL_H
|