fix: the source views for constraints and indexes are now cleared when the
model is reset as this will clear all selections. Unfortunatly the selection model does not trigger a selectionChanged when the model is reset. Close #16
This commit is contained in:
parent
f1020ac56e
commit
7c4f1a4752
4 changed files with 23 additions and 5 deletions
|
|
@ -321,7 +321,7 @@ void MainWindow::addPage(PlgPage* page, QString caption)
|
||||||
//addToolBarButtonsForPage(page);
|
//addToolBarButtonsForPage(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::removePage(PlgPage *page)
|
void MainWindow::removePage(PlgPage *)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ TablesPage::TablesPage(MainWindow *parent)
|
||||||
//m_namespaceFilterWidget = new NamespaceFilterWidget(this);
|
//m_namespaceFilterWidget = new NamespaceFilterWidget(this);
|
||||||
//ui->verticalLayoutTableView->addWidget(m_namespaceFilterWidget);
|
//ui->verticalLayoutTableView->addWidget(m_namespaceFilterWidget);
|
||||||
|
|
||||||
|
// Table selection
|
||||||
connect(ui->tableListTable->selectionModel(), &QItemSelectionModel::currentRowChanged, this,
|
connect(ui->tableListTable->selectionModel(), &QItemSelectionModel::currentRowChanged, this,
|
||||||
&TablesPage::tableListTable_currentRowChanged);
|
&TablesPage::tableListTable_currentRowChanged);
|
||||||
|
|
||||||
|
|
@ -65,9 +65,15 @@ TablesPage::TablesPage(MainWindow *parent)
|
||||||
|
|
||||||
connect(ui->constraintsTable->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
connect(ui->constraintsTable->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
||||||
&TablesPage::constraintsTable_selectionChanged);
|
&TablesPage::constraintsTable_selectionChanged);
|
||||||
|
connect(ui->constraintsTable->model(), &QAbstractItemModel::modelReset, this,
|
||||||
|
&TablesPage::constraintsTable_modelReset);
|
||||||
|
|
||||||
|
// React to changes in de selected indexes, does not trigger when model is reset
|
||||||
connect(ui->indexesTable->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
connect(ui->indexesTable->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
||||||
&TablesPage::indexesTable_selectionChanged);
|
&TablesPage::indexesTable_selectionChanged);
|
||||||
|
// Capture model reset independently
|
||||||
|
connect(ui->indexesTable->model(), &QAbstractItemModel::modelReset, this,
|
||||||
|
&TablesPage::indexesTable_modelReset);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -122,7 +128,7 @@ void TablesPage::constraintsTable_selectionChanged(const QItemSelection &/*selec
|
||||||
{
|
{
|
||||||
const auto indexes = ui->constraintsTable->selectionModel()->selectedIndexes();
|
const auto indexes = ui->constraintsTable->selectionModel()->selectedIndexes();
|
||||||
boost::container::flat_set<int> rijen;
|
boost::container::flat_set<int> rijen;
|
||||||
for (const auto e : indexes)
|
for (const auto &e : indexes)
|
||||||
rijen.insert(e.row());
|
rijen.insert(e.row());
|
||||||
|
|
||||||
QString drops;
|
QString drops;
|
||||||
|
|
@ -135,11 +141,16 @@ void TablesPage::constraintsTable_selectionChanged(const QItemSelection &/*selec
|
||||||
ui->constraintSqlEdit->setPlainText(drops % "\n" % creates);
|
ui->constraintSqlEdit->setPlainText(drops % "\n" % creates);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TablesPage::constraintsTable_modelReset()
|
||||||
|
{
|
||||||
|
ui->constraintSqlEdit->clear();
|
||||||
|
}
|
||||||
|
|
||||||
void TablesPage::indexesTable_selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/)
|
void TablesPage::indexesTable_selectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/)
|
||||||
{
|
{
|
||||||
const auto indexes = ui->indexesTable->selectionModel()->selectedIndexes();
|
const auto indexes = ui->indexesTable->selectionModel()->selectedIndexes();
|
||||||
boost::container::flat_set<int> rijen;
|
boost::container::flat_set<int> rijen;
|
||||||
for (const auto e : indexes)
|
for (const auto &e : indexes)
|
||||||
rijen.insert(e.row());
|
rijen.insert(e.row());
|
||||||
|
|
||||||
QString drops;
|
QString drops;
|
||||||
|
|
@ -153,6 +164,11 @@ void TablesPage::indexesTable_selectionChanged(const QItemSelection &/*selected*
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TablesPage::indexesTable_modelReset()
|
||||||
|
{
|
||||||
|
ui->indexSqlEdit->clear();
|
||||||
|
}
|
||||||
|
|
||||||
void TablesPage::on_tableListTable_doubleClicked(const QModelIndex &index)
|
void TablesPage::on_tableListTable_doubleClicked(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
PgClass table = m_tablesModel->getTable(index.row());
|
PgClass table = m_tablesModel->getTable(index.row());
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,9 @@ private slots:
|
||||||
void tableListTable_currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
void tableListTable_currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||||
// void constraintsTable_currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
// void constraintsTable_currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||||
void constraintsTable_selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
void constraintsTable_selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
||||||
|
void constraintsTable_modelReset();
|
||||||
void indexesTable_selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
void indexesTable_selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
||||||
|
void indexesTable_modelReset();
|
||||||
void on_tableListTable_doubleClicked(const QModelIndex &index);
|
void on_tableListTable_doubleClicked(const QModelIndex &index);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>2</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="columnsTab">
|
<widget class="QWidget" name="columnsTab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue