commit 40ae8644f9f81576033ff1f8f56428946029b4f4
Author: Richard Kimberly Heck <rikih...@lyx.org>
Date:   Sat Jun 1 20:25:20 2024 -0400

    Put new citation after selected item rather than at end of list.
    
    Fixes bug #12940.
    
    Patch from Daniel.
---
 src/frontends/qt/GuiSelectionManager.cpp | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/frontends/qt/GuiSelectionManager.cpp 
b/src/frontends/qt/GuiSelectionManager.cpp
index d99cd23897..55335d08e2 100644
--- a/src/frontends/qt/GuiSelectionManager.cpp
+++ b/src/frontends/qt/GuiSelectionManager.cpp
@@ -285,17 +285,26 @@ void GuiSelectionManager::addPB_clicked()
                return;
 
        QModelIndex const idxToAdd = selIdx.first();
-       int const srows = selectedModel->rowCount();
+       // Add item after selected item
+       int const currentRow = selectedLV->currentIndex().row();
+       int const srows = currentRow == -1 ? selectedModel->rowCount() :
+                                            currentRow + 1;
 
        QMap<int, QVariant> qm = availableModel->itemData(idxToAdd);
-       insertRowToSelected(srows, qm);
+       bool const isAdded = insertRowToSelected(srows, qm);
 
        selectionChanged(); //signal
-       
+
        QModelIndex const idx = selectedLV->currentIndex();
        if (idx.isValid())
                selectedLV->setCurrentIndex(idx);
 
+       // select and show last added item
+       if (isAdded) {
+               QModelIndex idx = selectedModel->index(srows, 0);
+               selectedLV->setCurrentIndex(idx);
+       }
+
        updateHook();
 }
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to