/* * Copyright 2008 Ben Boeckel * * 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 . */ // Header include #include "SpeciesAbilityUI.h" // Sigmod includes #include "../sigmod/Ability.h" #include "../sigmod/Sigmod.h" #include "../sigmod/SpeciesAbility.h" Sigmodr::SpeciesAbilityUI::SpeciesAbilityUI(Sigmod::SpeciesAbility* ability, QWidget* parent) : ObjectUI(parent) { setupUi(this); setObjects(ability, new Sigmod::SpeciesAbility(*ability)); } Sigmodr::SpeciesAbilityUI::~SpeciesAbilityUI() { } void Sigmodr::SpeciesAbilityUI::refreshGui() { const bool blocked = varAbility->blockSignals(true); varAbility->clear(); for (int i = 0; i < sigmod()->abilityCount(); ++i) { const Sigmod::Ability* ability = sigmod()->ability(i); varAbility->addItem(ability->name(), ability->id()); } varAbility->blockSignals(blocked); } void Sigmodr::SpeciesAbilityUI::setGui() { varAbility->setCurrentIndex(varAbility->findData(qobject_cast(modified())->ability())); varWeight->setValue(qobject_cast(modified())->weight()); } void Sigmodr::SpeciesAbilityUI::apply() { *qobject_cast(original()) = *qobject_cast(modified()); emit(changed(false)); } void Sigmodr::SpeciesAbilityUI::discard() { *qobject_cast(modified()) = *qobject_cast(original()); setGui(); emit(changed(false)); } void Sigmodr::SpeciesAbilityUI::on_varAbility_activated(const int ability) { qobject_cast(modified())->setAbility(varAbility->itemData(ability).toInt()); } void Sigmodr::SpeciesAbilityUI::on_varWeight_valueChanged(const int weight) { qobject_cast(modified())->setWeight(weight); }