src/radioGroup.h

Wed, 16 Jul 2014 15:00:41 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Wed, 16 Jul 2014 15:00:41 +0300
changeset 844
11587d419d2f
parent 794
c254ddc6618b
child 927
409b82a4765e
permissions
-rw-r--r--

- changed copyright lines to use my legal name instead of my nickname

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
844
11587d419d2f - changed copyright lines to use my legal name instead of my nickname
Teemu Piippo <crimsondusk64@gmail.com>
parents: 794
diff changeset
3 * Copyright (C) 2013, 2014 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 {
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
44 init (Qt::Vertical);
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
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
47 explicit RadioGroup (QWidget* parent = null) : QGroupBox (parent)
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
48 {
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
49 init (Qt::Vertical);
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
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
52 explicit RadioGroup (const QString& title, QWidget* parent = null);
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
53 explicit RadioGroup (const QString& title, QList<char const*> entries, int const defaultId,
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
54 const Qt::Orientation orient = Qt::Vertical, QWidget* parent = null);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
56 void addButton (const char* entry);
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();
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
60 void init (Qt::Orientation orient);
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
61 bool isChecked (int n) const;
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
62 void rowBreak();
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
63 void setCurrentRow (int row);
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
64 void setValue (int val);
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
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
67 QRadioButton* operator[] (int n) const;
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
68 RadioGroup& operator<< (QRadioButton* button);
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
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:
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
72 void buttonPressed (int btn);
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
73 void buttonReleased (int btn);
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
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
794
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
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:
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
88 void slot_buttonPressed (int btn);
c254ddc6618b - source reformat
Santeri Piippo <crimsondusk64@gmail.com>
parents: 655
diff changeset
89 void slot_buttonReleased (int btn);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
90 };

mercurial