1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
/* This file is part of the KDE project
* Copyright ( C ) 2010 Boudewijn Rempt <boud@valdyas.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KOPAVIEWBASE_H
#define KOPAVIEWBASE_H
#include "KoPageApp.h"
#include "KoPAViewMode.h"
class KoPACanvasBase;
class KoViewConverter;
class KoPAPageBase;
class KoPADocument;
class KoZoomHandler;
class KoZoomController;
#include "kopageapp_export.h"
class KoPAViewProxyObject;
/**
* Base class defining the View interface the KoPAViewMode class needs.
*/
class KOPAGEAPP_EXPORT KoPAViewBase {
public:
// proxy QObject
KoPAViewProxyObject *proxyObject;
explicit KoPAViewBase();
virtual ~KoPAViewBase();
/// @return the canvas for the application
virtual KoPACanvasBase * kopaCanvas() const = 0;
/// @return the document for the application
virtual KoPADocument * kopaDocument() const = 0;
/// XXX
virtual KoViewConverter * viewConverter( KoPACanvasBase * canvas );
virtual KoViewConverter * viewConverter() const;
virtual KoZoomController * zoomController() const = 0;
virtual KoZoomHandler * zoomHandler();
virtual KoZoomHandler *zoomHandler() const;
/// Set the active page and updates the UI
virtual void doUpdateActivePage( KoPAPageBase * page ) = 0;
/// Set page shown in the canvas to @p page
virtual void setActivePage( KoPAPageBase * page ) = 0;
/// @return Page that is shown in the canvas
virtual KoPAPageBase* activePage() const = 0;
/// XXX
virtual void navigatePage( KoPageApp::PageNavigation pageNavigation ) = 0;
/**
* @brief Enables/Disables the given actions
*
* The actions are of Type KoPAAction
*
* @param actions which should be enabled/disabled
* @param enable new state of the actions
*/
virtual void setActionEnabled( int actions, bool enable ) = 0;
/// XXX
virtual void updatePageNavigationActions() = 0;
/**
* @brief Set the view mode
*
* @param mode the new view mode
*/
virtual void setViewMode( KoPAViewMode* mode );
/// @return the active viewMode
virtual KoPAViewMode* viewMode() const;
/// Insert a new page after the current one
virtual void insertPage() = 0;
/// Paste the page if everything is ok
virtual void pagePaste() = 0;
/// XXX
virtual void editPaste() = 0;
/// XXX
virtual void setShowRulers(bool show) = 0;
private:
class Private;
Private * const d;
};
/**
* QObject proxy class for handling signals and slots
*/
class KOPAGEAPP_EXPORT KoPAViewProxyObject : public QObject {
Q_OBJECT
public:
explicit KoPAViewProxyObject(KoPAViewBase * parent);
void emitActivePageChanged() { emit activePageChanged(); }
public Q_SLOTS:
/// Set the active page and updates the UI
void updateActivePage( KoPAPageBase * page ) { m_view->viewMode()->updateActivePage(page); }
/// Shows/hides the rulers
void setShowRulers(bool show) { m_view->setShowRulers(show); }
/// Insert a new page after the current one
void insertPage() { m_view->insertPage(); }
void editPaste() { m_view->editPaste(); }
Q_SIGNALS:
/// Emitted every time the active page is changed
void activePageChanged();
private:
KoPAViewBase * m_view;
};
#endif // KOPAVIEWBASE_H
|