diff options
| author | Jesper K. Pedersen <jesper.pedersen@kdab.com> | 2013-04-25 16:47:17 +0200 |
|---|---|---|
| committer | Jesper K. Pedersen <jesper.pedersen@kdab.com> | 2013-04-30 06:53:17 +0200 |
| commit | 74ac0a518fcb79f14ab655ce68d424c034f6b846 (patch) | |
| tree | 2a0672f8ee2d56d01b69b6fafe7f36bbd7a544b7 /scriptmanager.cpp | |
| parent | 3d28db2eb6b6e33ab4ae0f7e976c576a19108dc4 (diff) | |
implemented include() to load scripts
Change-Id: I4e8a558fdb12f0a1e16551867274e35ac750fb04
Reviewed-by: Nicolas Arnaud-Cormos <nicolas@kdab.com>
Diffstat (limited to 'scriptmanager.cpp')
| -rw-r--r-- | scriptmanager.cpp | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/scriptmanager.cpp b/scriptmanager.cpp index 00b5b91..95f1130 100644 --- a/scriptmanager.cpp +++ b/scriptmanager.cpp @@ -53,10 +53,7 @@ #include <QMainWindow> #include <QDir> #include <QFileInfo> -#include <QDebug> #include <QFileSystemWatcher> -#include <QFile> -#include <QTextStream> #include <QSignalMapper> @@ -141,27 +138,16 @@ QStringList scriptListFromDir(const QString &path) void ScriptManager::runFile(const QString &fileName) { - QFile file(fileName); - - if (file.open(QIODevice::ReadOnly)) { - QTextStream stream(&file); - const QString sourceCode = stream.readAll(); - - Core::MessageManager::instance()->showOutputPane(); - Core::MessageManager::instance()->printToOutputPane(tr("Start %1...").arg(fileName), - Utils::NormalMessageFormat); - ErrorMessage message = m_runner->runScript(sourceCode, fileName); - if (message.hasError) - Core::MessageManager::instance()->printToOutputPane(tr("Error at line %1: %2\n").arg(message.line).arg(message.message), - Utils::ErrorMessageFormat); - else - Core::MessageManager::instance()->printToOutputPane(tr("The script exited normally\n"), - Utils::NormalMessageFormat); - } - else { - Core::MessageManager::instance()->printToOutputPane(tr("Error: %1 doesn't exist.\n").arg(fileName), + Core::MessageManager::instance()->showOutputPane(); + Core::MessageManager::instance()->printToOutputPane(tr("Start %1...").arg(fileName), + Utils::NormalMessageFormat); + ErrorMessage message = m_runner->runScript(fileName); + if (message.hasError) + Core::MessageManager::instance()->printToOutputPane(tr("Error at line %1: %2\n").arg(message.line).arg(message.message), Utils::ErrorMessageFormat); - } + else + Core::MessageManager::instance()->printToOutputPane(tr("The script exited normally\n"), + Utils::NormalMessageFormat); } void ScriptManager::directoryChanged(const QString &path, bool initialize) |
