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 "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_("<No prefix>"));
if (sortCB->isEnabled() && sortCB->isChecked()) {
if(caseSensitiveCB->isEnabled() && caseSensitiveCB->isChecked())
qSort(refsStrings.begin(), refsStrings.end());
else
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<QTreeWidgetItem *> 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_);

View File

@ -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

View File

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RefUi</class>
<widget class="QDialog" name="RefUi">
@ -6,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>435</width>
<height>500</height>
<height>539</height>
</rect>
</property>
<property name="windowTitle">
@ -15,18 +16,53 @@
<property name="sizeGripEnabled">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<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">
<property name="text">
<string>La&amp;bels in:</string>
<string>&amp;In[[buffer]]:</string>
</property>
<property name="buddy">
<cstring>bufferCO</cstring>
</property>
</widget>
</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">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@ -34,26 +70,26 @@
<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 name="toolTip">
<string>The (sub-)document from which the available labels are displayed</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
</layout>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;References</string>
<string>Available &amp;Labels:</string>
</property>
<property name="buddy">
<cstring>refsTW</cstring>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<item row="2" column="0">
<widget class="QTreeWidget" name="refsTW">
<column>
<property name="text">
@ -62,132 +98,71 @@
</column>
</widget>
</item>
<item row="4" column="0" colspan="3">
<item row="3" column="0">
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</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>
</property>
<item>
<widget class="QLabel" name="findKeysLA">
<widget class="QLabel" name="SortLA">
<property name="text">
<string>Fil&amp;ter:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
<string>So&amp;rt:</string>
</property>
<property name="buddy">
<cstring>findLE</cstring>
<cstring>sortingCO</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="findLE">
<widget class="QComboBox" name="sortingCO">
<property name="toolTip">
<string>Enter string to filter the label list</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>
<string>Sorting of the list of available labels</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="groupCB">
<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 name="text">
<string>Grou&amp;p</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</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>
</item>
<item row="6" column="0">
<item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="referenceL">
<property name="text">
<string>&amp;Label:</string>
<string>Sele&amp;cted Label:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
@ -197,19 +172,56 @@
</property>
</widget>
</item>
<item row="6" column="1" colspan="2">
<widget class="QLineEdit" name="referenceED"/>
<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 row="7" column="1" colspan="2">
<widget class="QComboBox" name="typeCO">
<item>
<widget class="QPushButton" name="gotoPB">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<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>
<item>
<property name="text">
@ -248,7 +260,11 @@
</item>
</widget>
</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">
<property name="enabled">
<bool>false</bool>
@ -264,25 +280,36 @@
</property>
</widget>
</item>
<item row="8" column="1" colspan="2">
<item>
<widget class="QLineEdit" name="nameED">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="9" column="0" colspan="3">
</layout>
</item>
<item row="7" column="0">
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</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>
</property>
<item>
<widget class="QPushButton" name="updatePB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -349,30 +376,12 @@
</item>
</layout>
</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>
</widget>
<tabstops>
<tabstop>bufferCO</tabstop>
<tabstop>refsTW</tabstop>
<tabstop>findLE</tabstop>
<tabstop>csFindCB</tabstop>
<tabstop>sortCB</tabstop>
<tabstop>caseSensitiveCB</tabstop>
<tabstop>groupCB</tabstop>
<tabstop>gotoPB</tabstop>
<tabstop>referenceED</tabstop>
<tabstop>typeCO</tabstop>
<tabstop>nameED</tabstop>

View File

@ -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