int const rows = selectedLV->model()->rowCount();
- bool const qualified = currentStyle.hasQualifiedList
- && (rows > 1
- || !params_["pretextlist"].empty()
- || !params_["posttextlist"].empty()
- || !getPreTexts().empty()
- || !getPostTexts().empty());
+ bool const qualified = currentStyle.hasQualifiedList && rows > 0;
selectedLV->horizontalHeader()->setVisible(qualified);
selectedLV->setColumnHidden(0, !qualified);
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);
}
int curr = selectedLV->model()->rowCount() - 1;
if (curr < 0 || selected_keys.empty()) {
+ last_chosen_style_ =
+ citationStyleCO->itemData(citationStyleCO->currentIndex()).toString();
citationStyleCO->clear();
citationStyleCO->setEnabled(false);
citationStyleLA->setEnabled(false);
// save old style selection
QString const curdata =
citationStyleCO->itemData(citationStyleCO->currentIndex()).toString();
- QString const olddata = (curdata.isEmpty()) ? style_ : curdata;
+ QString const olddata = (curdata.isEmpty()) ?
+ (last_chosen_style_.isEmpty() ? style_ : last_chosen_style_): curdata;
+ // reset this
+ last_chosen_style_.clear();
citationStyleCO->clear();
BiblioInfo::CiteStringMap::const_iterator cit = sty.begin();
BiblioInfo::CiteStringMap::const_iterator end = sty.end();
}
-void GuiCitation::setPreTexts(vector<docstring> const m)
+void GuiCitation::setPreTexts(vector<docstring> const & m)
{
+ // account for multiple use of the same keys
+ QList<QModelIndex> handled;
for (docstring const & s: m) {
QStandardItem * si = new QStandardItem();
docstring key;
si->setData(toqstr(pre));
si->setText(toqstr(pre));
QModelIndexList qmil =
- selected_model_.match(selected_model_.index(0, 1),
- Qt::DisplayRole, toqstr(key), 1,
- Qt::MatchFlags(Qt::MatchExactly | Qt::MatchWrap));
- if (!qmil.empty())
- selected_model_.setItem(qmil.front().row(), 0, si);
+ selected_model_.match(selected_model_.index(0, 1),
+ Qt::DisplayRole, toqstr(key), -1,
+ Qt::MatchFlags(Qt::MatchExactly | Qt::MatchWrap));
+ for (int i = 0; i < qmil.size(); ++i){
+ QModelIndex idx = qmil[i];
+ if (!handled.contains(idx)) {
+ selected_model_.setItem(idx.row(), 0, si);
+ handled.append(idx);
+ break;
+ }
+ }
}
}
for (int i = 0; i != selected_model_.rowCount(); ++i) {
QStandardItem const * key = selected_model_.item(i, 1);
QStandardItem const * pre = selected_model_.item(i, 0);
- if (key && pre && !key->text().isEmpty() && !pre->text().isEmpty())
+ if (key && pre && !key->text().isEmpty())
res.push_back(qstring_to_ucs4(key->text()) + " " + qstring_to_ucs4(pre->text()));
}
return res;
}
-void GuiCitation::setPostTexts(vector<docstring> const m)
+void GuiCitation::setPostTexts(vector<docstring> const & m)
{
+ // account for multiple use of the same keys
+ QList<QModelIndex> handled;
for (docstring const & s: m) {
QStandardItem * si = new QStandardItem();
docstring key;
si->setData(toqstr(post));
si->setText(toqstr(post));
QModelIndexList qmil =
- selected_model_.match(selected_model_.index(0, 1),
- Qt::DisplayRole, toqstr(key), 1,
- Qt::MatchFlags(Qt::MatchExactly | Qt::MatchWrap));
- if (!qmil.empty())
- selected_model_.setItem(qmil.front().row(), 2, si);
+ selected_model_.match(selected_model_.index(0, 1),
+ Qt::DisplayRole, toqstr(key), -1,
+ Qt::MatchFlags(Qt::MatchExactly | Qt::MatchWrap));
+ for (int i = 0; i < qmil.size(); ++i){
+ QModelIndex idx = qmil[i];
+ if (!handled.contains(idx)) {
+ selected_model_.setItem(idx.row(), 2, si);
+ handled.append(idx);
+ break;
+ }
+ }
}
}
for (int i = 0; i != selected_model_.rowCount(); ++i) {
QStandardItem const * key = selected_model_.item(i, 1);
QStandardItem const * post = selected_model_.item(i, 2);
- if (key && post && !key->text().isEmpty() && !post->text().isEmpty())
+ if (key && post && !key->text().isEmpty())
res.push_back(qstring_to_ucs4(key->text()) + " " + qstring_to_ucs4(post->text()));
}
return res;
&& (selectedLV->model()->rowCount() > 1
|| !pretexts.empty()
|| !posttexts.empty());
- std::map<docstring, docstring> pres;
+ vector<pair<docstring, docstring>> pres;
for (docstring const & s: pretexts) {
docstring key;
docstring val = split(s, key, ' ');
- pres[key] = val;
+ pres.push_back(make_pair(key, val));
}
- std::map<docstring, docstring> posts;
+ vector<pair<docstring, docstring>> posts;
for (docstring const & s: posttexts) {
docstring key;
docstring val = split(s, key, ' ');
- posts[key] = val;
+ posts.push_back(make_pair(key, val));
}
CiteItem ci;
ci.textBefore = qstring_to_ucs4(textBeforeED->text());