Skip to content
Snippets Groups Projects
Commit e9cfc6a4 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

update instruments list after change of name

parent eaa85c21
No related branches found
No related tags found
1 merge request!2405Update instrument & sample lists after change of name or description
......@@ -102,6 +102,13 @@ public:
emit AbstractSetModel::setChanged();
}
//! To be called when name or description of the current item have changed.
void currentDataChanged()
{
QModelIndex qi = m_qmodel->index(m_idx, 0);
m_qmodel->dataChanged(qi, qi, QVector<int>({Qt::DisplayRole, Qt::EditRole}));
}
size_t currentIndex() const { return m_idx; }
const T* currentItem() const { return m_idx < m_vec.size() ? m_vec.at(m_idx) : (T*)nullptr; }
T* currentItem() { return m_idx < m_vec.size() ? m_vec.at(m_idx) : (T*)nullptr; }
......@@ -135,6 +142,7 @@ public:
QAbstractListModel* model() override { return m_qmodel.get(); }
private:
//! To be called when m_idx may have fallen out of range.
void update_current()
{
if (m_idx == m_vec.size())
......
......@@ -168,7 +168,7 @@ QWidget* InstrumentView::createEditor(InstrumentItem* t)
connect(nameEdit, &QLineEdit::textEdited, [this, t](const QString& text) {
if (text != t->name()) {
t->setName(text);
emit m_set->setChanged();
m_set->currentDataChanged();
}
});
formLayout->addRow("Name:", nameEdit);
......@@ -181,7 +181,7 @@ QWidget* InstrumentView::createEditor(InstrumentItem* t)
descriptionEdit->setPlainText(t->description());
connect(descriptionEdit, &QTextEdit::textChanged, [this, t, descriptionEdit] {
t->setDescription(descriptionEdit->toPlainText());
emit m_set->setChanged();
m_set->currentDataChanged();
});
formLayout->addRow("Description:", descriptionEdit);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment