1 /*
2  * Stellarium
3  * Copyright (C) 2016 Florian Schaukowitsch
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
18 */
19 
20 //! @file
21 //! This is a private header for some StelDialog implementation classes, which require MOC'cing
22 //! Other classes should not include this header.
23 
24 #ifndef STELDIALOG_P_HPP
25 #define STELDIALOG_P_HPP
26 
27 #include "StelPropertyMgr.hpp"
28 #include "AngleSpinBox.hpp"
29 #include <QAbstractButton>
30 #include <QComboBox>
31 #include <QSpinBox>
32 #include <QDoubleSpinBox>
33 #include <QSlider>
34 #include <QGroupBox>
35 
36 //! A StelPropertyProxy that works with QAbstractButton widgets.
37 //! When the property changes, the widget's value is updated, while preventing widget signals to be sent.
38 //! This avoids emitting the valueChanged() signal, which would unnecessarily set the property value again, which may lead to problems.
39 class QAbstractButtonStelPropertyConnectionHelper : public StelPropertyProxy
40 {
41 	Q_OBJECT
42 public:
43 	QAbstractButtonStelPropertyConnectionHelper(StelProperty* prop,QAbstractButton* button);
44 
45 protected slots:
46 	virtual void onPropertyChanged(const QVariant& value) Q_DECL_OVERRIDE;
47 private:
48 	QAbstractButton* button;
49 };
50 
51 //! A StelPropertyProxy that works with QGroupBox widgets.
52 //! When the property changes, the widget's value is updated, while preventing widget signals to be sent.
53 //! This avoids emitting the valueChanged() signal, which would unnecessarily set the property value again, which may lead to problems.
54 class QGroupBoxStelPropertyConnectionHelper : public StelPropertyProxy
55 {
56 	Q_OBJECT
57 public:
58 	QGroupBoxStelPropertyConnectionHelper(StelProperty* prop,QGroupBox* box);
59 
60 protected slots:
61 	virtual void onPropertyChanged(const QVariant& value) Q_DECL_OVERRIDE;
62 private:
63 	QGroupBox* box;
64 };
65 
66 //! A StelPropertyProxy that works with QComboBox widgets.
67 //! When the property changes, the widget's value is updated, while preventing widget signals to be sent.
68 //! This avoids emitting the valueChanged() signal, which would unnecessarily set the property value again, which may lead to problems.
69 class QComboBoxStelPropertyConnectionHelper : public StelPropertyProxy
70 {
71 	Q_OBJECT
72 public:
73 	QComboBoxStelPropertyConnectionHelper(StelProperty* prop,QComboBox* combo);
74 
75 protected slots:
76 	virtual void onPropertyChanged(const QVariant& value) Q_DECL_OVERRIDE;
77 private:
78 	QComboBox* combo;
79 };
80 
81 //! A StelPropertyProxy that works with QComboBox widgets.
82 //! When the property changes, the widget's value is updated, while preventing widget signals to be sent.
83 //! This avoids emitting the valueChanged() signal, which would unnecessarily set the property value again, which may lead to problems.
84 class QComboBoxStelStringPropertyConnectionHelper : public StelPropertyProxy
85 {
86 	Q_OBJECT
87 public:
88 	QComboBoxStelStringPropertyConnectionHelper(StelProperty* prop,QComboBox* combo);
89 
90 protected slots:
91 	virtual void onPropertyChanged(const QVariant& value) Q_DECL_OVERRIDE;
92 private:
93 	QComboBox* combo;
94 };
95 
96 //! A StelPropertyProxy that works with QLineEdit widgets.
97 //! When the property changes, the widget's value is updated, while preventing widget signals to be sent.
98 //! This avoids emitting the valueChanged() signal, which would unnecessarily set the property value again, which may lead to problems.
99 class QLineEditStelPropertyConnectionHelper : public StelPropertyProxy
100 {
101 	Q_OBJECT
102 public:
103 	QLineEditStelPropertyConnectionHelper(StelProperty* prop,QLineEdit* edit);
104 
105 protected slots:
106 	virtual void onPropertyChanged(const QVariant& value) Q_DECL_OVERRIDE;
107 private:
108 	QLineEdit* edit;
109 };
110 
111 //! A StelPropertyProxy that works with QSpinBox widgets.
112 //! When the property changes, the widget's value is updated, while preventing widget signals to be sent.
113 //! This avoids emitting the valueChanged() signal, which would unnecessarily set the property value again, which may lead to problems.
114 class QSpinBoxStelPropertyConnectionHelper : public StelPropertyProxy
115 {
116 	Q_OBJECT
117 public:
118 	QSpinBoxStelPropertyConnectionHelper(StelProperty* prop,QSpinBox* spin);
119 
120 protected slots:
121 	virtual void onPropertyChanged(const QVariant& value) Q_DECL_OVERRIDE;
122 private:
123 	QSpinBox* spin;
124 };
125 
126 
127 //! A StelPropertyProxy that works with QDoubleSpinBox widgets.
128 //! When the property changes, the widget's value is updated, while preventing widget signals to be sent.
129 //! This avoids emitting the valueChanged() signal, which would unnecessarily set the property value again, which may lead to problems.
130 class QDoubleSpinBoxStelPropertyConnectionHelper : public StelPropertyProxy
131 {
132 	Q_OBJECT
133 public:
134 	QDoubleSpinBoxStelPropertyConnectionHelper(StelProperty* prop,QDoubleSpinBox* spin);
135 
136 protected slots:
137 	virtual void onPropertyChanged(const QVariant& value) Q_DECL_OVERRIDE;
138 private:
139 	QDoubleSpinBox* spin;
140 };
141 
142 //! A StelPropertyProxy that works with AngleSpinBox widgets.
143 //! When the property changes, the widget's value is updated, while preventing widget signals to be sent.
144 //! This avoids emitting the valueChanged() signal, which would unnecessarily set the property value again, which may lead to problems.
145 class AngleSpinBoxStelPropertyConnectionHelper : public StelPropertyProxy
146 {
147 	Q_OBJECT
148 public:
149 	AngleSpinBoxStelPropertyConnectionHelper(StelProperty* prop,AngleSpinBox* spin);
150 
151 protected slots:
152 	virtual void onPropertyChanged(const QVariant& value) Q_DECL_OVERRIDE;
153 private:
154 	AngleSpinBox* spin;
155 };
156 
157 class QSliderStelPropertyConnectionHelper : public StelPropertyProxy
158 {
159 	Q_OBJECT
160 public:
161 	QSliderStelPropertyConnectionHelper(StelProperty* prop, double minValue, double maxValue, QSlider* slider);
162 	QSliderStelPropertyConnectionHelper(StelProperty* prop, int minValue, int maxValue, QSlider* slider);
163 protected slots:
164 	virtual void onPropertyChanged(const QVariant& value) Q_DECL_OVERRIDE;
165 private slots:
166 	void sliderIntValueChanged(int val);
167 private:
168 	QSlider* slider;
169 	double minValue, maxValue,dRange;
170 };
171 
172 #endif // STELDIALOG_P_HPP
173