diff options
Diffstat (limited to 'sigmodr/tree/CoinListItemModel.cpp')
| -rw-r--r-- | sigmodr/tree/CoinListItemModel.cpp | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/sigmodr/tree/CoinListItemModel.cpp b/sigmodr/tree/CoinListItemModel.cpp deleted file mode 100644 index eb342acb..00000000 --- a/sigmodr/tree/CoinListItemModel.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2008-2009 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 "CoinListItemModel.h" - -// Sigmodr tree includes -#include "GroupObjectModel.h" - -// Sigmodr widget includes -#include <sigmodr/widgets/CoinListItemUI.h> - -// Sigmod includes -#include <sigmod/CoinList.h> -#include <sigmod/CoinListItem.h> -#include <sigmod/Item.h> -#include <sigmod/Game.h> -#include <sigmod/Species.h> - -// KDE includes -#include <KMenu> - -using namespace Sigmod; -using namespace Sigmodr::Widgets; -using namespace Sigmodr::Tree; - -CoinListItemModel::CoinListItemModel(BaseModel* parent, CoinListItem* item) : - ObjectModel(parent, item) -{ -} - -QVariant CoinListItemModel::data(int role) const -{ - if (role == Qt::DisplayRole) - { - CoinListItem* item = qobject_cast<CoinListItem*>(m_object); - if (item->type() == CoinListItem::Item) - { - const Item* _item = m_object->game()->itemById(item->object()); - if (_item) - return _item->name(); - } - else if (item->type() == CoinListItem::Species) - { - const Species* species = m_object->game()->speciesById(item->object()); - if (species) - return species->name(); - } - return ""; - } - else if (role == BaseModel::XmlRole) - { - QDomDocument xml(m_object->className()); - xml.appendChild(m_object->save()); - return xml.toString(); - } - else if (role == BaseModel::WidgetRole) - { - QWidget* widget = new CoinListItemUI(qobject_cast<CoinListItem*>(m_object), NULL); - return QVariant::fromValue(widget); - } - else if (role == BaseModel::ContextMenuRole) - { - KMenu* menu = new KMenu; - menu->addAction("&Delete Object", this, SLOT(deleteSelf())); - return QVariant::fromValue(menu); - } - return ObjectModel::data(role); -} - -void CoinListItemModel::deleteSelf() -{ - qobject_cast<GroupObjectModel*>(m_parent)->deleteObject(this); -} |
