1 /************************************************************************ 2 ** 3 ** @file vdatatool.h 4 ** @author Roman Telezhynskyi <dismine(at)gmail.com> 5 ** @date November 15, 2013 6 ** 7 ** @brief 8 ** @copyright 9 ** This source code is part of the Valentina project, a pattern making 10 ** program, whose allow create and modeling patterns of clothing. 11 ** Copyright (C) 2013-2015 Valentina project 12 ** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved. 13 ** 14 ** Valentina 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 ** Valentina 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 Valentina. If not, see <http://www.gnu.org/licenses/>. 26 ** 27 *************************************************************************/ 28 29 #ifndef VDATATOOL_H 30 #define VDATATOOL_H 31 32 #include <qcompilerdetection.h> 33 #include <QMetaObject> 34 #include <QObject> 35 #include <QString> 36 #include <QtGlobal> 37 #include <QLoggingCategory> 38 39 #include "../vpatterndb/vcontainer.h" 40 Q_DECLARE_LOGGING_CATEGORY(vTool)41Q_DECLARE_LOGGING_CATEGORY(vTool) 42 43 //We need QObject class because we use qobject_cast. 44 /** 45 * @brief The VDataTool class need for getting access to data container of tool. 46 */ 47 class VDataTool : public QObject 48 { 49 Q_OBJECT 50 public: 51 explicit VDataTool(VContainer *data, QObject *parent = nullptr); 52 virtual ~VDataTool() Q_DECL_EQ_DEFAULT; 53 VContainer getData() const; 54 void setData(const VContainer *value); 55 virtual quint32 referens() const; 56 virtual void incrementReferens(); 57 virtual void decrementReferens(); 58 virtual void GroupVisibility(quint32 object, bool visible)=0; 59 protected: 60 /** @brief data container with data */ 61 VContainer data; 62 63 /** @brief _referens keep count tools what use this tool. If value more than 1 you can't delete tool. */ 64 quint32 _referens; 65 private: 66 Q_DISABLE_COPY(VDataTool) 67 }; 68 69 //--------------------------------------------------------------------------------------------------------------------- 70 /** 71 * @brief getData return data container. 72 * @return container. 73 */ getData()74inline VContainer VDataTool::getData() const 75 { 76 return data; 77 } 78 79 //--------------------------------------------------------------------------------------------------------------------- 80 /** 81 * @brief setData set data container. 82 * @param value container. 83 */ setData(const VContainer * value)84inline void VDataTool::setData(const VContainer *value) 85 { 86 data = *value; 87 } 88 89 //--------------------------------------------------------------------------------------------------------------------- 90 /** 91 * @brief referens return count of referens. 92 * @return count count of referens. 93 */ referens()94inline quint32 VDataTool::referens() const 95 { 96 return _referens; 97 } 98 99 //--------------------------------------------------------------------------------------------------------------------- 100 /** 101 * @brief incrementReferens increment referens. 102 */ incrementReferens()103inline void VDataTool::incrementReferens() 104 { 105 ++_referens; 106 } 107 108 #endif // VDATATOOL_H 109