1 /* |
|
2 * LDForge: LDraw parts authoring CAD |
|
3 * Copyright (C) 2013 - 2017 Teemu 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 // Convenience widget - is a groupbox of radio buttons. |
|
34 // |
|
35 class RadioGroup : public QGroupBox |
|
36 { |
|
37 Q_OBJECT |
|
38 |
|
39 public: |
|
40 typedef QList<QRadioButton*>::Iterator Iterator; |
|
41 |
|
42 explicit RadioGroup() |
|
43 { |
|
44 init (Qt::Vertical); |
|
45 } |
|
46 |
|
47 explicit RadioGroup (QWidget* parent = nullptr) : QGroupBox (parent) |
|
48 { |
|
49 init (Qt::Vertical); |
|
50 } |
|
51 |
|
52 explicit RadioGroup (const QString& title, QWidget* parent = nullptr); |
|
53 explicit RadioGroup (const QString& title, QList<char const*> entries, int const defaultId, |
|
54 const Qt::Orientation orient = Qt::Vertical, QWidget* parent = nullptr); |
|
55 |
|
56 void addButton (QString entry); |
|
57 void addButton (QRadioButton* button); |
|
58 Iterator begin(); |
|
59 Iterator end(); |
|
60 void init (Qt::Orientation orient); |
|
61 bool isChecked (int n) const; |
|
62 void rowBreak(); |
|
63 void setCurrentRow (int row); |
|
64 void setValue (int val); |
|
65 int value() const; |
|
66 |
|
67 QRadioButton* operator[] (int n) const; |
|
68 RadioGroup& operator<< (QRadioButton* button); |
|
69 RadioGroup& operator<< (const char* entry); |
|
70 |
|
71 signals: |
|
72 void buttonPressed (int btn); |
|
73 void buttonReleased (int btn); |
|
74 void valueChanged (int val); |
|
75 |
|
76 private: |
|
77 QList<QRadioButton*> m_objects; |
|
78 QList<QBoxLayout*> m_layouts; |
|
79 QBoxLayout* m_coreLayout; |
|
80 QBoxLayout* m_currentLayout; |
|
81 bool m_vert; |
|
82 int m_curId, m_defId, m_oldId; |
|
83 QButtonGroup* m_buttonGroup; |
|
84 |
|
85 Q_DISABLE_COPY (RadioGroup) |
|
86 |
|
87 private slots: |
|
88 void slot_buttonPressed (int btn); |
|
89 void slot_buttonReleased (int btn); |
|
90 }; |
|