Clean up the crossrefs dialog.

This commit is contained in:
Juergen Spitzmueller 2016-09-17 13:03:33 +02:00
parent f3bdb669a9
commit 774becf693
3 changed files with 278 additions and 241 deletions

View File

@ -13,6 +13,8 @@
#include "GuiRef.h" #include "GuiRef.h"
#include "GuiApplication.h"
#include "Buffer.h" #include "Buffer.h"
#include "BufferList.h" #include "BufferList.h"
#include "FuncRequest.h" #include "FuncRequest.h"
@ -48,6 +50,26 @@ GuiRef::GuiRef(GuiView & lv)
at_ref_ = false; 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 avail. 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->setColumnCount(1);
refsTW->header()->setVisible(false); refsTW->header()->setVisible(false);
@ -59,9 +81,11 @@ GuiRef::GuiRef(GuiView & lv)
connect(typeCO, SIGNAL(activated(int)), connect(typeCO, SIGNAL(activated(int)),
this, SLOT(changed_adaptor())); this, SLOT(changed_adaptor()));
connect(referenceED, SIGNAL(textChanged(QString)),
this, SLOT(refTextChanged(QString)));
connect(referenceED, SIGNAL(textChanged(QString)), connect(referenceED, SIGNAL(textChanged(QString)),
this, SLOT(changed_adaptor())); this, SLOT(changed_adaptor()));
connect(findLE, SIGNAL(textEdited(QString)), connect(filter_, SIGNAL(textEdited(QString)),
this, SLOT(filterLabels())); this, SLOT(filterLabels()));
connect(csFindCB, SIGNAL(clicked()), connect(csFindCB, SIGNAL(clicked()),
this, SLOT(filterLabels())); this, SLOT(filterLabels()));
@ -73,10 +97,8 @@ GuiRef::GuiRef(GuiView & lv)
this, SLOT(selectionChanged())); this, SLOT(selectionChanged()));
connect(refsTW, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), connect(refsTW, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)),
this, SLOT(refSelected(QTreeWidgetItem *))); this, SLOT(refSelected(QTreeWidgetItem *)));
connect(sortCB, SIGNAL(clicked()), connect(sortingCO, SIGNAL(activated(int)),
this, SLOT(sortToggled())); this, SLOT(sortToggled()));
connect(caseSensitiveCB, SIGNAL(clicked()),
this, SLOT(caseSensitiveToggled()));
connect(groupCB, SIGNAL(clicked()), connect(groupCB, SIGNAL(clicked()),
this, SLOT(groupToggled())); this, SLOT(groupToggled()));
connect(gotoPB, SIGNAL(clicked()), connect(gotoPB, SIGNAL(clicked()),
@ -167,6 +189,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) void GuiRef::refSelected(QTreeWidgetItem * sel)
{ {
if (isBufferReadonly()) if (isBufferReadonly())
@ -190,13 +220,6 @@ void GuiRef::refSelected(QTreeWidgetItem * sel)
void GuiRef::sortToggled() void GuiRef::sortToggled()
{
caseSensitiveCB->setEnabled(sortCB->isChecked());
redoRefs();
}
void GuiRef::caseSensitiveToggled()
{ {
redoRefs(); redoRefs();
} }
@ -316,16 +339,14 @@ bool GuiRef::typeAllowed()
void GuiRef::setGoBack() void GuiRef::setGoBack()
{ {
gotoPB->setText(qt_("&Go Back")); gotoPB->setText(qt_("&Go Back"));
gotoPB->setToolTip(""); gotoPB->setToolTip(qt_("Jump back to the original cursor location"));
gotoPB->setToolTip(qt_("Jump back"));
} }
void GuiRef::setGotoRef() void GuiRef::setGotoRef()
{ {
gotoPB->setText(qt_("&Go to Label")); gotoPB->setText(qt_("&Go to Label"));
gotoPB->setToolTip(""); gotoPB->setToolTip(qt_("Jump to the selected label"));
gotoPB->setToolTip(qt_("Jump to label"));
} }
@ -392,13 +413,14 @@ void GuiRef::redoRefs()
if (noprefix) if (noprefix)
refsCategories.insert(0, qt_("<No prefix>")); refsCategories.insert(0, qt_("<No prefix>"));
if (sortCB->isEnabled() && sortCB->isChecked()) { QString const sort = sortingCO->isEnabled() ?
if(caseSensitiveCB->isEnabled() && caseSensitiveCB->isChecked()) sortingCO->itemData(sortingCO->currentIndex()).toString()
qSort(refsStrings.begin(), refsStrings.end()); : QString();
else if (sort == "nocase")
qSort(refsStrings.begin(), refsStrings.end(), qSort(refsStrings.begin(), refsStrings.end(),
caseInsensitiveLessThan /*defined above*/); caseInsensitiveLessThan /*defined above*/);
} else if (sort == "case")
qSort(refsStrings.begin(), refsStrings.end());
if (groupCB->isChecked()) { if (groupCB->isChecked()) {
QList<QTreeWidgetItem *> refsCats; QList<QTreeWidgetItem *> refsCats;
@ -459,6 +481,10 @@ void GuiRef::redoRefs()
// Re-activate the emission of signals by these widgets. // Re-activate the emission of signals by these widgets.
refsTW->blockSignals(false); refsTW->blockSignals(false);
referenceED->blockSignals(false); referenceED->blockSignals(false);
gotoPB->setEnabled(!referenceED->text().isEmpty());
typeCO->setEnabled(!referenceED->text().isEmpty());
typeLA->setEnabled(!referenceED->text().isEmpty());
} }
@ -472,13 +498,11 @@ void GuiRef::updateRefs()
Buffer const * buf = theBufferList().getBuffer(name); Buffer const * buf = theBufferList().getBuffer(name);
buf->getLabelList(refs_); buf->getLabelList(refs_);
} }
sortCB->setEnabled(!refs_.empty()); sortingCO->setEnabled(!refs_.empty());
caseSensitiveCB->setEnabled(sortCB->isEnabled() && sortCB->isChecked());
refsTW->setEnabled(!refs_.empty()); refsTW->setEnabled(!refs_.empty());
groupCB->setEnabled(!refs_.empty()); groupCB->setEnabled(!refs_.empty());
// refsTW should only be the focus proxy when it is enabled // refsTW should only be the focus proxy when it is enabled
setFocusProxy(refs_.empty() ? 0 : refsTW); setFocusProxy(refs_.empty() ? 0 : refsTW);
gotoPB->setEnabled(!refs_.empty());
redoRefs(); redoRefs();
} }
@ -510,7 +534,7 @@ void GuiRef::filterLabels()
while (*it) { while (*it) {
(*it)->setHidden( (*it)->setHidden(
(*it)->childCount() == 0 (*it)->childCount() == 0
&& !(*it)->text(0).contains(findLE->text(), cs) && !(*it)->text(0).contains(filter_->text(), cs)
); );
++it; ++it;
} }

View File

@ -14,6 +14,7 @@
#include "GuiDialog.h" #include "GuiDialog.h"
#include "ui_RefUi.h" #include "ui_RefUi.h"
#include "FancyLineEdit.h"
#include "insets/InsetCommandParams.h" #include "insets/InsetCommandParams.h"
@ -41,9 +42,9 @@ private Q_SLOTS:
void filterLabels(); void filterLabels();
void refHighlighted(QTreeWidgetItem *); void refHighlighted(QTreeWidgetItem *);
void selectionChanged(); void selectionChanged();
void refTextChanged(QString const &);
void refSelected(QTreeWidgetItem *); void refSelected(QTreeWidgetItem *);
void sortToggled(); void sortToggled();
void caseSensitiveToggled();
void groupToggled(); void groupToggled();
void updateClicked(); void updateClicked();
void resetDialog(); void resetDialog();
@ -93,6 +94,9 @@ private:
/// ///
InsetCommandParams params_; InsetCommandParams params_;
/// contains the search box
FancyLineEdit * filter_;
/// went to a reference ? /// went to a reference ?
bool at_ref_; bool at_ref_;
/// the last reference entered or examined /// the last reference entered or examined

View File

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>RefUi</class> <class>RefUi</class>
<widget class="QDialog" name="RefUi"> <widget class="QDialog" name="RefUi">
@ -6,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>435</width> <width>435</width>
<height>500</height> <height>539</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -15,45 +16,80 @@
<property name="sizeGripEnabled"> <property name="sizeGripEnabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" colspan="2"> <item row="0" column="0">
<widget class="QLabel" name="refsL"> <layout class="QGridLayout" name="gridLayout">
<property name="text"> <item row="0" column="0">
<string>La&amp;bels in:</string> <layout class="QVBoxLayout" name="verticalLayout">
</property> <item>
<property name="buddy"> <widget class="QLabel" name="findKeysLA">
<cstring>bufferCO</cstring> <property name="text">
</property> <string>&amp;Filter:</string>
</widget> </property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="refsL">
<property name="text">
<string>&amp;In[[buffer]]:</string>
</property>
<property name="buddy">
<cstring>bufferCO</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QHBoxLayout" name="filterBarL"/>
</item>
<item>
<widget class="QCheckBox" name="csFindCB">
<property name="toolTip">
<string>Filter case-sensitively</string>
</property>
<property name="text">
<string>Case Sensiti&amp;ve</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QComboBox" name="bufferCO">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>The (sub-)document from which the available labels are displayed</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item> </item>
<item row="0" column="2"> <item row="1" column="0">
<widget class="QComboBox" name="bufferCO">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>&amp;References</string> <string>Available &amp;Labels:</string>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>refsTW</cstring> <cstring>refsTW</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="3"> <item row="2" column="0">
<widget class="QTreeWidget" name="refsTW"> <widget class="QTreeWidget" name="refsTW">
<column> <column>
<property name="text"> <property name="text">
@ -62,121 +98,98 @@
</column> </column>
</widget> </widget>
</item> </item>
<item row="4" column="0" colspan="3"> <item row="3" column="0">
<layout class="QHBoxLayout"> <layout class="QHBoxLayout">
<property name="spacing"> <property name="spacing">
<number>6</number> <number>6</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QLabel" name="findKeysLA"> <widget class="QLabel" name="SortLA">
<property name="text"> <property name="text">
<string>Fil&amp;ter:</string> <string>So&amp;rt:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>findLE</cstring> <cstring>sortingCO</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="findLE"> <widget class="QComboBox" name="sortingCO">
<property name="toolTip"> <property name="toolTip">
<string>Enter string to filter the label list</string> <string>Sorting of the list of available labels</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="groupCB">
<property name="toolTip">
<string>Group the list of available labels by prefix (e.g. &quot;sec:&quot;)</string>
</property> </property>
<property name="text"> <property name="text">
<string/> <string>Grou&amp;p</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="csFindCB"> <spacer name="horizontalSpacer">
<property name="toolTip">
<string>Filter case-sensitively</string>
</property>
<property name="text">
<string>Case-sensiti&amp;ve</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="0" colspan="3">
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="sortCB">
<property name="toolTip">
<string>Sort labels in alphabetical order (case-insensitively unless the Case-sensitive option is checked)</string>
</property>
<property name="text">
<string>&amp;Sort</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="caseSensitiveCB">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Sort labels case-sensitively in alphabetical order</string>
</property>
<property name="text">
<string>Cas&amp;e-sensitive</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="groupCB">
<property name="toolTip">
<string>Group labels by prefix (e.g. &quot;sec:&quot;)</string>
</property>
<property name="text">
<string>Grou&amp;p</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer>
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>40</width>
<height>20</height> <height>20</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
</layout>
</item>
<item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="referenceL">
<property name="text">
<string>Sele&amp;cted Label:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>referenceED</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="referenceED">
<property name="toolTip">
<string>Select a label from the list above or enter a label manually</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="gotoPB"> <widget class="QPushButton" name="gotoPB">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="toolTip">
<string>Jump to the selected label</string>
</property>
<property name="text"> <property name="text">
<string>&amp;Go to Label</string> <string>&amp;Go to Label</string>
</property> </property>
@ -184,105 +197,119 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="typeLA">
<property name="text">
<string>Reference For&amp;mat:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>typeCO</cstring>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="typeCO">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Adjust the style of the cross-reference</string>
</property>
<item>
<property name="text">
<string>&lt;reference&gt;</string>
</property>
</item>
<item>
<property name="text">
<string>(&lt;reference&gt;)</string>
</property>
</item>
<item>
<property name="text">
<string>&lt;page&gt;</string>
</property>
</item>
<item>
<property name="text">
<string>on page &lt;page&gt;</string>
</property>
</item>
<item>
<property name="text">
<string>&lt;reference&gt; on page &lt;page&gt;</string>
</property>
</item>
<item>
<property name="text">
<string>Formatted reference</string>
</property>
</item>
<item>
<property name="text">
<string>Textual reference</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item row="6" column="0"> <item row="6" column="0">
<widget class="QLabel" name="referenceL"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="text"> <item>
<string>&amp;Label:</string> <widget class="QLabel" name="nameL">
</property> <property name="enabled">
<property name="alignment"> <bool>false</bool>
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> </property>
</property> <property name="text">
<property name="buddy"> <string>&amp;Name:</string>
<cstring>referenceED</cstring> </property>
</property> <property name="alignment">
</widget> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>nameED</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="nameED">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item> </item>
<item row="6" column="1" colspan="2"> <item row="7" column="0">
<widget class="QLineEdit" name="referenceED"/>
</item>
<item row="7" column="1" colspan="2">
<widget class="QComboBox" name="typeCO">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Cross-reference as it appears in output</string>
</property>
<item>
<property name="text">
<string>&lt;reference&gt;</string>
</property>
</item>
<item>
<property name="text">
<string>(&lt;reference&gt;)</string>
</property>
</item>
<item>
<property name="text">
<string>&lt;page&gt;</string>
</property>
</item>
<item>
<property name="text">
<string>on page &lt;page&gt;</string>
</property>
</item>
<item>
<property name="text">
<string>&lt;reference&gt; on page &lt;page&gt;</string>
</property>
</item>
<item>
<property name="text">
<string>Formatted reference</string>
</property>
</item>
<item>
<property name="text">
<string>Textual reference</string>
</property>
</item>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="nameL">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Name:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>nameED</cstring>
</property>
</widget>
</item>
<item row="8" column="1" colspan="2">
<widget class="QLineEdit" name="nameED">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="9" column="0" colspan="3">
<layout class="QHBoxLayout"> <layout class="QHBoxLayout">
<property name="spacing"> <property name="spacing">
<number>6</number> <number>6</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QPushButton" name="updatePB"> <widget class="QPushButton" name="updatePB">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -349,30 +376,12 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="7" column="0">
<widget class="QLabel" name="typeLA">
<property name="text">
<string>&amp;Format:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>typeCO</cstring>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>bufferCO</tabstop>
<tabstop>refsTW</tabstop> <tabstop>refsTW</tabstop>
<tabstop>findLE</tabstop>
<tabstop>csFindCB</tabstop> <tabstop>csFindCB</tabstop>
<tabstop>sortCB</tabstop>
<tabstop>caseSensitiveCB</tabstop>
<tabstop>groupCB</tabstop> <tabstop>groupCB</tabstop>
<tabstop>gotoPB</tabstop>
<tabstop>referenceED</tabstop> <tabstop>referenceED</tabstop>
<tabstop>typeCO</tabstop> <tabstop>typeCO</tabstop>
<tabstop>nameED</tabstop> <tabstop>nameED</tabstop>