/* * 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 "SpeciesItemUI.h" // Sigmod includes #include "../sigmod/Item.h" #include "../sigmod/Sigmod.h" #include "../sigmod/SpeciesItem.h" Sigmodr::SpeciesItemUI::SpeciesItemUI(Sigmod::SpeciesItem* item, QWidget* parent) : ObjectUI(parent) { setupUi(this); setObjects(item, new Sigmod::SpeciesItem(*item)); } Sigmodr::SpeciesItemUI::~SpeciesItemUI() { } void Sigmodr::SpeciesItemUI::refreshGui() { const bool blocked = varItem->blockSignals(true); varItem->clear(); for (int i = 0; i < sigmod()->itemCount(); ++i) { const Sigmod::Item* item = sigmod()->item(i); varItem->addItem(item->name(), item->id()); } varItem->blockSignals(blocked); } void Sigmodr::SpeciesItemUI::setGui() { varItem->setCurrentIndex(varItem->findData(qobject_cast(modified())->item())); varWeight->setValue(qobject_cast(modified())->weight()); } void Sigmodr::SpeciesItemUI::apply() { *qobject_cast(original()) = *qobject_cast(modified()); emit(changed(false)); } void Sigmodr::SpeciesItemUI::discard() { *qobject_cast(modified()) = *qobject_cast(original()); setGui(); emit(changed(false)); } void Sigmodr::SpeciesItemUI::on_varItem_activated(const int item) { qobject_cast(modified())->setItem(varItem->itemData(item).toInt()); } void Sigmodr::SpeciesItemUI::on_varWeight_valueChanged(const int weight) { qobject_cast(modified())->setWeight(weight); }