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"
|
#include "CustomDataRole.h"
|
||||||
|
|
||||||
void IndexModel::setData(std::shared_ptr<const PgDatabaseCatalog> cat, const std::optional<PgClass> &table)
|
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();
|
beginResetModel();
|
||||||
SCOPE_EXIT { endResetModel(); };
|
SCOPE_EXIT { endResetModel(); };
|
||||||
|
|
||||||
m_catalog = cat;
|
if (m_table)
|
||||||
m_table = table;
|
m_indexes = m_catalog->indexes()->getIndexesForTable(m_table->oid());
|
||||||
if (table)
|
|
||||||
m_indexes = cat->indexes()->getIndexesForTable(table->oid());
|
|
||||||
else
|
else
|
||||||
m_indexes.clear();
|
m_indexes.clear();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,10 @@ private:
|
||||||
|
|
||||||
using t_Indexes = std::vector<PgIndex>;
|
using t_Indexes = std::vector<PgIndex>;
|
||||||
t_Indexes m_indexes;
|
t_Indexes m_indexes;
|
||||||
|
QMetaObject::Connection refreshConnection;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INDEXMODEL_H
|
#endif // INDEXMODEL_H
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ CatalogIndexPage::CatalogIndexPage(QWidget *parent)
|
||||||
|
|
||||||
connect(m_tableView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
connect(m_tableView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
||||||
this, &CatalogIndexPage::tableView_selectionChanged);
|
this, &CatalogIndexPage::tableView_selectionChanged);
|
||||||
|
connect(m_indexModel, &IndexModel::modelReset, m_definitionView, &SqlCodePreview::clear);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CatalogIndexPage::catalogSet()
|
void CatalogIndexPage::catalogSet()
|
||||||
|
|
@ -26,7 +27,6 @@ void CatalogIndexPage::setFilter(const std::optional<PgClass> &cls)
|
||||||
{
|
{
|
||||||
m_indexModel->setData(m_catalog, cls);
|
m_indexModel->setData(m_catalog, cls);
|
||||||
m_tableView->resizeColumnsToContents();
|
m_tableView->resizeColumnsToContents();
|
||||||
m_definitionView->setPlainText({});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CatalogIndexPage::tableView_selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/)
|
void CatalogIndexPage::tableView_selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue