Commit dc7583eb authored by Pino Toscano's avatar Pino Toscano

Add the concept of "next destination" next to the "next viewport" one.

This allows a resolution, if set, of that named destination when opening a document.
CCBUG: 192032

svn path=/trunk/KDE/kdegraphics/okular/; revision=967542
parent aea55805
......@@ -719,6 +719,20 @@ bool DocumentPrivate::savePageDocumentInfo( KTemporaryFile *infoFile, int what )
return false;
}
DocumentViewport DocumentPrivate::nextDocumentViewport() const
{
DocumentViewport ret = m_nextDocumentViewport;
if ( !m_nextDocumentDestination.isEmpty() && m_generator )
{
DocumentViewport vp( m_generator->metaData( "NamedViewport", m_nextDocumentDestination ).toString() );
if ( vp.isValid() )
{
ret = vp;
}
}
return ret;
}
void DocumentPrivate::saveDocumentInfo() const
{
if ( m_xmlFileName.isEmpty() )
......@@ -1655,10 +1669,12 @@ bool Document::openDocument( const QString & docFile, const KUrl& url, const KMi
}
d->m_memCheckTimer->start( 2000 );
if (d->m_nextDocumentViewport.isValid())
const DocumentViewport nextViewport = d->nextDocumentViewport();
if ( nextViewport.isValid() )
{
setViewport(d->m_nextDocumentViewport);
setViewport( nextViewport );
d->m_nextDocumentViewport = DocumentViewport();
d->m_nextDocumentDestination = QString();
}
AudioPlayer::instance()->d->m_currentDocument = isstdin ? KUrl() : d->m_url;
......@@ -2472,6 +2488,11 @@ void Document::setNextDocumentViewport( const DocumentViewport & viewport )
d->m_nextDocumentViewport = viewport;
}
void Document::setNextDocumentDestination( const QString &namedDestination )
{
d->m_nextDocumentDestination = namedDestination;
}
void Document::searchText( int searchID, const QString & text, bool fromStart, Qt::CaseSensitivity caseSensitivity,
SearchType type, bool moveViewport, const QColor & color, bool noDialogs )
{
......@@ -2749,6 +2770,7 @@ void Document::processAction( const Action * action )
case Action::Goto: {
const GotoAction * go = static_cast< const GotoAction * >( action );
d->m_nextDocumentViewport = go->destViewport();
d->m_nextDocumentDestination = go->destinationName();
// Explanation of why d->m_nextDocumentViewport is needed:
// all openRelativeFile does is launch a signal telling we
......@@ -2766,12 +2788,14 @@ void Document::processAction( const Action * action )
}
else
{
const DocumentViewport nextViewport = d->nextDocumentViewport();
// skip local links that point to nowhere (broken ones)
if (!d->m_nextDocumentViewport.isValid())
if ( !nextViewport.isValid() )
return;
setViewport( d->m_nextDocumentViewport, -1, true );
setViewport( nextViewport, -1, true );
d->m_nextDocumentViewport = DocumentViewport();
d->m_nextDocumentDestination = QString();
}
} break;
......
......@@ -316,6 +316,13 @@ class OKULAR_EXPORT Document : public QObject
*/
void setNextDocumentViewport( const DocumentViewport &viewport );
/**
* Sets the next @p namedDestination in the viewport history.
*
* @since 0.9 (KDE 4.3)
*/
void setNextDocumentDestination( const QString &namedDestination );
/**
* Sets the zoom for the current document.
*
......
......@@ -112,6 +112,7 @@ class DocumentPrivate
SaveInterface* generatorSave( GeneratorInfo& info );
bool openDocumentInternal( const KService::Ptr& offer, bool isstdin, const QString& docFile, const QByteArray& filedata );
bool savePageDocumentInfo( KTemporaryFile *infoFile, int what ) const;
DocumentViewport nextDocumentViewport() const;
// private slots
void saveDocumentInfo() const;
......@@ -168,6 +169,7 @@ class DocumentPrivate
QLinkedList< DocumentViewport > m_viewportHistory;
QLinkedList< DocumentViewport >::iterator m_viewportIterator;
DocumentViewport m_nextDocumentViewport; // see Link::Goto for an explanation
QString m_nextDocumentDestination;
// observers / requests / allocator stuff
QMap< int, DocumentObserver * > m_observers;
......
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