diff options
| author | 2014-12-06 17:33:25 -0500 | |
|---|---|---|
| committer | 2014-12-06 17:33:25 -0500 | |
| commit | 7167ce41b61d2ba2cdb526777a4233eb84a3b66a (patch) | |
| tree | a35c14143716e1f2c98f808c81f89426045a946f /SQLiteStudio3/sqlitestudiocli/cli.h | |
Imported Upstream version 2.99.6upstream/2.99.6
Diffstat (limited to 'SQLiteStudio3/sqlitestudiocli/cli.h')
| -rw-r--r-- | SQLiteStudio3/sqlitestudiocli/cli.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/SQLiteStudio3/sqlitestudiocli/cli.h b/SQLiteStudio3/sqlitestudiocli/cli.h new file mode 100644 index 0000000..6f7c927 --- /dev/null +++ b/SQLiteStudio3/sqlitestudiocli/cli.h @@ -0,0 +1,62 @@ +#ifndef CLI_H +#define CLI_H + +#include "db/db.h" +#include <QObject> +#include <QTextStream> +#include <QStringList> +#include <QTime> + +class QThread; +class QFile; +class DbManager; +class CliCommand; + +class CLI : public QObject +{ + Q_OBJECT + + public: + ~CLI(); + + static CLI* getInstance(); + + void start(); + void setCurrentDb(Db* db); + Db* getCurrentDb() const; + void exit(); + QStringList getHistory() const; + QString getLine() const; + void applyHistoryLimit(); + + private: + explicit CLI(QObject* parent = nullptr); + + void waitForExecution(); + bool isComplete(const QString& contents) const; + void loadHistory(); + void addHistory(const QString& text); + void println(const QString& msg = QString()); + int historyLength() const; + + static CLI* instance; + + QString lastHistoryEntry; + QThread* thread = nullptr; + Db* currentDb = nullptr; + bool executionFinished = false; + bool doExit = false; + QString line; + + signals: + void execCommand(CliCommand* cmd); + + public slots: + void doWork(); + void done(); + void executionComplete(); + void clearHistory(); + void openDbFile(const QString& path); +}; + +#endif // CLI_H |
