2017-12-10 10:35:46 +01:00
|
|
|
|
#ifndef TABLESTABLEMODEL_H
|
|
|
|
|
|
#define TABLESTABLEMODEL_H
|
|
|
|
|
|
|
|
|
|
|
|
#include "BaseTableModel.h"
|
2017-12-17 19:54:23 +01:00
|
|
|
|
#include "PgClass.h"
|
2017-12-10 10:35:46 +01:00
|
|
|
|
#include <memory>
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
|
|
class PgClass;
|
|
|
|
|
|
class PgDatabaseCatalog;
|
|
|
|
|
|
|
2018-08-27 21:12:27 +02:00
|
|
|
|
class TablesTableModel: public QAbstractTableModel {
|
2017-12-10 10:35:46 +01:00
|
|
|
|
public:
|
|
|
|
|
|
enum e_Columns : int {
|
|
|
|
|
|
NameCol, ///< either table, ns.table or table (ns) depending on settings/filters
|
2017-12-12 20:13:53 +01:00
|
|
|
|
NamespaceCol,
|
2017-12-10 10:35:46 +01:00
|
|
|
|
OwnerCol,
|
|
|
|
|
|
TablespaceCol,
|
|
|
|
|
|
OptionsCol,
|
2018-01-06 21:22:22 +01:00
|
|
|
|
//AclCol,
|
2017-12-10 10:35:46 +01:00
|
|
|
|
colCount };
|
|
|
|
|
|
|
|
|
|
|
|
TablesTableModel(QObject *parent);
|
|
|
|
|
|
|
|
|
|
|
|
void setCatalog(std::shared_ptr<const PgDatabaseCatalog> cat);
|
|
|
|
|
|
|
2018-07-07 09:57:59 +02:00
|
|
|
|
virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
|
2018-01-07 09:02:53 +01:00
|
|
|
|
void setSortOrder(int so);
|
|
|
|
|
|
|
2017-12-10 10:35:46 +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;
|
|
|
|
|
|
|
2017-12-12 20:13:53 +01:00
|
|
|
|
virtual QVariant data(const QModelIndex &index, int role) const override;
|
2017-12-17 19:54:23 +01:00
|
|
|
|
PgClass getTable(int row) const;
|
2017-12-12 20:13:53 +01:00
|
|
|
|
Oid getTableOid(int row) const;
|
2017-12-10 10:35:46 +01:00
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
using t_Tables = std::vector<PgClass>;
|
|
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<const PgDatabaseCatalog> m_catalog;
|
|
|
|
|
|
t_Tables m_tables;
|
|
|
|
|
|
|
2018-08-27 21:12:27 +02:00
|
|
|
|
Oid getType(int column) const;
|
|
|
|
|
|
QVariant getData(const QModelIndex &index) const;
|
2017-12-10 10:35:46 +01:00
|
|
|
|
QString formatTableName(const PgClass &cls) const;
|
2018-01-07 09:02:53 +01:00
|
|
|
|
void doSort(int so);
|
2017-12-10 10:35:46 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // TABLESTABLEMODEL_H
|