]> git.lyx.org Git - lyx.git/commitdiff
GuiRef: only show "<No prefix>" if non-empty
authorScott Kostyshak <skostysh@lyx.org>
Fri, 19 Apr 2013 11:48:26 +0000 (07:48 -0400)
committerScott Kostyshak <skostysh@lyx.org>
Mon, 22 Apr 2013 19:39:16 +0000 (15:39 -0400)
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.

src/frontends/qt4/GuiRef.cpp

index c79dcb913949198997d81c9a408fc7d5ef6ae716..9e647504866b850014d675b97c91e01a0a4ba592 100644 (file)
@@ -350,19 +350,29 @@ 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(":")) {
-                       QString const pref = lab.split(':')[0];
-                       if (!pref.isEmpty() && !refsCategories.contains(pref))
-                                 refsCategories.append(pref);
+               if (groupCB->isChecked()) {
+                       if (lab.contains(":")) {
+                               QString const pref = lab.split(':')[0];
+                               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*/);
-       refsCategories.insert(0, qt_("<No prefix>"));
+       if (noprefix)
+               refsCategories.insert(0, qt_("<No prefix>"));
 
        if (sortCB->isEnabled() && sortCB->isChecked()) {
                if(caseSensitiveCB->isEnabled() && caseSensitiveCB->isChecked())