|
20 | 20 | #ifndef ARGACTION_H |
21 | 21 | #define ARGACTION_H |
22 | 22 |
|
23 | | -#include <QHash> |
| 23 | +#include <QMap> |
24 | 24 | #include <QString> |
25 | 25 | #include <QStringList> |
26 | 26 | #include <QDoubleSpinBox> |
27 | 27 | #include <QSpinBox> |
28 | 28 | #include <QCheckBox> |
29 | | -#include <QButtonGroup> |
| 29 | +#include <QRadioButton> |
30 | 30 | #include <QLineEdit> |
31 | 31 | #include <QComboBox> |
32 | 32 |
|
| 33 | +template <class T1, class T2> class QWidgetPair : public QWidget |
| 34 | +{ |
| 35 | +public: |
| 36 | + explicit QWidgetPair() {} |
| 37 | + explicit QWidgetPair(T1 *object1, T2 *object2) : |
| 38 | + object1(object1), object2(object2) {} |
| 39 | + |
| 40 | + T1 *object1; |
| 41 | + T2 *object2; |
| 42 | +}; |
| 43 | + |
33 | 44 | class argAction |
34 | 45 | { |
35 | 46 | protected: |
36 | | - |
37 | 47 | static bool setDoubleSpinBox(void *doubleSpinBox, const QString argValue); |
38 | 48 | static bool setSpinBox(void *spinBox, const QString argValue); |
39 | 49 | static bool setCheckBox(void *checkBox, const QString argValue); |
40 | 50 | static bool setLineEdit(void *lineEdit, const QString argValue); |
41 | 51 | static bool setComboBox(void *comboBox, const QString argValue); |
42 | | - static bool setButtonGroup(void *buttonGroup, const QString argValue); |
| 52 | + static bool setRadioButtonPair(void *radioButtonPair, const QString argValue); |
| 53 | + |
43 | 54 | static QString getDoubleSpinBox(void *doubleSpinBox); |
44 | 55 | static QString getSpinBox(void *spinBox); |
45 | 56 | static QString getCheckBox(void *checkBox); |
46 | 57 | static QString getLineEdit(void *lineEdit); |
47 | 58 | static QString getComboBox(void *comboBox); |
48 | | - static QString getButtonGroup(void *buttonGroup); |
| 59 | + static QString getRadioButtonPair(void *radioButtonPair); |
49 | 60 |
|
50 | 61 | struct argElement |
51 | 62 | { |
52 | 63 | bool (*setFunction)(void *object, QString argValue); |
53 | 64 | QString (*getFunction)(void *object); |
54 | 65 | void *object; |
55 | | - bool commentedOption; |
56 | 66 | }; |
57 | 67 |
|
58 | | - QHash<QString,argElement> argList; |
| 68 | + QMap<QString,argElement> argList; |
59 | 69 |
|
60 | 70 | public: |
61 | 71 | explicit argAction(); |
62 | 72 | ~argAction(); |
63 | 73 |
|
64 | 74 | bool setValue(const QString key, const QString value); |
| 75 | + QStringList getAllArgs(bool getCommentedOptions); |
| 76 | + bool setEnabled(const QString key, const bool enabled); |
65 | 77 |
|
66 | | - QStringList getAllArgs(const bool getCommentedOptions = false, const bool getDisabledObjects = false); |
67 | | - |
68 | | - inline void insert( const QString argName, QDoubleSpinBox *doubleSpinBox, const bool commentedOption = false ) |
| 78 | + inline void insert( const QString argName, QDoubleSpinBox *doubleSpinBox) |
69 | 79 | { |
70 | 80 | argList.insert( argName, (argElement){ .setFunction = &setDoubleSpinBox, .getFunction = &getDoubleSpinBox, |
71 | | - .object = doubleSpinBox, .commentedOption = commentedOption } ); |
| 81 | + .object = doubleSpinBox } ); |
72 | 82 | } |
73 | 83 |
|
74 | | - inline void insert( const QString argName, QSpinBox *spinBox, const bool commentedOption = false ) |
| 84 | + inline void insert( const QString argName, QSpinBox *spinBox) |
75 | 85 | { |
76 | 86 | argList.insert( argName, (argElement){ .setFunction = &setSpinBox, .getFunction = &getSpinBox, |
77 | | - .object = spinBox, .commentedOption = commentedOption } ); |
| 87 | + .object = spinBox } ); |
78 | 88 | } |
79 | 89 |
|
80 | | - inline void insert( const QString argName, QCheckBox *checkBox, const bool commentedOption = false ) |
| 90 | + inline void insert( const QString argName, QCheckBox *checkBox) |
81 | 91 | { |
82 | 92 | argList.insert( argName, (argElement){ .setFunction = &setCheckBox, .getFunction = &getCheckBox, |
83 | | - .object = checkBox, .commentedOption = commentedOption } ); |
| 93 | + .object = checkBox } ); |
84 | 94 | } |
85 | 95 |
|
86 | | - inline void insert( const QString argName, QLineEdit *lineEdit, const bool commentedOption = false ) |
| 96 | + inline void insert( const QString argName, QLineEdit *lineEdit) |
87 | 97 | { |
88 | 98 | argList.insert( argName, (argElement){ .setFunction = &setLineEdit, .getFunction = &getLineEdit, |
89 | | - .object = lineEdit, .commentedOption = commentedOption } ); |
| 99 | + .object = lineEdit } ); |
90 | 100 | } |
91 | 101 |
|
92 | | - inline void insert( const QString argName, QComboBox *comboBox, const bool commentedOption = false ) |
| 102 | + inline void insert( const QString argName, QComboBox *comboBox) |
93 | 103 | { |
94 | 104 | argList.insert( argName, (argElement){ .setFunction = &setComboBox, .getFunction = &getComboBox, |
95 | | - .object = comboBox, .commentedOption = commentedOption } ); |
| 105 | + .object = comboBox } ); |
96 | 106 | } |
97 | 107 |
|
98 | | - inline void insert( const QString argName, QButtonGroup *buttonGroup, const bool commentedOption = false ) |
| 108 | + inline void insert( const QString argName, QWidgetPair<QRadioButton, QRadioButton> *radioButtonPair) |
99 | 109 | { |
100 | | - argList.insert( argName, (argElement){ .setFunction = &setButtonGroup, .getFunction = &getButtonGroup, |
101 | | - .object = buttonGroup, .commentedOption = commentedOption } ); |
| 110 | + argList.insert( argName, (argElement){ .setFunction = &setRadioButtonPair, .getFunction = &getRadioButtonPair, |
| 111 | + .object = radioButtonPair } ); |
102 | 112 | } |
103 | | - |
104 | 113 | }; |
105 | 114 |
|
106 | 115 | #endif // ARGACTION_H |
0 commit comments