src/radioGroup.h

Thu, 04 Jan 2018 20:23:21 +0200

author
Santeri Piippo
date
Thu, 04 Jan 2018 20:23:21 +0200
changeset 1220
c4c37abbe22b
parent 1217
314e12e23c3a
child 1222
34def2630300
permissions
-rw-r--r--

reduce main.cpp

655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
968
4b93b7963456 Happy new year 2015
Teemu Piippo <crimsondusk64@gmail.com>
parents: 844
diff changeset
3 * Copyright (C) 2013 - 2015 Teemu Piippo
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 *
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 *
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 *
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #pragma once
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #include <QGroupBox>
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 #include <QSpinBox>
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 #include <map>
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 #include "main.h"
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 #include "basics.h"
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 class QIcon;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 class QCheckBox;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 class QButtonGroup;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 class QBoxLayout;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30 class QRadioButton;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 //
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 // Convenience widget - is a groupbox of radio buttons.
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
34 //
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 class RadioGroup : public QGroupBox
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37 Q_OBJECT
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
39 public:
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
40 typedef QList<QRadioButton*>::Iterator Iterator;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
42 explicit RadioGroup()
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
43 {
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 988
diff changeset
44 init(Qt::Vertical);
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
45 }
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 988
diff changeset
47 explicit RadioGroup(QWidget* parent = nullptr) : QGroupBox(parent)
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
48 {
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 988
diff changeset
49 init(Qt::Vertical);
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
50 }
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 988
diff changeset
52 explicit RadioGroup(const QString& title, QWidget* parent = nullptr);
314e12e23c3a fix paren style
Santeri Piippo
parents: 988
diff changeset
53 explicit RadioGroup(const QString& title, QList<char const*> entries, int const defaultId,
984
a7b6f987d269 null -> nullptr
Teemu Piippo <crimsondusk64@gmail.com>
parents: 968
diff changeset
54 const Qt::Orientation orient = Qt::Vertical, QWidget* parent = nullptr);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55
988
ac4a2ae54f76 Refactor LDObject API
Teemu Piippo <crimsondusk64@gmail.com>
parents: 984
diff changeset
56 void addButton (QString entry);
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
57 void addButton (QRadioButton* button);
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
58 Iterator begin();
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
59 Iterator end();
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 988
diff changeset
60 void init(Qt::Orientation orient);
314e12e23c3a fix paren style
Santeri Piippo
parents: 988
diff changeset
61 bool isChecked(int n) const;
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
62 void rowBreak();
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 988
diff changeset
63 void setCurrentRow(int row);
314e12e23c3a fix paren style
Santeri Piippo
parents: 988
diff changeset
64 void setValue(int val);
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
65 int value() const;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 988
diff changeset
67 QRadioButton* operator[](int n) const;
314e12e23c3a fix paren style
Santeri Piippo
parents: 988
diff changeset
68 RadioGroup& operator<<(QRadioButton* button);
314e12e23c3a fix paren style
Santeri Piippo
parents: 988
diff changeset
69 RadioGroup& operator<<(const char* entry);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
70
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
71 signals:
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 988
diff changeset
72 void buttonPressed(int btn);
314e12e23c3a fix paren style
Santeri Piippo
parents: 988
diff changeset
73 void buttonReleased(int btn);
314e12e23c3a fix paren style
Santeri Piippo
parents: 988
diff changeset
74 void valueChanged(int val);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
75
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
76 private:
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
77 QList<QRadioButton*> m_objects;
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
78 QList<QBoxLayout*> m_layouts;
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
79 QBoxLayout* m_coreLayout;
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
80 QBoxLayout* m_currentLayout;
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
81 bool m_vert;
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
82 int m_curId, m_defId, m_oldId;
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
83 QButtonGroup* m_buttonGroup;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
84
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 988
diff changeset
85 Q_DISABLE_COPY(RadioGroup)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
86
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
87 private slots:
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 988
diff changeset
88 void slot_buttonPressed(int btn);
314e12e23c3a fix paren style
Santeri Piippo
parents: 988
diff changeset
89 void slot_buttonReleased(int btn);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
90 };

mercurial