summaryrefslogtreecommitdiffstats
path: root/pokemodr/TileDelegate.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-02-06 05:02:11 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-02-06 05:02:11 +0000
commitb191a68ca2b1ec370fc1faafb078e4e201b2b459 (patch)
treef0e7c4f261fc17cf2fc761dd4daba9436355166a /pokemodr/TileDelegate.cpp
parentfa06bab5688417517e342b0b42a1b06e845aa778 (diff)
downloadsigen-b191a68ca2b1ec370fc1faafb078e4e201b2b459.tar.gz
sigen-b191a68ca2b1ec370fc1faafb078e4e201b2b459.tar.xz
sigen-b191a68ca2b1ec370fc1faafb078e4e201b2b459.zip
[ADD] Tilemap editing to the Map form
[ADD] MapUI.{h, cpp}, TilemapModel.{h, cpp}, TileDelegate.{h, cpp} [FIX] Editing area of the main window now has scroll bars [FIX] CoinListUI is now safer with its combobox creation for the values [FIX] Minor fixes in Tile and Map classes [FIX] Matrix cleaned up git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@57 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemodr/TileDelegate.cpp')
-rw-r--r--pokemodr/TileDelegate.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/pokemodr/TileDelegate.cpp b/pokemodr/TileDelegate.cpp
new file mode 100644
index 00000000..1fb26541
--- /dev/null
+++ b/pokemodr/TileDelegate.cpp
@@ -0,0 +1,53 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: pokegen/TileDelegate.cpp
+// Purpose: Provides an editor for tiles in the tilemap editor
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Sat Feb 2 01:31:30 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
+// MERCHANTMap 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 <kcombobox.h>
+#include "../general/ImageCache.h"
+#include "../pokemod/Pokemod.h"
+#include "../pokemod/Tile.h"
+#include "ObjectUI.h"
+#include "MapUI.h"
+#include "TileDelegate.h"
+#include "TilemapModel.h"
+
+QWidget* TileDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem&, const QModelIndex&) const
+{
+ KComboBox* editor = new KComboBox(parent);
+ return editor;
+}
+
+void TileDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
+{
+ for (int i = 0; i < static_cast<ObjectUI*>(editor->parent())->getOriginal()->getPokemod().getTileCount(); ++i)
+ static_cast<KComboBox*>(editor)->addItem(ImageCache::open(static_cast<ObjectUI*>(editor->parent())->getOriginal()->getPokemod().getTile(i).getPic()), static_cast<MapUI*>(editor->parent())->getOriginal()->getPokemod().getTile(i).getName());
+ static_cast<KComboBox*>(editor)->setCurrentIndex(index.data(Qt::EditRole).toInt());
+}
+
+void TileDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
+{
+ static_cast<TilemapModel*>(model)->setData(index, static_cast<KComboBox*>(editor)->currentIndex());
+}
+
+void TileDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex&) const
+{
+ editor->setGeometry(option.rect);
+}