mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
Case-insensitive reference sorting.
Patch from Manoj Rajagopalan. http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg147931.html git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28593 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
316764c611
commit
303177ad81
@ -57,6 +57,8 @@ GuiRef::GuiRef(GuiView & lv)
|
||||
// Enabling is set in updateRefs. Disable for now in case no
|
||||
// call to updateContents follows (e.g. read-only documents).
|
||||
sortCB->setEnabled(false);
|
||||
caseSensitiveCB->setEnabled(false);
|
||||
caseSensitiveCB->setChecked(false);
|
||||
refsLW->setEnabled(false);
|
||||
gotoPB->setEnabled(false);
|
||||
|
||||
@ -80,6 +82,8 @@ GuiRef::GuiRef(GuiView & lv)
|
||||
this, SLOT(refSelected(QListWidgetItem *)));
|
||||
connect(sortCB, SIGNAL(clicked()),
|
||||
this, SLOT(sortToggled()));
|
||||
connect(caseSensitiveCB, SIGNAL(clicked()),
|
||||
this, SLOT(caseSensitiveToggled()));
|
||||
connect(gotoPB, SIGNAL(clicked()),
|
||||
this, SLOT(gotoClicked()));
|
||||
connect(updatePB, SIGNAL(clicked()),
|
||||
@ -93,6 +97,7 @@ GuiRef::GuiRef(GuiView & lv)
|
||||
bc().setCancel(closePB);
|
||||
bc().addReadOnly(refsLW);
|
||||
bc().addReadOnly(sortCB);
|
||||
bc().addReadOnly(caseSensitiveCB);
|
||||
bc().addReadOnly(nameED);
|
||||
bc().addReadOnly(referenceED);
|
||||
bc().addReadOnly(typeCO);
|
||||
@ -170,6 +175,13 @@ void GuiRef::refSelected(QListWidgetItem * sel)
|
||||
|
||||
|
||||
void GuiRef::sortToggled()
|
||||
{
|
||||
caseSensitiveCB->setEnabled(sortCB->isChecked());
|
||||
redoRefs();
|
||||
}
|
||||
|
||||
|
||||
void GuiRef::caseSensitiveToggled()
|
||||
{
|
||||
redoRefs();
|
||||
}
|
||||
@ -306,6 +318,11 @@ void GuiRef::gotoRef()
|
||||
at_ref_ = !at_ref_;
|
||||
}
|
||||
|
||||
inline bool caseInsensitiveLessThan(QString const & s1, QString const & s2)
|
||||
{
|
||||
return s1.toLower() < s2.toLower();
|
||||
}
|
||||
|
||||
|
||||
void GuiRef::redoRefs()
|
||||
{
|
||||
@ -321,13 +338,20 @@ void GuiRef::redoRefs()
|
||||
// the first item inserted
|
||||
QString const oldSelection(referenceED->text());
|
||||
|
||||
for (vector<docstring>::const_iterator iter = refs_.begin();
|
||||
iter != refs_.end(); ++iter) {
|
||||
refsLW->addItem(toqstr(*iter));
|
||||
QStringList refsStrings;
|
||||
vector<docstring>::const_iterator iter;
|
||||
for (iter = refs_.begin(); iter != refs_.end(); ++iter)
|
||||
refsStrings.append(toqstr(*iter));
|
||||
|
||||
if (sortCB->isEnabled() && sortCB->isChecked()) {
|
||||
if(caseSensitiveCB->isEnabled() && caseSensitiveCB->isChecked())
|
||||
qSort(refsStrings.begin(), refsStrings.end());
|
||||
else
|
||||
qSort(refsStrings.begin(), refsStrings.end(),
|
||||
caseInsensitiveLessThan /*defined above*/);
|
||||
}
|
||||
|
||||
if (sortCB->isEnabled() && sortCB->isChecked())
|
||||
refsLW->sortItems();
|
||||
refsLW->addItems(refsStrings);
|
||||
|
||||
referenceED->setText(oldSelection);
|
||||
|
||||
@ -368,6 +392,7 @@ void GuiRef::updateRefs()
|
||||
buf->getLabelList(refs_);
|
||||
}
|
||||
sortCB->setEnabled(!refs_.empty());
|
||||
caseSensitiveCB->setEnabled(sortCB->isEnabled() && sortCB->isChecked());
|
||||
refsLW->setEnabled(!refs_.empty());
|
||||
// refsLW should only be the focus proxy when it is enabled
|
||||
setFocusProxy(refs_.empty() ? 0 : refsLW);
|
||||
|
@ -38,6 +38,7 @@ private Q_SLOTS:
|
||||
void selectionChanged();
|
||||
void refSelected(QListWidgetItem *);
|
||||
void sortToggled();
|
||||
void caseSensitiveToggled();
|
||||
void updateClicked();
|
||||
void reset_dialog();
|
||||
void dialog_rejected();
|
||||
|
@ -5,7 +5,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>347</width>
|
||||
<width>386</width>
|
||||
<height>423</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -16,27 +16,6 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="1" column="0" colspan="3" >
|
||||
<widget class="QListWidget" name="refsLW" />
|
||||
</item>
|
||||
<item row="0" column="2" >
|
||||
<widget class="QComboBox" name="bufferCO" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2" >
|
||||
<widget class="QLabel" name="refsL" >
|
||||
<property name="text" >
|
||||
@ -47,95 +26,86 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="3" >
|
||||
<item row="0" column="2" >
|
||||
<widget class="QComboBox" name="bufferCO" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3" >
|
||||
<widget class="QListWidget" name="refsLW" />
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<layout class="QHBoxLayout" >
|
||||
<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>&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&e-sensitive</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="okPB" >
|
||||
<property name="text" >
|
||||
<string>&OK</string>
|
||||
</property>
|
||||
<property name="default" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="applyPB" >
|
||||
<property name="text" >
|
||||
<string>&Apply</string>
|
||||
</property>
|
||||
<property name="default" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="closePB" >
|
||||
<property name="text" >
|
||||
<string>&Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QPushButton" name="updatePB" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Update the label list</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>&Update</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="gotoPB" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Jump to the label</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>&Go to Label</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="5" column="1" colspan="2" >
|
||||
<widget class="QLineEdit" name="nameED" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" >
|
||||
<widget class="QLabel" name="nameL" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>&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="4" column="0" >
|
||||
<widget class="QLabel" name="typeLA" >
|
||||
<property name="text" >
|
||||
<string>&Format:</string>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>typeLA</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" >
|
||||
<widget class="QLabel" name="referenceL" >
|
||||
<property name="text" >
|
||||
@ -149,12 +119,26 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2" >
|
||||
<widget class="QLineEdit" name="referenceED" />
|
||||
</item>
|
||||
<item row="4" column="0" >
|
||||
<widget class="QLabel" name="typeLA" >
|
||||
<property name="text" >
|
||||
<string>&Format:</string>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>typeLA</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="2" >
|
||||
<widget class="QComboBox" name="typeCO" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>1</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -194,60 +178,77 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2" >
|
||||
<widget class="QLineEdit" name="referenceED" />
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QCheckBox" name="sortCB" >
|
||||
<property name="toolTip" >
|
||||
<string>Sort labels in alphabetical order</string>
|
||||
<item row="5" column="0" >
|
||||
<widget class="QLabel" name="nameL" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>&Sort</string>
|
||||
<string>&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="2" column="1" colspan="2" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
<item row="5" column="1" colspan="2" >
|
||||
<widget class="QLineEdit" name="nameED" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="3" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="updatePB" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>3</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Update the label list</string>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="okPB" >
|
||||
<property name="text" >
|
||||
<string>&Update</string>
|
||||
<string>&OK</string>
|
||||
</property>
|
||||
<property name="default" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="gotoPB" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>3</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Jump to the label</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="applyPB" >
|
||||
<property name="text" >
|
||||
<string>&Go to Label</string>
|
||||
<string>&Apply</string>
|
||||
</property>
|
||||
<property name="default" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="closePB" >
|
||||
<property name="text" >
|
||||
<string>&Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -255,10 +256,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<pixmapfunction></pixmapfunction>
|
||||
<includes>
|
||||
<include location="local" >qt_i18n.h</include>
|
||||
</includes>
|
||||
<tabstops>
|
||||
<tabstop>bufferCO</tabstop>
|
||||
<tabstop>refsLW</tabstop>
|
||||
@ -272,6 +269,9 @@
|
||||
<tabstop>applyPB</tabstop>
|
||||
<tabstop>closePB</tabstop>
|
||||
</tabstops>
|
||||
<includes>
|
||||
<include location="local" >qt_i18n.h</include>
|
||||
</includes>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
Loading…
Reference in New Issue
Block a user