mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-07 05:45:33 +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 <QStackedLayout>
|
||||
#include <QSplitter>
|
||||
#include <QTimer>
|
||||
|
||||
#include "../../model/doc/document.hpp"
|
||||
#include "../../model/world/universalid.hpp"
|
||||
|
@ -35,6 +36,12 @@ void CSVWorld::ScriptSubView::addButtonBar()
|
|||
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)
|
||||
: SubView (id), mDocument (document), mColumn (-1), mBottom(0), mButtons (0),
|
||||
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)),
|
||||
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)
|
||||
|
@ -136,6 +149,9 @@ void CSVWorld::ScriptSubView::updateUserSetting (const QString& name, const QStr
|
|||
mButtons->updateUserSetting (name, value);
|
||||
|
||||
mErrors->updateUserSetting (name, value);
|
||||
|
||||
if (name=="script-editor/warnings")
|
||||
recompile();
|
||||
}
|
||||
|
||||
void CSVWorld::ScriptSubView::setStatusBar (bool show)
|
||||
|
@ -198,7 +214,7 @@ void CSVWorld::ScriptSubView::textChanged()
|
|||
mDocument.getUndoStack().push (new CSMWorld::ModifyCommand (*mModel,
|
||||
mModel->getModelIndex (getUniversalId().getId(), mColumn), source));
|
||||
|
||||
mErrors->update (source.toUtf8().constData());
|
||||
recompile();
|
||||
}
|
||||
|
||||
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->setTextCursor (cursor);
|
||||
|
||||
mErrors->update (source.toUtf8().constData());
|
||||
recompile();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -259,3 +275,12 @@ void CSVWorld::ScriptSubView::highlightError (int line, int column)
|
|||
mEditor->setFocus();
|
||||
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 QVBoxLayout;
|
||||
class QSplitter;
|
||||
class QTime;
|
||||
|
||||
namespace CSMDoc
|
||||
{
|
||||
|
@ -43,11 +44,14 @@ namespace CSVWorld
|
|||
QVBoxLayout mLayout;
|
||||
QSplitter *mMain;
|
||||
ScriptErrorTable *mErrors;
|
||||
QTimer *mCompileDelay;
|
||||
|
||||
private:
|
||||
|
||||
void addButtonBar();
|
||||
|
||||
void recompile();
|
||||
|
||||
public:
|
||||
|
||||
ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document);
|
||||
|
@ -77,6 +81,8 @@ namespace CSVWorld
|
|||
void switchToId (const std::string& id);
|
||||
|
||||
void highlightError (int line, int column);
|
||||
|
||||
void updateRequest();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue