Warning, file /office/calligra/libs/pageapp/KoPAView.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-2009 Thorsten Zachmann <zachmann@kde.org> 0004 Copyright (C) 2009 Inge Wallin <inge@lysator.liu.se> 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 KOPAVIEW_H 0023 #define KOPAVIEW_H 0024 0025 #include "KoPAViewBase.h" 0026 #include "KoPageApp.h" 0027 #include "kopageapp_export.h" 0028 0029 #include <KoView.h> 0030 #include <KoZoomMode.h> 0031 0032 class KoPart; 0033 class KoPACanvasBase; 0034 class KoPADocument; 0035 class KoPAPageBase; 0036 class KoPAViewMode; 0037 class KoPADocumentStructureDocker; 0038 class KoRuler; 0039 class KoShapeManager; 0040 class KoZoomController; 0041 class QUrl; 0042 class QAction; 0043 0044 class QTextDocument; 0045 class QTabBar; 0046 class KoCopyController; 0047 class KoCutController; 0048 class KoCanvasController; 0049 0050 /// Creates a view with a KoPACanvasBase and rulers 0051 class KOPAGEAPP_EXPORT KoPAView : public KoView, public KoPAViewBase 0052 { 0053 Q_OBJECT 0054 public: 0055 enum KoPAAction 0056 { 0057 ActionInsertPage = 1, 0058 ActionCopyPage = 2, 0059 ActionDeletePage = 4, 0060 ActionViewShowMasterPages = 8, 0061 ActionFormatMasterPage = 16, 0062 AllActions = 0xFF 0063 }; 0064 0065 enum KoPAFlags 0066 { 0067 NormalMode =1, 0068 ModeBox = 2 0069 }; 0070 0071 /** 0072 * Constructor 0073 * @param document the document of this view 0074 * @param parent the parent widget 0075 */ 0076 explicit KoPAView(KoPart *part, KoPADocument *document, KoPAFlags withModeBox, QWidget *parent); 0077 0078 ~KoPAView() override; 0079 0080 // KoPAViewBase/KoView overrides 0081 0082 void addImages(const QVector<QImage> &imageList, const QPoint &insertAt) override; 0083 0084 KoZoomController* zoomController() const override; 0085 0086 KoCopyController* copyController() const; 0087 0088 KoCutController* cutController() const; 0089 0090 QAction * deleteSelectionAction() const; 0091 0092 void updateReadWrite( bool readwrite ) override; 0093 0094 KoRuler *horizontalRuler(); 0095 KoRuler *verticalRuler(); 0096 0097 KoCanvasController *canvasController() const; 0098 /// @return the canvas for the application 0099 KoPACanvasBase * kopaCanvas() const override; 0100 /// @return the document for the application 0101 KoPADocument * kopaDocument() const override; 0102 /// @return Page that is shown in the canvas 0103 KoPAPageBase* activePage() const override; 0104 0105 /// Set page shown in the canvas to @p page 0106 void setActivePage( KoPAPageBase * page ) override; 0107 0108 void navigatePage( KoPageApp::PageNavigation pageNavigation ) override; 0109 0110 /// @return the shape manager used for this view 0111 KoShapeManager* shapeManager() const; 0112 0113 /// @return the master shape manager used for this view 0114 KoShapeManager* masterShapeManager() const; 0115 0116 /** 0117 * @brief Set the view mode 0118 * 0119 * @param mode the new view mode 0120 */ 0121 void setViewMode( KoPAViewMode* mode ) override; 0122 0123 /** 0124 * Set the active page and updates the UI 0125 */ 0126 void doUpdateActivePage( KoPAPageBase * page ) override; 0127 0128 /** 0129 * Paste the page if everything is ok 0130 */ 0131 void pagePaste() override; 0132 0133 /// reimplemented 0134 KoPrintJob * createPrintJob() override; 0135 0136 /** 0137 * Get the thumbnail for the page. 0138 * 0139 * Us this method instead the on in the pages directly 0140 */ 0141 QPixmap pageThumbnail(KoPAPageBase* page, const QSize& size); 0142 0143 /** 0144 * Save thumbnail to an image file. 0145 * 0146 * Export a thumbnail to disk using a pixmap file like e.g. PNG 0147 * This method uses a QPixmap::save() call. 0148 * 0149 * @param page page to get thumbnail of 0150 * @param url the url of the image file to be created 0151 * @param size the desired image size in px 0152 * @param format the format of the image file (see QPixmap::save()) 0153 * @param quality the quality of the image in [0,100] or -1 to use default (see QPixmap::save()) 0154 * 0155 * @returns whether the image was successfully saved 0156 */ 0157 bool exportPageThumbnail( KoPAPageBase * page, const QUrl &url, const QSize& size = QSize( 512, 512 ), 0158 const char * format = 0, int quality = -1 ); 0159 0160 /// Update page navigation actions 0161 void updatePageNavigationActions() override; 0162 0163 /// Shows/hides the rulers 0164 void setShowRulers(bool show) override; 0165 0166 /// Insert a new page after the current one 0167 void insertPage() override; 0168 0169 void centerPage(); 0170 0171 /// return a pointer to the tab bar (horizontal by default) 0172 QTabBar *tabBar() const; 0173 0174 /// set view Tab Bar position (vertical / horizontal) 0175 void setTabBarPosition(Qt::Orientation orientation); 0176 0177 /// Show a custom central widget and hides the standard one. 0178 void replaceCentralWidget(QWidget *newWidget); 0179 0180 /// hides any custom central widget and shows the standard widget. 0181 void restoreCentralWidget(); 0182 0183 Q_SIGNALS: 0184 /// emitted when select All action is triggered and the view is not visible 0185 void selectAllRequested(); 0186 /// emitted when deselect All action is triggered and the view is not visible 0187 void deselectAllRequested(); 0188 0189 protected: 0190 0191 /// creates the widgets (called from the constructor) 0192 void initGUI(KoPAFlags flags); 0193 /// creates the actions (called from the constructor) 0194 void initActions(); 0195 0196 /// Returns the document structure docker 0197 KoPADocumentStructureDocker* documentStructureDocker() const; 0198 0199 bool isMasterUsed( KoPAPageBase * page ); 0200 void editPaste() override; 0201 0202 void hideCustomCentralWidget(); 0203 0204 public Q_SLOTS: 0205 /** 0206 * @brief Enables/Disables the given actions 0207 * 0208 * The actions are of Type KoPAAction 0209 * 0210 * @param actions which should be enabled/disabled 0211 * @param enable new state of the actions 0212 */ 0213 void setActionEnabled( int actions, bool enable ) override; 0214 0215 /// Copy Page 0216 void copyPage(); 0217 0218 /// Delete the current page 0219 void deletePage(); 0220 0221 /// Make sure the canvas size matches the content 0222 void updateCanvasSize(bool forceUpdate = false); 0223 0224 /// Show/hide page margins 0225 void setShowPageMargins(bool state); 0226 0227 protected Q_SLOTS: 0228 0229 void pageUpdated(KoPAPageBase* page); 0230 void viewSnapToGrid(bool snap); 0231 void viewGuides(bool show); 0232 void slotZoomChanged( KoZoomMode::Mode mode, qreal zoom ); 0233 0234 void editDeleteSelection(); 0235 void editSelectAll(); 0236 void editDeselectAll(); 0237 0238 void formatMasterPage(); 0239 0240 void formatPageLayout(); 0241 0242 /// Change the current view mode to work on master pages 0243 void setMasterMode( bool master ); 0244 0245 // update the rulers 0246 void pageOffsetChanged(); 0247 0248 /// Called when the mouse position changes on the canvas 0249 virtual void updateMousePosition(const QPoint& position); 0250 0251 /// Called when the selection changed 0252 virtual void selectionChanged(); 0253 0254 /// Called when the clipboard changed 0255 virtual void clipboardDataChanged(); 0256 0257 /// Go to the previous page 0258 void goToPreviousPage(); 0259 /// Go to the next page 0260 void goToNextPage(); 0261 /// Go to the first page 0262 void goToFirstPage(); 0263 /// Go to the last page 0264 void goToLastPage(); 0265 0266 /** 0267 * Set the next document that should be used in find 0268 * 0269 * @param document The current document 0270 */ 0271 void findDocumentSetNext( QTextDocument * document ); 0272 0273 /** 0274 * Set the previous document that should be used in find 0275 * 0276 * @param document The current document 0277 */ 0278 void findDocumentSetPrevious( QTextDocument * document ); 0279 0280 /** 0281 * Re-initialize the document structure docker after active document in this 0282 * view has been changed 0283 */ 0284 void reinitDocumentDocker(); 0285 0286 /** 0287 * Import slideshow 0288 */ 0289 void importDocument(); 0290 0291 /** 0292 * Configure kopapage apps 0293 */ 0294 void configure(); 0295 0296 /** 0297 * This is called when the unit of the document changes 0298 */ 0299 void updateUnit(const KoUnit &unit); 0300 0301 protected: 0302 /// Re-implement this if you need special configuration control 0303 virtual void openConfiguration(); 0304 0305 private: 0306 class Private; 0307 Private * const d; 0308 }; 0309 0310 #endif /* KOPAVIEW_H */