X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsupport%2Fqstring_helpers.cpp;h=7e339def452beef377cfa3d476d0adbd34825dee;hb=76e99e9a20cf635d20effa597551f3a9af484465;hp=ded445fc72992efb38f64486e2a7a9b5cc7da2a1;hpb=9f9d9500c0825020844da261eb2e86922355aedb;p=lyx.git diff --git a/src/support/qstring_helpers.cpp b/src/support/qstring_helpers.cpp index ded445fc72..7e339def45 100644 --- a/src/support/qstring_helpers.cpp +++ b/src/support/qstring_helpers.cpp @@ -12,13 +12,24 @@ #include +#include "support/qstring_helpers.h" + +#include "support/debug.h" #include "support/docstring.h" +#include "support/qstring_helpers.h" +#include #include #include namespace lyx { +LyXErr & operator<<(LyXErr & err, QString const & str) +{ + return err << fromqstr(str); +} + + QString toqstr(char const * str) { return QString::fromUtf8(str); @@ -34,6 +45,8 @@ QString toqstr(docstring const & ucs4) { // If possible we let qt do the work, since this version does not // need to be superfast. + if (ucs4.empty()) + return QString(); return QString::fromUcs4((uint const *)ucs4.data(), ucs4.length()); } @@ -56,4 +69,32 @@ 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; +} + +QString charFilterRegExpC(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