Simplify connecting QItemSelection::currentRowChanged to PropertyProxyModel::activeRow
This commit is contained in:
parent
0cef509771
commit
e8f81557bb
3 changed files with 10 additions and 11 deletions
|
|
@ -97,8 +97,8 @@ QVariant PropertyProxyModel::data(const QModelIndex &proxyIndex, int role) const
|
||||||
return QVariant();
|
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<int>() << Qt::DisplayRole);
|
emit dataChanged(index(0, valueColumn), index(rowCount(QModelIndex()), valueColumn), QVector<int>() << Qt::DisplayRole);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,12 @@ public:
|
||||||
QVariant data(const QModelIndex &proxyIndex, int role) const;
|
QVariant data(const QModelIndex &proxyIndex, int role) const;
|
||||||
|
|
||||||
public Q_SLOTS:
|
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:
|
private:
|
||||||
enum Columns {
|
enum Columns {
|
||||||
|
|
|
||||||
|
|
@ -62,14 +62,8 @@ TablesPage::TablesPage(MainWindow *parent)
|
||||||
ui->tablePropertiesTable->setModel(property_model);
|
ui->tablePropertiesTable->setModel(property_model);
|
||||||
ui->tablePropertiesTable->setItemDelegate(pglab_delegate);
|
ui->tablePropertiesTable->setItemDelegate(pglab_delegate);
|
||||||
|
|
||||||
connect(ui->tableListTable->selectionModel(), &QItemSelectionModel::currentChanged,
|
connect(ui->tableListTable->selectionModel(), &QItemSelectionModel::currentRowChanged,
|
||||||
[property_model](const QModelIndex ¤t, const QModelIndex &) {
|
property_model, &PropertyProxyModel::setActiveRow);
|
||||||
int row = -1;
|
|
||||||
if (current.isValid())
|
|
||||||
row = current.row();
|
|
||||||
|
|
||||||
property_model->setActiveRow(row);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
//m_namespaceFilterWidget = new NamespaceFilterWidget(this);
|
//m_namespaceFilterWidget = new NamespaceFilterWidget(this);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue