File indexing completed on 2024-05-12 04:35:04
0001 /* This file is part of the TikZKit project. 0002 * 0003 * Copyright (C) 2015-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_PROPERTY_INTERFACE_H 0020 #define TIKZ_CORE_PROPERTY_INTERFACE_H 0021 0022 #include "tikz_export.h" 0023 0024 #include <QObject> // for Q_DECLARE_INTERFACE 0025 #include <QVector> 0026 0027 namespace tikz { 0028 namespace core { 0029 0030 class PropertyInterfacePrivate; 0031 class Property; 0032 class Entity; 0033 0034 /** 0035 * Interface to managing properties. 0036 * 0037 * @see Entity 0038 */ 0039 class TIKZKITCORE_EXPORT PropertyInterface 0040 { 0041 public: 0042 /** 0043 * Default constructor. 0044 */ 0045 PropertyInterface(); 0046 0047 /** 0048 * Virtual destructor. 0049 */ 0050 virtual ~PropertyInterface(); 0051 0052 /** 0053 * Returns the associated Entity of this PropertyInterface. 0054 * This function is used by properties thar rely on the underlying Entity. 0055 */ 0056 virtual Entity * entity() const = 0; 0057 0058 /** 0059 * Returns the associated Entity, or null, if no Entity was given. 0060 */ 0061 virtual PropertyInterface * parentPropertyInterface() const = 0; 0062 0063 /** 0064 * Adds @p property to the list of managed properties. 0065 */ 0066 void addProperty(Property * property); 0067 0068 /** 0069 * Removes @p property from the list of managed properties. 0070 */ 0071 void removeProperty(Property * property); 0072 0073 /** 0074 * Returns the property called @p propertyName. If the requested property 0075 * does not exist, either the parentPropertyInterface() is queried for the 0076 * requested property if @p fallbackToParents is set to @e true, or otherwise 0077 * a nullptr is returned. 0078 */ 0079 Property * property(const QString & propertyName, 0080 bool fallbackToParents = true) const; 0081 0082 /** 0083 * Returns @e true, if a property called @p propertyName exists, otherwise 0084 * @e false is returned. If @p fallbackToParents is set to @e true, the 0085 * parentPropertyInterface() is also queried for the requested property, 0086 * in case the property does not exist in this interface. 0087 */ 0088 bool hasProperty(const QString & propertyName, bool fallbackToParents = true); 0089 0090 /** 0091 * Returns a list of all properties managed by this PropertyInterface. 0092 * The returned list does not contain parent properties. 0093 */ 0094 QVector<Property *> properties() const; 0095 0096 // 0097 // Q_SIGNALS 0098 // 0099 public: 0100 /** 0101 * This signal is emitted whenever a property of this PropertyInterface 0102 * changed. 0103 * @param propertyInterface pointer to this PropertyInterface 0104 * @param property pointer to the changed property 0105 */ 0106 virtual void propertyChanged(PropertyInterface * propertyInterface, 0107 Property * property) = 0; 0108 0109 private: 0110 friend class PropertyPrivate; 0111 /** 0112 * Helper function that calls the signal propertyChanged() with 0113 */ 0114 void notifyPropertyChanged(Property * property); 0115 0116 /** 0117 * Helper function that calls the signal propertyChanged() with 0118 */ 0119 void notifyPropertyAboutToChange(Property * property); 0120 0121 private: 0122 // pimpl data pointer 0123 PropertyInterfacePrivate * const d; 0124 }; 0125 0126 } //namespace core 0127 } //namespace tikz 0128 0129 Q_DECLARE_INTERFACE(tikz::core::PropertyInterface, "org.tikzkit.core.PropertyInterface") 0130 0131 #endif // TIKZ_CORE_PROPERTY_INTERFACE_H 0132 0133 // kate: indent-width 4; replace-tabs on;