summaryrefslogtreecommitdiffstats
path: root/pokemodr/ObjectUI.cpp
blob: bfeab8ee7ed772e4c9c01b1e2c2192eec80e2e9f (plain)
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
104
105
106
107
108
109
110
111
112
/*
 * 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 "ObjectUI.h"

// Pokemod includes
#include "../pokemod/Object.h"

// KDE includes
#include <KMessageBox>

ObjectUI::ObjectUI(QWidget* parent) :
        QWidget(parent),
        m_changed(false),
        m_object(NULL),
        m_object_mod(NULL)
{
    connect(this, SIGNAL(changed(bool)), SLOT(setChanged(bool)));
}

ObjectUI::~ObjectUI()
{
    delete m_object_mod;
}

void ObjectUI::reload()
{
    refreshGui();
    setGui();
}

bool ObjectUI::isChanged() const
{
    return m_changed;
}

const Object* ObjectUI::original() const
{
    return m_object;
}

Object* ObjectUI::original()
{
    return m_object;
}

const Object* ObjectUI::modified() const
{
    return m_object_mod;
}

Object* ObjectUI::modified()
{
    return m_object_mod;
}

void ObjectUI::setChanged(const bool changed)
{
    m_changed = changed;
}

void ObjectUI::errorMessage(const QString& message)
{
    KMessageBox::error(this, message, "Error");
}

void ObjectUI::warningMessage(const QString& message)
{
    KMessageBox::warningContinueCancel(this, message, "Warning");
}

void ObjectUI::initGui()
{
}

void ObjectUI::refreshGui()
{
}

void ObjectUI::setObjects(Object* original, Object* modified)
{
    m_object = original;
    m_object_mod = modified;
    connect(m_object_mod, SIGNAL(changed()), this, SIGNAL(changed()));
    connect(m_object_mod, SIGNAL(changed()), this, SLOT(setGui()));
    connect(m_object_mod, SIGNAL(error(const QString&)), this, SLOT(setGui()));
    connect(m_object_mod, SIGNAL(error(const QString&)), this, SLOT(errorMessage(const QString&)));
    connect(m_object_mod, SIGNAL(warning(const QString&)), this, SLOT(warningMessage(const QString&)));
    init();
}

void ObjectUI::init()
{
    initGui();
    reload();
    emit(changed(false));
}