From b191a68ca2b1ec370fc1faafb078e4e201b2b459 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 6 Feb 2008 05:02:11 +0000 Subject: [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 --- pokemodr/TileDelegate.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 pokemodr/TileDelegate.cpp (limited to 'pokemodr/TileDelegate.cpp') 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 . +///////////////////////////////////////////////////////////////////////////// + +#include +#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(editor->parent())->getOriginal()->getPokemod().getTileCount(); ++i) + static_cast(editor)->addItem(ImageCache::open(static_cast(editor->parent())->getOriginal()->getPokemod().getTile(i).getPic()), static_cast(editor->parent())->getOriginal()->getPokemod().getTile(i).getName()); + static_cast(editor)->setCurrentIndex(index.data(Qt::EditRole).toInt()); +} + +void TileDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const +{ + static_cast(model)->setData(index, static_cast(editor)->currentIndex()); +} + +void TileDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex&) const +{ + editor->setGeometry(option.rect); +} -- cgit