Commit 1be2696c authored by Michel Ludwig's avatar Michel Ludwig
Browse files

Allow for more control over when source locations are shown graphically.

The method 'showSourceLocation' has been extended with a new parameter which
controls whether the given source location is shown graphically. A new method
'clearLastShownSourceLocation' has been added; and a corresponding implementation
is provided.
parent 689f6507
......@@ -30,8 +30,16 @@ class OKULAR_EXPORT ViewerInterface
/**
* Show the specified source location centrally in the viewer.
*
* @param showGraphically controls whether the given source location will be
* shown graphically in the viewer (if that feature is globally activated)
*/
virtual void showSourceLocation(const QString& fileName, int line, int column) = 0;
virtual void showSourceLocation(const QString& fileName, int line, int column, bool showGraphically = true) = 0;
/**
* Clear the source location that was set last in the viewer.
*/
virtual void clearLastShownSourceLocation() = 0;
/**
* Allows to control whether source locations are shown graphically, or not.
......
......@@ -834,12 +834,21 @@ KUrl Part::realUrl() const
// ViewerInterface
void Part::showSourceLocation(const QString& fileName, int line, int column)
void Part::showSourceLocation(const QString& fileName, int line, int column, bool showGraphically)
{
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() );
if( showGraphically )
{
m_pageView->setLastSourceLocationViewport( m_document->viewport() );
}
}
void Part::clearLastShownSourceLocation()
{
m_pageView->clearLastSourceLocationViewport();
m_pageView->viewport()->update();
}
void Part::setWatchFileModeEnabled(bool enabled)
......
......@@ -120,7 +120,8 @@ class Part : public KParts::ReadOnlyPart, public Okular::DocumentObserver, publi
KUrl realUrl() const;
void showSourceLocation(const QString& fileName, int line, int column);
void showSourceLocation(const QString& fileName, int line, int column, bool showGraphically = true);
void clearLastShownSourceLocation();
void setWatchFileModeEnabled(bool enable);
void setShowSourceLocationsGraphically(bool show);
......
......@@ -275,6 +275,9 @@ PageView::PageView( QWidget *parent, Okular::Document *document )
d->mouseAnn = 0;
d->tableDividersGuessed = false;
d->viewportMoveActive = false;
d->lastSourceLocationViewportPageNumber = -1;
d->lastSourceLocationViewportNormalizedX = 0.0;
d->lastSourceLocationViewportNormalizedY = 0.0;
d->viewportMoveTimer = 0;
d->scrollIncrement = 0;
d->autoScrollTimer = 0;
......@@ -977,6 +980,13 @@ void PageView::setLastSourceLocationViewport( const Okular::DocumentViewport& vp
d->lastSourceLocationViewportPageNumber = vp.pageNumber;
}
void PageView::clearLastSourceLocationViewport()
{
d->lastSourceLocationViewportPageNumber = -1;
d->lastSourceLocationViewportNormalizedX = 0.0;
d->lastSourceLocationViewportNormalizedY = 0.0;
}
void PageView::notifyViewportChanged( bool smoothMove )
{
QMetaObject::invokeMethod(this, "slotRealNotifyViewportChanged", Qt::QueuedConnection, Q_ARG( bool, smoothMove ));
......
......@@ -104,6 +104,7 @@ Q_OBJECT
QPoint contentAreaPoint( const QPoint & pos ) const;
void setLastSourceLocationViewport( const Okular::DocumentViewport& vp );
void clearLastSourceLocationViewport();
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