Make eventScriptLabelModel and eventScriptLabelCompleter into values rather than pointers
This commit is contained in:
parent
f72d4bda50
commit
e310732169
3 changed files with 26 additions and 19 deletions
|
@ -62,7 +62,7 @@ public:
|
|||
QStringList secretBaseIds;
|
||||
QStringList bgEventFacingDirections;
|
||||
QStringList trainerTypes;
|
||||
QStringList eventScriptLabels;
|
||||
QStringList globalScriptLabels;
|
||||
QMap<QString, int> metatileBehaviorMap;
|
||||
QMap<int, QString> metatileBehaviorMapInverse;
|
||||
QMap<QString, QString> facingDirections;
|
||||
|
@ -180,7 +180,7 @@ public:
|
|||
QString getScriptDefaultString(bool usePoryScript, QString mapName) const;
|
||||
QString getMapScriptsFilePath(const QString &mapName) const;
|
||||
QStringList getEventScriptsFilePaths() const;
|
||||
QCompleter *getEventScriptLabelCompleter(QStringList additionalCompletions) const;
|
||||
QCompleter *getEventScriptLabelCompleter(QStringList additionalScriptLabels);
|
||||
|
||||
bool loadMapBorder(Map *map);
|
||||
|
||||
|
@ -223,8 +223,8 @@ private:
|
|||
static int default_map_size;
|
||||
static int max_object_events;
|
||||
|
||||
QStringListModel *eventScriptLabelModel = nullptr;
|
||||
QCompleter *eventScriptLabelCompleter = nullptr;
|
||||
QStringListModel eventScriptLabelModel;
|
||||
QCompleter eventScriptLabelCompleter;
|
||||
|
||||
signals:
|
||||
void reloadProject();
|
||||
|
|
|
@ -467,15 +467,15 @@ QStringList ParseUtil::getGlobalScriptLabels(const QString &filePath) {
|
|||
return getGlobalRawScriptLabels(readTextFile(filePath));
|
||||
else if (filePath.endsWith(".pory"))
|
||||
return getGlobalPoryScriptLabels(readTextFile(filePath));
|
||||
|
||||
return { };
|
||||
else
|
||||
return { };
|
||||
}
|
||||
|
||||
QStringList ParseUtil::getGlobalRawScriptLabels(QString text) {
|
||||
removeStringLiterals(text);
|
||||
removeLineComments(text, "@");
|
||||
|
||||
auto rawScriptLabels = QStringList();
|
||||
QStringList rawScriptLabels;
|
||||
|
||||
QRegularExpressionMatchIterator it = re_globalIncScriptLabel.globalMatch(text);
|
||||
while (it.hasNext()) {
|
||||
|
@ -490,7 +490,7 @@ QStringList ParseUtil::getGlobalPoryScriptLabels(QString text) {
|
|||
removeStringLiterals(text);
|
||||
removeLineComments(text, {"//", "#"});
|
||||
|
||||
auto poryScriptLabels = QStringList();
|
||||
QStringList poryScriptLabels;
|
||||
|
||||
QRegularExpressionMatchIterator it = re_globalPoryScriptLabel.globalMatch(text);
|
||||
while (it.hasNext())
|
||||
|
@ -520,12 +520,15 @@ QString ParseUtil::removeLineComments(QString text, const QStringList &commentSy
|
|||
}
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||
|
||||
#include <QProcess>
|
||||
|
||||
QStringList ParseUtil::splitShellCommand(QStringView command) {
|
||||
return QProcess::splitCommand(command);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// The source for QProcess::splitCommand() as of Qt 5.15.2
|
||||
QStringList ParseUtil::splitShellCommand(QStringView command) {
|
||||
QStringList args;
|
||||
|
@ -565,4 +568,5 @@ QStringList ParseUtil::splitShellCommand(QStringView command) {
|
|||
|
||||
return args;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -36,7 +36,10 @@ int Project::max_map_data_size = 10240; // 0x2800
|
|||
int Project::default_map_size = 20;
|
||||
int Project::max_object_events = 64;
|
||||
|
||||
Project::Project(QWidget *parent) : QObject(parent)
|
||||
Project::Project(QWidget *parent) :
|
||||
QObject(parent),
|
||||
eventScriptLabelModel(this),
|
||||
eventScriptLabelCompleter(this)
|
||||
{
|
||||
initSignals();
|
||||
}
|
||||
|
@ -2313,12 +2316,12 @@ bool Project::readMiscellaneousConstants() {
|
|||
|
||||
bool Project::readEventScriptLabels() {
|
||||
for (const auto &filePath : getEventScriptsFilePaths())
|
||||
eventScriptLabels << ParseUtil::getGlobalScriptLabels(filePath);
|
||||
globalScriptLabels << ParseUtil::getGlobalScriptLabels(filePath);
|
||||
|
||||
eventScriptLabelModel = new QStringListModel(eventScriptLabels, this);
|
||||
eventScriptLabelCompleter = new QCompleter(eventScriptLabelModel, this);
|
||||
eventScriptLabelCompleter->setCaseSensitivity(Qt::CaseInsensitive);
|
||||
eventScriptLabelCompleter->setFilterMode(Qt::MatchContains);
|
||||
eventScriptLabelModel.setStringList(globalScriptLabels);
|
||||
eventScriptLabelCompleter.setModel(&eventScriptLabelModel);
|
||||
eventScriptLabelCompleter.setCaseSensitivity(Qt::CaseInsensitive);
|
||||
eventScriptLabelCompleter.setFilterMode(Qt::MatchContains);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -2386,11 +2389,11 @@ QStringList Project::getEventScriptsFilePaths() const {
|
|||
return filePaths;
|
||||
}
|
||||
|
||||
QCompleter *Project::getEventScriptLabelCompleter(QStringList additionalCompletions) const {
|
||||
additionalCompletions += eventScriptLabels;
|
||||
additionalCompletions.removeDuplicates();
|
||||
eventScriptLabelModel->setStringList(additionalCompletions);
|
||||
return eventScriptLabelCompleter;
|
||||
QCompleter *Project::getEventScriptLabelCompleter(QStringList additionalScriptLabels) {
|
||||
additionalScriptLabels << globalScriptLabels;
|
||||
additionalScriptLabels.removeDuplicates();
|
||||
eventScriptLabelModel.setStringList(additionalScriptLabels);
|
||||
return &eventScriptLabelCompleter;
|
||||
}
|
||||
|
||||
void Project::loadEventPixmaps(QList<Event*> objects) {
|
||||
|
|
Loading…
Reference in a new issue