/* * 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 "SpeciesMoveUI.h" // Sigmod includes #include "../sigmod/Move.h" #include "../sigmod/Rules.h" #include "../sigmod/Sigmod.h" #include "../sigmod/SpeciesMove.h" Sigmodr::SpeciesMoveUI::SpeciesMoveUI(Sigmod::SpeciesMove* move, QWidget* parent) : ObjectUI(parent) { setupUi(this); setObjects(move, new Sigmod::SpeciesMove(*move)); } Sigmodr::SpeciesMoveUI::~SpeciesMoveUI() { } void Sigmodr::SpeciesMoveUI::refreshGui() { const bool blocked = varMove->blockSignals(true); varMove->clear(); for (int i = 0; i < sigmod()->moveCount(); ++i) { const Sigmod::Move* move = sigmod()->move(i); varMove->addItem(move->name(), move->id()); } varMove->blockSignals(blocked); varLevel->setMaximum(sigmod()->rules()->maxLevel()); varWildLevel->setMaximum(sigmod()->rules()->maxLevel()); } void Sigmodr::SpeciesMoveUI::setGui() { varMove->setCurrentIndex(varMove->findData(qobject_cast(modified())->move())); varLevel->setValue(qobject_cast(modified())->level()); varWildLevel->setValue(qobject_cast(modified())->wild()); } void Sigmodr::SpeciesMoveUI::apply() { *qobject_cast(original()) = *qobject_cast(modified()); emit(changed(false)); } void Sigmodr::SpeciesMoveUI::discard() { *qobject_cast(modified()) = *qobject_cast(original()); setGui(); emit(changed(false)); } void Sigmodr::SpeciesMoveUI::on_varMove_activated(const int move) { qobject_cast(modified())->setMove(varMove->itemData(move).toInt()); } void Sigmodr::SpeciesMoveUI::on_varLevel_valueChanged(const int level) { qobject_cast(modified())->setLevel(level); } void Sigmodr::SpeciesMoveUI::on_varWildLevel_valueChanged(const int wildLevel) { qobject_cast(modified())->setWild(wildLevel); }