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 --- Plugins/SqlFormatterSimple/SqlFormatterSimple.pro | 28 ++++++++++++ Plugins/SqlFormatterSimple/SqlFormatterSimple.ui | 51 ++++++++++++++++++++++ Plugins/SqlFormatterSimple/sqlformattersimple.json | 7 +++ Plugins/SqlFormatterSimple/sqlformattersimple.qrc | 5 +++ .../SqlFormatterSimple/sqlformattersimple_global.h | 12 +++++ .../sqlformattersimpleplugin.cpp | 50 +++++++++++++++++++++ .../SqlFormatterSimple/sqlformattersimpleplugin.h | 38 ++++++++++++++++ 7 files changed, 191 insertions(+) create mode 100644 Plugins/SqlFormatterSimple/SqlFormatterSimple.pro create mode 100644 Plugins/SqlFormatterSimple/SqlFormatterSimple.ui create mode 100644 Plugins/SqlFormatterSimple/sqlformattersimple.json create mode 100644 Plugins/SqlFormatterSimple/sqlformattersimple.qrc create mode 100644 Plugins/SqlFormatterSimple/sqlformattersimple_global.h create mode 100644 Plugins/SqlFormatterSimple/sqlformattersimpleplugin.cpp create mode 100644 Plugins/SqlFormatterSimple/sqlformattersimpleplugin.h (limited to 'Plugins/SqlFormatterSimple') diff --git a/Plugins/SqlFormatterSimple/SqlFormatterSimple.pro b/Plugins/SqlFormatterSimple/SqlFormatterSimple.pro new file mode 100644 index 0000000..2c60801 --- /dev/null +++ b/Plugins/SqlFormatterSimple/SqlFormatterSimple.pro @@ -0,0 +1,28 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2013-12-02T16:14:12 +# +#------------------------------------------------- + +include($$PWD/../../SQLiteStudio3/plugins.pri) + +QT -= gui + +TARGET = SqlFormatterSimple +TEMPLATE = lib + +DEFINES += SQLFORMATTERSIMPLE_LIBRARY + +SOURCES += sqlformattersimpleplugin.cpp + +HEADERS += sqlformattersimpleplugin.h\ + sqlformattersimple_global.h + +FORMS += \ + SqlFormatterSimple.ui + +OTHER_FILES += \ + sqlformattersimple.json + +RESOURCES += \ + sqlformattersimple.qrc diff --git a/Plugins/SqlFormatterSimple/SqlFormatterSimple.ui b/Plugins/SqlFormatterSimple/SqlFormatterSimple.ui new file mode 100644 index 0000000..7e81ee0 --- /dev/null +++ b/Plugins/SqlFormatterSimple/SqlFormatterSimple.ui @@ -0,0 +1,51 @@ + + + SqlFormatterSimplePlugin + + + + 0 + 0 + 354 + 290 + + + + + + + Upper case keywords + + + SqlFormatterSimple.UpperCaseKeywords + + + + + + + Reduce multiple whitespaces to single whitespace + + + SqlFormatterSimple.TrimLongSpaces + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/Plugins/SqlFormatterSimple/sqlformattersimple.json b/Plugins/SqlFormatterSimple/sqlformattersimple.json new file mode 100644 index 0000000..ff51f13 --- /dev/null +++ b/Plugins/SqlFormatterSimple/sqlformattersimple.json @@ -0,0 +1,7 @@ +{ + "type": "CodeFormatterPlugin", + "title": "SQL Simple", + "description": "Basic formatter with very little options.", + "version": 10000, + "author": "SalSoft" +} diff --git a/Plugins/SqlFormatterSimple/sqlformattersimple.qrc b/Plugins/SqlFormatterSimple/sqlformattersimple.qrc new file mode 100644 index 0000000..febfbd2 --- /dev/null +++ b/Plugins/SqlFormatterSimple/sqlformattersimple.qrc @@ -0,0 +1,5 @@ + + + SqlFormatterSimple.ui + + diff --git a/Plugins/SqlFormatterSimple/sqlformattersimple_global.h b/Plugins/SqlFormatterSimple/sqlformattersimple_global.h new file mode 100644 index 0000000..926a1b0 --- /dev/null +++ b/Plugins/SqlFormatterSimple/sqlformattersimple_global.h @@ -0,0 +1,12 @@ +#ifndef SQLFORMATTERSIMPLE_GLOBAL_H +#define SQLFORMATTERSIMPLE_GLOBAL_H + +#include + +#if defined(SQLFORMATTERSIMPLE_LIBRARY) +# define SQLFORMATTERSIMPLESHARED_EXPORT Q_DECL_EXPORT +#else +# define SQLFORMATTERSIMPLESHARED_EXPORT Q_DECL_IMPORT +#endif + +#endif // SQLFORMATTERSIMPLE_GLOBAL_H 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() +{ +} diff --git a/Plugins/SqlFormatterSimple/sqlformattersimpleplugin.h b/Plugins/SqlFormatterSimple/sqlformattersimpleplugin.h new file mode 100644 index 0000000..dde25c8 --- /dev/null +++ b/Plugins/SqlFormatterSimple/sqlformattersimpleplugin.h @@ -0,0 +1,38 @@ +#ifndef SQLFORMATTERSIMPLEPLUGIN_H +#define SQLFORMATTERSIMPLEPLUGIN_H + +#include "sqlformattersimple_global.h" +#include "plugins/sqlformatterplugin.h" +#include "config_builder.h" +#include "plugins/genericplugin.h" +#include "plugins/uiconfiguredplugin.h" +#include + +CFG_CATEGORIES(SqlFormatterSimpleConfig, + CFG_CATEGORY(SqlFormatterSimple, + CFG_ENTRY(bool, UpperCaseKeywords, true) + CFG_ENTRY(bool, TrimLongSpaces, true) + ) +) + +class SQLFORMATTERSIMPLESHARED_EXPORT SqlFormatterSimplePlugin : public GenericPlugin, public SqlFormatterPlugin, public UiConfiguredPlugin +{ + Q_OBJECT + SQLITESTUDIO_PLUGIN("sqlformattersimple.json") + + public: + SqlFormatterSimplePlugin(); + + QString format(SqliteQueryPtr query); + bool init(); + void deinit(); + QString getConfigUiForm() const; + CfgMain* getMainUiConfig(); + void configDialogOpen(); + void configDialogClosed(); + + private: + CFG_LOCAL_PERSISTABLE(SqlFormatterSimpleConfig, cfg) +}; + +#endif // SQLFORMATTERSIMPLEPLUGIN_H -- cgit v1.2.3