#include <config.h>
-#include "support/qstring_helpers.h"\r
-\r
-#include "support/debug.h"\r
+#include "support/qstring_helpers.h"
+
+#include "support/debug.h"
#include "support/docstring.h"
+#include "support/qstring_helpers.h"
+#include <QRegExp>
#include <QString>
#include <QVector>
namespace lyx {
-LyXErr & operator<<(LyXErr & err, QString const & str)\r
-{\r
- return err << fromqstr(str);\r
-}\r
-\r
-\r
+LyXErr & operator<<(LyXErr & err, QString const & str)
+{
+ return err << fromqstr(str);
+}
+
+
QString toqstr(char const * str)
{
return QString::fromUtf8(str);
// need to be superfast.
if (ucs4.empty())
return QString();
+#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
+ return QString::fromStdU32String(reinterpret_cast<std::u32string const &>(ucs4));
+#else
return QString::fromUcs4((uint const *)ucs4.data(), ucs4.length());
+#endif
}
QString toqstr(char_type ucs4)
{
+#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
+ return QString::fromStdU32String(std::u32string(1, ucs4));
+#else
union { char_type c; uint i; } u = { ucs4 };
return QString::fromUcs4(&u.i, 1);
+#endif
}
docstring qstring_to_ucs4(QString const & qstr)
return str.isEmpty() ? std::string() : std::string(str.toUtf8());
}
+QString charFilterRegExp(QString const & filter)
+{
+ QString re = ".*";
+ for (QChar const & c : filter) {
+ 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 (QChar const & c : filter) {
+ if (c.isLower())
+ re += "["+ QRegExp::escape(c) + QRegExp::escape(c.toUpper()) + "]";
+ else
+ re += QRegExp::escape(c);
+ }
+ return re + ")";
+}
+
+
+
} // namespace lyx