提交 c50f4880 编写于 作者: M Matt Gajownik

UI: Dynamically set widget index when renaming sources

上级 cb970d0c
...@@ -318,12 +318,13 @@ bool SourceTreeItem::IsEditing() ...@@ -318,12 +318,13 @@ bool SourceTreeItem::IsEditing()
void SourceTreeItem::EnterEditMode() void SourceTreeItem::EnterEditMode()
{ {
setFocusPolicy(Qt::StrongFocus); setFocusPolicy(Qt::StrongFocus);
int index = boxLayout->indexOf(label);
boxLayout->removeWidget(label); boxLayout->removeWidget(label);
editor = new QLineEdit(label->text()); editor = new QLineEdit(label->text());
editor->setStyleSheet("background: none"); editor->setStyleSheet("background: none");
editor->selectAll(); editor->selectAll();
editor->installEventFilter(this); editor->installEventFilter(this);
boxLayout->insertWidget(2, editor); boxLayout->insertWidget(index, editor);
setFocusProxy(editor); setFocusProxy(editor);
} }
...@@ -338,11 +339,12 @@ void SourceTreeItem::ExitEditMode(bool save) ...@@ -338,11 +339,12 @@ void SourceTreeItem::ExitEditMode(bool save)
std::string newName = QT_TO_UTF8(editor->text()); std::string newName = QT_TO_UTF8(editor->text());
setFocusProxy(nullptr); setFocusProxy(nullptr);
int index = boxLayout->indexOf(editor);
boxLayout->removeWidget(editor); boxLayout->removeWidget(editor);
delete editor; delete editor;
editor = nullptr; editor = nullptr;
setFocusPolicy(Qt::NoFocus); setFocusPolicy(Qt::NoFocus);
boxLayout->insertWidget(2, label); boxLayout->insertWidget(index, label);
/* ----------------------------------------- */ /* ----------------------------------------- */
/* check for empty string */ /* check for empty string */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册