Added UrlChanged notification in notifySetup to fix BookmarkList not updating after save as

This commit is contained in:
Fabio D'Urso 2014-05-11 17:38:30 +02:00
parent 859168eaa8
commit 48c324f77c
3 changed files with 8 additions and 5 deletions

View file

@ -2213,7 +2213,7 @@ Document::OpenResult Document::openDocument( const QString & docFile, const KUrl
d->m_bookmarkManager->setUrl( d->m_url ); d->m_bookmarkManager->setUrl( d->m_url );
// 3. setup observers inernal lists and data // 3. setup observers inernal lists and data
foreachObserver( notifySetup( d->m_pagesVector, DocumentObserver::DocumentChanged ) ); foreachObserver( notifySetup( d->m_pagesVector, DocumentObserver::DocumentChanged | DocumentObserver::UrlChanged ) );
// 4. set initial page (restoring the page saved in xml if loaded) // 4. set initial page (restoring the page saved in xml if loaded)
DocumentViewport loadedViewport = (*d->m_viewportIterator); DocumentViewport loadedViewport = (*d->m_viewportIterator);
@ -2408,7 +2408,7 @@ void Document::closeDocument()
d->m_rotation = Rotation0; d->m_rotation = Rotation0;
// send an empty list to observers (to free their data) // send an empty list to observers (to free their data)
foreachObserver( notifySetup( QVector< Page * >(), DocumentObserver::DocumentChanged ) ); foreachObserver( notifySetup( QVector< Page * >(), DocumentObserver::DocumentChanged | DocumentObserver::UrlChanged ) );
// delete pages and clear 'd->m_pagesVector' container // delete pages and clear 'd->m_pagesVector' container
QVector< Page * >::const_iterator pIt = d->m_pagesVector.constBegin(); QVector< Page * >::const_iterator pIt = d->m_pagesVector.constBegin();
@ -2462,7 +2462,7 @@ void Document::addObserver( DocumentObserver * pObserver )
// if the observer is added while a document is already opened, tell it // if the observer is added while a document is already opened, tell it
if ( !d->m_pagesVector.isEmpty() ) if ( !d->m_pagesVector.isEmpty() )
{ {
pObserver->notifySetup( d->m_pagesVector, DocumentObserver::DocumentChanged ); pObserver->notifySetup( d->m_pagesVector, DocumentObserver::DocumentChanged | DocumentObserver::UrlChanged );
pObserver->notifyViewportChanged( false /*disables smoothMove*/ ); pObserver->notifyViewportChanged( false /*disables smoothMove*/ );
} }
} }
@ -4023,6 +4023,7 @@ bool Document::swapBackingFile( const QString &newFileName, const KUrl & url )
d->m_docFileName = newFileName; d->m_docFileName = newFileName;
d->updateMetadataXmlNameAndDocSize(); d->updateMetadataXmlNameAndDocSize();
d->m_bookmarkManager->setUrl( d->m_url ); d->m_bookmarkManager->setUrl( d->m_url );
foreachObserver( notifySetup( d->m_pagesVector, DocumentObserver::UrlChanged ) );
return true; return true;
} }
else else
@ -4063,6 +4064,7 @@ bool Document::swapBackingFileArchive( const QString &newFileName, const KUrl &
d->m_docFileName = tempFileName; d->m_docFileName = tempFileName;
d->updateMetadataXmlNameAndDocSize(); d->updateMetadataXmlNameAndDocSize();
d->m_bookmarkManager->setUrl( d->m_url ); d->m_bookmarkManager->setUrl( d->m_url );
foreachObserver( notifySetup( d->m_pagesVector, DocumentObserver::UrlChanged ) );
return true; return true;
} }
else else

View file

@ -53,7 +53,8 @@ class OKULAR_EXPORT DocumentObserver
*/ */
enum SetupFlags { enum SetupFlags {
DocumentChanged = 1, ///< The document is a new document. DocumentChanged = 1, ///< The document is a new document.
NewLayoutForPages = 2 ///< All the pages have NewLayoutForPages = 2, ///< All the pages have
UrlChanged = 4 ///< The URL has changed @since 0.20 (KDE 4.14)
}; };
/** /**

View file

@ -169,7 +169,7 @@ BookmarkList::~BookmarkList()
void BookmarkList::notifySetup( const QVector< Okular::Page * > & pages, int setupFlags ) void BookmarkList::notifySetup( const QVector< Okular::Page * > & pages, int setupFlags )
{ {
Q_UNUSED( pages ); Q_UNUSED( pages );
if ( !( setupFlags & Okular::DocumentObserver::DocumentChanged ) ) if ( !( setupFlags & Okular::DocumentObserver::UrlChanged ) )
return; return;
// clear contents // clear contents