diff options
| author | 2015-11-25 16:48:41 -0500 | |
|---|---|---|
| committer | 2015-11-25 16:48:41 -0500 | |
| commit | 8e640722c62692818ab840d50b3758f89a41a54e (patch) | |
| tree | 38197eb1688a5afc338081ea17e15f938976e422 /SQLiteStudio3/sqlitestudiocli/cli.cpp | |
| parent | 9618f0ebbf4b88045247c01ce8c8f58203508ebf (diff) | |
Imported Upstream version 3.0.7upstream/3.0.7
Diffstat (limited to 'SQLiteStudio3/sqlitestudiocli/cli.cpp')
| -rw-r--r-- | SQLiteStudio3/sqlitestudiocli/cli.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/SQLiteStudio3/sqlitestudiocli/cli.cpp b/SQLiteStudio3/sqlitestudiocli/cli.cpp index 0f527ac..87c4f93 100644 --- a/SQLiteStudio3/sqlitestudiocli/cli.cpp +++ b/SQLiteStudio3/sqlitestudiocli/cli.cpp @@ -9,12 +9,14 @@ #include "common/utils_sql.h" #include "climsghandler.h" #include "clicompleter.h" +#include "services/notifymanager.h" #include <QCoreApplication> #include <QThread> #include <QFile> #include <QSet> #include <QStringList> #include <QLibrary> +#include <QString> #if defined(Q_OS_WIN32) #include "readline.h" @@ -36,6 +38,9 @@ CLI::CLI(QObject* parent) : history_base = 0; // for some reason this was set to 1 under Unix, making 1st history entry to be always ommited #endif + connect(NOTIFY_MANAGER, SIGNAL(notifyInfo(QString)), this, SLOT(printInfo(QString))); + connect(NOTIFY_MANAGER, SIGNAL(notifyWarning(QString)), this, SLOT(printWarn(QString))); + connect(NOTIFY_MANAGER, SIGNAL(notifyError(QString)), this, SLOT(printError(QString))); loadHistory(); CliCompleter::getInstance()->init(this); @@ -43,6 +48,7 @@ CLI::CLI(QObject* parent) : CLI::~CLI() { + safe_delete(thread); } CLI* CLI::getInstance() @@ -53,6 +59,11 @@ CLI* CLI::getInstance() return instance; } +void CLI::dispose() +{ + safe_delete(instance); +} + void CLI::start() { thread = new QThread(this); @@ -153,6 +164,24 @@ int CLI::historyLength() const #endif } +void CLI::printWarn(const QString &msg) +{ + static_qstring(tpl, "[WARNING] %1"); + qOut << tpl.arg(msg) << "\n"; +} + +void CLI::printError(const QString &msg) +{ + static_qstring(tpl, "[ERROR] %1"); + qOut << tpl.arg(msg) << "\n"; +} + +void CLI::printInfo(const QString &msg) +{ + static_qstring(tpl, "[INFO] %1"); + qOut << tpl.arg(msg) << "\n"; +} + void CLI::waitForExecution() { executionFinished = false; |
