mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-13 12:40:04 +00:00
very basic, but safe putting down " "
This commit is contained in:
parent
17af865a9f
commit
3cc23a9cb3
@ -1,6 +1,10 @@
|
||||
#include "scriptedit.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <QDragEnterEvent>
|
||||
#include <QRegExp>
|
||||
#include <QString>
|
||||
|
||||
#include "../../model/world/universalid.hpp"
|
||||
#include "../../model/world/tablemimedata.hpp"
|
||||
@ -64,8 +68,21 @@ void CSVWorld::ScriptEdit::dropEvent (QDropEvent* event)
|
||||
{
|
||||
if (mAllowedTypes.contains (it->getType()))
|
||||
{
|
||||
QString::fromStdString ('"' + it->getId() + '"');
|
||||
if (stringNeedsQuote(it->getId()))
|
||||
{
|
||||
insertPlainText(QString::fromStdString ('"' + it->getId() + '"'));
|
||||
} else {
|
||||
insertPlainText(QString::fromStdString (it->getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CSVWorld::ScriptEdit::stringNeedsQuote (const std::string& id)
|
||||
{
|
||||
QString string(QString::fromStdString(id)); //<regex> 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));
|
||||
}
|
||||
|
@ -30,6 +30,8 @@ namespace CSVWorld
|
||||
void dropEvent (QDropEvent* event);
|
||||
|
||||
void dragMoveEvent (QDragMoveEvent* event);
|
||||
|
||||
bool stringNeedsQuote(const std::string& id);
|
||||
};
|
||||
}
|
||||
#endif // SCRIPTEDIT_H
|
Loading…
x
Reference in New Issue
Block a user