summaryrefslogtreecommitdiffstats
path: root/pokemodr/TilemapModel.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-04-17 23:34:36 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-04-17 23:34:36 +0000
commit6679f5cffa9d35a23b76605ddfbf3257f882b6ee (patch)
treec8e41854a60b64e8569939bca6b827807175ef9a /pokemodr/TilemapModel.cpp
parent05980e883719b1c8ebde1bd2fcbf4f8c16df7ad6 (diff)
[FIX] Frac -> Fraction
[FIX] ImageCache and Ini removed [FIX] Fraction/Point widgets moved to pokemodr [FIX] Copy ctors made for pokemod classes [FIX] Ctors in pokemod fixed [FIX] Copyright headers fixed in pokemodr [FIX] PokeModr updated to new API and fixed in some places git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@99 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemodr/TilemapModel.cpp')
-rw-r--r--pokemodr/TilemapModel.cpp96
1 files changed, 47 insertions, 49 deletions
diff --git a/pokemodr/TilemapModel.cpp b/pokemodr/TilemapModel.cpp
index 1e4e8ec5..22c57aba 100644
--- a/pokemodr/TilemapModel.cpp
+++ b/pokemodr/TilemapModel.cpp
@@ -1,50 +1,48 @@
-/////////////////////////////////////////////////////////////////////////////
-// Name: pokegen/TilemapModel.cpp
-// Purpose: Provides a model for tiles in the tilemap editor
-// Author: Ben Boeckel
-// Modified by: Ben Boeckel
-// Created: Tue Feb 5 19:43:22 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/>.
-/////////////////////////////////////////////////////////////////////////////
-
+/*
+ * 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/>.
+ */
+
+// KDE includes
#include <kcombobox.h>
-#include <ImageCache.h>
-
+// Pokemod includes
#include <Tile.h>
+// PokeModr includes
#include "ObjectUI.h"
#include "MapUI.h"
+
+// Header include
#include "TilemapModel.h"
-TilemapModel::TilemapModel(QObject* parent, Matrix<int>* tilemap, const Pokemod* mod) :
+TilemapModel::TilemapModel(QObject* parent, Matrix<int>* map, const Pokemod* pokemod) :
QAbstractTableModel(parent),
- map(tilemap),
- pokemod(mod)
+ m_map(map),
+ m_pokemod(pokemod)
{
}
int TilemapModel::rowCount(const QModelIndex&) const
{
- return map->getHeight();
+ return m_map->height();
}
int TilemapModel::columnCount(const QModelIndex&) const
{
- return map->getWidth();
+ return m_map->width();
}
QVariant TilemapModel::data(const QModelIndex& index, int role) const
@@ -53,17 +51,17 @@ QVariant TilemapModel::data(const QModelIndex& index, int role) const
return QVariant();
if (role == Qt::DisplayRole)
{
- int idx = pokemod->getTileIndex(map->at(index.row(), index.column()));
+ int idx = m_pokemod->tileIndex(m_map->at(index.row(), index.column()));
if (idx != INT_MAX)
- return ImageCache::open(pokemod->getTile(idx)->getPic());
+ return m_pokemod->tile(idx)->sprite();
}
if (role == Qt::EditRole)
- map->at(index.row(), index.column());
+ m_map->at(index.row(), index.column());
if (role == Qt::ToolTipRole)
{
- int idx = pokemod->getTileIndex(map->at(index.row(), index.column()));
+ int idx = m_pokemod->tileIndex(m_map->at(index.row(), index.column()));
if (idx != INT_MAX)
- return pokemod->getTile(idx)->getName();
+ return m_pokemod->tile(idx)->name();
}
return QVariant();
}
@@ -79,7 +77,7 @@ bool TilemapModel::setData(const QModelIndex& index, const QVariant& value, int
{
if (role != Qt::EditRole)
return false;
- map->set(index.row(), index.column(), pokemod->getTile(value.toInt())->getId());
+ (*m_map)(index.row(), index.column()) = m_pokemod->tile(value.toInt())->id();
emit(dataChanged(index, index));
return true;
}
@@ -91,25 +89,25 @@ Qt::ItemFlags TilemapModel::flags(const QModelIndex&) const
bool TilemapModel::addRow()
{
- return insertRows(map->getHeight(), 1);
+ return insertRows(m_map->height(), 1);
}
bool TilemapModel::addColumn()
{
- return insertColumns(map->getWidth(), 1);
+ return insertColumns(m_map->width(), 1);
}
bool TilemapModel::insertRows(int row, int count, const QModelIndex&)
{
emit(beginInsertRows(QModelIndex(), row, row + count));
- if (map->getWidth())
+ if (m_map->width())
{
for (int i = 0; i < count; ++i)
- map->insertRow(row);
+ m_map->insertRow(row);
}
else
{
- map->addCol();
+ m_map->addColumn();
insertColumns(0, 0);
}
emit(endInsertRows());
@@ -119,14 +117,14 @@ bool TilemapModel::insertRows(int row, int count, const QModelIndex&)
bool TilemapModel::insertColumns(int column, int count, const QModelIndex&)
{
emit(beginInsertColumns(QModelIndex(), column, column + count));
- if (map->getHeight())
+ if (m_map->height())
{
for (int i = 0; i < count; ++i)
- map->insertCol(column);
+ m_map->insertColumn(column);
}
else
{
- map->addRow();
+ m_map->addRow();
insertRows(0, 0);
}
emit(endInsertColumns());
@@ -135,22 +133,22 @@ bool TilemapModel::insertColumns(int column, int count, const QModelIndex&)
bool TilemapModel::removeRows(int row, int count, const QModelIndex&)
{
- if (map->getHeight() == 1)
- removeColumns(0, map->getWidth());
+ if (m_map->height() == 1)
+ removeColumns(0, m_map->width());
emit(beginRemoveRows(QModelIndex(), row, row + count - 1));
for (int i = 0; i < count; ++i)
- map->deleteRow(row);
+ m_map->deleteRow(row);
emit(endRemoveRows());
return true;
}
bool TilemapModel::removeColumns(int column, int count, const QModelIndex&)
{
- if (map->getWidth() == 1)
- removeRows(0, map->getHeight());
+ if (m_map->width() == 1)
+ removeRows(0, m_map->height());
emit(beginRemoveColumns(QModelIndex(), column, column + count - 1));
for (int i = 0; i < count; ++i)
- map->deleteCol(column);
+ m_map->deleteColumn(column);
emit(endRemoveColumns());
return true;
}