diff --git a/pglab/PropertyProxyModel.cpp b/pglab/PropertyProxyModel.cpp index 38d0233..1448a3d 100644 --- a/pglab/PropertyProxyModel.cpp +++ b/pglab/PropertyProxyModel.cpp @@ -97,8 +97,8 @@ QVariant PropertyProxyModel::data(const QModelIndex &proxyIndex, int role) const return QVariant(); } -void PropertyProxyModel::setActiveRow(int row) +void PropertyProxyModel::setActiveRow(const QModelIndex &row) { - activeRow = row; + activeRow = row.isValid() ? row.row() : -1; emit dataChanged(index(0, valueColumn), index(rowCount(QModelIndex()), valueColumn), QVector() << Qt::DisplayRole); } diff --git a/pglab/PropertyProxyModel.h b/pglab/PropertyProxyModel.h index 789dd72..4d3ea9b 100644 --- a/pglab/PropertyProxyModel.h +++ b/pglab/PropertyProxyModel.h @@ -17,7 +17,12 @@ public: QVariant data(const QModelIndex &proxyIndex, int role) const; public Q_SLOTS: - void setActiveRow(int row); + /** Updates the model (and view) to show the values for row + * + * The column part of the index is not used QModelIndex is used to make is eacy to connect to + * QItemSelectionModel::currentRowChanged + */ + void setActiveRow(const QModelIndex &row); private: enum Columns { diff --git a/pglab/TablesPage.cpp b/pglab/TablesPage.cpp index 5c15fac..9f33e57 100644 --- a/pglab/TablesPage.cpp +++ b/pglab/TablesPage.cpp @@ -62,14 +62,8 @@ TablesPage::TablesPage(MainWindow *parent) ui->tablePropertiesTable->setModel(property_model); ui->tablePropertiesTable->setItemDelegate(pglab_delegate); - connect(ui->tableListTable->selectionModel(), &QItemSelectionModel::currentChanged, - [property_model](const QModelIndex ¤t, const QModelIndex &) { - int row = -1; - if (current.isValid()) - row = current.row(); - - property_model->setActiveRow(row); - }); + connect(ui->tableListTable->selectionModel(), &QItemSelectionModel::currentRowChanged, + property_model, &PropertyProxyModel::setActiveRow); //m_namespaceFilterWidget = new NamespaceFilterWidget(this);