This commit is contained in:
Richard Kimberly Heck 2018-10-18 21:11:14 -04:00
parent 35fac4ab51
commit 1cc859d713
4 changed files with 21 additions and 29 deletions

View File

@ -24,6 +24,7 @@
#include "support/gettext.h"
#include "support/lassert.h"
#include "support/lstrings.h"
#include "support/qstring_helpers.h"
#include <QAbstractTextDocumentLayout>
#include <QComboBox>
@ -290,20 +291,6 @@ QString CCItemDelegate::underlineFilter(QString const & s) const
}
static QString charFilterRegExpCC(QString const & filter)
{
QString re = ".*";
for (int i = 0; i < filter.length(); ++i) {
QChar c = filter[i];
if (c.isLower())
re += "[" + QRegExp::escape(c) + QRegExp::escape(c.toUpper()) + "]";
else
re += QRegExp::escape(c);
}
return re;
}
void CategorizedCombo::Private::setFilter(QString const & s)
{
bool enabled = p->view()->updatesEnabled();
@ -315,7 +302,7 @@ void CategorizedCombo::Private::setFilter(QString const & s)
lastSel_ = filterModel_->mapToSource(filterModel_->index(sel, 0)).row();
filter_ = s;
filterModel_->setFilterRegExp(charFilterRegExpCC(filter_));
filterModel_->setFilterRegExp(charFilterRegExp(filter_));
countCategories();
// restore old selection

View File

@ -321,20 +321,6 @@ QString LayoutItemDelegate::underlineFilter(QString const & s) const
}
static QString charFilterRegExp(QString const & filter)
{
QString re = ".*";
for (int i = 0; i < filter.length(); ++i) {
QChar c = filter[i];
if (c.isLower())
re += "["+ QRegExp::escape(c) + QRegExp::escape(c.toUpper()) + "]";
else
re += QRegExp::escape(c);
}
return re;
}
void LayoutBox::Private::setFilter(QString const & s)
{
// exit early if nothing has to be done

View File

@ -16,6 +16,7 @@
#include "support/debug.h"
#include "support/docstring.h"
#include "support/qstring_helpers.h"
#include <QString>
#include <QVector>
@ -67,4 +68,17 @@ std::string fromqstr(QString const & str)
return str.isEmpty() ? std::string() : std::string(str.toUtf8());
}
QString charFilterRegExp(QString const & filter)
{
QString re = ".*";
for (int i = 0; i < filter.length(); ++i) {
QChar c = filter[i];
if (c.isLower())
re += "["+ QRegExp::escape(c) + QRegExp::escape(c.toUpper()) + "]";
else
re += QRegExp::escape(c);
}
return re;
}
} // namespace lyx

View File

@ -80,6 +80,11 @@ docstring qstring_to_ucs4(QString const & qstr);
*/
std::string fromqstr(QString const & str);
/**
* constructs a regex to filter on consecutive characters
*/
QString charFilterRegExp(QString const & filter);
} // namespace lyx
#endif // QSTRING_HELPERS_H