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

0001 /* This file is part of the TikZKit project.
0002  *
0003  * Copyright (C) 2013-2014 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 
0020 #ifndef TIKZ_METAPOS_P_H
0021 #define TIKZ_METAPOS_P_H
0022 
0023 #include "tikz.h"
0024 
0025 #include "Uid.h"
0026 #include "Pos.h"
0027 #include <QSharedPointer>
0028 
0029 namespace tikz {
0030 namespace core {
0031 
0032 class Document;
0033 class MetaPos;
0034 class MetaPosHelper;
0035 
0036 /**
0037  * Private data structure for MetaPos.
0038  */
0039 class MetaPosPrivate : public QObject
0040 {
0041     Q_OBJECT
0042 
0043     public:
0044         MetaPos * q = nullptr;
0045         Document * doc = nullptr;
0046 
0047         tikz::Pos pos;
0048         Uid nodeId;
0049         QString anchor;
0050 
0051     public:
0052         MetaPosPrivate(MetaPos * metaPos);
0053 
0054     public:
0055         /**
0056          * Start changing the MetaPos.
0057          * This call is ref-counted. For each beginChange() you finally
0058          * have to call endChange().
0059          */
0060         void beginChange();
0061 
0062         /**
0063          * End of changing the MetaPos.
0064          * This will call MetaPos::changed(), if the number of calls of endChange()
0065          * matches the calls the one of beginConfig(), i.e. the ref-counter is zero.
0066          *
0067          * Using beginConfig() and endChange() allows to change multiple
0068          * config values, while still only emitting the changed() signal only once.
0069          */
0070         void endChange();
0071 
0072     public Q_SLOTS:
0073         /**
0074          * This slot is called whenever attached Node%s changed.
0075          */
0076         void changeRequest();
0077 
0078     Q_SIGNALS:
0079         /**
0080          * This signal is emitted either when a new node is set with setNode(),
0081          * when the x/y position of the node changed, or when the associated
0082          * Style of the node changed.
0083          */
0084         void changed(tikz::core::MetaPos * metaPos);
0085 
0086     protected:
0087         /**
0088          * Change ref counter;
0089          */
0090         int changeRefCounter = 0;
0091 };
0092 
0093 }
0094 }
0095 
0096 #endif // TIKZ_METAPOS_P_H
0097 
0098 // kate: indent-width 4; replace-tabs on;