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

+ VectorWC::delete_current, simplify instrs model code

rename member var
parent 71ef98c5
No related branches found
No related tags found
1 merge request!2387unify code for list views
...@@ -52,6 +52,12 @@ public: ...@@ -52,6 +52,12 @@ public:
super::delete_at(i); super::delete_at(i);
update_current(); update_current();
} }
void delete_current()
{
ASSERT(m_current_index != size_t(-1));
super::delete_at(m_current_index);
update_current();
}
T* release_at(size_t i) T* release_at(size_t i)
{ {
super::release_at(i); super::release_at(i);
......
...@@ -58,11 +58,10 @@ QVariant InstrumentsQModel::data(const QModelIndex& index, int role) const ...@@ -58,11 +58,10 @@ QVariant InstrumentsQModel::data(const QModelIndex& index, int role) const
void InstrumentsQModel::removeInstrument() void InstrumentsQModel::removeInstrument()
{ {
const InstrumentItem* t = set()->currentItem(); const size_t row = set()->currentIndex();
ASSERT(row != size_t(-1));
const int row = set()->index_of(t);
beginRemoveRows({}, row, row); beginRemoveRows({}, row, row);
set()->delete_element(t); set()->delete_current();
endRemoveRows(); endRemoveRows();
emit set()->setChanged(); emit set()->setChanged();
...@@ -78,7 +77,7 @@ QModelIndex InstrumentsQModel::copyInstrument() ...@@ -78,7 +77,7 @@ QModelIndex InstrumentsQModel::copyInstrument()
QModelIndex InstrumentsQModel::pushInstrument(InstrumentItem* t) QModelIndex InstrumentsQModel::pushInstrument(InstrumentItem* t)
{ {
const int row = set()->instrumentItems().size(); const size_t row = set()->size();
beginInsertRows({}, row, row); beginInsertRows({}, row, row);
set()->push_back(t); set()->push_back(t);
endInsertRows(); endInsertRows();
......
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