File indexing completed on 2024-05-12 04:35:04

0001 /* This file is part of the TikZKit project.
0002  *
0003  * Copyright (C) 2016 Dominik Haumann <dhaumann@kde.org>
0004  *
0005  * This library is free software; you can redistribute it and/or modify
0006  * it under the terms of the GNU Library General Public License as published
0007  * by the Free Software Foundation, either version 2 of the License, or
0008  * (at your option) any later version.
0009  *
0010  * This library 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 Library General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Library General Public License
0016  * along with this library; see the file COPYING.LIB.  If not, see
0017  * <http://www.gnu.org/licenses/>.
0018  */
0019 #ifndef TIKZ_CORE_STRING_PROPERTY_H
0020 #define TIKZ_CORE_STRING_PROPERTY_H
0021 
0022 #include "Property.h"
0023 
0024 namespace tikz {
0025 namespace core {
0026 
0027 /**
0028  * Color property.
0029  */
0030 class TIKZKITCORE_EXPORT StringProperty : public Property
0031 {
0032 public:
0033     /**
0034      * Constructor that creates a property @p propertyName as part of @p entity.
0035      */
0036     explicit StringProperty(const QString & propertyName, PropertyInterface * interface);
0037 
0038     /**
0039      * Virtual destructor.
0040      */
0041     virtual ~StringProperty();
0042 
0043 public:
0044     /**
0045      * Set the text of this property to @p text.
0046      */
0047     void setText(const QString & text);
0048 
0049     /**
0050      * Returns the text of this property.
0051      */
0052     QString text() const;
0053 
0054 public: // Property overrides
0055     /**
0056      * Returns the type of the property.
0057      * The type is used to cast the property to the respective derived type.
0058      */
0059     const char * propertyType() const override;
0060 
0061     /**
0062      * Reset the property to its default value.
0063      * @see isSet()
0064      */
0065     void unset() override;
0066 
0067 protected:
0068     /**
0069      * Load the payload of the Property state from the @p json object.
0070      */
0071     void loadData(const QJsonObject & json) override;
0072 
0073     /**
0074      * Save the payload of the Property state to the @p json object.
0075      */
0076     void saveData(QJsonObject & json) override;
0077 
0078 private:
0079     QString m_text;
0080 };
0081 
0082 } //namespace core
0083 } //namespace tikz
0084 
0085 #endif // TIKZ_CORE_STRING_PROPERTY_H
0086 
0087 // kate: indent-width 4; replace-tabs on;