summaryrefslogtreecommitdiffstats
path: root/pokemodr/TilemapModel.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-02-23 08:06:38 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-02-23 08:06:38 +0000
commit82bf5001730ebd1b2c8448138e2ebaff2332dea2 (patch)
treebde71f89089f000da6127d371b585bfc42f647b4 /pokemodr/TilemapModel.cpp
parentda42e77ec57e3ecf0ecc2e1b8fe8b21a50ac58cd (diff)
downloadsigen-82bf5001730ebd1b2c8448138e2ebaff2332dea2.tar.gz
sigen-82bf5001730ebd1b2c8448138e2ebaff2332dea2.tar.xz
sigen-82bf5001730ebd1b2c8448138e2ebaff2332dea2.zip
[FIX] Map editing looks promisingly partially fixed
[FIX] Cleaned up map editing Model/View [ADD] Tilemap editing now has insertion of rows/columns git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@74 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemodr/TilemapModel.cpp')
-rw-r--r--pokemodr/TilemapModel.cpp47
1 files changed, 36 insertions, 11 deletions
diff --git a/pokemodr/TilemapModel.cpp b/pokemodr/TilemapModel.cpp
index 5312fb21..d90fcbe9 100644
--- a/pokemodr/TilemapModel.cpp
+++ b/pokemodr/TilemapModel.cpp
@@ -35,11 +35,6 @@ TilemapModel::TilemapModel(QObject* parent, Matrix<int>* tilemap, const Pokemod*
map(tilemap),
pokemod(mod)
{
- setGui();
-}
-
-void TilemapModel::setGui()
-{
}
int TilemapModel::rowCount(const QModelIndex&) const
@@ -86,26 +81,54 @@ Qt::ItemFlags TilemapModel::flags(const QModelIndex&) const
return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
+bool TilemapModel::addRow()
+{
+ return insertRows(map->getHeight(), 1);
+}
+
+bool TilemapModel::addColumn()
+{
+ return insertColumns(map->getWidth(), 1);
+}
+
bool TilemapModel::insertRows(int row, int count, const QModelIndex&)
{
- emit(beginInsertRows(QModelIndex(), row, row + count - 1));
- for (int i = 0; i < count; ++i)
- map->insertRow(row);
+ emit(beginInsertRows(QModelIndex(), row, row + count));
+ if (map->getWidth())
+ {
+ for (int i = 0; i < count; ++i)
+ map->insertRow(row);
+ }
+ else
+ {
+ map->addCol();
+ insertColumns(0, 0);
+ }
emit(endInsertRows());
return true;
}
bool TilemapModel::insertColumns(int column, int count, const QModelIndex&)
{
- emit(beginInsertColumns(QModelIndex(), column, column + count - 1));
- for (int i = 0; i < count; ++i)
- map->insertCol(column);
+ emit(beginInsertColumns(QModelIndex(), column, column + count));
+ if (map->getHeight())
+ {
+ for (int i = 0; i < count; ++i)
+ map->insertCol(column);
+ }
+ else
+ {
+ map->addRow();
+ insertRows(0, 0);
+ }
emit(endInsertColumns());
return true;
}
bool TilemapModel::removeRows(int row, int count, const QModelIndex&)
{
+ if (map->getHeight() == 1)
+ removeColumns(0, map->getWidth());
emit(beginRemoveRows(QModelIndex(), row, row + count - 1));
for (int i = 0; i < count; ++i)
map->deleteRow(row);
@@ -115,6 +138,8 @@ bool TilemapModel::removeRows(int row, int count, const QModelIndex&)
bool TilemapModel::removeColumns(int column, int count, const QModelIndex&)
{
+ if (map->getWidth() == 1)
+ removeRows(0, map->getHeight());
emit(beginRemoveColumns(QModelIndex(), column, column + count - 1));
for (int i = 0; i < count; ++i)
map->deleteCol(column);