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:
eelke 2019-02-09 14:59:33 +01:00
parent 3fb88edab2
commit 3fdd42ffb2
13 changed files with 56 additions and 41 deletions

View file

@ -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 &current, const QModelIndex &previous)

View file

@ -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,

View file

@ -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 &current, const QModelIndex &previous)

View file

@ -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);

View file

@ -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;