Warning, file /office/calligra/libs/flake/KoShapeController.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 * 0003 * Copyright (C) 2006-2007, 2010 Thomas Zander <zander@kde.org> 0004 * Copyright (C) 2006-2008 Thorsten Zachmann <zachmann@kde.org> 0005 * 0006 * This library is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU Library General Public 0008 * License as published by the Free Software Foundation; either 0009 * version 2 of the License, or (at your option) any later version. 0010 * 0011 * This library is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 * Library General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU Library General Public License 0017 * along with this library; see the file COPYING.LIB. If not, write to 0018 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0019 * Boston, MA 02110-1301, USA. 0020 */ 0021 0022 #ifndef KOSHAPECONTROLLER_H 0023 #define KOSHAPECONTROLLER_H 0024 0025 #include "flake_export.h" 0026 0027 #include <QList> 0028 #include <QMetaType> 0029 0030 class KoCanvasBase; 0031 class KoShape; 0032 class KoShapeBasedDocumentBase; 0033 class KUndo2Command; 0034 class KoDocumentResourceManager; 0035 0036 /** 0037 * Class used by tools to maintain the list of shapes. 0038 * All applications have some sort of list of all shapes that belong to the document. 0039 * The applications implement the KoShapeBasedDocumentBase interface (all pure virtuals) 0040 * to add and remove shapes from the document. To ensure that an application can expect 0041 * a certain protocol to be adhered to when adding/removing shapes, all tools use the API 0042 * from this class for maintaining the list of shapes in the document. So no tool gets 0043 * to access the application directly. 0044 */ 0045 class FLAKE_EXPORT KoShapeController 0046 { 0047 public: 0048 /** 0049 * Create a new Controller; typically not called by applications, only 0050 * by the KonCanvasBase constructor. 0051 * @param canvas the canvas this controller works for. The canvas can be 0 0052 * @param shapeBasedDocument the application provided shapeBasedDocument that we can call. 0053 */ 0054 KoShapeController(KoCanvasBase *canvas, KoShapeBasedDocumentBase *shapeBasedDocument); 0055 /// destructor 0056 ~KoShapeController(); 0057 0058 /** 0059 * @brief Add a shape to the document. 0060 * If the shape has no parent, the active layer will become its parent. 0061 * 0062 * @param shape to add to the document 0063 * @param parent the parent command if the resulting command is a compound undo command. 0064 * 0065 * @return command which will insert the shape into the document or 0 if the 0066 * insertion was cancelled. The command is not yet executed. 0067 */ 0068 KUndo2Command* addShape(KoShape *shape, KUndo2Command *parent = 0); 0069 0070 /** 0071 * @brief Add a shape to the document, skipping any dialogs or other user interaction. 0072 * 0073 * @param shape to add to the document 0074 * @param parent the parent command if the resulting command is a compound undo command. 0075 * 0076 * @return command which will insert the shape into the document. The command is not yet executed. 0077 */ 0078 KUndo2Command* addShapeDirect(KoShape *shape, KUndo2Command *parent = 0); 0079 0080 /** 0081 * @brief Remove a shape from the document. 0082 * 0083 * @param shape to remove from the document 0084 * @param parent the parent command if the resulting command is a compound undo command. 0085 * 0086 * @return command which will remove the shape from the document. 0087 * The command is not yet executed. 0088 */ 0089 KUndo2Command* removeShape(KoShape *shape, KUndo2Command *parent = 0); 0090 0091 /** 0092 * Remove a shape from the document. 0093 * 0094 * @param shapes the set of shapes to remove from the document 0095 * @param parent the parent command if the resulting command is a compound undo command. 0096 * 0097 * @return command which will remove the shape from the document. 0098 * The command is not yet executed. 0099 */ 0100 KUndo2Command* removeShapes(const QList<KoShape*> &shapes, KUndo2Command *parent = 0); 0101 0102 /** 0103 * @brief Set the KoShapeBasedDocumentBase used to add/remove shapes. 0104 * 0105 * NOTE: only Sheets uses this method. Do not use it in your application. Sheets 0106 * has to also call: 0107 * <code>KoToolManager::instance()->updateShapeControllerBase(shapeBasedDocument, canvas->canvasController());</code> 0108 * 0109 * @param shapeBasedDocument the new shapeBasedDocument. 0110 */ 0111 void setShapeControllerBase(KoShapeBasedDocumentBase *shapeBasedDocument); 0112 0113 /** 0114 * Return a pointer to the resource manager associated with the 0115 * shape-set (typically a document). The resource manager contains 0116 * document wide resources * such as variable managers, the image 0117 * collection and others. 0118 */ 0119 KoDocumentResourceManager *resourceManager() const; 0120 0121 /** 0122 * @brief Returns the KoShapeBasedDocumentBase used to add/remove shapes. 0123 * 0124 * @return the KoShapeBasedDocumentBase 0125 */ 0126 KoShapeBasedDocumentBase *documentBase() const; 0127 0128 private: 0129 class Private; 0130 Private * const d; 0131 }; 0132 0133 Q_DECLARE_METATYPE(KoShapeController *) 0134 0135 #endif