File indexing completed on 2024-04-28 16:13:35
0001 /* 0002 * This file is part of the KDE project 0003 * 0004 * Copyright (C) 2013 Arjen Hiemstra <ahiemstra@heimr.nl> 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 0023 0024 #ifndef CALLIGRA_COMPONENTS_DOCUMENT_H 0025 #define CALLIGRA_COMPONENTS_DOCUMENT_H 0026 0027 #include <QObject> 0028 0029 #include "Global.h" 0030 0031 class KoDocument; 0032 class KoZoomController; 0033 class KoCanvasController; 0034 class QGraphicsWidget; 0035 class KoFindBase; 0036 0037 namespace Calligra { 0038 namespace Components { 0039 0040 /** 0041 * \brief The Document object provides a loader for Calligra Documents. 0042 * 0043 */ 0044 class Document : public QObject 0045 { 0046 Q_OBJECT 0047 Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) 0048 Q_PROPERTY(QObject* document READ document NOTIFY documentChanged) 0049 Q_PROPERTY(QObject* part READ part NOTIFY documentChanged) 0050 Q_PROPERTY(Calligra::Components::DocumentType::Type documentType READ documentType NOTIFY documentTypeChanged) 0051 Q_PROPERTY(Calligra::Components::DocumentStatus::Status status READ status NOTIFY statusChanged) 0052 Q_PROPERTY(QSize documentSize READ documentSize NOTIFY documentSizeChanged) 0053 Q_PROPERTY(bool readOnly READ readOnly WRITE setReadOnly NOTIFY readOnlyChanged) 0054 0055 /** 0056 * \property currentIndex 0057 * \brief The current visible 'index', i.e. page, sheet or slide. 0058 * 0059 * Due to the abstraction of the difference between the three document types 0060 * we need some way to handle the "current visible item" based on an arbitrary 0061 * number. 0062 * 0063 * \default -1 if #source is not set or failed to load. 0 otherwise. 0064 * \get currentIndex() const 0065 * \set setcurrentIndex() 0066 * \notify currentIndexChanged() 0067 * 0068 * \todo This should probably be a property of View, but since DocumentImpl currently 0069 * creates the canvas it is currently pretty much a document property. 0070 */ 0071 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) 0072 /** 0073 * \property indexCount 0074 * \brief The number of "indexes" in the document, i.e. pages, slides, etc. 0075 * 0076 * \default 0 0077 * \get indexCount() const 0078 * \notify indexCountChanged() 0079 */ 0080 Q_PROPERTY(int indexCount READ indexCount NOTIFY indexCountChanged) 0081 0082 /** 0083 * \property textEditor 0084 * \brief The instance of KoTextEditor for the currently selected object in the document, or null 0085 * 0086 * \default null 0087 * \get textEditor() const 0088 * \notify textEditorChanged() 0089 */ 0090 Q_PROPERTY(QObject* textEditor READ textEditor NOTIFY textEditorChanged) 0091 0092 public: 0093 explicit Document(QObject* parent = 0); 0094 ~Document() override; 0095 0096 QUrl source() const; 0097 void setSource(const QUrl& value); 0098 0099 bool readOnly() const; 0100 void setReadOnly(bool readOnly); 0101 0102 DocumentType::Type documentType() const; 0103 DocumentStatus::Status status() const; 0104 QSize documentSize() const; 0105 QObject* document() const; 0106 virtual QObject* part() const; 0107 0108 /** 0109 * Getter for property #currentIndex. 0110 */ 0111 int currentIndex() const; 0112 /** 0113 * Setter for property #currentIndex. 0114 */ 0115 void setCurrentIndex(int newValue); 0116 /** 0117 * Getter for property #indexCount. 0118 */ 0119 int indexCount() const; 0120 0121 /** 0122 * \internal 0123 * These methods are used internally by the components and not exposed 0124 * to QML. 0125 * @{ 0126 */ 0127 KoFindBase* finder() const; 0128 QGraphicsWidget* canvas() const; 0129 KoCanvasController* canvasController() const; 0130 KoZoomController* zoomController() const; 0131 KoDocument* koDocument() const; 0132 0133 /** 0134 * \return The url of the link at point or an empty url if there is no link at point. 0135 */ 0136 virtual QUrl urlAtPoint( const QPoint& point ); 0137 0138 QObject* textEditor(); 0139 // Deselects any text selection present in the document, and deselects all shapes 0140 // This is highly useful, as it makes navigation prettier. 0141 Q_INVOKABLE void deselectEverything(); 0142 0143 /** 0144 * @} 0145 */ 0146 Q_SIGNALS: 0147 void sourceChanged(); 0148 void statusChanged(); 0149 void documentChanged(); 0150 void readOnlyChanged(); 0151 void documentSizeChanged(); 0152 void documentTypeChanged(); 0153 void textEditorChanged(); 0154 0155 /** 0156 * Notify signal for property #currentIndex. 0157 */ 0158 void currentIndexChanged(); 0159 /** 0160 * Notify signal for property #indexCount 0161 */ 0162 void indexCountChanged(); 0163 /** 0164 * \brief Emitted whenever the backend wants to update the view. 0165 */ 0166 void requestViewUpdate(); 0167 0168 private: 0169 class Private; 0170 Private* const d; 0171 }; 0172 0173 } // Namespace Components 0174 } // Namespace Calligra 0175 0176 Q_DECLARE_METATYPE(Calligra::Components::Document*) 0177 0178 #endif // CALLIGRA_COMPONENTS_DOCUMENT_H