diff --git a/UI/source-tree.cpp b/UI/source-tree.cpp index fa21620d4733afe1df80329e9528764d76b341d4..fdd4c37c8880162b9204a40ebfc19af5997ba962 100644 --- a/UI/source-tree.cpp +++ b/UI/source-tree.cpp @@ -318,12 +318,13 @@ bool SourceTreeItem::IsEditing() void SourceTreeItem::EnterEditMode() { setFocusPolicy(Qt::StrongFocus); + int index = boxLayout->indexOf(label); boxLayout->removeWidget(label); editor = new QLineEdit(label->text()); editor->setStyleSheet("background: none"); editor->selectAll(); editor->installEventFilter(this); - boxLayout->insertWidget(2, editor); + boxLayout->insertWidget(index, editor); setFocusProxy(editor); } @@ -338,11 +339,12 @@ void SourceTreeItem::ExitEditMode(bool save) std::string newName = QT_TO_UTF8(editor->text()); setFocusProxy(nullptr); + int index = boxLayout->indexOf(editor); boxLayout->removeWidget(editor); delete editor; editor = nullptr; setFocusPolicy(Qt::NoFocus); - boxLayout->insertWidget(2, label); + boxLayout->insertWidget(index, label); /* ----------------------------------------- */ /* check for empty string */