From f23924e82496414c3d15e5b2f768f30221b711c0 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Fri, 21 Oct 2016 22:05:54 +0200 Subject: [PATCH] Refs dialog redesign. --- src/frontends/qt4/GuiRef.cpp | 87 ++++--- src/frontends/qt4/GuiRef.h | 7 +- src/frontends/qt4/ui/RefUi.ui | 437 +++++++++++++++++----------------- status.22x | 5 + 4 files changed, 294 insertions(+), 242 deletions(-) diff --git a/src/frontends/qt4/GuiRef.cpp b/src/frontends/qt4/GuiRef.cpp index 0d213874e3..3bb898872c 100644 --- a/src/frontends/qt4/GuiRef.cpp +++ b/src/frontends/qt4/GuiRef.cpp @@ -13,6 +13,8 @@ #include "GuiRef.h" +#include "GuiApplication.h" + #include "Buffer.h" #include "BufferList.h" #include "FuncRequest.h" @@ -48,6 +50,26 @@ GuiRef::GuiRef(GuiView & lv) at_ref_ = false; + // The filter bar + filter_ = new FancyLineEdit(this); +#if QT_VERSION >= 0x040600 + filter_->setButtonPixmap(FancyLineEdit::Right, getPixmap("images/", "editclear", "svgz,png")); + filter_->setButtonVisible(FancyLineEdit::Right, true); + filter_->setButtonToolTip(FancyLineEdit::Right, qt_("Clear text")); + filter_->setAutoHideButton(FancyLineEdit::Right, true); +#endif +#if QT_VERSION >= 0x040700 + filter_->setPlaceholderText(qt_("All available labels")); +#endif + filter_->setToolTip(qt_("Enter string to filter the list of available labels")); + + filterBarL->addWidget(filter_, 0); + findKeysLA->setBuddy(filter_); + + sortingCO->addItem(qt_("By Occurrence"), "unsorted"); + sortingCO->addItem(qt_("Alphabetically (Case-Insensitive)"), "nocase"); + sortingCO->addItem(qt_("Alphabetically (Case-Sensitive)"), "case"); + refsTW->setColumnCount(1); refsTW->header()->setVisible(false); @@ -59,10 +81,14 @@ GuiRef::GuiRef(GuiView & lv) connect(typeCO, SIGNAL(activated(int)), this, SLOT(changed_adaptor())); + connect(referenceED, SIGNAL(textChanged(QString)), + this, SLOT(refTextChanged(QString))); connect(referenceED, SIGNAL(textChanged(QString)), this, SLOT(changed_adaptor())); - connect(findLE, SIGNAL(textEdited(QString)), + connect(filter_, SIGNAL(textEdited(QString)), this, SLOT(filterLabels())); + connect(filter_, SIGNAL(rightButtonClicked()), + this, SLOT(resetFilter())); connect(csFindCB, SIGNAL(clicked()), this, SLOT(filterLabels())); connect(nameED, SIGNAL(textChanged(QString)), @@ -73,10 +99,8 @@ GuiRef::GuiRef(GuiView & lv) this, SLOT(selectionChanged())); connect(refsTW, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(refSelected(QTreeWidgetItem *))); - connect(sortCB, SIGNAL(clicked()), + connect(sortingCO, SIGNAL(activated(int)), this, SLOT(sortToggled())); - connect(caseSensitiveCB, SIGNAL(clicked()), - this, SLOT(caseSensitiveToggled())); connect(groupCB, SIGNAL(clicked()), this, SLOT(groupToggled())); connect(gotoPB, SIGNAL(clicked()), @@ -167,6 +191,14 @@ void GuiRef::refHighlighted(QTreeWidgetItem * sel) } +void GuiRef::refTextChanged(QString const & str) +{ + gotoPB->setEnabled(!str.isEmpty()); + typeCO->setEnabled(!str.isEmpty()); + typeLA->setEnabled(!str.isEmpty()); +} + + void GuiRef::refSelected(QTreeWidgetItem * sel) { if (isBufferReadonly()) @@ -190,13 +222,6 @@ void GuiRef::refSelected(QTreeWidgetItem * sel) void GuiRef::sortToggled() -{ - caseSensitiveCB->setEnabled(sortCB->isChecked()); - redoRefs(); -} - - -void GuiRef::caseSensitiveToggled() { redoRefs(); } @@ -270,7 +295,7 @@ void GuiRef::updateContents() int const thebuffer = theBufferList().bufferNum(buffer().fileName()); // restore the buffer combo setting for new insets - if (params_["reference"].empty() && restored_buffer_ != -1 + if (new_inset && restored_buffer_ != -1 && restored_buffer_ < bufferCO->count() && thebuffer == active_buffer_) bufferCO->setCurrentIndex(restored_buffer_); else { @@ -316,16 +341,14 @@ bool GuiRef::typeAllowed() void GuiRef::setGoBack() { gotoPB->setText(qt_("&Go Back")); - gotoPB->setToolTip(""); - gotoPB->setToolTip(qt_("Jump back")); + gotoPB->setToolTip(qt_("Jump back to the original cursor location")); } void GuiRef::setGotoRef() { gotoPB->setText(qt_("&Go to Label")); - gotoPB->setToolTip(""); - gotoPB->setToolTip(qt_("Jump to label")); + gotoPB->setToolTip(qt_("Jump to the selected label")); } @@ -392,13 +415,14 @@ void GuiRef::redoRefs() if (noprefix) refsCategories.insert(0, qt_("")); - if (sortCB->isEnabled() && sortCB->isChecked()) { - if(caseSensitiveCB->isEnabled() && caseSensitiveCB->isChecked()) - qSort(refsStrings.begin(), refsStrings.end()); - else - qSort(refsStrings.begin(), refsStrings.end(), - caseInsensitiveLessThan /*defined above*/); - } + QString const sort = sortingCO->isEnabled() ? + sortingCO->itemData(sortingCO->currentIndex()).toString() + : QString(); + if (sort == "nocase") + qSort(refsStrings.begin(), refsStrings.end(), + caseInsensitiveLessThan /*defined above*/); + else if (sort == "case") + qSort(refsStrings.begin(), refsStrings.end()); if (groupCB->isChecked()) { QList refsCats; @@ -459,6 +483,10 @@ void GuiRef::redoRefs() // Re-activate the emission of signals by these widgets. refsTW->blockSignals(false); referenceED->blockSignals(false); + + gotoPB->setEnabled(!referenceED->text().isEmpty()); + typeCO->setEnabled(!referenceED->text().isEmpty()); + typeLA->setEnabled(!referenceED->text().isEmpty()); } @@ -472,13 +500,11 @@ void GuiRef::updateRefs() Buffer const * buf = theBufferList().getBuffer(name); buf->getLabelList(refs_); } - sortCB->setEnabled(!refs_.empty()); - caseSensitiveCB->setEnabled(sortCB->isEnabled() && sortCB->isChecked()); + sortingCO->setEnabled(!refs_.empty()); refsTW->setEnabled(!refs_.empty()); groupCB->setEnabled(!refs_.empty()); // refsTW should only be the focus proxy when it is enabled setFocusProxy(refs_.empty() ? 0 : refsTW); - gotoPB->setEnabled(!refs_.empty()); redoRefs(); } @@ -510,13 +536,20 @@ void GuiRef::filterLabels() while (*it) { (*it)->setHidden( (*it)->childCount() == 0 - && !(*it)->text(0).contains(findLE->text(), cs) + && !(*it)->text(0).contains(filter_->text(), cs) ); ++it; } } +void GuiRef::resetFilter() +{ + filter_->setText(QString()); + filterLabels(); +} + + bool GuiRef::initialiseParams(std::string const & data) { InsetCommand::string2params(data, params_); diff --git a/src/frontends/qt4/GuiRef.h b/src/frontends/qt4/GuiRef.h index 250d407645..4c7d48899e 100644 --- a/src/frontends/qt4/GuiRef.h +++ b/src/frontends/qt4/GuiRef.h @@ -14,6 +14,7 @@ #include "GuiDialog.h" #include "ui_RefUi.h" +#include "FancyLineEdit.h" #include "insets/InsetCommandParams.h" @@ -39,11 +40,12 @@ private Q_SLOTS: void changed_adaptor(); void gotoClicked(); void filterLabels(); + void resetFilter(); void refHighlighted(QTreeWidgetItem *); void selectionChanged(); + void refTextChanged(QString const &); void refSelected(QTreeWidgetItem *); void sortToggled(); - void caseSensitiveToggled(); void groupToggled(); void updateClicked(); void resetDialog(); @@ -93,6 +95,9 @@ private: /// InsetCommandParams params_; + /// contains the search box + FancyLineEdit * filter_; + /// went to a reference ? bool at_ref_; /// the last reference entered or examined diff --git a/src/frontends/qt4/ui/RefUi.ui b/src/frontends/qt4/ui/RefUi.ui index daad34192c..3e457266d6 100644 --- a/src/frontends/qt4/ui/RefUi.ui +++ b/src/frontends/qt4/ui/RefUi.ui @@ -1,3 +1,4 @@ + RefUi @@ -6,7 +7,7 @@ 0 0 435 - 500 + 539 @@ -15,45 +16,80 @@ true - - - - - La&bels in: - - - bufferCO - - + + + + + + + + + &Filter: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + &In[[buffer]]: + + + bufferCO + + + + + + + + + + + + + + + + Filter case-sensitively + + + Case Sensiti&ve + + + + + + + + + + 0 + 0 + + + + The (sub-)document from which the available labels are displayed + + + + + + - - - - - 0 - 0 - - - - - - - - Qt::Horizontal - - - - + - &References + Available &Labels: refsTW - + @@ -62,121 +98,98 @@ - + 6 - + + 0 + + + 0 + + + 0 + + 0 - + - Fil&ter: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + So&rt: - findLE + sortingCO - + - Enter string to filter the label list + Sorting of the list of available labels + + + + + + + Group the list of available labels by prefix (e.g. "sec:") - + Grou&p - - - Filter case-sensitively - - - Case-sensiti&ve - - - - - - - - - 6 - - - 0 - - - - - 6 - - - 0 - - - - - Sort labels in alphabetical order (case-insensitively unless the Case-sensitive option is checked) - - - &Sort - - - - - - - false - - - Sort labels case-sensitively in alphabetical order - - - Cas&e-sensitive - - - - - - - Group labels by prefix (e.g. "sec:") - - - Grou&p - - - - - - - + Qt::Horizontal - 20 + 40 20 + + + + + + + + Sele&cted Label: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + referenceED + + + + + + + Select a label from the list above or enter a label manually + + + - + 0 0 + + Jump to the selected label + &Go to Label @@ -184,105 +197,119 @@ + + + + + + Reference For&mat: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + typeCO + + + + + + + + 0 + 0 + + + + Adjust the style of the cross-reference + + + + <reference> + + + + + (<reference>) + + + + + <page> + + + + + on page <page> + + + + + <reference> on page <page> + + + + + Formatted reference + + + + + Textual reference + + + + + + - - - &Label: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - referenceED - - + + + + + false + + + &Name: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + nameED + + + + + + + false + + + + - - - - - - - - 0 - 0 - - - - Cross-reference as it appears in output - - - - <reference> - - - - - (<reference>) - - - - - <page> - - - - - on page <page> - - - - - <reference> on page <page> - - - - - Formatted reference - - - - - Textual reference - - - - - - - - false - - - &Name: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - nameED - - - - - - - false - - - - + 6 - + + 0 + + + 0 + + + 0 + + 0 - + 0 0 @@ -349,30 +376,12 @@ - - - - &Format: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - typeCO - - - - bufferCO refsTW - findLE csFindCB - sortCB - caseSensitiveCB groupCB - gotoPB referenceED typeCO nameED diff --git a/status.22x b/status.22x index 783957afee..87b7522399 100644 --- a/status.22x +++ b/status.22x @@ -26,6 +26,11 @@ What's new - The citation dialog has been redesigned, following user suggestions. +- Remember citation style settings both within and between sessions + (bug 10256). + +- Improve cross-references dialog design. + * DOCUMENTATION AND LOCALIZATION