]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiRef.cpp
Fix handling of the add branch textfield in GuiBranches
[lyx.git] / src / frontends / qt4 / GuiRef.cpp
index 93f8193fc2d8546e9607e1a7aad98ec33c26bb2c..5082daa2667023ff9fe9595372bd0403ce2cd776 100644 (file)
@@ -32,6 +32,7 @@
 #include <QPushButton>
 #include <QToolTip>
 #include <QCloseEvent>
+#include <QHeaderView>
 
 using namespace std;
 using namespace lyx::support;
@@ -68,10 +69,10 @@ GuiRef::GuiRef(GuiView & lv)
                this, SLOT(changed_adaptor()));
        connect(referenceED, SIGNAL(textChanged(QString)),
                this, SLOT(changed_adaptor()));
-       connect(findLE, SIGNAL(returnPressed()), 
-               this, SLOT(on_searchPB_clicked()));
+       connect(findLE, SIGNAL(textEdited(QString)), 
+               this, SLOT(filterLabels()));
        connect(csFindCB, SIGNAL(clicked()), 
-               this, SLOT(on_searchPB_clicked()));
+               this, SLOT(filterLabels()));
        connect(nameED, SIGNAL(textChanged(QString)),
                this, SLOT(changed_adaptor()));
        connect(refsTW, SIGNAL(itemClicked(QTreeWidgetItem *, int)),
@@ -202,7 +203,6 @@ void GuiRef::groupToggled()
 
 void GuiRef::updateClicked()
 {
-       findLE->clear();
        updateRefs();
 }
 
@@ -255,7 +255,7 @@ void GuiRef::updateContents()
        FileNameList const & buffers = theBufferList().fileNames();
        for (FileNameList::const_iterator it = buffers.begin();
             it != buffers.end(); ++it) {
-               bufferCO->addItem(toqstr(makeDisplayPath(it->absFilename())));
+               bufferCO->addItem(toqstr(makeDisplayPath(it->absFileName())));
        }
 
        int const thebuffer = theBufferList().bufferNum(buffer().fileName());
@@ -355,7 +355,6 @@ void GuiRef::redoRefs()
 
        QStringList refsStrings;
        QStringList refsCategories;
-       refsCategories.append(qt_("No prefix"));
        vector<docstring>::const_iterator iter;
        for (iter = refs_.begin(); iter != refs_.end(); ++iter) {
                QString const lab = toqstr(*iter);
@@ -366,6 +365,10 @@ void GuiRef::redoRefs()
                                  refsCategories.append(pref);
                }
        }
+       // sort categories case-intensively
+       qSort(refsCategories.begin(), refsCategories.end(),
+             caseInsensitiveLessThan /*defined above*/);
+       refsCategories.insert(0, qt_("<No prefix>"));
 
        if (sortCB->isEnabled() && sortCB->isChecked()) {
                if(caseSensitiveCB->isEnabled() && caseSensitiveCB->isChecked())
@@ -384,7 +387,7 @@ void GuiRef::redoRefs()
                        for (int i = 0; i < refsStrings.size(); ++i) {
                                QString const ref = refsStrings.at(i);
                                if ((ref.startsWith(cat + QString(":")))
-                                   || (cat == qt_("No prefix")
+                                   || (cat == qt_("<No prefix>")
                                        && !ref.contains(":"))) {
                                        QTreeWidgetItem * child =
                                                new QTreeWidgetItem(item);
@@ -429,6 +432,9 @@ void GuiRef::redoRefs()
        refsTW->setUpdatesEnabled(true);
        refsTW->update();
 
+       // redo filter
+       filterLabels();
+
        // Re-activate the emission of signals by these widgets.
        refsTW->blockSignals(false);
        referenceED->blockSignals(false);
@@ -473,17 +479,11 @@ void GuiRef::gotoBookmark()
 }
 
 
-void GuiRef::on_findLE_textChanged(const QString & text)
+void GuiRef::filterLabels()
 {
-       searchPB->setDisabled(text.isEmpty());
-}
-
-
-void GuiRef::on_searchPB_clicked()
-{
-       QTreeWidgetItemIterator it(refsTW);
        Qt::CaseSensitivity cs = csFindCB->isChecked() ?
                Qt::CaseSensitive : Qt::CaseInsensitive;
+       QTreeWidgetItemIterator it(refsTW);
        while (*it) {
                (*it)->setHidden(
                        (*it)->childCount() == 0
@@ -496,14 +496,14 @@ void GuiRef::on_searchPB_clicked()
 
 bool GuiRef::initialiseParams(std::string const & data)
 {
-       InsetCommand::string2params("ref", data, params_);
+       InsetCommand::string2params(data, params_);
        return true;
 }
 
 
 void GuiRef::dispatchParams()
 {
-       std::string const lfun = InsetCommand::params2string("ref", params_);
+       std::string const lfun = InsetCommand::params2string(params_);
        dispatch(FuncRequest(getLfun(), lfun));
 }