Seamly2D
Code documentation
vlinetypeproperty.h
Go to the documentation of this file.
1 /******************************************************************************
2  * @file vlinetypeproperty.h
3  ** @author DS Caskey
4  ** @date Feb 7, 2023
5  **
6  ** @brief
7  ** @copyright
8  ** This source code is part of the Seamly2D project, a pattern making
9  ** program, whose allow create and modeling patterns of clothing.
10  ** Copyright (C) 2017-2023 Seamly2D project
11  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
12  **
13  ** Seamly2D is free software: you can redistribute it and/or modify
14  ** it under the terms of the GNU General Public License as published by
15  ** the Free Software Foundation, either version 3 of the License, or
16  ** (at your option) any later version.
17  **
18  ** Seamly2D is distributed in the hope that it will be useful,
19  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
20  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  ** GNU General Public License for more details.
22  **
23  ** You should have received a copy of the GNU General Public License
24  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
25  **
26  *************************************************************************/
27 
28 /************************************************************************
29  **
30  ** @file vlinetypeproperty.h
31  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
32  ** @date 29 1, 2015
33  **
34  ** @brief
35  ** @copyright
36  ** This source code is part of the Valentine project, a pattern making
37  ** program, whose allow create and modeling patterns of clothing.
38  ** Copyright (C) 2013-2015 Seamly2D project
39  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
40  **
41  ** Seamly2D is free software: you can redistribute it and/or modify
42  ** it under the terms of the GNU General Public License as published by
43  ** the Free Software Foundation, either version 3 of the License, or
44  ** (at your option) any later version.
45  **
46  ** Seamly2D is distributed in the hope that it will be useful,
47  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
48  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49  ** GNU General Public License for more details.
50  **
51  ** You should have received a copy of the GNU General Public License
52  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
53  **
54  *************************************************************************/
55 
56 #ifndef VLINETYPEPROPERTY_H
57 #define VLINETYPEPROPERTY_H
58 
59 #include <qcompilerdetection.h>
60 #include <QIcon>
61 #include <QMap>
62 #include <QMetaObject>
63 #include <QObject>
64 #include <QString>
65 #include <QStyleOptionViewItem>
66 #include <QVariant>
67 #include <QVector>
68 #include <Qt>
69 #include <QtGlobal>
70 
71 #include "../vproperty.h"
72 
73 namespace VPE
74 {
75 
77 {
78  Q_OBJECT
79 public:
80  //! Constructor
81  explicit LineTypeProperty(const QString &name);
82 
83  //! Destructor
84  virtual ~LineTypeProperty() Q_DECL_OVERRIDE {}
85 
86  //! Get the data how it should be displayed
87  virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
88 
89  //! Returns an editor widget, or NULL if it doesn't supply one
90  //! \param parent The widget to which the editor will be added as a child
91  //! \options Render options
92  //! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
93  //! slots.
94  virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &options,
95  const QAbstractItemDelegate *delegate) Q_DECL_OVERRIDE;
96 
97  //! Gets the data from the widget
98  virtual QVariant getEditorData(const QWidget *editor) const Q_DECL_OVERRIDE;
99 
100  //! Sets the line styles
101  virtual void setLineTypes(const QMap<QString, QString> &styles);
102 
103  //! Get the settings. This function has to be implemented in a subclass in order to have an effect
104  virtual QMap<QString, QString> getLineTypes() const;
105 
106  //! Sets the value of the property
107  virtual void setValue(const QVariant &value) Q_DECL_OVERRIDE;
108 
109  //! Returns a string containing the type of the property
110  virtual QString type() const Q_DECL_OVERRIDE;
111 
112  //! Clones this property
113  //! \param include_children Indicates whether to also clone the children
114  //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
115  //! to fill all the data into container. This can also be used when subclassing this function.
116  //! \return Returns the newly created property (or container, if it was not NULL)
117  Q_REQUIRED_RESULT virtual VProperty *clone(bool include_children = true,
118  VProperty *container = nullptr) const Q_DECL_OVERRIDE;
119 
120  static int indexOfLineType(const QMap<QString, QString> &styles, const QString &style);
121 
122 public slots:
123  void currentIndexChanged(int index);
124 
125 protected:
126  QMap<QString, QString> m_lineTypes;
130 
131 private:
132  QIcon createIcon(const QString &type);
133  Q_DISABLE_COPY(LineTypeProperty)
134 };
135 
136 }
137 
138 #endif // VLINETYPEPROPERTY_H
static int indexOfLineType(const QMap< QString, QString > &styles, const QString &style)
virtual QMap< QString, QString > getLineTypes() const
Get the settings. This function has to be implemented in a subclass in order to have an effect.
virtual void setValue(const QVariant &value) Q_DECL_OVERRIDE
Sets the value of the property.
virtual Q_REQUIRED_RESULT VProperty * clone(bool include_children=true, VProperty *container=nullptr) const Q_DECL_OVERRIDE
Clones this property.
void currentIndexChanged(int index)
QIcon createIcon(const QString &type)
virtual QString type() const Q_DECL_OVERRIDE
Returns a string containing the type of the property.
virtual QVariant getEditorData(const QWidget *editor) const Q_DECL_OVERRIDE
Gets the data from the widget.
virtual QVariant data(int column=DPC_Name, int role=Qt::DisplayRole) const Q_DECL_OVERRIDE
Get the data how it should be displayed.
LineTypeProperty(const QString &name)
Constructor.
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &options, const QAbstractItemDelegate *delegate) Q_DECL_OVERRIDE
Returns an editor widget, or NULL if it doesn't supply one.
QMap< QString, QString > m_lineTypes
QVector< QString > m_indexList
virtual void setLineTypes(const QMap< QString, QString > &styles)
Sets the line styles.
virtual ~LineTypeProperty() Q_DECL_OVERRIDE
Destructor.