///////////////////////////////////////////////////////////////////////////
TocItem::TocItem(DocIterator const & dit, int d, docstring const & s,
- bool output_active, FuncRequest const & action)
- : dit_(dit), depth_(d), str_(s), output_(output_active),
+ bool output_active, bool missing, FuncRequest const & action)
+ : dit_(dit), depth_(d), str_(s), output_(output_active), missing_(missing),
action_(action)
{
}
prefix += cross;
prefix += thin;
}
+ if (missing_) {
+ prefix += _("MISSING: ");
+ }
return prefix + str_;
}
{
public:
/// Default constructor for STL containers.
- TocItem() : dit_(0), depth_(0), output_(false) {}
+ TocItem() : dit_(0), depth_(0), output_(false), missing_(false) {}
///
TocItem(DocIterator const & dit,
int depth,
docstring const & s,
bool output_active,
+ bool missing = false,
FuncRequest const & action = FuncRequest(LFUN_UNKNOWN_ACTION)
);
///
///
bool isOutput() const { return output_; }
///
+ bool isMissing() const { return missing_; }
+ ///
void setAction(FuncRequest const & a) { action_ = a; }
/// custom action, or the default one (paragraph-goto) if not customised
docstring str_;
/// Is this item in a note, inactive branch, etc?
bool output_;
+ /// Is this item missing, e.g. missing label?
+ bool missing_;
/// Custom action
FuncRequest action_;
};
bool const cur_item_selected = sel->isSelected();
if (cur_item_selected)
- referenceED->setText(sel->text(0));
+ referenceED->setText(sel->data(0, Qt::UserRole).toString());
if (at_ref_)
gotoRef();
bool const cur_item_selected = sel->isSelected();
if (cur_item_selected)
- referenceED->setText(sel->text(0));
+ referenceED->setText(sel->data(0, Qt::UserRole).toString());
// <enter> or double click, inserts ref and closes dialog
slotOK();
}
// the first item inserted
QString const oldSelection(referenceED->text());
- QStringList refsStrings;
+ QStringList refsNames;
+ QStringList refsAsStrings;
QStringList refsCategories;
- vector<docstring>::const_iterator iter;
+ vector<std::pair<docstring, docstring>>::const_iterator iter;
bool noprefix = false;
for (iter = refs_.begin(); iter != refs_.end(); ++iter) {
- QString const lab = toqstr(*iter);
- refsStrings.append(lab);
+ // the plain label name
+ QString const lab = toqstr((*iter).first);
+ refsNames.append(lab);
+ // the label as gui string
+ refsAsStrings.append(toqstr((*iter).second));
if (groupCB->isChecked()) {
if (lab.contains(":")) {
QString const pref = lab.split(':')[0];
sortingCO->itemData(sortingCO->currentIndex()).toString()
: QString();
if (sort_method == "nocase")
- sort(refsStrings.begin(), refsStrings.end(),
+ sort(refsNames.begin(), refsNames.end(),
caseInsensitiveLessThan /*defined above*/);
else if (sort_method == "case")
- sort(refsStrings.begin(), refsStrings.end());
+ sort(refsNames.begin(), refsNames.end());
if (groupCB->isChecked()) {
QList<QTreeWidgetItem *> refsCats;
QString const & cat = refsCategories.at(i);
QTreeWidgetItem * item = new QTreeWidgetItem(refsTW);
item->setText(0, cat);
- for (int j = 0; j < refsStrings.size(); ++j) {
- QString const & ref = refsStrings.at(j);
+ for (int j = 0; j < refsNames.size(); ++j) {
+ QString const & ref = 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);
- child->setText(0, ref);
+ item->setText(0, refsAsStrings.at(j));
+ item->setData(0, Qt::UserRole, ref);
item->addChild(child);
}
}
refsTW->addTopLevelItems(refsCats);
} else {
QList<QTreeWidgetItem *> refsItems;
- for (int i = 0; i < refsStrings.size(); ++i) {
+ for (int i = 0; i < refsNames.size(); ++i) {
QTreeWidgetItem * item = new QTreeWidgetItem(refsTW);
- item->setText(0, refsStrings.at(i));
+ QString const & ref = refsNames.at(i);
+ item->setText(0, refsAsStrings.at(i));
+ item->setData(0, Qt::UserRole, ref);
refsItems.append(item);
}
refsTW->addTopLevelItems(refsItems);
broken_ = true;
setBroken(broken_);
shared_ptr<Toc> toc = backend.toc("label");
- toc->push_back(TocItem(cpit, 0, screenLabel(), output_active));
+ if (TocBackend::findItem(*toc, 0, label) == toc->end())
+ toc->push_back(TocItem(cpit, 0, label, output_active, true));
+ toc->push_back(TocItem(cpit, 1, screenLabel(), output_active));
shared_ptr<Toc> toc2 = backend.toc("brokenrefs");
toc2->push_back(TocItem(cpit, 0, screenLabel(), output_active));
}