diff --git a/code/studio/src/plugins/tile_editor/land.h b/code/studio/src/plugins/tile_editor/land.h index 8538d7b08..93d244d9d 100644 --- a/code/studio/src/plugins/tile_editor/land.h +++ b/code/studio/src/plugins/tile_editor/land.h @@ -1,17 +1,17 @@ -// Ryzom Core Studio - Tile Editor plugin -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License +// Ryzom Core Studio - Tile Editor plugin +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero 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 Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . diff --git a/code/studio/src/plugins/tile_editor/tile_item.cpp b/code/studio/src/plugins/tile_editor/tile_item.cpp index 7ae177220..d2fa3793f 100644 --- a/code/studio/src/plugins/tile_editor/tile_item.cpp +++ b/code/studio/src/plugins/tile_editor/tile_item.cpp @@ -307,11 +307,11 @@ QVariant TileItemNode::data(int column, int role) const // Retrieve the target tile size. uint32 tileSize = TileModel::getTileTypeSize(parent->getTileType()); - if(tileFilename.isEmpty() || tileFilename == "empty") - tileFilename = ":/placeHolder/images/empty_image.png"; - - QPixmap pixmap;// = new QPixmap(); - if(!pixmap.load(tileFilename)) + if(tileFilename.isEmpty() || tileFilename == "empty") + tileFilename = ":/placeHolder/images/empty_image.png"; + + QPixmap pixmap;// = new QPixmap(); + if(!pixmap.load(tileFilename)) nlinfo("failed to load %s", tileFilename.toAscii().data()); if(TileModel::CurrentZoomFactor == TileModel::TileZoom200) diff --git a/code/studio/src/plugins/tile_editor/tile_item_delegate.h b/code/studio/src/plugins/tile_editor/tile_item_delegate.h index 90c831fb8..015f32021 100644 --- a/code/studio/src/plugins/tile_editor/tile_item_delegate.h +++ b/code/studio/src/plugins/tile_editor/tile_item_delegate.h @@ -12,44 +12,44 @@ // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . -#ifndef TILE_ITEM_DELEGATE_H -#define TILE_ITEM_DELEGATE_H - -#include -#include -#include - -#include - -class TileItemDelegate : public QStyledItemDelegate - { - public: - - enum TZoomFactor - { - ZoomSmall = 0, - ZoomNormal = 1, - ZoomLarge = 2 - }; - - static const int PIXMAP_MARGIN = 5; - - TileItemDelegate(); - virtual ~TileItemDelegate(); - - void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; - QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index ) const; - - TZoomFactor getZoomFactor(); - void setZoomFactor(TZoomFactor zoomFactor); - -public Q_SLOTS: - void currentTab(int index); - - private: - TZoomFactor m_zoomFactor; - int m_imageHint; - }; - -#endif // TILE_ITEM_DELEGATE_H +// along with this program. If not, see . +#ifndef TILE_ITEM_DELEGATE_H +#define TILE_ITEM_DELEGATE_H + +#include +#include +#include + +#include + +class TileItemDelegate : public QStyledItemDelegate + { + public: + + enum TZoomFactor + { + ZoomSmall = 0, + ZoomNormal = 1, + ZoomLarge = 2 + }; + + static const int PIXMAP_MARGIN = 5; + + TileItemDelegate(); + virtual ~TileItemDelegate(); + + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; + QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index ) const; + + TZoomFactor getZoomFactor(); + void setZoomFactor(TZoomFactor zoomFactor); + +public Q_SLOTS: + void currentTab(int index); + + private: + TZoomFactor m_zoomFactor; + int m_imageHint; + }; + +#endif // TILE_ITEM_DELEGATE_H diff --git a/code/studio/src/plugins/tile_editor/tile_model.cpp b/code/studio/src/plugins/tile_editor/tile_model.cpp index 99cc557e3..037be65cd 100644 --- a/code/studio/src/plugins/tile_editor/tile_model.cpp +++ b/code/studio/src/plugins/tile_editor/tile_model.cpp @@ -24,22 +24,22 @@ // Initialize the static members TileModel::TTileZoomFactor TileModel::CurrentZoomFactor; -TileModel::TileModel(const QStringList &headers, QObject *parent) : QAbstractItemModel(parent) -{ - QVector rootData; - Q_FOREACH(QString header, headers) - rootData << header; - - rootItem = new Node(rootData); - - TileModel::CurrentZoomFactor = TileModel::TileZoom100; - m_indexDisplay = true; - m_fileDisplay = true; -} - -TileModel::~TileModel() -{ - delete rootItem; +TileModel::TileModel(const QStringList &headers, QObject *parent) : QAbstractItemModel(parent) +{ + QVector rootData; + Q_FOREACH(QString header, headers) + rootData << header; + + rootItem = new Node(rootData); + + TileModel::CurrentZoomFactor = TileModel::TileZoom100; + m_indexDisplay = true; + m_fileDisplay = true; +} + +TileModel::~TileModel() +{ + delete rootItem; } Node *TileModel::getItem(const QModelIndex &index) const @@ -92,33 +92,33 @@ int TileModel::columnCount(const QModelIndex &parent) const return parentItem->columnCount(); } -QVariant TileModel::data(const QModelIndex &index, int role) const -{ - if(!index.isValid()) - return QVariant(); - - Node *item = static_cast(index.internalPointer()); - - // Translate the display role to the settings-specific role. - - if(role == Qt::DisplayRole) - { - if(m_indexDisplay && m_fileDisplay) - role = TileFilenameIndexRole; - else if(m_fileDisplay) - role = TileFilenameRole; - else if(m_indexDisplay) - role = TileIndexRole; - } - return item->data(index.column(), role); +QVariant TileModel::data(const QModelIndex &index, int role) const +{ + if(!index.isValid()) + return QVariant(); + + Node *item = static_cast(index.internalPointer()); + + // Translate the display role to the settings-specific role. + + if(role == Qt::DisplayRole) + { + if(m_indexDisplay && m_fileDisplay) + role = TileFilenameIndexRole; + else if(m_fileDisplay) + role = TileFilenameRole; + else if(m_indexDisplay) + role = TileIndexRole; + } + return item->data(index.column(), role); } -Qt::ItemFlags TileModel::flags(const QModelIndex &index) const -{ - if(!index.isValid()) - return Qt::ItemIsEnabled; - - return Qt::ItemIsEnabled|Qt::ItemIsSelectable; +Qt::ItemFlags TileModel::flags(const QModelIndex &index) const +{ + if(!index.isValid()) + return Qt::ItemIsEnabled; + + return Qt::ItemIsEnabled|Qt::ItemIsSelectable; } QVariant TileModel::headerData(int section, Qt::Orientation orientation, int role) const