Put new citation after selected item rather than at end of list.

Fixes bug #12940.

Patch from Daniel.
This commit is contained in:
Richard Kimberly Heck 2024-06-01 20:25:20 -04:00
parent a114f12868
commit 40ae8644f9

View File

@ -285,17 +285,26 @@ void GuiSelectionManager::addPB_clicked()
return; return;
QModelIndex const idxToAdd = selIdx.first(); 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); QMap<int, QVariant> qm = availableModel->itemData(idxToAdd);
insertRowToSelected(srows, qm); bool const isAdded = insertRowToSelected(srows, qm);
selectionChanged(); //signal selectionChanged(); //signal
QModelIndex const idx = selectedLV->currentIndex(); QModelIndex const idx = selectedLV->currentIndex();
if (idx.isValid()) if (idx.isValid())
selectedLV->setCurrentIndex(idx); selectedLV->setCurrentIndex(idx);
// select and show last added item
if (isAdded) {
QModelIndex idx = selectedModel->index(srows, 0);
selectedLV->setCurrentIndex(idx);
}
updateHook(); updateHook();
} }