Seamly2D
Code documentation
plaintext_property.h
Go to the documentation of this file.
1 /************************************************************************
2  **
3  ** @file plaintext_property.h
4  ** @author DS Caskey
5  ** @date Feb 18, 2023
6  **
7  ** @brief
8  ** @copyright
9  ** This source code is part of the Seamly2D project, a pattern making
10  ** program, whose allow create and modeling patterns of clothing.
11  ** Copyright (C) 2017-2023 Seamly2D project
12  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
13  **
14  ** Seamly2D is free software: you can redistribute it and/or modify
15  ** it under the terms of the GNU General Public License as published by
16  ** the Free Software Foundation, either version 3 of the License, or
17  ** (at your option) any later version.
18  **
19  ** Seamly2D is distributed in the hope that it will be useful,
20  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
21  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  ** GNU General Public License for more details.
23  **
24  ** You should have received a copy of the GNU General Public License
25  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
26  **
27  *************************************************************************/
28 
29 #ifndef PLAINTEXT_PROPERTY_H
30 #define PLAINTEXT_PROPERTY_H
31 
32 #include <qcompilerdetection.h>
33 #include <QMap>
34 #include <QMetaObject>
35 #include <QObject>
36 #include <QString>
37 #include <QStringList>
38 #include <QStyleOptionViewItem>
39 #include <QVariant>
40 #include <QtGlobal>
41 
42 #include "../vproperty.h"
43 
44 namespace VPE
45 {
46 
47 
48 //! Class for holding a plain text property
50 {
51  Q_OBJECT
52 public:
53  PlainTextProperty(const QString &name, const QMap<QString, QVariant> &settings);
54 
55  explicit PlainTextProperty(const QString &name);
56 
57  virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &options,
58  const QAbstractItemDelegate *delegate) Q_DECL_OVERRIDE;
59 
60 
61  virtual QVariant getEditorData(const QWidget *editor) const Q_DECL_OVERRIDE;
62 
63  void setReadOnly(bool readOnly);
64  void setOsSeparator(bool separator);
65  void setClearButtonEnable(bool value);
66 
67 
68  virtual void setSetting(const QString &key, const QVariant &value) Q_DECL_OVERRIDE;
69  virtual QVariant getSetting(const QString &key) const Q_DECL_OVERRIDE;
70  virtual QStringList getSettingKeys() const Q_DECL_OVERRIDE;
71 
72  virtual QString type() const Q_DECL_OVERRIDE;
73 
74  Q_REQUIRED_RESULT virtual VProperty *clone(bool include_children = true,
75  VProperty *container = nullptr) const Q_DECL_OVERRIDE;
76 
77  virtual void updateParent(const QVariant &value) Q_DECL_OVERRIDE;
78 
79  int getTypeForParent() const;
80  void setTypeForParent(int value);
81 
82 protected:
83  bool m_readOnly;
86 
87  virtual bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
88 
89 private:
90  Q_DISABLE_COPY(PlainTextProperty)
91 };
92 
93 }
94 #endif // PLAINTEXT_PROPERTY_H
Class for holding a plain text property.
void setReadOnly(bool readOnly)
virtual void updateParent(const QVariant &value) Q_DECL_OVERRIDE
virtual void setSetting(const QString &key, const QVariant &value) Q_DECL_OVERRIDE
setSetting Sets the settings.
virtual bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE
void setClearButtonEnable(bool value)
void setOsSeparator(bool separator)
virtual QVariant getEditorData(const QWidget *editor) const Q_DECL_OVERRIDE
getEditorData Gets the data from the widget @oaram editor
virtual Q_REQUIRED_RESULT VProperty * clone(bool include_children=true, VProperty *container=nullptr) const Q_DECL_OVERRIDE
clone Clones this property
PlainTextProperty(const QString &name, const QMap< QString, QVariant > &settings)
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &options, const QAbstractItemDelegate *delegate) Q_DECL_OVERRIDE
createEditor Returns an editor widget, or NULL if it doesn't supply one
void setTypeForParent(int value)
virtual QString type() const Q_DECL_OVERRIDE
type Returns a string containing the type of the property.
virtual QStringList getSettingKeys() const Q_DECL_OVERRIDE
getSettingKeys Returns the list of keys of the property's settings.
virtual QVariant getSetting(const QString &key) const Q_DECL_OVERRIDE
getSetting Gets the settings.his function has to be implemented in a subclass in order to have an eff...