File indexing completed on 2024-05-19 04:36:35
0001 /* This file is part of the KDE libraries 0002 Copyright (C) 2001-2014 Christoph Cullmann <cullmann@kde.org> 0003 Copyright (C) 2005-2014 Dominik Haumann (dhaumann@kde.org) 0004 0005 This library is free software; you can redistribute it and/or 0006 modify it under the terms of the GNU Library General Public 0007 License as published by the Free Software Foundation; either 0008 version 2 of the License, or (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 GNU 0013 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, write to 0017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #ifndef TIKZ_UI_DOCUMENT_H 0022 #define TIKZ_UI_DOCUMENT_H 0023 0024 #include "tikzui_export.h" 0025 0026 #include <tikz/core/Document.h> 0027 0028 class QGraphicsView; 0029 0030 namespace tikz { 0031 namespace ui { 0032 0033 class DocumentPrivate; 0034 class View; 0035 class MainWindow; 0036 0037 class NodeItem; 0038 class PathItem; 0039 0040 class TIKZKITUI_EXPORT Document : public tikz::core::Document 0041 { 0042 Q_OBJECT 0043 0044 protected: 0045 /** 0046 * Constructor. 0047 * 0048 * Create a new document with \p parent. 0049 * 0050 * Pass it the internal implementation to store a d-pointer. 0051 * 0052 * \param impl d-pointer to use 0053 * \param parent parent object 0054 * \see Editor::createDocument() 0055 */ 0056 Document(DocumentPrivate * impl, QObject *parent); 0057 0058 public: 0059 /** 0060 * Virtual destructor. 0061 */ 0062 virtual ~Document(); 0063 0064 public: 0065 /** 0066 * Create a new view attached to @p parent. 0067 * @param parent parent widget 0068 * @return the new view 0069 */ 0070 virtual View *createView(QWidget * parent, 0071 tikz::ui::MainWindow * mainWindow = nullptr) = 0; 0072 0073 /** 0074 * Returns the views pre-casted to tikz::ui::View%s 0075 */ 0076 virtual QVector<View *> views() const = 0; 0077 0078 Q_SIGNALS: 0079 /** 0080 * This signal is emitted whenever the \p document creates a new \p view. 0081 * It should be called for every view to help applications / plugins to 0082 * attach to the \p view. 0083 * \attention This signal should be emitted after the view constructor is 0084 * completed, e.g. in the createView() method. 0085 * \param document the document for which a new view is created 0086 * \param view the new view 0087 * \see createView() 0088 */ 0089 void viewCreated(tikz::ui::Document *document, tikz::ui::View *view); 0090 0091 public: 0092 /** 0093 * Returns all NodeItem%s in the DocumentPrivate. 0094 */ 0095 virtual QVector<NodeItem*> nodeItems() const = 0; 0096 0097 /** 0098 * Returns all PathItem%s in the DocumentPrivate. 0099 */ 0100 virtual QVector<PathItem*> pathItems() const = 0; 0101 0102 /** 0103 * Creates a new NodeItem associated with this document. 0104 * If the node is not needed anymore, delete it by 0105 * calling deleteNodeItem(nodeItem). 0106 */ 0107 virtual NodeItem * createNodeItem() = 0; 0108 0109 /** 0110 * Creates a new path associated with this document. 0111 * If the path is not needed anymore, delete it by 0112 * calling deletePathItem(pathItem). 0113 */ 0114 virtual tikz::ui::PathItem * createPathItem(tikz::PathType type = tikz::PathType::Line) = 0; 0115 0116 /** 0117 * Remove @p node from the document by deleting the node object. 0118 * Afterwards, the pointer is invalid. 0119 * @param node node to delete 0120 */ 0121 virtual void deleteNodeItem(NodeItem * node) = 0; 0122 0123 /** 0124 * Remove @p path from the document by deleting the path object. 0125 * Afterwards, the pointer is invalid. 0126 * @param path path to delete 0127 */ 0128 virtual void deletePathItem(tikz::ui::PathItem * path) = 0; 0129 0130 private: 0131 /** 0132 * private d-pointer, pointing to the internal implementation 0133 */ 0134 DocumentPrivate * const d; 0135 }; 0136 0137 } 0138 } 0139 0140 #endif // TIKZ_UI_DOCUMENT_H 0141 0142 // kate: indent-width 4; replace-tabs on;