1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
/////////////////////////////////////////////////////////////////////////////
// Name: pokegen/SpeciesItemUI.cpp
// Purpose: SpeciesItem UI form handling
// Author: Ben Boeckel
// Modified by: Ben Boeckel
// Created: Mon Feb 18 18:08:04 2008
// Copyright: ©2007-2008 Ben Boeckel and Nerdy Productions
// Licence:
// 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/>.
/////////////////////////////////////////////////////////////////////////////
#include <QMetaObject>
#include <QVariant>
#include <BugCatcher.h>
#include <Exception.h>
#include <Item.h>
#include <Pokemod.h>
#include <SpeciesItem.h>
#include "SpeciesItemUI.h"
SpeciesItemUI::SpeciesItemUI(SpeciesItem* s, QWidget* parent) :
ObjectUI(parent),
speciesItem(s),
speciesItem_mod(new SpeciesItem(s->getPokemod(), *s, s->getId()))
{
setupUi(this);
QMetaObject::connectSlotsByName(this);
setObjects(speciesItem, speciesItem_mod);
connect(this, SIGNAL(changed(bool)), boxButtons, SLOT(setDisabled(bool)));
for (int i = 0; i < speciesItem->getPokemod()->getItemCount(); ++i)
{
const Item* it = speciesItem->getPokemod()->getItem(i);
varItem->addItem(it->getName());
varItem->setItemData(i, it->getId());
}
setGui();
}
// KToolbar SpeciesItemUI::getToolbar(QWidget* parent)
// {
//
// }
void SpeciesItemUI::setGui()
{
varItem->setCurrentIndex(varItem->findData(speciesItem_mod->getItem()));
varWeight->setValue(speciesItem_mod->getWeight());
}
void SpeciesItemUI::on_buttonApply_clicked()
{
*speciesItem = *speciesItem_mod;
emit(changed(false));
}
void SpeciesItemUI::on_buttonDiscard_clicked()
{
*speciesItem_mod = *speciesItem;
emit(changed(false));
setGui();
}
void SpeciesItemUI::on_varItem_currentIndexChanged(const int i)
{
try
{
speciesItem_mod->setItem(varItem->itemData(i).toInt());
emit(changed(true));
}
catch (BoundsException& e)
{
BugCatcher::report(e);
}
setGui();
}
void SpeciesItemUI::on_varWeight_valueChanged(const int w)
{
try
{
speciesItem_mod->setWeight(w);
emit(changed(true));
}
catch (BoundsException& e)
{
BugCatcher::report(e);
setGui();
}
}
|