Seamly2D
Code documentation
lineweight_property.h
Go to the documentation of this file.
1 /******************************************************************************
2  * @file lineweight_property.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 #ifndef LINEWEIGHT_PROPERTY_H
29 #define LINEWEIGHT_PROPERTY_H
30 
31 #include <qcompilerdetection.h>
32 #include <QIcon>
33 #include <QMap>
34 #include <QMetaObject>
35 #include <QObject>
36 #include <QString>
37 #include <QStyleOptionViewItem>
38 #include <QVariant>
39 #include <QVector>
40 #include <Qt>
41 #include <QtGlobal>
42 
43 #include "../vproperty.h"
44 
45 namespace VPE
46 {
47 
49 {
50  Q_OBJECT
51 public:
52  //! Constructor
53  explicit LineWeightProperty(const QString &name);
54 
55  //! Destructor
56  virtual ~LineWeightProperty() Q_DECL_OVERRIDE {}
57 
58  //! Get the data how it should be displayed
59  virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
60 
61  //! Returns an editor widget, or NULL if it doesn't supply one
62  //! \param parent The widget to which the editor will be added as a child
63  //! \options Render options
64  //! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
65  //! slots.
66  virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &options,
67  const QAbstractItemDelegate *delegate) Q_DECL_OVERRIDE;
68 
69  //! Gets the data from the widget
70  virtual QVariant getEditorData(const QWidget *editor) const Q_DECL_OVERRIDE;
71 
72  //! Sets the line styles
73  virtual void setLineWeights(const QMap<QString, QString> &weights);
74 
75  //! Get the settings. This function has to be implemented in a subclass in order to have an effect
76  virtual QMap<QString, QString> getLineWeights() const;
77 
78  //! Sets the value of the property
79  virtual void setValue(const QVariant &value) Q_DECL_OVERRIDE;
80 
81  //! Returns a string containing the type of the property
82  virtual QString type() const Q_DECL_OVERRIDE;
83 
84  //! Clones this property
85  //! \param include_children Indicates whether to also clone the children
86  //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
87  //! to fill all the data into container. This can also be used when subclassing this function.
88  //! \return Returns the newly created property (or container, if it was not NULL)
89  Q_REQUIRED_RESULT virtual VProperty *clone(bool include_children = true,
90  VProperty *container = nullptr) const Q_DECL_OVERRIDE;
91 
92  static int indexOfLineWeight(const QMap<QString, QString> &lineWeights, const QString &weight);
93 
94 public slots:
95  void currentIndexChanged(int index);
96 
97 protected:
98  QMap<QString, QString> m_lineWeights;
99  QVector<QString> m_indexList;
102 
103 private:
104  QIcon createIcon(const qreal &width);
105  Q_DISABLE_COPY(LineWeightProperty)
106 };
107 
108 }
109 
110 #endif // LINEWEIGHT_PROPERTY_H
LineWeightProperty(const QString &name)
Constructor.
virtual void setValue(const QVariant &value) Q_DECL_OVERRIDE
Sets the value of the property.
virtual QVariant getEditorData(const QWidget *editor) const Q_DECL_OVERRIDE
Gets the data from the widget.
virtual Q_REQUIRED_RESULT VProperty * clone(bool include_children=true, VProperty *container=nullptr) const Q_DECL_OVERRIDE
Clones this property.
virtual ~LineWeightProperty() Q_DECL_OVERRIDE
Destructor.
virtual void setLineWeights(const QMap< QString, QString > &weights)
Sets the line styles.
virtual QVariant data(int column=DPC_Name, int role=Qt::DisplayRole) const Q_DECL_OVERRIDE
Get the data how it should be displayed.
QMap< QString, QString > m_lineWeights
static int indexOfLineWeight(const QMap< QString, QString > &lineWeights, const QString &weight)
QIcon createIcon(const qreal &width)
QVector< QString > m_indexList
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.
virtual QString type() const Q_DECL_OVERRIDE
Returns a string containing the type of the property.
virtual QMap< QString, QString > getLineWeights() const
Get the settings. This function has to be implemented in a subclass in order to have an effect.