#include "Cursor.h"
#include "FancyLineEdit.h"
#include "FuncRequest.h"
+#include "PDFOptions.h"
#include "qt_helpers.h"
buttonBox->button(QDialogButtonBox::Reset)->setText(qt_("&Update"));
buttonBox->button(QDialogButtonBox::Reset)->setToolTip(qt_("Update the label list"));
- refsTW->setColumnCount(1);
- refsTW->header()->setVisible(false);
-
connect(this, SIGNAL(rejected()), this, SLOT(dialogRejected()));
connect(typeCO, SIGNAL(activated(int)),
this, SLOT(changed_adaptor()));
connect(noprefixCB, SIGNAL(clicked()),
this, SLOT(changed_adaptor()));
+ connect(nolinkCB, SIGNAL(clicked()),
+ this, SLOT(changed_adaptor()));
enableBoxes();
bool const isLabelOnly = (reftype == "labelonly");
bool const usingRefStyle = buffer().params().use_refstyle;
bool const intext = bufferview()->cursor().inTexted();
+ bool const hyper_on = buffer().params().pdfoptions().use_hyperref;
pluralCB->setEnabled(intext && isFormatted && usingRefStyle);
capsCB->setEnabled(intext && isFormatted && usingRefStyle);
noprefixCB->setEnabled(intext && isLabelOnly);
+ // disabling of hyperlinks not supported by formatted references
+ nolinkCB->setEnabled(hyper_on && intext && !isFormatted && !isLabelOnly);
}
pluralCB->setChecked(params_["plural"] == "true");
capsCB->setChecked(params_["caps"] == "true");
noprefixCB->setChecked(params_["noprefix"] == "true");
+ nolinkCB->setChecked(params_["nolink"] == "true");
// insert buffer list
bufferCO->clear();
from_ascii("true") : from_ascii("false");
params_["noprefix"] = noprefixCB->isChecked() ?
from_ascii("true") : from_ascii("false");
+ params_["nolink"] = nolinkCB->isChecked() ?
+ from_ascii("true") : from_ascii("false");
restored_buffer_ = bufferCO->currentIndex();
}
at_ref_ = !at_ref_;
}
+inline bool caseInsensitiveLessThanVec(std::tuple<QString, QString, QString> const & s1, std::tuple<QString, QString, QString> const & s2)
+{
+ return std::get<0>(s1).toLower() < std::get<0>(s2).toLower();
+}
+
inline bool caseInsensitiveLessThan(QString const & s1, QString const & s2)
{
return s1.toLower() < s2.toLower();
// the first item inserted
QString const oldSelection(referenceED->text());
- QStringList refsNames;
- QStringList refsAsStrings;
+ // Plain label, GUI string, and dereferenced string.
+ // This might get resorted below
+ QVector<std::tuple<QString, QString,QString>> refsNames;
+ // List of categories (prefixes)
QStringList refsCategories;
- vector<std::pair<docstring, docstring>>::const_iterator iter;
+ // Do we have a prefix-less label at all?
bool noprefix = false;
- for (iter = refs_.begin(); iter != refs_.end(); ++iter) {
- // the plain label name
- QString const lab = toqstr((*iter).first);
- refsNames.append(lab);
- // the label as gui string
- refsAsStrings.append(toqstr((*iter).second));
+ for (auto const & theref : refs_) {
+ // first: plain label name, second: gui name, third: pretty name
+ QString const lab = toqstr(get<0>(theref));
+ refsNames.append({lab, toqstr(get<1>(theref)), toqstr(get<2>(theref))});
if (groupCB->isChecked()) {
if (lab.contains(":")) {
QString const pref = lab.split(':')[0];
noprefix = true;
}
}
- // sort categories case-intensively
+ // sort categories case-insensitively
sort(refsCategories.begin(), refsCategories.end(),
caseInsensitiveLessThan /*defined above*/);
if (noprefix)
QString const sort_method = sortingCO->isEnabled() ?
sortingCO->itemData(sortingCO->currentIndex()).toString()
: QString();
+ // Sort items if so requested.
if (sort_method == "nocase")
sort(refsNames.begin(), refsNames.end(),
- caseInsensitiveLessThan /*defined above*/);
+ caseInsensitiveLessThanVec /*defined above*/);
else if (sort_method == "case")
sort(refsNames.begin(), refsNames.end());
QTreeWidgetItem * item = new QTreeWidgetItem(refsTW);
item->setText(0, cat);
for (int j = 0; j < refsNames.size(); ++j) {
- QString const & ref = refsNames.at(j);
+ QString const ref = std::get<0>(refsNames.at(j));
if ((ref.startsWith(cat + QString(":")))
|| (cat == qt_("<No prefix>")
&& (!ref.mid(1).contains(":") || ref.left(1).contains(":")))) {
QTreeWidgetItem * child =
new QTreeWidgetItem(item);
- item->setText(0, refsAsStrings.at(j));
- item->setData(0, Qt::UserRole, ref);
+ QString const val = std::get<1>(refsNames.at(j));
+ QString const pretty = std::get<2>(refsNames.at(j));
+ child->setText(0, val);
+ child->setData(0, Qt::UserRole, ref);
+ child->setText(1, pretty);
item->addChild(child);
}
}
QList<QTreeWidgetItem *> refsItems;
for (int i = 0; i < refsNames.size(); ++i) {
QTreeWidgetItem * item = new QTreeWidgetItem(refsTW);
- QString const & ref = refsNames.at(i);
- item->setText(0, refsAsStrings.at(i));
+ QString const ref = std::get<0>(refsNames.at(i));
+ QString const val = std::get<1>(refsNames.at(i));
+ QString const pretty = std::get<2>(refsNames.at(i));
+ item->setText(0, val);
item->setData(0, Qt::UserRole, ref);
+ item->setText(1, pretty);
refsItems.append(item);
}
refsTW->addTopLevelItems(refsItems);
(*it)->setHidden(
(*it)->childCount() == 0
&& !(*it)->text(0).contains(filter_->text(), cs)
+ && !(*it)->text(1).contains(filter_->text(), cs)
);
++it;
}