Collection of small fixes and improvements
- Selections stay clearly visible when focus changes to other widget - Autoresize columns - Table properties view now correctly allows selection in both columns and draws selection correctly - Tables can be sorted again and now by any column
This commit is contained in:
parent
3fb88edab2
commit
3fdd42ffb2
13 changed files with 56 additions and 41 deletions
|
|
@ -1,16 +1,18 @@
|
|||
#include "ColumnPage.h"
|
||||
#include "ResultTableModelUtil.h"
|
||||
#include "UserConfiguration.h"
|
||||
#include "PgLabTableView.h"
|
||||
#include "catalog/PgClass.h"
|
||||
#include "SqlCodePreview.h"
|
||||
|
||||
#include "ColumnTableModel.h"
|
||||
#include "CustomFilterSortModel.h"
|
||||
#include "CustomDataRole.h"
|
||||
#include "PgLabItemDelegate.h"
|
||||
#include "PgLabTableView.h"
|
||||
#include "ResultTableModelUtil.h"
|
||||
#include "SqlCodePreview.h"
|
||||
//#include "PgLabItemDelegate.h"
|
||||
#include "SqlFormattingUtils.h"
|
||||
#include "UserConfiguration.h"
|
||||
#include "catalog/PgClass.h"
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QStringBuilder>
|
||||
#include <unordered_set>
|
||||
#include "SqlFormattingUtils.h"
|
||||
|
||||
ColumnPage::ColumnPage(QWidget *parent)
|
||||
: QSplitter(Qt::Vertical, parent)
|
||||
|
|
@ -21,7 +23,7 @@ ColumnPage::ColumnPage(QWidget *parent)
|
|||
addWidget(m_definitionView);
|
||||
|
||||
m_columnModel = new ColumnTableModel(this);
|
||||
m_sortFilterProxy = new CustomFilterSortModel(this);
|
||||
m_sortFilterProxy = new QSortFilterProxyModel(this);
|
||||
m_sortFilterProxy->setSourceModel(m_columnModel);
|
||||
m_tableView->setModel(m_sortFilterProxy);
|
||||
m_tableView->setSortingEnabled(true);
|
||||
|
|
@ -39,13 +41,9 @@ void ColumnPage::setData(std::shared_ptr<const PgDatabaseCatalog> cat, const std
|
|||
m_columnModel->setData(cat, cls);
|
||||
m_Class = cls;
|
||||
m_tableView->resizeColumnsToContents();
|
||||
m_definitionView->setPlainText("");
|
||||
}
|
||||
|
||||
//void ColumnPage::setFilter(const std::optional<PgClass> &cls)
|
||||
//{
|
||||
// m_sortFilterProxy->setOidFilterTable(cls ? cls->oid() : InvalidOid, FirstHiddenValue);
|
||||
//}
|
||||
|
||||
void ColumnPage::tableView_selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/)
|
||||
{
|
||||
auto&& indexes = m_tableView->selectionModel()->selectedIndexes();
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class PgLabTableView;
|
|||
class SqlCodePreview;
|
||||
class PgDatabaseCatalog;
|
||||
class ColumnTableModel;
|
||||
class CustomFilterSortModel;
|
||||
class QSortFilterProxyModel;
|
||||
class QItemSelection;
|
||||
class QAbstractItemModel;
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ private:
|
|||
PgLabTableView *m_tableView = nullptr;
|
||||
SqlCodePreview *m_definitionView = nullptr;
|
||||
ColumnTableModel *m_columnModel = nullptr;
|
||||
CustomFilterSortModel *m_sortFilterProxy = nullptr;
|
||||
QSortFilterProxyModel *m_sortFilterProxy = nullptr;
|
||||
std::shared_ptr<const PgDatabaseCatalog> m_catalog;
|
||||
std::optional<PgClass> m_Class;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "PgLabTableView.h"
|
||||
#include "PgLabItemDelegate.h"
|
||||
#include <QHeaderView>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
PgLabTableView::PgLabTableView(QWidget *parent)
|
||||
: QTableView(parent)
|
||||
|
|
@ -9,7 +10,13 @@ PgLabTableView::PgLabTableView(QWidget *parent)
|
|||
setItemDelegate(new PgLabItemDelegate(this));
|
||||
setWordWrap(false);
|
||||
|
||||
auto pal = palette();
|
||||
pal.setColor(QPalette::Inactive, QPalette::Highlight, pal.color(QPalette::Active, QPalette::Highlight));
|
||||
pal.setColor(QPalette::Inactive, QPalette::HighlightedText, pal.color(QPalette::Active, QPalette::HighlightedText));
|
||||
setPalette(pal);
|
||||
|
||||
auto vertical_header = verticalHeader();
|
||||
vertical_header->setMinimumSectionSize(16);
|
||||
vertical_header->setDefaultSectionSize(20);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,10 +3,13 @@
|
|||
|
||||
#include <QTableView>
|
||||
|
||||
class QSortFilterProxyModel;
|
||||
|
||||
class PgLabTableView : public QTableView {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PgLabTableView(QWidget *parent = nullptr);
|
||||
|
||||
};
|
||||
|
||||
#endif // PGLABTABLEVIEW_H
|
||||
|
|
|
|||
|
|
@ -3,14 +3,13 @@
|
|||
#include "PropertyProxyModel.h"
|
||||
#include "ResultTableModelUtil.h"
|
||||
#include "SqlCodePreview.h"
|
||||
#include <QTableView>
|
||||
#include "PgLabTableView.h"
|
||||
|
||||
|
||||
PropertiesPage::PropertiesPage(QWidget *parent) : QSplitter(parent)
|
||||
{
|
||||
m_tableView = new QTableView(this);
|
||||
// m_definitionView = new SqlCodePreview(this);
|
||||
m_tableView = new PgLabTableView(this);
|
||||
addWidget(m_tableView);
|
||||
// addWidget(m_definitionView);
|
||||
|
||||
SetTableViewDefault(m_tableView);
|
||||
|
||||
|
|
@ -32,4 +31,5 @@ void PropertiesPage::setSourceModel(QAbstractItemModel *model)
|
|||
void PropertiesPage::setActiveRow(const QModelIndex &row)
|
||||
{
|
||||
m_propertyProxyModel->setActiveRow(row);
|
||||
m_tableView->resizeColumnsToContents();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,21 +3,19 @@
|
|||
|
||||
#include <QSplitter>
|
||||
|
||||
class QTableView;
|
||||
class SqlCodePreview;
|
||||
class PgDatabaseCatalog;
|
||||
class PropertyProxyModel;
|
||||
class PgLabTableView;
|
||||
class QAbstractItemModel;
|
||||
|
||||
class PropertiesPage : public QSplitter
|
||||
{
|
||||
class PropertiesPage : public QSplitter {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PropertiesPage(QWidget *parent = nullptr);
|
||||
|
||||
void setSourceModel(QAbstractItemModel *model);
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
/** Updates the model (and view) to show the values for row
|
||||
*
|
||||
|
|
@ -27,8 +25,7 @@ public slots:
|
|||
void setActiveRow(const QModelIndex &row);
|
||||
|
||||
private:
|
||||
QTableView *m_tableView = nullptr;
|
||||
// SqlCodePreview *m_definitionView = nullptr;
|
||||
PgLabTableView *m_tableView = nullptr;
|
||||
PropertyProxyModel *m_propertyProxyModel = nullptr;
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -102,3 +102,8 @@ void PropertyProxyModel::setActiveRow(const QModelIndex &row)
|
|||
activeRow = row.isValid() ? row.row() : -1;
|
||||
emit dataChanged(index(0, valueColumn), index(rowCount(QModelIndex()), valueColumn), QVector<int>() << Qt::DisplayRole);
|
||||
}
|
||||
|
||||
Qt::ItemFlags PropertyProxyModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,14 +7,15 @@ class PropertyProxyModel : public QIdentityProxyModel {
|
|||
Q_OBJECT
|
||||
public:
|
||||
PropertyProxyModel(QObject * parent = nullptr);
|
||||
QModelIndex mapToSource(const QModelIndex &proxyIndex) const;
|
||||
QModelIndex mapFromSource(const QModelIndex &sourceIndex) const;
|
||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
|
||||
QModelIndex parent(const QModelIndex &child) const;
|
||||
int rowCount(const QModelIndex &parent) const;
|
||||
int columnCount(const QModelIndex &parent) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||
QVariant data(const QModelIndex &proxyIndex, int role) const;
|
||||
QModelIndex mapToSource(const QModelIndex &proxyIndex) const override;
|
||||
QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override;
|
||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
||||
QModelIndex parent(const QModelIndex &child) const override;
|
||||
int rowCount(const QModelIndex &parent) const override;
|
||||
int columnCount(const QModelIndex &parent) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||
QVariant data(const QModelIndex &proxyIndex, int role) const override;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
|
||||
public Q_SLOTS:
|
||||
/** Updates the model (and view) to show the values for row
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ void CatalogFunctionsPage::setCatalog(std::shared_ptr<const PgDatabaseCatalog> c
|
|||
{
|
||||
m_catalog = cat;
|
||||
m_model->setCatalog(cat);
|
||||
m_functionTable->resizeColumnsToContents();
|
||||
}
|
||||
|
||||
void CatalogFunctionsPage::functionTable_currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ CatalogIndexPage::CatalogIndexPage(QWidget *parent)
|
|||
{
|
||||
m_indexModel = new IndexModel(this);
|
||||
m_sortFilterProxy->setSourceModel(m_indexModel);
|
||||
|
||||
m_tableView->setItemDelegateForColumn(0, new IconColumnDelegate(this));
|
||||
|
||||
connect(m_tableView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
||||
|
|
|
|||
|
|
@ -33,17 +33,13 @@ CatalogSequencesPage::CatalogSequencesPage(QWidget *parent)
|
|||
|
||||
void CatalogSequencesPage::retranslateUi()
|
||||
{
|
||||
// auto set_tabtext = [this] (QWidget *widget, QString translation) {
|
||||
// m_detailTabs->setTabText(m_detailTabs->indexOf(widget), translation);
|
||||
// };
|
||||
|
||||
// set_tabtext(m_definitionView, QApplication::translate("FunctionsPage", "SQL", nullptr));
|
||||
}
|
||||
|
||||
void CatalogSequencesPage::setCatalog(std::shared_ptr<const PgDatabaseCatalog> cat)
|
||||
{
|
||||
m_catalog = cat;
|
||||
m_model->setCatalog(cat);
|
||||
m_sequenceTable->resizeColumnsToContents();
|
||||
}
|
||||
|
||||
void CatalogSequencesPage::sequenceTable_currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
||||
|
|
|
|||
|
|
@ -15,12 +15,15 @@
|
|||
|
||||
#include <QApplication>
|
||||
#include <QStringBuilder>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QTableWidget>
|
||||
|
||||
CatalogTablesPage::CatalogTablesPage(QWidget *parent)
|
||||
: QSplitter(Qt::Horizontal, parent)
|
||||
{
|
||||
m_tableView = new PgLabTableView(this);
|
||||
m_tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
m_tableView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
m_detailsTabs = new QTabWidget(this);
|
||||
|
||||
// Populate splitter
|
||||
|
|
@ -29,7 +32,10 @@ CatalogTablesPage::CatalogTablesPage(QWidget *parent)
|
|||
|
||||
// Setup model(s)
|
||||
m_tablesModel = new TablesTableModel(this);
|
||||
m_tableView->setModel(m_tablesModel);
|
||||
m_tablesSortFilter = new QSortFilterProxyModel(this);
|
||||
m_tablesSortFilter->setSourceModel(m_tablesModel);
|
||||
m_tableView->setModel(m_tablesSortFilter);
|
||||
m_tableView->setSortingEnabled(true);
|
||||
|
||||
// - Columns page
|
||||
m_columnsPage = new ColumnPage(this);
|
||||
|
|
@ -70,7 +76,7 @@ CatalogTablesPage::CatalogTablesPage(QWidget *parent)
|
|||
this, &CatalogTablesPage::tableListTable_layoutChanged);
|
||||
}
|
||||
|
||||
void CatalogTablesPage::retranslateUi(bool all)
|
||||
void CatalogTablesPage::retranslateUi(bool /*all*/)
|
||||
{
|
||||
auto set_tabtext = [this] (QWidget *widget, QString translation) {
|
||||
m_detailsTabs->setTabText(m_detailsTabs->indexOf(widget), translation);
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ class PgLabTableView;
|
|||
class PropertiesPage;
|
||||
class QTabWidget;
|
||||
class SqlCodePreview;
|
||||
class QSortFilterProxyModel;
|
||||
class TablesTableModel;
|
||||
class TriggerPage;
|
||||
|
||||
|
|
@ -32,6 +33,7 @@ public:
|
|||
private:
|
||||
PgLabTableView *m_tableView = nullptr;
|
||||
TablesTableModel* m_tablesModel = nullptr;
|
||||
QSortFilterProxyModel *m_tablesSortFilter = nullptr;
|
||||
|
||||
// Details
|
||||
QTabWidget *m_detailsTabs = nullptr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue