]> git.lyx.org Git - lyx.git/commitdiff
Put new citation after selected item rather than at end of list.
authorRichard Kimberly Heck <rikiheck@lyx.org>
Sun, 2 Jun 2024 00:25:20 +0000 (20:25 -0400)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Mon, 3 Jun 2024 00:54:46 +0000 (20:54 -0400)
Fixes bug #12940.

Patch from Daniel.

(cherry picked from commit 40ae8644f9f81576033ff1f8f56428946029b4f4)

src/frontends/qt/GuiSelectionManager.cpp
status.24x

index d99cd238972f36a71554556788d3d6f8fa4059fd..55335d08e2b488a1f3fc059d8b966208b4ed27fe 100644 (file)
@@ -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();
 }
 
index f4ab64b448eabd99db6dfe5bb0c5960e947e16b5..830cf44644e05aa1754049959f4b2f8d4c082ca8 100644 (file)
@@ -88,6 +88,8 @@ What's new
 
 - Allow "longest label" to be empty (bug 11934).
 
+- Put new citation after selected item rather than at end of list (bug 12940).
+
 
 * INTERNALS