File indexing completed on 2024-05-12 05:39:42
0001 /*************************************************************************** 0002 * Copyright (C) 2014 by Renaud Guezennec * 0003 * https://rolisteam.org/ * 0004 * * 0005 * This file is part of rcse * 0006 * * 0007 * rcse is free software; you can redistribute it and/or modify * 0008 * it under the terms of the GNU General Public License as published by * 0009 * the Free Software Foundation; either version 2 of the License, or * 0010 * (at your option) any later version. * 0011 * * 0012 * rcse is distributed in the hope that it will be useful, * 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0015 * GNU General Public License for more details. * 0016 * * 0017 * You should have received a copy of the GNU General Public License * 0018 * along with this program; if not, write to the * 0019 * Free Software Foundation, Inc., * 0020 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0021 ***************************************************************************/ 0022 #ifndef CHARACTERSHEETITEM_H 0023 #define CHARACTERSHEETITEM_H 0024 0025 #include <QJsonObject> 0026 #include <QTextStream> 0027 #include <QVariant> 0028 0029 #include <charactersheet/charactersheet_global.h> 0030 0031 class QGraphicsScene; 0032 class EditorController; 0033 /** 0034 * @brief The Item class 0035 */ 0036 class CHARACTERSHEET_EXPORT TreeSheetItem : public QObject 0037 { 0038 Q_OBJECT 0039 Q_PROPERTY(QString id READ id WRITE setId NOTIFY idChanged) 0040 Q_PROPERTY(TreeSheetItem::TreeItemType itemType READ itemType CONSTANT) 0041 public: 0042 enum TreeItemType 0043 { 0044 SectionItem, 0045 FieldItem, 0046 TableItem, 0047 SliderItem 0048 }; 0049 Q_ENUM(TreeItemType) 0050 0051 enum ColumnId 0052 { 0053 ID, 0054 LABEL, 0055 VALUE, 0056 VALUES, 0057 TYPE, 0058 X, 0059 Y, 0060 WIDTH, 0061 HEIGHT, 0062 FitFont, 0063 FONT, 0064 TEXT_ALIGN, 0065 TEXTCOLOR, 0066 BGCOLOR, 0067 BORDER, 0068 PAGE, 0069 TOOLTIP 0070 }; 0071 Q_ENUM(ColumnId) 0072 0073 TreeSheetItem(TreeSheetItem::TreeItemType type, QObject* parent= nullptr); 0074 0075 virtual bool mayHaveChildren() const; 0076 virtual bool hasChildren(); 0077 virtual int childrenCount() const; 0078 virtual void appendChild(TreeSheetItem*); 0079 0080 virtual TreeSheetItem* childFromId(const QString& id) const; 0081 virtual TreeSheetItem* childAt(int) const; 0082 0083 virtual QString id() const; 0084 virtual QString path() const; 0085 0086 void setId(const QString& id); 0087 0088 TreeSheetItem* parentTreeItem() const; 0089 void setParent(TreeSheetItem* parent); 0090 int rowInParent(); 0091 virtual int indexOfChild(TreeSheetItem* itm); 0092 0093 TreeSheetItem::TreeItemType itemType() const; 0094 virtual bool removeChild(TreeSheetItem*); 0095 virtual bool deleteChild(TreeSheetItem*); 0096 virtual void setFieldInDictionnary(QHash<QString, QString>& dict) const= 0; 0097 virtual void changeKeyChild(const QString& oldkey, const QString& newKey, TreeSheetItem* child); 0098 0099 virtual void setOrig(TreeSheetItem* m_origine)= 0; 0100 0101 virtual void save(QJsonObject& json, bool exp= false) {} 0102 virtual void load(const QJsonObject& json) {} 0103 virtual void saveDataItem(QJsonObject& json) {} 0104 virtual void loadDataItem(const QJsonObject& json) {} 0105 0106 signals: 0107 void characterSheetItemChanged(TreeSheetItem* item); 0108 void idChanged(); 0109 0110 protected: 0111 TreeSheetItem::TreeItemType m_itemType; 0112 TreeSheetItem* m_parent; 0113 QString m_id; 0114 }; 0115 0116 #endif // CHARACTERSHEETITEM_H