Retrieve tables sizes asynchronously when opening the catalog.
This commit is contained in:
parent
8fe5e05f7d
commit
39195153cd
8 changed files with 163 additions and 52 deletions
|
|
@ -7,11 +7,10 @@
|
|||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class OpenDatabase;
|
||||
class PgClass;
|
||||
class PgDatabaseCatalog;
|
||||
|
||||
|
||||
|
||||
class TablesTableModel: public QAbstractTableModel {
|
||||
public:
|
||||
using RowItem = PgClass;
|
||||
|
|
@ -24,14 +23,14 @@ public:
|
|||
OptionsCol,
|
||||
AclCol,
|
||||
CommentCol,
|
||||
TotalSize,
|
||||
TableSize,
|
||||
IndexSize,
|
||||
ToastSize,
|
||||
TotalSizeCol,
|
||||
TableSizeCol,
|
||||
IndexSizeCol,
|
||||
ToastSizeCol,
|
||||
|
||||
colCount };
|
||||
|
||||
TablesTableModel(QObject *parent);
|
||||
TablesTableModel(std::shared_ptr<OpenDatabase> opendatabase, QObject *parent);
|
||||
|
||||
void setNamespaceFilter(NamespaceFilter nsf);
|
||||
void setCatalog(std::shared_ptr<const PgDatabaseCatalog> cat);
|
||||
|
|
@ -50,16 +49,44 @@ public:
|
|||
Oid getTableOid(int row) const;
|
||||
|
||||
private:
|
||||
using t_Tables = std::vector<PgClass>;
|
||||
class TableSize {
|
||||
public:
|
||||
int oid;
|
||||
int64_t totalBytes = -1;
|
||||
int64_t indexBytes = -1;
|
||||
int64_t toastBytes = -1;
|
||||
|
||||
TableSize()
|
||||
: oid(0)
|
||||
{}
|
||||
};
|
||||
using TableSizes = std::vector<class TableSize>;
|
||||
|
||||
class Table {
|
||||
public:
|
||||
PgClass _class;
|
||||
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();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue