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/commands/clicommandsql.h | |
Imported Upstream version 2.99.6upstream/2.99.6
Diffstat (limited to 'SQLiteStudio3/sqlitestudiocli/commands/clicommandsql.h')
| -rw-r--r-- | SQLiteStudio3/sqlitestudiocli/commands/clicommandsql.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/SQLiteStudio3/sqlitestudiocli/commands/clicommandsql.h b/SQLiteStudio3/sqlitestudiocli/commands/clicommandsql.h new file mode 100644 index 0000000..5423a85 --- /dev/null +++ b/SQLiteStudio3/sqlitestudiocli/commands/clicommandsql.h @@ -0,0 +1,66 @@ +#ifndef CLICOMMANDSQL_H +#define CLICOMMANDSQL_H + +#include "clicommand.h" +#include "db/sqlquery.h" + +class QueryExecutor; + +class CliCommandSql : public CliCommand +{ + Q_OBJECT + + public: + void execute(); + QString shortHelp() const; + QString fullHelp() const; + bool isAsyncExecution() const; + void defineSyntax(); + + private: + class SortedColumnWidth + { + public: + SortedColumnWidth(); + + bool operator<(const SortedColumnWidth& other); + + int getHeaderWidth() const; + void setHeaderWidth(int value); + void setMaxHeaderWidth(int value); + void incrHeaderWidth(int value = 1); + void decrHeaderWidth(int value = 1); + + int getDataWidth() const; + void setDataWidth(int value); + void setMinDataWidth(int value); + void incrDataWidth(int value = 1); + void decrDataWidth(int value = 1); + + void incrWidth(int value = 0); + int getWidth() const; + bool isHeaderLonger() const; + + private: + void updateWidth(); + + int width; + int headerWidth; + int dataWidth; + }; + + void printResultsClassic(QueryExecutor *executor, SqlQueryPtr results); + void printResultsFixed(QueryExecutor *executor, SqlQueryPtr results); + void printResultsColumns(QueryExecutor *executor, SqlQueryPtr results); + void printResultsRowByRow(QueryExecutor *executor, SqlQueryPtr results); + void shrinkColumns(QList<SortedColumnWidth*>& columnWidths, int termCols, int resultColumnsCount, int totalWidth); + void printColumnHeader(const QList<int>& widths, const QStringList& columns); + void printColumnDataRow(const QList<int>& widths, const SqlResultsRowPtr& row, int rowIdOffset); + + QString getValueString(const QVariant& value); + + private slots: + void executionFailed(int code, const QString& msg); +}; + +#endif // CLICOMMANDSQL_H |
