]> git.lyx.org Git - lyx.git/blobdiff - src/support/qstring_helpers.cpp
Remove old workaround that is not needed anymore
[lyx.git] / src / support / qstring_helpers.cpp
index ded445fc72992efb38f64486e2a7a9b5cc7da2a1..7e339def452beef377cfa3d476d0adbd34825dee 100644 (file)
 
 #include <config.h>
 
+#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)
+{
+       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