The table inheritance works mostly

When a table has partitions or inheritance children these are listed as subnodes. A subnode can appear multiple times under different parents as postgresql supports inheriting multiple tables.

The sizes are still missing and maybe some things I have note verified yet are not correct.
This commit is contained in:
eelke 2023-01-22 15:57:22 +01:00
parent ccd88d0578
commit 39dbab4d36
17 changed files with 452 additions and 127 deletions

View file

@ -1,19 +1,34 @@
#pragma once
#include <QTableWidget>
#include <QTreeView>
#include <QSortFilterProxyModel>
#include "util/PgLabTableView.h"
#include <optional>
class PgDatabaseCatalog;
template <typename TableModel>
template <typename ViewType>
void ResizeColumnsToContent(ViewType *vt)
{
vt->resizeColumnsToContents();
}
template <>
inline void ResizeColumnsToContent<QTreeView>(QTreeView *)
{
}
template <typename TableModel, typename ViewType = PgLabTableView>
class PgLabTableViewHelper {
public:
PgLabTableViewHelper(QWidget * parent, TableModel *tableModel)
{
m_tableView = new PgLabTableView(parent);
m_tableView = new ViewType(parent);
m_dataModel = tableModel;
m_sortFilter = new QSortFilterProxyModel(parent);
@ -27,7 +42,7 @@ public:
: PgLabTableViewHelper(parent, new TableModel(parent))
{}
PgLabTableView *tableView() const
ViewType *tableView() const
{
return m_tableView;
}
@ -45,7 +60,7 @@ public:
void setCatalog(std::shared_ptr<PgDatabaseCatalog> cat)
{
m_dataModel->setCatalog(cat);
m_tableView->resizeColumnsToContents();
ResizeColumnsToContent(m_tableView);
}
QModelIndex currentSourceIndex() const
@ -57,15 +72,15 @@ public:
return m_sortFilter->mapToSource(index);
}
typename TableModel::RowItem rowItemForSourceRow(int row) const
typename TableModel::RowItem rowItemForSourceRow(QModelIndex index) const
{
return m_dataModel->rowItem(row);
return m_dataModel->rowItem(index);
}
typename TableModel::RowItem rowItemForProxyIndex(QModelIndex index)
{
QModelIndex sourceIndex = m_sortFilter->mapToSource(index);
return m_dataModel->rowItem(sourceIndex.row());
return m_dataModel->rowItem(sourceIndex);
}
typename TableModel::RowItem rowItemForProxyRow(int row) const
@ -79,12 +94,12 @@ public:
if (!index.isValid())
return {};
return rowItemForSourceRow(index.row());
return rowItemForSourceRow(index);
}
private:
PgLabTableView *m_tableView = nullptr;
ViewType *m_tableView = nullptr;
TableModel *m_dataModel = nullptr;
QSortFilterProxyModel *m_sortFilter = nullptr;
};