diff options
Diffstat (limited to 'pokemodr/FlagWidget.cpp')
| -rw-r--r-- | pokemodr/FlagWidget.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/pokemodr/FlagWidget.cpp b/pokemodr/FlagWidget.cpp new file mode 100644 index 00000000..70f47a45 --- /dev/null +++ b/pokemodr/FlagWidget.cpp @@ -0,0 +1,62 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "FlagWidget.h" + +// Qt includes +#include <QMetaObject> + +FlagWidget::FlagWidget(QWidget* parent, const Flag& value) : + QGroupBox(parent), + m_value(value) +{ + setupUi(this); + QMetaObject::connectSlotsByName(this); + connect(this, SIGNAL(clicked(bool)), SLOT(boxClicked(bool))); +} + +Flag FlagWidget::value() const +{ + return m_value; +} + +void FlagWidget::setValue(const Flag& value) +{ + m_value = value; + setChecked(m_value.status() == Flag::Ignore); + varFlag->setValue(m_value.flag()); + varState->setCheckState((m_value.status() == Flag::On) ? Qt::Checked : Qt::Unchecked); + emit(valueChanged(m_value)); +} + +void FlagWidget::boxClicked(const bool clicked) +{ + if (!clicked) + m_value.setStatus(Flag::Ignore); +} + +void FlagWidget::on_varFlag_valueChanged(const int flag) +{ + m_value.setFlag(flag); +} + +void FlagWidget::on_varState_checked(const bool state) +{ + m_value.setStatus(state ? Flag::On : Flag::Off); +} + |
