File indexing completed on 2024-05-26 16:15:07
0001 /* This file is part of the KDE project 0002 * Copyright ( C ) 2010 Boudewijn Rempt <boud@valdyas.org> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Library General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2 of the License, or (at your option) any later version. 0008 * 0009 * This library is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 * Library General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU Library General Public License 0015 * along with this library; see the file COPYING.LIB. If not, write to 0016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 * Boston, MA 02110-1301, USA. 0018 */ 0019 #ifndef KOPAVIEWBASE_H 0020 #define KOPAVIEWBASE_H 0021 0022 #include "KoPageApp.h" 0023 #include "KoPAViewMode.h" 0024 0025 class KoPACanvasBase; 0026 class KoViewConverter; 0027 class KoPAPageBase; 0028 class KoPADocument; 0029 class KoZoomHandler; 0030 class KoZoomController; 0031 0032 #include "kopageapp_export.h" 0033 0034 class KoPAViewProxyObject; 0035 0036 /** 0037 * Base class defining the View interface the KoPAViewMode class needs. 0038 */ 0039 class KOPAGEAPP_EXPORT KoPAViewBase { 0040 0041 public: 0042 0043 // proxy QObject 0044 KoPAViewProxyObject *proxyObject; 0045 0046 explicit KoPAViewBase(); 0047 virtual ~KoPAViewBase(); 0048 0049 /// @return the canvas for the application 0050 virtual KoPACanvasBase * kopaCanvas() const = 0; 0051 0052 /// @return the document for the application 0053 virtual KoPADocument * kopaDocument() const = 0; 0054 0055 /// XXX 0056 virtual KoViewConverter * viewConverter( KoPACanvasBase * canvas ); 0057 virtual KoViewConverter * viewConverter() const; 0058 virtual KoZoomController * zoomController() const = 0; 0059 0060 virtual KoZoomHandler * zoomHandler(); 0061 virtual KoZoomHandler *zoomHandler() const; 0062 0063 /// Set the active page and updates the UI 0064 virtual void doUpdateActivePage( KoPAPageBase * page ) = 0; 0065 0066 /// Set page shown in the canvas to @p page 0067 virtual void setActivePage( KoPAPageBase * page ) = 0; 0068 0069 /// @return Page that is shown in the canvas 0070 virtual KoPAPageBase* activePage() const = 0; 0071 0072 /// XXX 0073 virtual void navigatePage( KoPageApp::PageNavigation pageNavigation ) = 0; 0074 0075 /** 0076 * @brief Enables/Disables the given actions 0077 * 0078 * The actions are of Type KoPAAction 0079 * 0080 * @param actions which should be enabled/disabled 0081 * @param enable new state of the actions 0082 */ 0083 virtual void setActionEnabled( int actions, bool enable ) = 0; 0084 0085 /// XXX 0086 virtual void updatePageNavigationActions() = 0; 0087 0088 /** 0089 * @brief Set the view mode 0090 * 0091 * @param mode the new view mode 0092 */ 0093 virtual void setViewMode( KoPAViewMode* mode ); 0094 0095 /// @return the active viewMode 0096 virtual KoPAViewMode* viewMode() const; 0097 0098 /// Insert a new page after the current one 0099 virtual void insertPage() = 0; 0100 0101 /// Paste the page if everything is ok 0102 virtual void pagePaste() = 0; 0103 0104 /// XXX 0105 virtual void editPaste() = 0; 0106 0107 /// XXX 0108 virtual void setShowRulers(bool show) = 0; 0109 0110 private: 0111 0112 class Private; 0113 Private * const d; 0114 }; 0115 0116 /** 0117 * QObject proxy class for handling signals and slots 0118 */ 0119 class KOPAGEAPP_EXPORT KoPAViewProxyObject : public QObject { 0120 0121 Q_OBJECT 0122 0123 public: 0124 0125 explicit KoPAViewProxyObject(KoPAViewBase * parent); 0126 0127 void emitActivePageChanged() { emit activePageChanged(); } 0128 0129 public Q_SLOTS: 0130 0131 /// Set the active page and updates the UI 0132 void updateActivePage( KoPAPageBase * page ) { m_view->viewMode()->updateActivePage(page); } 0133 0134 /// Shows/hides the rulers 0135 void setShowRulers(bool show) { m_view->setShowRulers(show); } 0136 0137 /// Insert a new page after the current one 0138 void insertPage() { m_view->insertPage(); } 0139 0140 void editPaste() { m_view->editPaste(); } 0141 0142 Q_SIGNALS: 0143 0144 /// Emitted every time the active page is changed 0145 void activePageChanged(); 0146 0147 private: 0148 0149 KoPAViewBase * m_view; 0150 }; 0151 0152 #endif // KOPAVIEWBASE_H