|
1 /* |
|
2 * LDForge: LDraw parts authoring CAD |
|
3 * Copyright (C) 2013, 2014 Santeri Piippo |
|
4 * |
|
5 * This program is free software: you can redistribute it and/or modify |
|
6 * it under the terms of the GNU General Public License as published by |
|
7 * the Free Software Foundation, either version 3 of the License, or |
|
8 * (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, see <http://www.gnu.org/licenses/>. |
|
17 */ |
|
18 |
|
19 #pragma once |
|
20 #include <QGroupBox> |
|
21 #include <QSpinBox> |
|
22 #include <map> |
|
23 #include "main.h" |
|
24 #include "basics.h" |
|
25 |
|
26 class QIcon; |
|
27 class QCheckBox; |
|
28 class QButtonGroup; |
|
29 class QBoxLayout; |
|
30 class QRadioButton; |
|
31 |
|
32 // ============================================================================= |
|
33 // RadioGroup |
|
34 // |
|
35 // Convenience widget - is a groupbox of radio buttons. |
|
36 // ============================================================================= |
|
37 class RadioGroup : public QGroupBox |
|
38 { |
|
39 Q_OBJECT |
|
40 |
|
41 public: |
|
42 typedef QList<QRadioButton*>::Iterator Iterator; |
|
43 |
|
44 explicit RadioGroup() |
|
45 { |
|
46 init (Qt::Vertical); |
|
47 } |
|
48 |
|
49 explicit RadioGroup (QWidget* parent = null) : QGroupBox (parent) |
|
50 { |
|
51 init (Qt::Vertical); |
|
52 } |
|
53 |
|
54 explicit RadioGroup (const QString& title, QWidget* parent = null); |
|
55 explicit RadioGroup (const QString& title, QList<char const*> entries, int const defaultId, |
|
56 const Qt::Orientation orient = Qt::Vertical, QWidget* parent = null); |
|
57 |
|
58 void addButton (const char* entry); |
|
59 void addButton (QRadioButton* button); |
|
60 Iterator begin(); |
|
61 Iterator end(); |
|
62 void init (Qt::Orientation orient); |
|
63 bool isChecked (int n) const; |
|
64 void rowBreak(); |
|
65 void setCurrentRow (int row); |
|
66 void setValue (int val); |
|
67 int value() const; |
|
68 |
|
69 QRadioButton* operator[] (int n) const; |
|
70 RadioGroup& operator<< (QRadioButton* button); |
|
71 RadioGroup& operator<< (const char* entry); |
|
72 |
|
73 signals: |
|
74 void buttonPressed (int btn); |
|
75 void buttonReleased (int btn); |
|
76 void valueChanged (int val); |
|
77 |
|
78 private: |
|
79 QList<QRadioButton*> m_objects; |
|
80 QList<QBoxLayout*> m_layouts; |
|
81 QBoxLayout* m_coreLayout; |
|
82 QBoxLayout* m_currentLayout; |
|
83 bool m_vert; |
|
84 int m_curId, m_defId, m_oldId; |
|
85 QButtonGroup* m_buttonGroup; |
|
86 |
|
87 Q_DISABLE_COPY (RadioGroup) |
|
88 |
|
89 private slots: |
|
90 void slot_buttonPressed (int btn); |
|
91 void slot_buttonReleased (int btn); |
|
92 }; |