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