Reorganization of pgLab project
This commit is contained in:
parent
7300865c77
commit
c71fdc4af7
78 changed files with 204 additions and 148 deletions
|
|
@ -1,95 +0,0 @@
|
|||
#ifndef TABLESTABLEMODEL_H
|
||||
#define TABLESTABLEMODEL_H
|
||||
|
||||
#include "BaseTableModel.h"
|
||||
#include "NamespaceFilter.h"
|
||||
#include "catalog/PgClass.h"
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class OpenDatabase;
|
||||
class PgClass;
|
||||
class PgDatabaseCatalog;
|
||||
|
||||
class TablesTableModel: public QAbstractTableModel {
|
||||
public:
|
||||
using RowItem = PgClass;
|
||||
enum e_Columns : int {
|
||||
NameCol, ///< either table, ns.table or table (ns) depending on settings/filters
|
||||
NamespaceCol,
|
||||
KindCol,
|
||||
OwnerCol,
|
||||
TablespaceCol,
|
||||
OptionsCol,
|
||||
AclCol,
|
||||
CommentCol,
|
||||
TotalSizeCol,
|
||||
TableSizeCol,
|
||||
IndexSizeCol,
|
||||
ToastSizeCol,
|
||||
|
||||
colCount };
|
||||
|
||||
TablesTableModel(std::shared_ptr<OpenDatabase> opendatabase, QObject *parent);
|
||||
|
||||
void setNamespaceFilter(NamespaceFilter nsf);
|
||||
void setCatalog(std::shared_ptr<const PgDatabaseCatalog> cat);
|
||||
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||
|
||||
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;
|
||||
RowItem rowItem(int row) const
|
||||
{
|
||||
return getTable(row);
|
||||
}
|
||||
Oid getTableOid(int row) const;
|
||||
|
||||
private:
|
||||
class TableSize {
|
||||
public:
|
||||
int oid;
|
||||
int64_t totalBytes = -1;
|
||||
int64_t indexBytes = -1;
|
||||
int64_t toastBytes = -1;
|
||||
|
||||
TableSize()
|
||||
: oid(0)
|
||||
{}
|
||||
};
|
||||
using TableSizes = std::vector<TableSize>;
|
||||
|
||||
class Table {
|
||||
public:
|
||||
PgClass _class;
|
||||
TableSize sizes;
|
||||
|
||||
Table(const PgClass &cls)
|
||||
: _class(cls)
|
||||
{}
|
||||
};
|
||||
using t_Tables = std::vector<Table>;
|
||||
|
||||
std::shared_ptr<const PgDatabaseCatalog> m_catalog;
|
||||
NamespaceFilter m_namespaceFilter = NamespaceFilter::User;
|
||||
t_Tables m_tables;
|
||||
QMetaObject::Connection refreshConnection;
|
||||
std::shared_ptr<OpenDatabase> openDatabase;
|
||||
|
||||
|
||||
Oid getType(int column) const;
|
||||
QVariant getData(const QModelIndex &index) const;
|
||||
|
||||
void StartLoadTableSizes(std::map<Oid, int> oidIndex);
|
||||
TableSizes QueryTableSizes() const;
|
||||
void PopulateSizes(std::map<Oid, int> oidIndex, std::vector<TableSize> sizes);
|
||||
|
||||
private slots:
|
||||
void refresh();
|
||||
|
||||
};
|
||||
|
||||
#endif // TABLESTABLEMODEL_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue