65 lines
1.6 KiB
C++
65 lines
1.6 KiB
C++
#ifndef TABLESTABLEMODEL_H
|
|
#define TABLESTABLEMODEL_H
|
|
|
|
#include "BaseTableModel.h"
|
|
#include "NamespaceFilter.h"
|
|
#include "catalog/PgClass.h"
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
class PgClass;
|
|
class PgDatabaseCatalog;
|
|
|
|
|
|
|
|
class TablesTableModel: public QAbstractTableModel {
|
|
public:
|
|
enum e_Columns : int {
|
|
NameCol, ///< either table, ns.table or table (ns) depending on settings/filters
|
|
NamespaceCol,
|
|
KindCol,
|
|
OwnerCol,
|
|
TablespaceCol,
|
|
OptionsCol,
|
|
AclCol,
|
|
CommentCol,
|
|
colCount };
|
|
|
|
TablesTableModel(QObject *parent);
|
|
|
|
void setNamespaceFilter(NamespaceFilter nsf);
|
|
void setCatalog(std::shared_ptr<const PgDatabaseCatalog> cat);
|
|
|
|
virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
|
|
void setSortOrder(int so);
|
|
|
|
// 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;
|
|
|
|
virtual QVariant data(const QModelIndex &index, int role) const override;
|
|
PgClass getTable(int row) const;
|
|
Oid getTableOid(int row) const;
|
|
|
|
private:
|
|
using t_Tables = std::vector<PgClass>;
|
|
|
|
std::shared_ptr<const PgDatabaseCatalog> m_catalog;
|
|
NamespaceFilter m_namespaceFilter = NamespaceFilter::User;
|
|
t_Tables m_tables;
|
|
QMetaObject::Connection refreshConnection;
|
|
|
|
|
|
Oid getType(int column) const;
|
|
QVariant getData(const QModelIndex &index) const;
|
|
// QString formatTableName(const PgClass &cls) const;
|
|
void doSort(int so);
|
|
private slots:
|
|
void refresh();
|
|
|
|
};
|
|
|
|
#endif // TABLESTABLEMODEL_H
|