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

0001 /*
0002  * This file is part of the KDE project
0003  *
0004  * SPDX-FileCopyrightText: 2013 Shantanu Tushar <shantanu@kde.org>
0005  * SPDX-FileCopyrightText: 2013 Sujith Haridasan <sujith.h@gmail.com>
0006  * SPDX-FileCopyrightText: 2013 Arjen Hiemstra <ahiemstra@heimr.nl>
0007  *
0008  * SPDX-License-Identifier: LGPL-2.0-or-later
0009  *
0010  */
0011 
0012 #ifndef CQTEXTDOCUMENTCANVAS_H
0013 #define CQTEXTDOCUMENTCANVAS_H
0014 
0015 #include "CQCanvasBase.h"
0016 
0017 class KWDocument;
0018 class KoDocument;
0019 class KoCanvasController;
0020 class KoCanvasBase;
0021 class KoFindMatch;
0022 
0023 class CQTextDocumentCanvas : public CQCanvasBase
0024 {
0025     Q_OBJECT
0026     Q_PROPERTY(QString searchTerm READ searchTerm WRITE setSearchTerm NOTIFY searchTermChanged)
0027     Q_PROPERTY(QObject* documentModel READ documentModel NOTIFY documentModelChanged)
0028     Q_PROPERTY(QObject* document READ doc NOTIFY documentModelChanged);
0029     Q_PROPERTY(QSize documentSize READ documentSize NOTIFY documentSizeChanged)
0030     Q_PROPERTY(int currentPageNumber READ currentPageNumber WRITE setCurrentPageNumber NOTIFY currentPageNumberChanged)
0031     Q_PROPERTY(QObjectList linkTargets READ linkTargets NOTIFY linkTargetsChanged)
0032     Q_PROPERTY(QObject* textEditor READ textEditor NOTIFY textEditorChanged)
0033     Q_PROPERTY(QObject* notes READ notes NOTIFY notesChanged)
0034 
0035     Q_PROPERTY(bool hasSelection READ hasSelection NOTIFY selectionChanged)
0036     Q_PROPERTY(QRectF selectionStartPos READ selectionStartPos NOTIFY selectionChanged)
0037     Q_PROPERTY(QRectF selectionEndPos READ selectionEndPos NOTIFY selectionChanged)
0038     Q_PROPERTY(QObject* zoomAction READ zoomAction NOTIFY zoomActionChanged)
0039 
0040     Q_PROPERTY(QSizeF thumbnailSize READ thumbnailSize WRITE setThumbnailSize NOTIFY thumbnailSizeChanged)
0041 public:
0042     explicit CQTextDocumentCanvas(QDeclarativeItem* parent = 0);
0043     virtual ~CQTextDocumentCanvas();
0044 
0045     int currentPageNumber() const;
0046     void setCurrentPageNumber(const int &currentPageNumber);
0047     int cameraY() const;
0048     void setCameraY (int cameraY);
0049 
0050     QString searchTerm() const;
0051     void setSearchTerm(const QString &term);
0052 
0053     QObject *documentModel() const;
0054     QSize documentSize() const;
0055 
0056     virtual void render(QPainter* painter, const QRectF& target);
0057 
0058     KWDocument* document() const;
0059     Q_INVOKABLE QObject* doc() const;
0060     Q_INVOKABLE QObject* part() const;
0061 
0062     QObjectList linkTargets() const;
0063 
0064     Q_INVOKABLE qreal pagePosition( int page );
0065 
0066     virtual qreal shapeTransparency() const;
0067     virtual void setShapeTransparency(qreal newTransparency);
0068 
0069     QObject* textEditor();
0070     // Deselects any text selection present in the document, and deselects all shapes
0071     // This is highly useful, as it makes navigation prettier.
0072     Q_INVOKABLE void deselectEverything();
0073 
0074     // A list model of notes as created using addSticker(QString) and addNote(QString, QColor)
0075     QObject* notes() const;
0076     // Adds a sticker (simply an SVG) to the position indicated by the center of the viewport.
0077     Q_INVOKABLE void addSticker(const QString& imageUrl);
0078     // Adds a note to the position indicated by the center of the viewport. Color is the color
0079     // the text and the background sticker should have.
0080     Q_INVOKABLE void addNote(const QString& text, const QString& color, const QString& imageUrl);
0081 
0082     bool hasSelection() const;
0083     QRectF selectionStartPos() const;
0084     QRectF selectionEndPos() const;
0085 
0086     QObject* zoomAction() const;
0087 
0088     QSizeF thumbnailSize() const;
0089     void setThumbnailSize(const QSizeF& newSize);
0090 Q_SIGNALS:
0091     void searchTermChanged();
0092     void documentModelChanged();
0093     void documentSizeChanged();
0094     void currentPageNumberChanged();
0095     void cameraYChanged();
0096     void linkTargetsChanged();
0097     void textEditorChanged();
0098     void notesChanged();
0099     void selectionChanged();
0100     void zoomActionChanged();
0101     void thumbnailSizeChanged();
0102 
0103 protected:
0104     virtual bool event( QEvent* event );
0105     virtual void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry);
0106     virtual void openFile(const QString& uri);
0107     virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *e);
0108     virtual void mousePressEvent(QGraphicsSceneMouseEvent *e);
0109     virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *e);
0110     virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *e);
0111 
0112 private Q_SLOTS:
0113     void findNoMatchFound();
0114     void findMatchFound(const KoFindMatch& match);
0115     void updateCanvas();
0116     void findPrevious();
0117     void findNext();
0118     void updateDocumentSize(const QSize &size);
0119     void currentToolChanged(KoCanvasController* controller, int uniqueToolId);
0120 
0121 private:
0122     void createAndSetCanvasControllerOn(KoCanvasBase *canvas);
0123     void createAndSetZoomController(KoCanvasBase *canvas);
0124     void updateZoomControllerAccordingToDocument(const KoDocument *document);
0125     void alignTopWith(int y);
0126     void gotoPage(int pageNumber, KoDocument *document);
0127 
0128     class Private;
0129     Private * const d;
0130 };
0131 #endif // CQTEXTDOCUMENTCANVAS_H