Commit c65b99ec authored by Thorsten Zachmann's avatar Thorsten Zachmann

o Added possibility to switch the view mode to work on master pages.

svn path=/trunk/koffice/; revision=651008
parent 8709b1b9
......@@ -153,6 +153,10 @@ void KoPAView::initActions()
m_actionViewSnapToGrid = new KToggleAction(i18n("Snap to Grid"), this);
actionCollection()->addAction("view_snaptogrid", m_actionViewSnapToGrid);
m_actionViewShowMasterPages = new KToggleAction(i18n( "Show Master Pages" ), this );
actionCollection()->addAction( "view_masterpages", m_actionViewShowMasterPages );
connect( m_actionViewShowMasterPages, SIGNAL( triggered( bool ) ), this, SLOT( setMasterMode( bool ) ) );
m_viewRulers = new KToggleAction(i18n("Show Rulers"), this);
actionCollection()->addAction("view_rulers", m_viewRulers );
m_viewRulers->setToolTip(i18n("Show/hide the view's rulers"));
......@@ -174,6 +178,11 @@ void KoPAView::slotZoomChanged( KoZoomMode::Mode mode, double zoom )
kopaCanvas()->update();
}
void KoPAView::setMasterMode( bool master )
{
m_viewMode->setMasterMode( master );
}
KoShapeManager* KoPAView::shapeManager() const
{
return m_canvas->shapeManager();
......
......@@ -91,6 +91,9 @@ protected slots:
void viewGrid();
void slotZoomChanged( KoZoomMode::Mode mode, double zoom );
/// Change the current view mode to work on master pages
void setMasterMode( bool master );
/// Called when the canvas controller is resized
virtual void canvasControllerResized();
......@@ -113,6 +116,7 @@ private:
KToggleAction *m_actionViewSnapToGrid;
KToggleAction *m_actionViewShowGrid;
KToggleAction *m_actionViewShowMasterPages;
KoRuler *m_horizontalRuler;
KoRuler *m_verticalRuler;
......
......@@ -48,6 +48,16 @@ public:
virtual void keyPressEvent( QKeyEvent *event ) = 0;
virtual void keyReleaseEvent( QKeyEvent *event ) = 0;
virtual void wheelEvent( QWheelEvent * event, const QPointF &point ) = 0;
/**
* @brief Switch the active view mode to work on master/normal pages
*
* The default implementation does not change anything. If it is needed in the
* view mode you have to implement it.
*
* @param master if true work on master pages, if false work on normal pages
*/
virtual void setMasterMode( bool master ) { Q_UNUSED(master); }
protected:
KoPACanvas * m_canvas;
......
......@@ -27,10 +27,14 @@
#include <KoShapeManager.h>
#include "KoPACanvas.h"
#include "KoPADocument.h"
#include "KoPAPage.h"
#include "KoPAMasterPage.h"
#include "KoPAView.h"
KoPAViewModeNormal::KoPAViewModeNormal( KoPAView * view, KoPACanvas * canvas )
: KoPAViewMode( view, canvas )
, m_masterMode( false )
, m_savedPage( 0 )
{
}
......@@ -112,3 +116,18 @@ void KoPAViewModeNormal::wheelEvent( QWheelEvent * event, const QPointF &point )
{
m_toolProxy->wheelEvent( event, point );
}
void KoPAViewModeNormal::setMasterMode( bool master )
{
KoPAPage * page = dynamic_cast<KoPAPage *>( m_view->activePage() );
if ( master ) {
if ( page ) {
m_view->setActivePage( page->masterPage() );
m_savedPage = page;
}
}
else if ( m_savedPage ) {
m_view->setActivePage( m_savedPage );
m_savedPage = 0;
}
}
......@@ -22,6 +22,8 @@
#include "KoPAViewMode.h"
class KoPAPage;
class KOPAGEAPP_EXPORT KoPAViewModeNormal : public KoPAViewMode
{
public:
......@@ -37,6 +39,23 @@ public:
void keyPressEvent( QKeyEvent *event );
void keyReleaseEvent( QKeyEvent *event );
void wheelEvent( QWheelEvent * event, const QPointF &point );
/**
* @brief Switch the active view mode to work on master/normal pages
*
* When it is switched to master mode the master page of the current active page
* is selected. If it switches back the page which was shown before going into
* the master mode is shown. If the mode is the same nothing happens.
*
* @param master if true work on master pages, if false work on normal pages
*/
virtual void setMasterMode( bool master );
private:
/// if true it works on master pages, if false on normal pages
bool m_masterMode;
/// the page which was active before entering the master mode
KoPAPage * m_savedPage;
};
#endif /* KOPAVIEWMODENORMAL_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment