diff --git a/apps/opencs/view/world/scriptedit.cpp b/apps/opencs/view/world/scriptedit.cpp index 79b123ee47..fccac75b41 100644 --- a/apps/opencs/view/world/scriptedit.cpp +++ b/apps/opencs/view/world/scriptedit.cpp @@ -11,7 +11,8 @@ CSVWorld::ScriptEdit::ScriptEdit (QWidget* parent, const CSMDoc::Document& document) : QTextEdit (parent), - mDocument (document) + mDocument (document), + mWhiteListQoutes("^[a-z|_]{1}[a-z|0-9|_]{0,}$", Qt::CaseInsensitive) { mAllowedTypes < is only for c++11, so let's use qregexp for now. + const QString string(QString::fromStdString(id)); // is only for c++11, so let's use qregexp for now. //I'm not quite sure when do we need to put quotes. To be safe we will use quotes for anything other than… - QRegExp regexp("^[a-z|_]{1}[a-z|0-9|_]{0,}$", Qt::CaseInsensitive); - return !(string.contains(regexp)); + return !(string.contains(mWhiteListQoutes)); } diff --git a/apps/opencs/view/world/scriptedit.hpp b/apps/opencs/view/world/scriptedit.hpp index afad120485..b4627c2fee 100644 --- a/apps/opencs/view/world/scriptedit.hpp +++ b/apps/opencs/view/world/scriptedit.hpp @@ -7,6 +7,7 @@ #include "../../model/world/universalid.hpp" class QWidget; +class QRegExp; namespace CSMDoc { @@ -24,6 +25,7 @@ namespace CSVWorld private: QVector mAllowedTypes; const CSMDoc::Document& mDocument; + const QRegExp mWhiteListQoutes; void dragEnterEvent (QDragEnterEvent* event); @@ -31,7 +33,7 @@ namespace CSVWorld void dragMoveEvent (QDragMoveEvent* event); - bool stringNeedsQuote(const std::string& id); + bool stringNeedsQuote(const std::string& id) const; }; } #endif // SCRIPTEDIT_H \ No newline at end of file