Commit 00b01aa9 authored by Michel Ludwig's avatar Michel Ludwig
Browse files

Add method 'setLastSourceLocationViewport( const Okular::DocumentViewport& vp )' to PageView

Undo changes to the class 'DocumentViewport'.
parent 872c537f
......@@ -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;
......
......@@ -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;
};
/**
......
......@@ -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
......@@ -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();
}
......
......@@ -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 )
{
......
......@@ -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 )
{
......
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