diff --git a/lib/utils/list-editor.cpp b/lib/utils/list-editor.cpp index e325b0bf..e4a459e0 100644 --- a/lib/utils/list-editor.cpp +++ b/lib/utils/list-editor.cpp @@ -33,6 +33,34 @@ void ListEditor::showEvent(QShowEvent *e) UpdateListSize(); } +static QListWidgetItem *getItemFromWidget(QListWidget *list, QWidget *widget) +{ + for (int i = 0; i < list->count(); i++) { + auto item = list->item(i); + if (!item) { + continue; + } + auto itemWidget = list->itemWidget(item); + if (itemWidget == widget) { + return item; + } + } + return nullptr; +} + +int ListEditor::GetIndexOfSignal() const +{ + auto sender = this->sender(); + if (!sender) { + return -1; + } + auto widget = qobject_cast(sender); + if (!widget) { + return -1; + } + return _list->row(getItemFromWidget(_list, widget)); +} + void ListEditor::UpdateListSize() { SetHeightToContentHeight(_list); diff --git a/lib/utils/list-editor.hpp b/lib/utils/list-editor.hpp index 966207c2..0b54b154 100644 --- a/lib/utils/list-editor.hpp +++ b/lib/utils/list-editor.hpp @@ -25,6 +25,7 @@ private slots: protected: void UpdateListSize(); + int GetIndexOfSignal() const; QListWidget *_list; ListControls *_controls; diff --git a/plugins/base/utils/osc-helpers.cpp b/plugins/base/utils/osc-helpers.cpp index 0e827245..a98bc46c 100644 --- a/plugins/base/utils/osc-helpers.cpp +++ b/plugins/base/utils/osc-helpers.cpp @@ -660,34 +660,6 @@ void OSCMessageEdit::Down() UpdateListSize(); } -static QListWidgetItem *getItemFromWidget(QListWidget *list, QWidget *widget) -{ - for (int i = 0; i < list->count(); i++) { - auto item = list->item(i); - if (!item) { - continue; - } - auto itemWidget = list->itemWidget(item); - if (itemWidget == widget) { - return item; - } - } - return nullptr; -} - -int OSCMessageEdit::GetIndexOfSignal() -{ - auto sender = this->sender(); - if (!sender) { - return -1; - } - auto widget = qobject_cast(sender); - if (!widget) { - return -1; - } - return _list->row(getItemFromWidget(_list, widget)); -} - void OSCMessageEdit::ElementFocussed() { int idx = GetIndexOfSignal(); diff --git a/plugins/base/utils/osc-helpers.hpp b/plugins/base/utils/osc-helpers.hpp index 3fc362d7..a83ee78f 100644 --- a/plugins/base/utils/osc-helpers.hpp +++ b/plugins/base/utils/osc-helpers.hpp @@ -157,7 +157,6 @@ signals: private: void InsertElement(const OSCMessageElement &); - int GetIndexOfSignal(); VariableLineEdit *_address;