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

+ InstrumentsSet::onCurrentChanged; restore instr editor

parent 683a80ea
No related branches found
No related tags found
1 merge request!2387unify code for list views
......@@ -30,16 +30,19 @@ public:
{
super::push_back(e);
m_current_index = super::size() - 1;
onCurrentChanged();
}
void insert_at(size_t i, T* e)
{
super::insert_at(i, e);
m_current_index = i;
onCurrentChanged();
}
void replace_at(size_t i, T* e)
{
super::replace_at(i, e);
m_current_index = i;
onCurrentChanged();
}
void delete_element(const T* e)
{
......@@ -80,7 +83,10 @@ public:
void setCurrentIndex(size_t i)
{
ASSERT(i < super::size() || i == size_t(-1));
m_current_index = i;
if (i != m_current_index) {
m_current_index = i;
onCurrentChanged();
}
}
size_t currentIndex() const { return m_current_index; }
const T* currentItem() const
......@@ -95,11 +101,15 @@ public:
private:
void update_current()
{
if (m_current_index == super::size())
if (m_current_index == super::size()) {
m_current_index = super::size() - 1;
onCurrentChanged();
}
}
size_t m_current_index = -1;
virtual void onCurrentChanged() const {}
};
#endif // BORNAGAIN_BASE_TYPES_VECTORWC_H
......@@ -61,6 +61,11 @@ signals:
//! Signals name change of the given instrument.
//! In addition to this, instrumentChanged() will be emitted as well.
void instrumentNameChanged(const InstrumentItem* instrument) const;
void instrumentSelected() const;
private:
void onCurrentChanged() const override { emit instrumentSelected(); }
};
#endif // BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTSSET_H
......@@ -30,9 +30,6 @@ public:
QSize sizeHint() const override;
QSize minimumSizeHint() const override;
signals:
void instrumentSelected(InstrumentItem* instrument);
private slots:
void onStoreInLibrary() const;
void onLoadFromLibrary();
......
......@@ -68,7 +68,7 @@ InstrumentView::InstrumentView()
//... Finalize
connect(m_listing, &InstrumentsQListView::instrumentSelected, this,
connect(gDoc->instruments(), &InstrumentsSet::instrumentSelected, this,
&InstrumentView::createWidgetsForCurrentInstrument);
// Initial state
......
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