commit d402ed679de2743738e52ddac208ddef3d00ad8e
Author: Scott Kostyshak <[email protected]>
Date:   Fri Mar 21 13:29:31 2025 +0100

    Select branch in tree after it is added
    
    It makes sense for the user to follow up on the newly added branch
    by using the buttons on the right (which act on the selected
    branch).
---
 src/frontends/qt/GuiBranches.cpp | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/frontends/qt/GuiBranches.cpp b/src/frontends/qt/GuiBranches.cpp
index 4fa4d09fc9..710d01c1e5 100644
--- a/src/frontends/qt/GuiBranches.cpp
+++ b/src/frontends/qt/GuiBranches.cpp
@@ -28,6 +28,7 @@
 
 #include "support/gettext.h"
 #include "support/lstrings.h"
+#include "support/lassert.h"
 
 #include <QKeyEvent>
 #include <QListWidget>
@@ -186,6 +187,16 @@ void GuiBranches::on_addBranchPB_pressed()
        branchlist_.add(qstring_to_ucs4(new_branch));
        newBranchLE->clear();
        addBranchPB->setEnabled(false);
+
+       // need to first update the view so that the QTreeWidgetItem exists
+       // in the tree when we search for it to select it.
+       updateView();
+       // now select the newly added branch
+       QList<QTreeWidgetItem *> items_found = 
branchesTW->findItems(new_branch, Qt::MatchExactly);
+       LASSERT(items_found.size() == 1, return);
+       branchesTW->setCurrentItem(items_found[0]);
+
+       // and update again to show the new selection.
        updateView();
 }
 
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to