pg_classes can be loaded now, used in TablesTableModel for overview of tables in database.

This commit is contained in:
eelke 2017-12-10 10:35:46 +01:00
parent 43e6042794
commit 6466062cc8
23 changed files with 524 additions and 173 deletions

46
pglab/TablesTableModel.h Normal file
View file

@ -0,0 +1,46 @@
#ifndef TABLESTABLEMODEL_H
#define TABLESTABLEMODEL_H
#include "BaseTableModel.h"
#include <memory>
#include <vector>
class PgClass;
class PgDatabaseCatalog;
class TablesTableModel: public BaseTableModel
{
public:
enum e_Columns : int {
NameCol, ///< either table, ns.table or table (ns) depending on settings/filters
OwnerCol,
TablespaceCol,
OptionsCol,
AclCol,
colCount };
TablesTableModel(QObject *parent);
void setCatalog(std::shared_ptr<const PgDatabaseCatalog> cat);
// 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;
protected:
virtual Oid getType(int column) const override;
virtual QVariant getData(const QModelIndex &index) const override;
private:
using t_Tables = std::vector<PgClass>;
std::shared_ptr<const PgDatabaseCatalog> m_catalog;
t_Tables m_tables;
QString formatTableName(const PgClass &cls) const;
};
#endif // TABLESTABLEMODEL_H