GuiRef: only show "<No prefix>" if non-empty

If "Group" is checked, "<No prefix>" is shown only if there exists a
label with no prefix. Before, it was shown even when it was empty and
even when there were no labels at all.
This commit is contained in:
Scott Kostyshak 2013-04-19 07:48:26 -04:00
parent 914b1d8200
commit 9887dd48ca

View File

@ -350,18 +350,28 @@ void GuiRef::redoRefs()
QStringList refsStrings;
QStringList refsCategories;
vector<docstring>::const_iterator iter;
bool noprefix = false;
for (iter = refs_.begin(); iter != refs_.end(); ++iter) {
QString const lab = toqstr(*iter);
refsStrings.append(lab);
if (groupCB->isChecked() && lab.contains(":")) {
if (groupCB->isChecked()) {
if (lab.contains(":")) {
QString const pref = lab.split(':')[0];
if (!pref.isEmpty() && !refsCategories.contains(pref))
if (!refsCategories.contains(pref)) {
if (!pref.isEmpty())
refsCategories.append(pref);
else
noprefix = true;
}
}
else
noprefix = true;
}
}
// sort categories case-intensively
qSort(refsCategories.begin(), refsCategories.end(),
caseInsensitiveLessThan /*defined above*/);
if (noprefix)
refsCategories.insert(0, qt_("<No prefix>"));
if (sortCB->isEnabled() && sortCB->isChecked()) {