diff -r c7f8989c995f -r f179241a72a8 src/widgets.cpp --- a/src/widgets.cpp Fri Aug 23 01:20:09 2013 +0300 +++ b/src/widgets.cpp Fri Aug 23 13:01:36 2013 +0300 @@ -16,12 +16,9 @@ * along with this program. If not, see . */ -// I still find the radio box useful... find a way to use this in Designer. +// I still find the radio group useful... find a way to use this in Designer. // I probably need to look into how to make Designer plugins. -// -// The name is quite confusing too considering there's the check box and radio -// button around. This widget is a group of radio buttons. -// TODO: rename to RadioGroup, make this usable in Designer +// TODO: try make this usable in Designer #include #include @@ -33,7 +30,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -RadioBox::RadioBox (const QString& title, QWidget* parent) : QGroupBox (title, parent) { +RadioGroup::RadioGroup (const QString& title, QWidget* parent) : QGroupBox (title, parent) { init (Qt::Vertical); } @@ -45,13 +42,13 @@ // ============================================================================= // ----------------------------------------------------------------------------- -bool RadioBox::isChecked (int n) const { +bool RadioGroup::isChecked (int n) const { return m_buttonGroup->checkedId() == n; } // ============================================================================= // ----------------------------------------------------------------------------- -void RadioBox::init (Qt::Orientation orient) { +void RadioGroup::init (Qt::Orientation orient) { m_vert = orient == Qt::Vertical; m_buttonGroup = new QButtonGroup; @@ -70,7 +67,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -RadioBox::RadioBox (const QString& title, initlist entries, int const defaultId, +RadioGroup::RadioGroup (const QString& title, initlist entries, int const defaultId, const Qt::Orientation orient, QWidget* parent) : QGroupBox (title, parent), m_defId (defaultId) { init (orient); @@ -82,7 +79,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -void RadioBox::rowBreak() { +void RadioGroup::rowBreak() { QBoxLayout* newLayout = new QBoxLayout (m_vert ? QBoxLayout::TopToBottom : QBoxLayout::LeftToRight); m_currentLayout = newLayout; m_layouts << newLayout; @@ -92,14 +89,14 @@ // ============================================================================= // ----------------------------------------------------------------------------- -void RadioBox::addButton (const char* entry) { +void RadioGroup::addButton (const char* entry) { QRadioButton* button = new QRadioButton (entry); addButton (button); } // ============================================================================= // ----------------------------------------------------------------------------- -void RadioBox::addButton (QRadioButton* button) { +void RadioGroup::addButton (QRadioButton* button) { bool const selectThis = (m_curId == m_defId); m_objects << button; @@ -112,45 +109,45 @@ // ============================================================================= // ----------------------------------------------------------------------------- -RadioBox& RadioBox::operator<< (QRadioButton* button) { +RadioGroup& RadioGroup::operator<< (QRadioButton* button) { addButton (button); return *this; } // ============================================================================= // ----------------------------------------------------------------------------- -RadioBox& RadioBox::operator<< (const char* entry) { +RadioGroup& RadioGroup::operator<< (const char* entry) { addButton (entry); return *this; } // ============================================================================= // ----------------------------------------------------------------------------- -void RadioBox::setCurrentRow (uint row) { +void RadioGroup::setCurrentRow (uint row) { m_currentLayout = m_layouts[row]; } // ============================================================================= // ----------------------------------------------------------------------------- -int RadioBox::value() const { +int RadioGroup::value() const { return m_buttonGroup->checkedId(); } // ============================================================================= // ----------------------------------------------------------------------------- -void RadioBox::setValue (int val) { +void RadioGroup::setValue (int val) { m_buttonGroup->button (val)->setChecked (true); } // ============================================================================= // ----------------------------------------------------------------------------- -QRadioButton* RadioBox::operator[] (uint n) const { +QRadioButton* RadioGroup::operator[] (uint n) const { return m_objects[n]; } // ============================================================================= // ----------------------------------------------------------------------------- -void RadioBox::slot_buttonPressed (int btn) { +void RadioGroup::slot_buttonPressed (int btn) { emit buttonPressed (btn); m_oldId = m_buttonGroup->checkedId(); @@ -158,7 +155,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- -void RadioBox::slot_buttonReleased (int btn) { +void RadioGroup::slot_buttonReleased (int btn) { emit buttonReleased (btn); int newid = m_buttonGroup->checkedId(); @@ -168,12 +165,12 @@ // ============================================================================= // ----------------------------------------------------------------------------- -RadioBox::it RadioBox::begin() { +RadioGroup::it RadioGroup::begin() { return m_objects.begin(); } // ============================================================================= // ----------------------------------------------------------------------------- -RadioBox::it RadioBox::end() { +RadioGroup::it RadioGroup::end() { return m_objects.end(); } \ No newline at end of file