summaryrefslogtreecommitdiffstats
path: root/sigmodr/MapEditor.cpp
blob: aeff13129b4d321dcdefefd21f20605857cbcd07 (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
/*
 * 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 "MapEditor.h"

// Sigmodr includes
#include "MapScene.h"

// KDE includes
#include <KIcon>
#include <KPushButton>

// Qt includes
#include <QtGui/QGraphicsView>
#include <QtGui/QGridLayout>

Sigmodr::MapEditor::MapEditor(QWidget* parent) :
        QWidget(parent)
{
    setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
    QGridLayout* layout = new QGridLayout;
    m_view = new QGraphicsView;
    m_view->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    layout->addWidget(m_view, 0, 0, 6, 1);
    m_addTile = new KPushButton(KIcon("list-add"), "Add Tile");
    layout->addWidget(m_addTile, 0, 1, 1, 1);
    m_removeTiles = new KPushButton(KIcon("list-remove"), "Remove Tiles");
    layout->addWidget(m_removeTiles, 1, 1, 1, 1);
    m_moveToTop = new KPushButton(KIcon("arrow-up-double"), "Move to Top");
    layout->addWidget(m_moveToTop, 2, 1, 1, 1);
    m_moveUp = new KPushButton(KIcon("arrow-up"), "Move Up");
    layout->addWidget(m_moveUp, 3, 1, 1, 1);
    m_moveDown = new KPushButton(KIcon("arrow-down"), "Move Down");
    layout->addWidget(m_moveDown, 4, 1, 1, 1);
    m_moveToBottom = new KPushButton(KIcon("arrow-down-double"), "Move to Bottom");
    layout->addWidget(m_moveToBottom, 5, 1, 1, 1);
    setLayout(layout);
}

void Sigmodr::MapEditor::setMap(Sigmod::Map* map)
{
    m_map = map;
    m_scene = new MapScene(map, this);
    connect(m_scene, SIGNAL(changed()), this, SIGNAL(changed()));
    connect(m_addTile, SIGNAL(pressed()), m_scene, SLOT(addTile()));
    connect(m_removeTiles, SIGNAL(pressed()), m_scene, SLOT(removeTiles()));
    m_view->setScene(m_scene);
}

void Sigmodr::MapEditor::reset()
{
}