allow setting parametrization for multiple nodes at once

This commit is contained in:
Jussi Kuokkanen 2023-10-20 11:26:40 +03:00
parent 49b28238ce
commit e45f9a5f10
2 changed files with 12 additions and 8 deletions

View File

@ -130,12 +130,16 @@ bool indexApplicableForIndex(QModelIndex &orig, QModelIndex &other) {
return assignableInfoEquals(origAssData.assignableInfo(), otherAssData.assignableInfo());
}
void DeviceTreeView::commitData(QWidget *w) {
for (auto &index : m_editSelection) {
// See if node is applicable to being set the same value
// as the node the editor was opened for
if (indexApplicableForIndex(m_editedIndex, index))
m_delegate->setModelData(w, model(), index);
void DeviceTreeView::dataChanged(
const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles) {
auto assData = topLeft.data(DeviceModel::AssignableRole);
if (assData.isValid() && roles.contains(DeviceModel::AssignableRole)) {
for (auto &index : m_editSelection) {
// See if node is applicable to being set the same value
// as the node the editor was opened for
if (indexApplicableForIndex(m_editedIndex, index))
model()->setData(index, assData, DeviceModel::AssignableRole);
}
}
QTreeView::commitData(w);
QTreeView::dataChanged(topLeft, bottomRight, roles);
}

View File

@ -37,7 +37,7 @@ protected:
}
// TODO: allow to start editing with the keyboard
EditTriggers editTriggers() { return QAbstractItemView::AllEditTriggers; }
void commitData(QWidget *) override;
void dataChanged(const QModelIndex &, const QModelIndex &, const QVector<int> &) override;
private:
// Suspend/resume readable updates
void suspendChildren(const QModelIndex &);