From 3080523b0d6b58fbd588fa4e887e4c9ce4eea8c2 Mon Sep 17 00:00:00 2001 From: eelke Date: Sun, 26 Aug 2018 07:11:46 +0200 Subject: [PATCH] First step in using HorizontalProxyModel to show selected row in properties table. HorizontalProxyModel now inherits from QIdentityProxyModel which provides a more complete base implementation (maybe to much?) for now it seems to do what we want, forward relevant signals which the abstract base didn't. Issues: Properties table needs formatting and shows all rows as columns instead of values of a single row. --- pglab/HorizontalProxyModel.cpp | 2 +- pglab/HorizontalProxyModel.h | 4 ++-- pglab/TablesPage.cpp | 6 +++++- pglab/TablesPage.ui | 11 ++++++++--- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/pglab/HorizontalProxyModel.cpp b/pglab/HorizontalProxyModel.cpp index e11c41b..f50f6f1 100644 --- a/pglab/HorizontalProxyModel.cpp +++ b/pglab/HorizontalProxyModel.cpp @@ -5,7 +5,7 @@ HorizontalProxyModel::HorizontalProxyModel(QObject *parent) - : QAbstractProxyModel(parent) + : QIdentityProxyModel(parent) { } diff --git a/pglab/HorizontalProxyModel.h b/pglab/HorizontalProxyModel.h index 2e073c9..5646a03 100644 --- a/pglab/HorizontalProxyModel.h +++ b/pglab/HorizontalProxyModel.h @@ -1,9 +1,9 @@ #ifndef HORIZONTALPROXYMODEL_H #define HORIZONTALPROXYMODEL_H -#include +#include -class HorizontalProxyModel : public QAbstractProxyModel { +class HorizontalProxyModel : public QIdentityProxyModel { public: HorizontalProxyModel(QObject * parent = nullptr); QModelIndex mapToSource(const QModelIndex &proxyIndex) const; diff --git a/pglab/TablesPage.cpp b/pglab/TablesPage.cpp index 1ba5897..fe99126 100644 --- a/pglab/TablesPage.cpp +++ b/pglab/TablesPage.cpp @@ -7,7 +7,7 @@ #include "ResultTableModelUtil.h" #include "ColumnTableModel.h" #include "ConstraintModel.h" -//#include "NamespaceFilterWidget.h" +#include "HorizontalProxyModel.h" #include "IconColumnDelegate.h" #include "IndexModel.h" #include "SqlFormattingUtils.h" @@ -53,6 +53,10 @@ TablesPage::TablesPage(MainWindow *parent) ui->indexesTable->setItemDelegate(new PgLabItemDelegate(ui->indexesTable)); ui->indexesTable->setItemDelegateForColumn(0, delegate); + HorizontalProxyModel* proxy_model = new HorizontalProxyModel(this); + proxy_model->setSourceModel(m_tablesModel); + ui->tablePropertiesTable->setModel(proxy_model); + //m_namespaceFilterWidget = new NamespaceFilterWidget(this); //ui->verticalLayoutTableView->addWidget(m_namespaceFilterWidget); diff --git a/pglab/TablesPage.ui b/pglab/TablesPage.ui index 4481693..0df84f6 100644 --- a/pglab/TablesPage.ui +++ b/pglab/TablesPage.ui @@ -1,4 +1,4 @@ - + TablesPage @@ -13,7 +13,7 @@ Form - + @@ -38,7 +38,7 @@ - 0 + 3 @@ -90,6 +90,11 @@ Properties + + + + +