From 347800eff3fb16db67c94189fcaf2f83ef761bd0 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Tue, 23 Jul 2019 10:34:33 +0200 Subject: [PATCH] Allow multiple insertion of citation key with qualified citation lists Fixes: #11618 --- src/frontends/qt/GuiCitation.cpp | 2 ++ src/frontends/qt/GuiSelectionManager.cpp | 5 +++-- src/frontends/qt/GuiSelectionManager.h | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/frontends/qt/GuiCitation.cpp b/src/frontends/qt/GuiCitation.cpp index 196ec44d2b..3ef4bb77f3 100644 --- a/src/frontends/qt/GuiCitation.cpp +++ b/src/frontends/qt/GuiCitation.cpp @@ -368,6 +368,8 @@ void GuiCitation::updateFormatting(CitationStyle const & currentStyle) availableLV->setToolTip(qt_("All references available for citing.\n" "To add the selected one, hit Add, press Enter or double-click.\n" "Hit Ctrl-Enter to add and close the dialog.")); + // With qualified citation lists, it makes sense to add the same key multiple times + selectionManager->allowMultiSelection(currentStyle.hasQualifiedList); } diff --git a/src/frontends/qt/GuiSelectionManager.cpp b/src/frontends/qt/GuiSelectionManager.cpp index 9eeb5c9685..4a735ed2d6 100644 --- a/src/frontends/qt/GuiSelectionManager.cpp +++ b/src/frontends/qt/GuiSelectionManager.cpp @@ -55,7 +55,8 @@ GuiSelectionManager::GuiSelectionManager(QObject * parent, : QObject(parent), availableLV(avail), selectedLV(sel), addPB(add), deletePB(del), upPB(up), downPB(down), availableModel(amod), selectedModel(smod), - selectedHasFocus_(false), main_sel_col_(main_sel_col) + selectedHasFocus_(false), main_sel_col_(main_sel_col), + allow_multi_selection_(false) { selectedLV->setModel(smod); availableLV->setModel(amod); @@ -144,7 +145,7 @@ void GuiSelectionManager::updateAddPB() availableLV->selectionModel()->selectedIndexes(); addPB->setEnabled(arows > 0 && !availSels.isEmpty() && - !isSelected(availSels.first())); + (allow_multi_selection_ || !isSelected(availSels.first()))); } diff --git a/src/frontends/qt/GuiSelectionManager.h b/src/frontends/qt/GuiSelectionManager.h index 9875396864..926adc589f 100644 --- a/src/frontends/qt/GuiSelectionManager.h +++ b/src/frontends/qt/GuiSelectionManager.h @@ -67,6 +67,8 @@ public: /// Returns the selected index. Note that this will depend upon /// selectedFocused(). QModelIndex getSelectedIndex(int const c = 0) const; + /// + void allowMultiSelection(bool b) { allow_multi_selection_ = b; } Q_SIGNALS: /// Emitted when the list of selected items has changed. @@ -148,6 +150,8 @@ private: bool selectedHasFocus_; /// int main_sel_col_; + /// + bool allow_multi_selection_; }; } // namespace frontend