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
|
#ifndef DBPLUGINOPTION_H
#define DBPLUGINOPTION_H
#include <QString>
#include <QVariant>
/**
* @brief Database plugin connection options.
*
* It is used to identify connection options that the DbPlugin implementation needs
* for the plugin to be configured by the user in the DbDialog.
*
* Single DbPluginOption represents in DbDialog:
* <ul>
* <li>single QLabel with text set to DbPluginOption::label,</li>
* <li>an input widget, that depends on DbPluginOption::type.</li>
* </ul>
*
* The input widget is different for different data type expected for the option.
* See DbPluginOption::Type for details.
*
* After user entered his values for options in DbDialog, they are passed
* to the DbPlugin::getInstance() and later to the Db::init(). Options are passed
* as key-value pairs, given the DbPluginOption::key and value specified by the user
* in DbDialog.
*/
struct DbPluginOption
{
/**
* @brief Handler for custom path browser implemented by the plugin.
*/
typedef std::function<QString(const QString&)> CustomBrowseHandler;
/**
* @brief Option data type
*
* Determinates what kind of input widget will be added to DbDialog.
*/
enum Type
{
STRING = 0, /**< QLineEdit will be added. */
INT = 1, /**< QSpinBox will be added */
BOOL = 2, /**< QCheckBox will be added */
DOUBLE = 3, /**< QDoubleSpinBox will be added */
FILE = 4, /**< QLineEdit will be added */
PASSWORD = 5, /**< QLineEdit with value masking will be added */
CHOICE = 6, /**< QComboBox will be added */
CUSTOM_PATH_BROWSE = 7, /**< File path browse button will be handled by the plugin. No additional editor will be added. */
SQL = 8, /**< SqlEditor will be added. */
};
/**
* @brief Name for the key in QHash collected from options in DbDialog and
* later passed to DbPlugin::getInstance().
*/
QString key;
/**
* @brief Label text to be used in DbDialog to inform user what is this option.
*/
QString label;
/**
* @brief Optional tooltip to show for added widget.
*/
QString toolTip;
/**
* @brief Optional placeholder text for QLineEdit widget.
*/
QString placeholderText;
/**
* @brief List of values for QComboBox.
*/
QStringList choiceValues;
/**
* @brief List of value for QComboBox, including it's data (hidden) component.
*/
QMap<QString, QVariant> choiceDataValues;
/**
* @brief Default value to be set in the editor widget.
*/
QVariant defaultValue;
/**
* @brief Indicates if the combobox should be read only or writable.
*/
bool choiceReadOnly = true;
/**
* @brief Minimum value for numeric editors (double or int).
*/
QVariant minValue;
/**
* @brief Maximum value for numeric editors (double or int).
*/
QVariant maxValue;
/**
* @brief Expected data type for the option.
*/
Type type;
/**
* @brief Handler for custom path browser implemented by the plugin.
*/
CustomBrowseHandler customBrowseHandler = nullptr;
};
#endif // DBPLUGINOPTION_H
|