Index page now correctly responds to reload.
This commit is contained in:
parent
60d8f36328
commit
fa46971930
3 changed files with 17 additions and 5 deletions
|
|
@ -6,14 +6,22 @@
|
|||
#include "CustomDataRole.h"
|
||||
|
||||
void IndexModel::setData(std::shared_ptr<const PgDatabaseCatalog> cat, const std::optional<PgClass> &table)
|
||||
{
|
||||
if (cat != m_catalog) {
|
||||
m_catalog = cat;
|
||||
refreshConnection = connect(m_catalog.get(), &PgDatabaseCatalog::refreshed, this, &IndexModel::refresh);
|
||||
}
|
||||
m_table = table;
|
||||
refresh();
|
||||
}
|
||||
|
||||
void IndexModel::refresh()
|
||||
{
|
||||
beginResetModel();
|
||||
SCOPE_EXIT { endResetModel(); };
|
||||
|
||||
m_catalog = cat;
|
||||
m_table = table;
|
||||
if (table)
|
||||
m_indexes = cat->indexes()->getIndexesForTable(table->oid());
|
||||
if (m_table)
|
||||
m_indexes = m_catalog->indexes()->getIndexesForTable(m_table->oid());
|
||||
else
|
||||
m_indexes.clear();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,10 @@ private:
|
|||
|
||||
using t_Indexes = std::vector<PgIndex>;
|
||||
t_Indexes m_indexes;
|
||||
QMetaObject::Connection refreshConnection;
|
||||
|
||||
private slots:
|
||||
void refresh();
|
||||
};
|
||||
|
||||
#endif // INDEXMODEL_H
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ CatalogIndexPage::CatalogIndexPage(QWidget *parent)
|
|||
|
||||
connect(m_tableView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
||||
this, &CatalogIndexPage::tableView_selectionChanged);
|
||||
connect(m_indexModel, &IndexModel::modelReset, m_definitionView, &SqlCodePreview::clear);
|
||||
}
|
||||
|
||||
void CatalogIndexPage::catalogSet()
|
||||
|
|
@ -26,7 +27,6 @@ void CatalogIndexPage::setFilter(const std::optional<PgClass> &cls)
|
|||
{
|
||||
m_indexModel->setData(m_catalog, cls);
|
||||
m_tableView->resizeColumnsToContents();
|
||||
m_definitionView->setPlainText({});
|
||||
}
|
||||
|
||||
void CatalogIndexPage::tableView_selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue