mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-07 02:28:35 +00:00
Refactor
This commit is contained in:
parent
35fac4ab51
commit
1cc859d713
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user