mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-21 07:09:39 +00:00
put script compilation in script subview behind a timer
This commit is contained in:
parent
9abc57d988
commit
7f89d3688f
2 changed files with 33 additions and 2 deletions
|
@ -5,6 +5,7 @@
|
||||||
#include <QStatusBar>
|
#include <QStatusBar>
|
||||||
#include <QStackedLayout>
|
#include <QStackedLayout>
|
||||||
#include <QSplitter>
|
#include <QSplitter>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include "../../model/doc/document.hpp"
|
#include "../../model/doc/document.hpp"
|
||||||
#include "../../model/world/universalid.hpp"
|
#include "../../model/world/universalid.hpp"
|
||||||
|
@ -35,6 +36,12 @@ void CSVWorld::ScriptSubView::addButtonBar()
|
||||||
mButtons, SLOT (universalIdChanged (const CSMWorld::UniversalId&)));
|
mButtons, SLOT (universalIdChanged (const CSMWorld::UniversalId&)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVWorld::ScriptSubView::recompile()
|
||||||
|
{
|
||||||
|
if (!mCompileDelay->isActive())
|
||||||
|
mCompileDelay->start (5000);
|
||||||
|
}
|
||||||
|
|
||||||
CSVWorld::ScriptSubView::ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document)
|
CSVWorld::ScriptSubView::ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document)
|
||||||
: SubView (id), mDocument (document), mColumn (-1), mBottom(0), mButtons (0),
|
: SubView (id), mDocument (document), mColumn (-1), mBottom(0), mButtons (0),
|
||||||
mCommandDispatcher (document, CSMWorld::UniversalId::getParentType (id.getType()))
|
mCommandDispatcher (document, CSMWorld::UniversalId::getParentType (id.getType()))
|
||||||
|
@ -101,6 +108,12 @@ CSVWorld::ScriptSubView::ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc:
|
||||||
|
|
||||||
connect (mErrors, SIGNAL (highlightError (int, int)),
|
connect (mErrors, SIGNAL (highlightError (int, int)),
|
||||||
this, SLOT (highlightError (int, int)));
|
this, SLOT (highlightError (int, int)));
|
||||||
|
|
||||||
|
mCompileDelay = new QTimer (this);
|
||||||
|
mCompileDelay->setSingleShot (true);
|
||||||
|
connect (mCompileDelay, SIGNAL (timeout()), this, SLOT (updateRequest()));
|
||||||
|
|
||||||
|
recompile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::ScriptSubView::updateUserSetting (const QString& name, const QStringList& value)
|
void CSVWorld::ScriptSubView::updateUserSetting (const QString& name, const QStringList& value)
|
||||||
|
@ -136,6 +149,9 @@ void CSVWorld::ScriptSubView::updateUserSetting (const QString& name, const QStr
|
||||||
mButtons->updateUserSetting (name, value);
|
mButtons->updateUserSetting (name, value);
|
||||||
|
|
||||||
mErrors->updateUserSetting (name, value);
|
mErrors->updateUserSetting (name, value);
|
||||||
|
|
||||||
|
if (name=="script-editor/warnings")
|
||||||
|
recompile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::ScriptSubView::setStatusBar (bool show)
|
void CSVWorld::ScriptSubView::setStatusBar (bool show)
|
||||||
|
@ -198,7 +214,7 @@ void CSVWorld::ScriptSubView::textChanged()
|
||||||
mDocument.getUndoStack().push (new CSMWorld::ModifyCommand (*mModel,
|
mDocument.getUndoStack().push (new CSMWorld::ModifyCommand (*mModel,
|
||||||
mModel->getModelIndex (getUniversalId().getId(), mColumn), source));
|
mModel->getModelIndex (getUniversalId().getId(), mColumn), source));
|
||||||
|
|
||||||
mErrors->update (source.toUtf8().constData());
|
recompile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::ScriptSubView::dataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight)
|
void CSVWorld::ScriptSubView::dataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight)
|
||||||
|
@ -219,7 +235,7 @@ void CSVWorld::ScriptSubView::dataChanged (const QModelIndex& topLeft, const QMo
|
||||||
mEditor->setPlainText (source);
|
mEditor->setPlainText (source);
|
||||||
mEditor->setTextCursor (cursor);
|
mEditor->setTextCursor (cursor);
|
||||||
|
|
||||||
mErrors->update (source.toUtf8().constData());
|
recompile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,3 +275,12 @@ void CSVWorld::ScriptSubView::highlightError (int line, int column)
|
||||||
mEditor->setFocus();
|
mEditor->setFocus();
|
||||||
mEditor->setTextCursor (cursor);
|
mEditor->setTextCursor (cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVWorld::ScriptSubView::updateRequest()
|
||||||
|
{
|
||||||
|
QModelIndex index = mModel->getModelIndex (getUniversalId().getId(), mColumn);
|
||||||
|
|
||||||
|
QString source = mModel->data (index).toString();
|
||||||
|
|
||||||
|
mErrors->update (source.toUtf8().constData());
|
||||||
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ class QModelIndex;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QVBoxLayout;
|
class QVBoxLayout;
|
||||||
class QSplitter;
|
class QSplitter;
|
||||||
|
class QTime;
|
||||||
|
|
||||||
namespace CSMDoc
|
namespace CSMDoc
|
||||||
{
|
{
|
||||||
|
@ -43,11 +44,14 @@ namespace CSVWorld
|
||||||
QVBoxLayout mLayout;
|
QVBoxLayout mLayout;
|
||||||
QSplitter *mMain;
|
QSplitter *mMain;
|
||||||
ScriptErrorTable *mErrors;
|
ScriptErrorTable *mErrors;
|
||||||
|
QTimer *mCompileDelay;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void addButtonBar();
|
void addButtonBar();
|
||||||
|
|
||||||
|
void recompile();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document);
|
ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document);
|
||||||
|
@ -77,6 +81,8 @@ namespace CSVWorld
|
||||||
void switchToId (const std::string& id);
|
void switchToId (const std::string& id);
|
||||||
|
|
||||||
void highlightError (int line, int column);
|
void highlightError (int line, int column);
|
||||||
|
|
||||||
|
void updateRequest();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue