File indexing completed on 2024-05-12 05:39:42
0001 /*************************************************************************** 0002 * Copyright (C) 2015 by Renaud Guezennec * 0003 * https://rolisteam.org/contact * 0004 * * 0005 * rolisteam is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0019 ***************************************************************************/ 0020 #ifndef CSITEM_H 0021 #define CSITEM_H 0022 0023 #include "charactersheet/charactersheetitem.h" 0024 #include <QColor> 0025 #include <QPointF> 0026 #include <QPointer> 0027 #include <QRectF> 0028 #include <QString> 0029 0030 #include <charactersheet/charactersheet_global.h> 0031 0032 class QGraphicsItem; 0033 /** 0034 * @brief The CSItem class is managing some item values for RCSE. 0035 */ 0036 class CHARACTERSHEET_EXPORT CSItem : public TreeSheetItem 0037 { 0038 Q_OBJECT 0039 Q_PROPERTY(QString value READ value WRITE setValue NOTIFY valueChanged) 0040 Q_PROPERTY(int page READ page WRITE setPage NOTIFY pageChanged) 0041 Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged) 0042 Q_PROPERTY(QString formula READ formula WRITE setFormula NOTIFY formulaChanged) 0043 Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) 0044 Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged) 0045 Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged) 0046 Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged) 0047 Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged) 0048 Q_PROPERTY(BorderLine border READ border WRITE setBorder NOTIFY borderChanged) 0049 Q_PROPERTY(QColor bgColor READ bgColor WRITE setBgColor NOTIFY bgColorChanged) 0050 0051 public: 0052 enum BorderLine 0053 { 0054 UP= 1, 0055 LEFT= 2, 0056 DOWN= 4, 0057 RIGHT= 8, 0058 ALL= 15, 0059 NONE= 16 0060 }; 0061 Q_ENUM(BorderLine) 0062 enum TypeField 0063 { 0064 TEXTINPUT, 0065 TEXTFIELD, 0066 TEXTAREA, 0067 SELECT, 0068 CHECKBOX, 0069 IMAGE, 0070 RLABEL, 0071 DICEBUTTON, 0072 FUNCBUTTON, 0073 WEBPAGE, 0074 SLIDER, 0075 HIDDEN, 0076 NEXTPAGE, 0077 PREVIOUSPAGE, 0078 TABLE 0079 }; 0080 Q_ENUM(TypeField) 0081 CSItem(TreeSheetItem::TreeItemType type, QObject* parent= nullptr, bool addCount= true); 0082 0083 QColor bgColor() const; 0084 QColor textColor() const; 0085 virtual qreal x() const; 0086 virtual qreal y() const; 0087 virtual qreal width() const; 0088 virtual qreal height() const; 0089 CSItem::BorderLine border() const; 0090 bool hasFormula() const; 0091 0092 QString label() const; 0093 QString value() const; 0094 bool isReadOnly() const; 0095 int page() const; 0096 QString formula() const; 0097 virtual void setSecondPosition(QPointF nend); 0098 virtual QVariant valueFrom(TreeSheetItem::ColumnId, int role) const; 0099 virtual void setValueFrom(TreeSheetItem::ColumnId, const QVariant& data); 0100 0101 CSItem::TypeField fieldType() const; 0102 void setFieldType(const CSItem::TypeField& currentType); 0103 0104 QString getTooltip() const; 0105 void setTooltip(const QString& tooltip); 0106 0107 CSItem* orig() const; 0108 void setOrig(TreeSheetItem* orig) override; 0109 0110 static void resetCount(); 0111 static void setCount(int i); 0112 0113 virtual void setFieldInDictionnary(QHash<QString, QString>& dict) const override; 0114 public slots: 0115 void setBgColor(const QColor& bgColor); 0116 void setTextColor(const QColor& textColor); 0117 virtual void setX(qreal x); 0118 virtual void setY(qreal y); 0119 virtual void setWidth(qreal width); 0120 virtual void setHeight(qreal height); 0121 void setBorder(const CSItem::BorderLine& border); 0122 virtual void setValue(const QString& value, bool fromNetwork= false); 0123 void setReadOnly(bool readOnly); 0124 void setPage(int page); 0125 void setLabel(const QString& label); 0126 void setFormula(const QString& formula); 0127 void updateLabelFromOrigin(); 0128 0129 signals: 0130 void xChanged(); 0131 void yChanged(); 0132 void widthChanged(); 0133 void heightChanged(); 0134 void borderChanged(); 0135 void valueChanged(); 0136 void textColorChanged(); 0137 void textAlignChanged(); 0138 void bgColorChanged(); 0139 void valuesChanged(); 0140 void pageChanged(); 0141 void readOnlyChanged(); 0142 void formulaChanged(); 0143 void labelChanged(); 0144 0145 protected: 0146 QSizeF m_rect; 0147 QPointF m_pos; 0148 QColor m_bgColor; 0149 QColor m_textColor; 0150 BorderLine m_border; 0151 QPointF m_posPrivate; 0152 int m_page; 0153 QString m_value; 0154 QString m_label; 0155 QString m_tooltip; 0156 QString m_formula; 0157 bool m_readOnly; 0158 bool m_hasDefaultValue; 0159 TypeField m_fieldType; 0160 QPointer<CSItem> m_orig; 0161 bool m_fromNetwork= false; 0162 0163 static int m_count; 0164 }; 0165 0166 #endif // CSITEM_H