Warning, file /office/calligra/libs/flake/KoConnectionShape.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2007 Boudewijn Rempt <boud@kde.org>
0003  * Copyright (C) 2007 Thorsten Zachmann <zachmann@kde.org>
0004  * Copyright (C) 2007 Jan Hambrecht <jaham@gmx.net>
0005  * Copyright (C) 2009 Thomas Zander <zander@kde.org>
0006  *
0007  * This library is free software; you can redistribute it and/or
0008  * modify it under the terms of the GNU Library General Public
0009  * License as published by the Free Software Foundation; either
0010  * version 2 of the License, or (at your option) any later version.
0011  *
0012  * This library is distributed in the hope that it will be useful,
0013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015  * Library General Public License for more details.
0016  *
0017  * You should have received a copy of the GNU Library General Public License
0018  * along with this library; see the file COPYING.LIB.  If not, write to
0019  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0020  * Boston, MA 02110-1301, USA.
0021  */
0022 
0023 #ifndef KO_CONNECTION_SHAPE_H
0024 #define KO_CONNECTION_SHAPE_H
0025 
0026 #include "KoParameterShape.h"
0027 
0028 #include "flake_export.h"
0029 
0030 #define KOCONNECTIONSHAPEID "KoConnectionShape"
0031 
0032 class KoConnectionShapePrivate;
0033 
0034 /// API docs go here
0035 class FLAKE_EXPORT KoConnectionShape : public KoParameterShape
0036 {
0037 public:
0038     enum Type {
0039         Standard, ///< escapes connected shapes with straight lines, connects with perpendicular lines
0040         Lines,    ///< escapes connected shapes with straight lines, connects with straight line
0041         Straight, ///< one straight line between connected shapes
0042         Curve     ///< a single curved line between connected shapes
0043     };
0044 
0045     // IDs of the connecting handles
0046     enum HandleId {
0047         StartHandle,
0048         EndHandle,
0049         ControlHandle_1,
0050         ControlHandle_2,
0051         ControlHandle_3
0052     };
0053 
0054     KoConnectionShape();
0055     ~KoConnectionShape() override;
0056 
0057     // reimplemented
0058     void saveOdf(KoShapeSavingContext &context) const override;
0059 
0060     // reimplemented
0061     bool loadOdf(const KoXmlElement &element, KoShapeLoadingContext &context) override;
0062 
0063     // reimplemented
0064     QString pathShapeId() const override;
0065 
0066     /**
0067      * Sets the first shape this connector is connected to
0068      *
0069      * Passing a null pointer as the first parameter will sever the connection.
0070      *
0071      * @param shape the shape to connect to or null to reset the connection
0072      * @param connectionPointId the id of the connection point to connect to
0073      * @return true if connection could be established, otherwise false
0074      */
0075     bool connectFirst(KoShape *shape, int connectionPointId);
0076 
0077     /**
0078     * Sets the second shape the connector is connected to
0079     *
0080     * Passing a null pointer as the first parameter will sever the connection.
0081     *
0082     * @param shape the shape to connect to or null to reset the connection
0083     * @param connectionPointId the id of the connection point to connect to
0084     * @return true if connection could be established, otherwise false
0085     */
0086     bool connectSecond(KoShape *shape, int connectionPointId);
0087 
0088     /**
0089      * Return the first shape this connection is attached to, or null if none.
0090      */
0091     KoShape *firstShape() const;
0092 
0093     /**
0094      * Return the connection point id of the first shape we are connected to.
0095      * In case we are not connected to a first shape the return value is undefined.
0096      * @see firstShape(), KoShape::connectionPoints()
0097      */
0098     int firstConnectionId() const;
0099 
0100     /**
0101      * Return the second shape this connection is attached to, or null if none.
0102      */
0103     KoShape *secondShape() const;
0104 
0105     /**
0106      * Return the connection point id of the second shape we are connected to.
0107      * In case we are not connected to a second shape the return value is undefined.
0108      * @see firstShape(), KoShape::connectionPoints()
0109      */
0110     int secondConnectionId() const;
0111 
0112     /**
0113      * Finishes the loading of a connection.
0114      */
0115     void finishLoadingConnection();
0116 
0117     /// Returns connection type
0118     Type type() const;
0119 
0120     /// Sets the connection type
0121     void setType(Type connectionType);
0122 
0123     /// Updates connections to shapes
0124     void updateConnections();
0125 
0126 protected:
0127     /// reimplemented
0128     void moveHandleAction(int handleId, const QPointF &point, Qt::KeyboardModifiers modifiers = Qt::NoModifier) override;
0129 
0130     /// reimplemented
0131     void updatePath(const QSizeF &size) override;
0132 
0133     /// reimplemented
0134     void shapeChanged(ChangeType type, KoShape *shape) override;
0135 
0136 private:
0137     Q_DECLARE_PRIVATE(KoConnectionShape)
0138 };
0139 
0140 #endif