1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
#ifndef BUILTINPLUGIN_H
#define BUILTINPLUGIN_H
#include "coreSQLiteStudio_global.h"
#include "plugins/plugin.h"
/**
* @brief Helper class for implementing built-in plugins
*
* This class can be inherited, so most of the abstract methods from Plugin interface get implemented.
* All details (description, name, title, author, ...) are defined using Q_CLASSINFO.
*
* There are macros defined to help you with defining those details. You don't need to define
* Q_CLASSINFO and know all required keys. You can use following macros:
* <ul>
* <li>::SQLITESTUDIO_PLUGIN_TITLE</li>
* <li>::SQLITESTUDIO_PLUGIN_DESC</li>
* <li>::SQLITESTUDIO_PLUGIN_UI</li>
* <li>::SQLITESTUDIO_PLUGIN_VERSION</li>
* <li>::SQLITESTUDIO_PLUGIN_AUTHOR</li>
* </ul>
*
* Most of plugin implementations will use this class as a base, because it simplifies process
* of plugin development. Using this class you don't have to implement any of virtual methods
* from Plugin interface. It's enough to define meta information, like this:
* @code
* class MyPlugin : GenericPlugin
* {
* Q_OBJECT
*
* SQLITESTUDIO_PLUGIN
* SQLITESTUDIO_PLUGIN_TITLE("My plugin")
* SQLITESTUDIO_PLUGIN_DESC("Does nothing. It's an example plugin.")
* SQLITESTUDIO_PLUGIN_UI("formObjectName")
* SQLITESTUDIO_PLUGIN_VERSION(10000)
* SQLITESTUDIO_PLUGIN_AUTHOR("sqlitestudio.pl")
* };
* @endcode
*/class API_EXPORT BuiltInPlugin : public QObject, public virtual Plugin
{
Q_OBJECT
Q_INTERFACES(Plugin)
public:
/**
* @brief Provides plugin internal name.
* @return Plugin class name.
*/
QString getName() const;
/**
* @brief Provides plugin title.
* @return Title defined in plugin's metadata file with key "title" or (if not defined) the same value as getName().
*/
QString getTitle() const;
/**
* @brief Provides plugin description.
* @return Description as defined in plugin's metadata file with key "description", or null QString if not defined.
*/
QString getDescription() const;
/**
* @brief Provides plugin numeric version.
* @return Version number as defined in plugin's metadata file with key "version", or 0 if not defined.
*/
int getVersion() const;
/**
* @brief Converts plugin version to human readable form.
* @return Version in format X.Y.Z.
*/
QString getPrintableVersion() const;
/**
* @brief Provides an author name.
* @return Author name as defined with in plugin's metadata file with key "author", or null QString if not defined.
*/
QString getAuthor() const;
/**
* @brief Does nothing.
* @return Always true.
*
* This is a default (empty) implementation of init() for plugins.
*/
bool init();
/**
* @brief Does nothing.
*
* This is a default (empty) implementation of init() for plugins.
*/
void deinit();
private:
/**
* @brief Extracts class meta information with given key.
* @param key Key to extract.
* @return Value of the meta information, or null if there's no information with given key.
*
* This is a helper method which queries Qt's meta object subsystem for class meta information defined with Q_CLASSINFO.
*/
const char* getMetaInfo(const QString& key) const;
};
/**
* @def SQLITESTUDIO_PLUGIN_TITLE
* @brief Defines plugin title.
*
* This is a built-in plugin replacement for "title" key in external plugin's json metadata file.
*/
#define SQLITESTUDIO_PLUGIN_TITLE(Title) Q_CLASSINFO("title", Title)
/**
* @def SQLITESTUDIO_PLUGIN_DESC
* @brief Defines plugin description.
*
* This is a built-in plugin replacement for "description" key in external plugin's json metadata file.
*/
#define SQLITESTUDIO_PLUGIN_DESC(Desc) Q_CLASSINFO("description", Desc)
/**
* @def SQLITESTUDIO_PLUGIN_UI
* @brief Defines Qt Designer Form object name to be used in configuration dialog.
*
* This is a built-in plugin replacement for "ui" key in external plugin's json metadata file.
*/
#define SQLITESTUDIO_PLUGIN_UI(FormName) Q_CLASSINFO("ui", FormName)
/**
* @def SQLITESTUDIO_PLUGIN_VERSION
* @brief Defines plugin version.
*
* This is a built-in plugin replacement for "version" key in external plugin's json metadata file.
*/
#define SQLITESTUDIO_PLUGIN_VERSION(Ver) Q_CLASSINFO("version", #Ver)
/**
* @def SQLITESTUDIO_PLUGIN_AUTHOR
* @brief Defines an author of the plugin.
*
* This is a built-in plugin replacement for "author" key in external plugin's json metadata file.
*/
#define SQLITESTUDIO_PLUGIN_AUTHOR(Author) Q_CLASSINFO("author", Author)
#endif // BUILTINPLUGIN_H
|