From 00b01aa9870adf7b70d352b7441d879a0b98c235 Mon Sep 17 00:00:00 2001 From: Michel Ludwig Date: Tue, 1 Nov 2011 21:13:20 +0000 Subject: [PATCH] Add method 'setLastSourceLocationViewport( const Okular::DocumentViewport& vp )' to PageView Undo changes to the class 'DocumentViewport'. --- core/document.cpp | 6 +++--- core/document.h | 7 +------ core/global.h | 9 --------- part.cpp | 4 ++++ ui/pageview.cpp | 25 +++++++++++++++---------- ui/pageview.h | 2 ++ 6 files changed, 25 insertions(+), 28 deletions(-) diff --git a/core/document.cpp b/core/document.cpp index 6e9619bce..b3ddb4667 100644 --- a/core/document.cpp +++ b/core/document.cpp @@ -757,7 +757,7 @@ DocumentViewport DocumentPrivate::nextDocumentViewport() const DocumentViewport ret = m_nextDocumentViewport; if ( !m_nextDocumentDestination.isEmpty() && m_generator ) { - DocumentViewport vp( m_generator->metaData( "NamedViewport", m_nextDocumentDestination ).toString(), Okular::SourceLocationViewport ); + DocumentViewport vp( m_generator->metaData( "NamedViewport", m_nextDocumentDestination ).toString() ); if ( vp.isValid() ) { ret = vp; @@ -3741,8 +3741,8 @@ DocumentViewport::DocumentViewport( int n ) autoFit.height = false; } -DocumentViewport::DocumentViewport( const QString & xmlDesc, ViewportType type ) - : pageNumber( -1 ), type( type ) +DocumentViewport::DocumentViewport( const QString & xmlDesc ) + : pageNumber( -1 ) { // default settings (maybe overridden below) rePos.enabled = false; diff --git a/core/document.h b/core/document.h index 6c273135a..78ce53a1f 100644 --- a/core/document.h +++ b/core/document.h @@ -786,7 +786,7 @@ class OKULAR_EXPORT DocumentViewport /** * Creates a new viewport from the given xml @p description. */ - DocumentViewport( const QString &description, Okular::ViewportType type = Okular::NormalViewport ); + DocumentViewport( const QString &description ); /** * Returns the viewport as xml description. @@ -836,11 +836,6 @@ class OKULAR_EXPORT DocumentViewport bool width; bool height; } autoFit; - - /** - * Describes the type of this viewport. - */ - Okular::ViewportType type; }; /** diff --git a/core/global.h b/core/global.h index ae4c87b08..96b21fb2e 100644 --- a/core/global.h +++ b/core/global.h @@ -92,15 +92,6 @@ enum EmbedMode ViewerWidgetMode, // the part acts as a widget that can display all kinds of documents }; -/** - * Describes the type of viewport objects - */ -enum ViewportType -{ - NormalViewport, ///< - SourceLocationViewport ///< Viewport position that corresponds to a source location -}; - } #endif diff --git a/part.cpp b/part.cpp index dcd9064a8..09a11b133 100644 --- a/part.cpp +++ b/part.cpp @@ -839,6 +839,7 @@ void Part::showSourceLocation(const QString& fileName, int line, int column) const QString u = QString( "src:%1 %2" ).arg( line ).arg( fileName ); GotoAction action( QString(), u ); m_document->processAction( &action ); + m_pageView->setLastSourceLocationViewport( m_document->viewport() ); } void Part::setWatchFileModeEnabled(bool enabled) @@ -2423,6 +2424,9 @@ void Part::unsetDummyMode() // attach the actions of the children widgets too m_formsMessage->setActionButton( m_pageView->toggleFormsAction() ); + + // ensure history actions are in the correct state + updateViewActions(); } diff --git a/ui/pageview.cpp b/ui/pageview.cpp index d28c59124..d147c045c 100644 --- a/ui/pageview.cpp +++ b/ui/pageview.cpp @@ -962,6 +962,21 @@ void PageView::updateActionState( bool haspages, bool documentChanged, bool hasf } } +void PageView::setLastSourceLocationViewport( const Okular::DocumentViewport& vp ) +{ + if( vp.rePos.enabled ) + { + d->lastSourceLocationViewportNormalizedX = normClamp( vp.rePos.normalizedX, 0.5 ); + d->lastSourceLocationViewportNormalizedY = normClamp( vp.rePos.normalizedY, 0.0 ); + } + else + { + d->lastSourceLocationViewportNormalizedX = 0.5; + d->lastSourceLocationViewportNormalizedY = 0.0; + } + d->lastSourceLocationViewportPageNumber = vp.pageNumber; +} + void PageView::notifyViewportChanged( bool smoothMove ) { // if we are the one changing viewport, skip this nofity @@ -990,10 +1005,6 @@ void PageView::notifyViewportChanged( bool smoothMove ) #ifdef PAGEVIEW_DEBUG kDebug() << "document viewport changed"; #endif - if( vp.type == Okular::SourceLocationViewport ) - { - d->lastSourceLocationViewportPageNumber = vp.pageNumber; - } // relayout in "Single Pages" mode or if a relayout is pending d->blockPixmapsRequest = true; if ( !Okular::Settings::viewContinuous() || d->dirtyLayout ) @@ -1023,12 +1034,6 @@ void PageView::notifyViewportChanged( bool smoothMove ) newCenterY += viewport()->height() / 2 - 10; } - if( vp.type == Okular::SourceLocationViewport ) - { - d->lastSourceLocationViewportNormalizedX = normClamp( vp.rePos.normalizedX, 0.5 ); - d->lastSourceLocationViewportNormalizedY = normClamp( vp.rePos.normalizedY, 0.0 ); - } - // if smooth movement requested, setup parameters and start it if ( smoothMove ) { diff --git a/ui/pageview.h b/ui/pageview.h index f0051af30..cb614a634 100644 --- a/ui/pageview.h +++ b/ui/pageview.h @@ -35,6 +35,7 @@ class KUrl; namespace Okular { class Action; class Document; +class DocumentViewport; class Annotation; class FormField; } @@ -102,6 +103,7 @@ Q_OBJECT QPoint contentAreaPosition() const; QPoint contentAreaPoint( const QPoint & pos ) const; + void setLastSourceLocationViewport( const Okular::DocumentViewport& vp ); public slots: void errorMessage( const QString & message, int duration = -1 ) {