-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathNamingPolicySettingsPage.h
130 lines (105 loc) · 3.82 KB
/
NamingPolicySettingsPage.h
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
//-----------------------------------------------------------------------------
// File: NamingPolicySettingsPage.h
//-----------------------------------------------------------------------------
// Project: Kactus 2
// Author: Joni-Matti Maatta
// Date: 13.6.2011
//
// Description:
// settings property page for specifying naming policies.
//-----------------------------------------------------------------------------
#ifndef NAMINGPOLICYSETTINGSPAGE_H
#define NAMINGPOLICYSETTINGSPAGE_H
#include "SettingsPage.h"
#include <QComboBox>
#include <QLabel>
#include <QSettings>
#include <QPlainTextEdit>
#include <QGroupBox>
class ListManager;
class SnippetTextEdit;
//-----------------------------------------------------------------------------
//! NamingPolicySettingsPage class.
//-----------------------------------------------------------------------------
class NamingPolicySettingsPage : public SettingsPage
{
Q_OBJECT
public:
/*!
* Constructor.
*
* @param [in/out] settings The settings store.
*/
NamingPolicySettingsPage(QSettings& settings);
/*!
* Destructor.
*/
virtual ~NamingPolicySettingsPage() = default;
// Disable copying.
NamingPolicySettingsPage(NamingPolicySettingsPage const& rhs) = delete;
NamingPolicySettingsPage& operator=(NamingPolicySettingsPage const& rhs) = delete;
/*!
* Applies the changes that were done in the page.
*/
virtual void apply() override final;
private slots:
/*!
* Updates the widget contents according to the new category selection.
*
* @param [in] index The category index.
*/
void onCategoryChanged(int index);
/*!
* Saves the values of the currently selected category.
*/
void saveCurrentValues();
private:
//-----------------------------------------------------------------------------
//! Policy type enumeration.
//-----------------------------------------------------------------------------
enum PolicyType
{
POLICY_ENUMERATION = 0,
POLICY_FORMAT
};
//-----------------------------------------------------------------------------
//! Policy category structure.
//-----------------------------------------------------------------------------
struct PolicyCategory
{
QString key; //!< The name of the settings key.
QString name; //!< The name of the policy category.
PolicyType type; //!< The policy type for the category.
QStringList values; //!< The allowed value(s) for the policy.
QStringList magicWords; //!< Available magic words. Only relevant if policy type is POLICY_FORMAT.
/*!
* Constructor.
*/
explicit PolicyCategory(QString const& key, QString const& name, PolicyType type)
: key(key),
name(name),
type(type),
values()
{
}
};
//-----------------------------------------------------------------------------
// Data.
//-----------------------------------------------------------------------------
//! Policy categories data.
QList<PolicyCategory> categories_;
//! The index of the currently selected category.
int curCategoryIndex_;
//! Element selection combo box.
QComboBox* categoryCombo_;
//! Label for suggested names.
QLabel* valuesLabel_;
//! Suggested names list edit.
ListManager* valuesList_;
//! Label for naming format edit.
QGroupBox* formatGroup_;
//! Text box for naming format.
SnippetTextEdit* formatEdit_;
};
//-----------------------------------------------------------------------------
#endif // NAMINGPOLICYSETTINGSPAGE_H