From 7167ce41b61d2ba2cdb526777a4233eb84a3b66a Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Sat, 6 Dec 2014 17:33:25 -0500 Subject: Imported Upstream version 2.99.6 --- .../sqlformattersimpleplugin.cpp | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Plugins/SqlFormatterSimple/sqlformattersimpleplugin.cpp (limited to 'Plugins/SqlFormatterSimple/sqlformattersimpleplugin.cpp') diff --git a/Plugins/SqlFormatterSimple/sqlformattersimpleplugin.cpp b/Plugins/SqlFormatterSimple/sqlformattersimpleplugin.cpp new file mode 100644 index 0000000..0cb60c5 --- /dev/null +++ b/Plugins/SqlFormatterSimple/sqlformattersimpleplugin.cpp @@ -0,0 +1,50 @@ +#include "sqlformattersimpleplugin.h" + +SqlFormatterSimplePlugin::SqlFormatterSimplePlugin() +{ +} + +QString SqlFormatterSimplePlugin::format(SqliteQueryPtr query) +{ + TokenList tokens = query->tokens; + foreach (TokenPtr token, tokens) + { + if (token->type == Token::KEYWORD && cfg.SqlFormatterSimple.UpperCaseKeywords.get()) + token->value = token->value.toUpper(); + + if (token->type == Token::SPACE && cfg.SqlFormatterSimple.TrimLongSpaces.get() && + token->value.length() > 1) + token->value = " "; + } + + return tokens.detokenize(); +} + +bool SqlFormatterSimplePlugin::init() +{ + Q_INIT_RESOURCE(sqlformattersimple); + return GenericPlugin::init(); +} + +void SqlFormatterSimplePlugin::deinit() +{ + Q_CLEANUP_RESOURCE(sqlformattersimple); +} + +QString SqlFormatterSimplePlugin::getConfigUiForm() const +{ + return "SqlFormatterSimplePlugin"; +} + +CfgMain* SqlFormatterSimplePlugin::getMainUiConfig() +{ + return &cfg; +} + +void SqlFormatterSimplePlugin::configDialogOpen() +{ +} + +void SqlFormatterSimplePlugin::configDialogClosed() +{ +} -- cgit v1.2.3