Introduced own version of QTableView called PgLabTableView that has some other defaults.
This commit is contained in:
parent
f0ffcf4abd
commit
f6ea2ce0a6
9 changed files with 42 additions and 32 deletions
|
|
@ -1,7 +1,7 @@
|
|||
#include "ColumnPage.h"
|
||||
#include "ResultTableModelUtil.h"
|
||||
#include "UserConfiguration.h"
|
||||
#include <QTableView>
|
||||
#include "PgLabTableView.h"
|
||||
#include "catalog/PgClass.h"
|
||||
#include "SqlCodePreview.h"
|
||||
#include "ColumnTableModel.h"
|
||||
|
|
@ -15,13 +15,11 @@
|
|||
ColumnPage::ColumnPage(QWidget *parent)
|
||||
: QSplitter(Qt::Vertical, parent)
|
||||
{
|
||||
m_tableView = new QTableView(this);
|
||||
m_tableView = new PgLabTableView(this);
|
||||
m_definitionView = new SqlCodePreview(this);
|
||||
addWidget(m_tableView);
|
||||
addWidget(m_definitionView);
|
||||
|
||||
SetTableViewDefault(m_tableView);
|
||||
|
||||
m_columnModel = new ColumnTableModel(this);
|
||||
m_sortFilterProxy = new CustomFilterSortModel(this);
|
||||
m_sortFilterProxy->setSourceModel(m_columnModel);
|
||||
|
|
@ -30,12 +28,6 @@ ColumnPage::ColumnPage(QWidget *parent)
|
|||
m_tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
m_sortFilterProxy->sort(ColumnTableModel::AttnumCol, Qt::AscendingOrder);
|
||||
|
||||
// With this delegate the coloring of the datatype column doesn't work....
|
||||
// auto item_delegate = new PgLabItemDelegate(this);
|
||||
// m_tableView->setItemDelegate(item_delegate);
|
||||
|
||||
//auto icon_delegate = new IconColumnDelegate(this);
|
||||
|
||||
connect(m_tableView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
||||
this, &ColumnPage::tableView_selectionChanged);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include <optional>
|
||||
|
||||
|
||||
class QTableView;
|
||||
class PgLabTableView;
|
||||
class SqlCodePreview;
|
||||
class PgDatabaseCatalog;
|
||||
class ColumnTableModel;
|
||||
|
|
@ -28,7 +28,7 @@ signals:
|
|||
public slots:
|
||||
|
||||
private:
|
||||
QTableView *m_tableView = nullptr;
|
||||
PgLabTableView *m_tableView = nullptr;
|
||||
SqlCodePreview *m_definitionView = nullptr;
|
||||
ColumnTableModel *m_columnModel = nullptr;
|
||||
CustomFilterSortModel *m_sortFilterProxy = nullptr;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#include "ProcTableModel.h"
|
||||
#include "SqlCodePreview.h"
|
||||
#include <QApplication>
|
||||
#include <QTableView>
|
||||
#include "PgLabTableView.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QTabWidget>
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ FunctionsPage::FunctionsPage(QWidget *parent)
|
|||
: QSplitter(Qt::Horizontal, parent)
|
||||
{
|
||||
// create widgets
|
||||
m_functionTable = new QTableView(this);
|
||||
m_functionTable = new PgLabTableView(this);
|
||||
m_detailTabs = new QTabWidget(this);
|
||||
m_definitionView = new SqlCodePreview(this);
|
||||
|
||||
|
|
@ -31,8 +31,6 @@ FunctionsPage::FunctionsPage(QWidget *parent)
|
|||
// setLayout(mainLayout);
|
||||
|
||||
// Do further initialization of widgets and models
|
||||
SetTableViewDefault(m_functionTable);
|
||||
|
||||
m_model = new ProcTableModel(this);
|
||||
m_sortFilterProxy = new CustomFilterSortModel(this);
|
||||
m_sortFilterProxy->setSourceModel(m_model);
|
||||
|
|
@ -40,9 +38,6 @@ FunctionsPage::FunctionsPage(QWidget *parent)
|
|||
m_functionTable->setSortingEnabled(true);
|
||||
m_functionTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
|
||||
auto item_delegate = new PgLabItemDelegate(this);
|
||||
m_functionTable->setItemDelegate(item_delegate);
|
||||
|
||||
connect(m_functionTable->selectionModel(), &QItemSelectionModel::currentRowChanged, this,
|
||||
&FunctionsPage::functionTable_currentRowChanged);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
class QTableView;
|
||||
class PgLabTableView;
|
||||
class PgDatabaseCatalog;
|
||||
class ProcTableModel;
|
||||
class CustomFilterSortModel;
|
||||
|
|
@ -25,7 +25,7 @@ public slots:
|
|||
|
||||
void functionTable_currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||
private:
|
||||
QTableView *m_functionTable = nullptr;
|
||||
PgLabTableView *m_functionTable = nullptr;
|
||||
QTabWidget *m_detailTabs = nullptr;
|
||||
SqlCodePreview *m_definitionView = nullptr;
|
||||
ProcTableModel *m_model = nullptr;
|
||||
|
|
|
|||
14
pglab/PgLabTableView.cpp
Normal file
14
pglab/PgLabTableView.cpp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include "PgLabTableView.h"
|
||||
#include "PgLabItemDelegate.h"
|
||||
#include <QHeaderView>
|
||||
|
||||
PgLabTableView::PgLabTableView(QWidget *parent)
|
||||
: QTableView(parent)
|
||||
{
|
||||
setAlternatingRowColors(true);
|
||||
setItemDelegate(new PgLabItemDelegate(this));
|
||||
|
||||
auto vertical_header = verticalHeader();
|
||||
vertical_header->setMinimumSectionSize(16);
|
||||
vertical_header->setDefaultSectionSize(20);
|
||||
}
|
||||
12
pglab/PgLabTableView.h
Normal file
12
pglab/PgLabTableView.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef PGLABTABLEVIEW_H
|
||||
#define PGLABTABLEVIEW_H
|
||||
|
||||
#include <QTableView>
|
||||
|
||||
class PgLabTableView : public QTableView {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PgLabTableView(QWidget *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // PGLABTABLEVIEW_H
|
||||
|
|
@ -5,11 +5,11 @@
|
|||
#include "PgLabItemDelegate.h"
|
||||
#include "SequenceModel.h"
|
||||
#include "SqlCodePreview.h"
|
||||
#include <QTableView>
|
||||
#include "PgLabTableView.h"
|
||||
|
||||
SequencesPage::SequencesPage(QWidget *parent)
|
||||
{
|
||||
m_sequenceTable = new QTableView(this);
|
||||
m_sequenceTable = new PgLabTableView(this);
|
||||
m_definitionView = new SqlCodePreview(this);
|
||||
|
||||
// build widget tree
|
||||
|
|
@ -17,8 +17,6 @@ SequencesPage::SequencesPage(QWidget *parent)
|
|||
addWidget(m_sequenceTable);
|
||||
addWidget(m_definitionView);
|
||||
|
||||
SetTableViewDefault(m_sequenceTable);
|
||||
|
||||
m_model = new SequenceModel(this);
|
||||
m_sortFilterProxy = new CustomFilterSortModel(this);
|
||||
m_sortFilterProxy->setSourceModel(m_model);
|
||||
|
|
@ -26,9 +24,6 @@ SequencesPage::SequencesPage(QWidget *parent)
|
|||
m_sequenceTable->setSortingEnabled(true);
|
||||
m_sequenceTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
|
||||
auto item_delegate = new PgLabItemDelegate(this);
|
||||
m_sequenceTable->setItemDelegate(item_delegate);
|
||||
|
||||
connect(m_sequenceTable->selectionModel(), &QItemSelectionModel::currentRowChanged, this,
|
||||
&SequencesPage::sequenceTable_currentRowChanged);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
class QTableView;
|
||||
class PgLabTableView;
|
||||
class PgDatabaseCatalog;
|
||||
class SequenceModel;
|
||||
class CustomFilterSortModel;
|
||||
|
|
@ -25,7 +25,7 @@ public slots:
|
|||
void sequenceTable_currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||
|
||||
private:
|
||||
QTableView *m_sequenceTable = nullptr;
|
||||
PgLabTableView *m_sequenceTable = nullptr;
|
||||
//QTabWidget *m_detailTabs = nullptr;
|
||||
SqlCodePreview *m_definitionView = nullptr;
|
||||
SequenceModel *m_model = nullptr;
|
||||
|
|
|
|||
|
|
@ -83,7 +83,8 @@ PropertyProxyModel.cpp \
|
|||
EditColumnTableModel.cpp \
|
||||
SequenceModel.cpp \
|
||||
SequencesPage.cpp \
|
||||
DatabaseWindow.cpp
|
||||
DatabaseWindow.cpp \
|
||||
PgLabTableView.cpp
|
||||
|
||||
HEADERS += \
|
||||
QueryResultModel.h \
|
||||
|
|
@ -144,7 +145,8 @@ CustomDataRole.h \
|
|||
EditColumnTableModel.h \
|
||||
SequenceModel.h \
|
||||
SequencesPage.h \
|
||||
DatabaseWindow.h
|
||||
DatabaseWindow.h \
|
||||
PgLabTableView.h
|
||||
|
||||
FORMS += mainwindow.ui \
|
||||
ConnectionManagerWindow.ui \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue