Refs dialog redesign.

This commit is contained in:
Juergen Spitzmueller 2016-10-21 22:05:54 +02:00
parent 54248a6e98
commit f23924e824
4 changed files with 294 additions and 242 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 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->setColumnCount(1);
refsTW->header()->setVisible(false); refsTW->header()->setVisible(false);
@ -59,10 +81,14 @@ 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(filter_, SIGNAL(rightButtonClicked()),
this, SLOT(resetFilter()));
connect(csFindCB, SIGNAL(clicked()), connect(csFindCB, SIGNAL(clicked()),
this, SLOT(filterLabels())); this, SLOT(filterLabels()));
connect(nameED, SIGNAL(textChanged(QString)), connect(nameED, SIGNAL(textChanged(QString)),
@ -73,10 +99,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 +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) void GuiRef::refSelected(QTreeWidgetItem * sel)
{ {
if (isBufferReadonly()) if (isBufferReadonly())
@ -190,13 +222,6 @@ void GuiRef::refSelected(QTreeWidgetItem * sel)
void GuiRef::sortToggled() void GuiRef::sortToggled()
{
caseSensitiveCB->setEnabled(sortCB->isChecked());
redoRefs();
}
void GuiRef::caseSensitiveToggled()
{ {
redoRefs(); redoRefs();
} }
@ -270,7 +295,7 @@ void GuiRef::updateContents()
int const thebuffer = theBufferList().bufferNum(buffer().fileName()); int const thebuffer = theBufferList().bufferNum(buffer().fileName());
// restore the buffer combo setting for new insets // 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_) && restored_buffer_ < bufferCO->count() && thebuffer == active_buffer_)
bufferCO->setCurrentIndex(restored_buffer_); bufferCO->setCurrentIndex(restored_buffer_);
else { else {
@ -316,16 +341,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 +415,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 +483,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 +500,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,13 +536,20 @@ 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;
} }
} }
void GuiRef::resetFilter()
{
filter_->setText(QString());
filterLabels();
}
bool GuiRef::initialiseParams(std::string const & data) bool GuiRef::initialiseParams(std::string const & data)
{ {
InsetCommand::string2params(data, params_); InsetCommand::string2params(data, params_);

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"
@ -39,11 +40,12 @@ private Q_SLOTS:
void changed_adaptor(); void changed_adaptor();
void gotoClicked(); void gotoClicked();
void filterLabels(); void filterLabels();
void resetFilter();
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 +95,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,18 +16,53 @@
<property name="sizeGripEnabled"> <property name="sizeGripEnabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2"> <item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="findKeysLA">
<property name="text">
<string>&amp;Filter:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="refsL"> <widget class="QLabel" name="refsL">
<property name="text"> <property name="text">
<string>La&amp;bels in:</string> <string>&amp;In[[buffer]]:</string>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>bufferCO</cstring> <cstring>bufferCO</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2"> </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"> <widget class="QComboBox" name="bufferCO">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@ -34,26 +70,26 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
</widget> <property name="toolTip">
</item> <string>The (sub-)document from which the available labels are displayed</string>
<item row="1" column="0" colspan="3">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="3"> </layout>
</item>
</layout>
</item>
<item row="1" column="0">
<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,132 +98,71 @@
</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>
<property name="text">
<string/>
</property>
</widget>
</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 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> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="groupCB"> <widget class="QCheckBox" name="groupCB">
<property name="toolTip"> <property name="toolTip">
<string>Group labels by prefix (e.g. &quot;sec:&quot;)</string> <string>Group the list of available labels by prefix (e.g. &quot;sec:&quot;)</string>
</property> </property>
<property name="text"> <property name="text">
<string>Grou&amp;p</string> <string>Grou&amp;p</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout>
</item>
<item> <item>
<spacer> <spacer name="horizontalSpacer">
<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>
<item>
<widget class="QPushButton" name="gotoPB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Go to Label</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item row="6" column="0"> <item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="referenceL"> <widget class="QLabel" name="referenceL">
<property name="text"> <property name="text">
<string>&amp;Label:</string> <string>Sele&amp;cted Label:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
@ -197,19 +172,56 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="1" colspan="2"> <item>
<widget class="QLineEdit" name="referenceED"/> <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 row="7" column="1" colspan="2"> <item>
<widget class="QComboBox" name="typeCO"> <widget class="QPushButton" name="gotoPB">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" 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"> <property name="toolTip">
<string>Cross-reference as it appears in output</string> <string>Jump to the selected label</string>
</property>
<property name="text">
<string>&amp;Go to Label</string>
</property>
</widget>
</item>
</layout>
</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> </property>
<item> <item>
<property name="text"> <property name="text">
@ -248,7 +260,11 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="8" column="0"> </layout>
</item>
<item row="6" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="nameL"> <widget class="QLabel" name="nameL">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@ -264,25 +280,36 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="1" colspan="2"> <item>
<widget class="QLineEdit" name="nameED"> <widget class="QLineEdit" name="nameED">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="0" colspan="3"> </layout>
</item>
<item row="7" 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="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>

View File

@ -26,6 +26,11 @@ What's new
- The citation dialog has been redesigned, following user suggestions. - 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 * DOCUMENTATION AND LOCALIZATION