Moved code from TablesPage into seperate PropetiesPage component
Clears up the TablePage and makes rhe propertypage reusable.
This commit is contained in:
parent
b8cfb223be
commit
38ae5f50e4
8 changed files with 73 additions and 36 deletions
25
pglab/PropertiesPage.cpp
Normal file
25
pglab/PropertiesPage.cpp
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#include "PropertiesPage.h"
|
||||
#include "PgLabItemDelegate.h"
|
||||
#include "PropertyProxyModel.h"
|
||||
#include "ResultTableModelUtil.h"
|
||||
#include "SqlCodePreview.h"
|
||||
#include <QTableView>
|
||||
|
||||
PropertiesPage::PropertiesPage(QWidget *parent) : QSplitter(parent)
|
||||
{
|
||||
m_tableView = new QTableView(this);
|
||||
// m_definitionView = new SqlCodePreview(this);
|
||||
addWidget(m_tableView);
|
||||
// addWidget(m_definitionView);
|
||||
|
||||
SetTableViewDefault(m_tableView);
|
||||
|
||||
m_propertyProxyModel = new PropertyProxyModel(this);
|
||||
m_tableView->setModel(m_propertyProxyModel);
|
||||
|
||||
auto item_delegate = new PgLabItemDelegate(this);
|
||||
m_tableView->setItemDelegate(item_delegate);
|
||||
}
|
||||
|
||||
|
||||
//property_model->setSourceModel(m_tablesModel);
|
||||
28
pglab/PropertiesPage.h
Normal file
28
pglab/PropertiesPage.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef PROPERTIESPAGE_H
|
||||
#define PROPERTIESPAGE_H
|
||||
|
||||
#include <QSplitter>
|
||||
|
||||
class QTableView;
|
||||
class SqlCodePreview;
|
||||
class PgDatabaseCatalog;
|
||||
class PropertyProxyModel;
|
||||
|
||||
class PropertiesPage : public QSplitter
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PropertiesPage(QWidget *parent = nullptr);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
QTableView *m_tableView = nullptr;
|
||||
// SqlCodePreview *m_definitionView = nullptr;
|
||||
PropertyProxyModel *m_propertyProxyModel = nullptr;
|
||||
|
||||
};
|
||||
|
||||
#endif // PROPERTIESPAGE_H
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
#include "IndexModel.h"
|
||||
#include "MainWindow.h"
|
||||
#include "PgLabItemDelegate.h"
|
||||
#include "PropertyProxyModel.h"
|
||||
#include "PropertiesPage.h"
|
||||
#include "ResultTableModelUtil.h"
|
||||
#include "SqlFormattingUtils.h"
|
||||
#include "SqlSyntaxHighlighter.h"
|
||||
|
|
@ -54,14 +54,6 @@ TablesPage::TablesPage(MainWindow *parent)
|
|||
ui->indexesTable->setItemDelegate(pglab_delegate);
|
||||
ui->indexesTable->setItemDelegateForColumn(0, icon_delegate);
|
||||
|
||||
// Properties
|
||||
PropertyProxyModel* property_model = new PropertyProxyModel(this);
|
||||
property_model->setSourceModel(m_tablesModel);
|
||||
SetTableViewDefault(ui->tablePropertiesTable);
|
||||
ui->tablePropertiesTable->setModel(property_model);
|
||||
ui->tablePropertiesTable->setItemDelegate(pglab_delegate);
|
||||
|
||||
|
||||
// Set code editor fonts
|
||||
QFont code_font = UserConfiguration::instance()->codeFont();
|
||||
ui->constraintSqlEdit->setFont(code_font);
|
||||
|
|
@ -71,14 +63,11 @@ TablesPage::TablesPage(MainWindow *parent)
|
|||
// Connect signals
|
||||
// ---------------
|
||||
// Table selection
|
||||
connect(ui->tableListTable->selectionModel(), &QItemSelectionModel::currentRowChanged,
|
||||
property_model, &PropertyProxyModel::setActiveRow);
|
||||
// connect(ui->tableListTable->selectionModel(), &QItemSelectionModel::currentRowChanged,
|
||||
// property_model, &PropertyProxyModel::setActiveRow);
|
||||
connect(ui->tableListTable->selectionModel(), &QItemSelectionModel::currentRowChanged, this,
|
||||
&TablesPage::tableListTable_currentRowChanged);
|
||||
|
||||
// connect(ui->constraintsTable->selectionModel(), &QItemSelectionModel::currentRowChanged, this,
|
||||
// &TablesPage::constraintsTable_currentRowChanged);
|
||||
|
||||
connect(ui->constraintsTable->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
||||
&TablesPage::constraintsTable_selectionChanged);
|
||||
connect(ui->constraintsTable->model(), &QAbstractItemModel::modelReset, this,
|
||||
|
|
@ -92,8 +81,12 @@ TablesPage::TablesPage(MainWindow *parent)
|
|||
&TablesPage::indexesTable_modelReset);
|
||||
|
||||
// Non designer based code
|
||||
m_propertiesPage = new PropertiesPage(this);
|
||||
m_propertiesTab = addDetailTab(m_propertiesPage);
|
||||
|
||||
m_triggerPage = new TriggerPage(this);
|
||||
m_triggerTab = addDetailTab(m_triggerPage, tr("Triggers"));
|
||||
m_triggerTab = addDetailTab(m_triggerPage);
|
||||
|
||||
retranslateUi(false);
|
||||
}
|
||||
|
||||
|
|
@ -103,16 +96,17 @@ void TablesPage::retranslateUi(bool all)
|
|||
if (all)
|
||||
ui->retranslateUi(this);
|
||||
|
||||
ui->twDetails->setTabText(ui->twDetails->indexOf(m_propertiesTab), QApplication::translate("TablesPage", "Properties", nullptr));
|
||||
ui->twDetails->setTabText(ui->twDetails->indexOf(m_triggerTab), QApplication::translate("TablesPage", "Triggers", nullptr));
|
||||
}
|
||||
|
||||
|
||||
QWidget* TablesPage::addDetailTab(QWidget *contents, QString caption)
|
||||
QWidget* TablesPage::addDetailTab(QWidget *contents)
|
||||
{
|
||||
auto tab = new QWidget();
|
||||
auto verticalLayout = new QVBoxLayout(tab);
|
||||
verticalLayout->addWidget(contents);
|
||||
ui->twDetails->addTab(tab, caption);
|
||||
ui->twDetails->addTab(tab, "");
|
||||
return tab;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ class PgDatabaseCatalog;
|
|||
class NamespaceFilterWidget;
|
||||
class IndexModel;
|
||||
class MainWindow;
|
||||
class PropertiesPage;
|
||||
class TriggerPage;
|
||||
|
||||
class TablesPage : public QWidget
|
||||
|
|
@ -30,6 +31,8 @@ public:
|
|||
private:
|
||||
Ui::TablesPage *ui;
|
||||
MainWindow *m_window;
|
||||
QWidget *m_propertiesTab;
|
||||
PropertiesPage *m_propertiesPage;
|
||||
QWidget *m_triggerTab;
|
||||
TriggerPage *m_triggerPage;
|
||||
std::shared_ptr<PgDatabaseCatalog> m_catalog;
|
||||
|
|
@ -40,7 +43,7 @@ private:
|
|||
//NamespaceFilterWidget* m_namespaceFilterWidget;
|
||||
|
||||
void retranslateUi(bool all = true);
|
||||
QWidget* addDetailTab(QWidget *contents, QString caption);
|
||||
QWidget* addDetailTab(QWidget *contents);
|
||||
private slots:
|
||||
|
||||
void tableListTable_currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
</widget>
|
||||
<widget class="QTabWidget" name="twDetails">
|
||||
<property name="currentIndex">
|
||||
<number>3</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="columnsTab">
|
||||
<attribute name="title">
|
||||
|
|
@ -86,16 +86,6 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="propertiesTab">
|
||||
<attribute name="title">
|
||||
<string>Properties</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayoutProperties">
|
||||
<item>
|
||||
<widget class="QTableView" name="tablePropertiesTable"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
|||
|
|
@ -21,9 +21,6 @@ TriggerPage::TriggerPage(QWidget *parent)
|
|||
|
||||
SetTableViewDefault(m_tableView);
|
||||
|
||||
QFont code_font = UserConfiguration::instance()->codeFont();
|
||||
m_definitionView->setFont(code_font);
|
||||
|
||||
m_model = new TriggerTableModel(this);
|
||||
m_sortFilterProxy = new CustomFilterSortModel(this);
|
||||
m_sortFilterProxy->setSourceModel(m_model);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
#ifndef TRIGGERPAGE_H
|
||||
#define TRIGGERPAGE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QSplitter>
|
||||
#include <memory>
|
||||
|
||||
class QSplitter;
|
||||
class QTableView;
|
||||
class SqlCodePreview;
|
||||
class PgDatabaseCatalog;
|
||||
|
|
|
|||
|
|
@ -82,7 +82,8 @@ PropertyProxyModel.cpp \
|
|||
TriggerTableModel.cpp \
|
||||
TriggerPage.cpp \
|
||||
SqlCodePreview.cpp \
|
||||
CustomFilterSortModel.cpp
|
||||
CustomFilterSortModel.cpp \
|
||||
PropertiesPage.cpp
|
||||
|
||||
HEADERS += \
|
||||
QueryResultModel.h \
|
||||
|
|
@ -135,7 +136,8 @@ CustomDataRole.h \
|
|||
TriggerTableModel.h \
|
||||
TriggerPage.h \
|
||||
SqlCodePreview.h \
|
||||
CustomFilterSortModel.h
|
||||
CustomFilterSortModel.h \
|
||||
PropertiesPage.h
|
||||
|
||||
FORMS += mainwindow.ui \
|
||||
ConnectionManagerWindow.ui \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue