add a function to remove a list of bookmark belonging to the specified url

svn path=/trunk/KDE/kdegraphics/okular/; revision=1072132
This commit is contained in:
Pino Toscano 2010-01-09 13:13:43 +00:00
parent 4ee7112fe7
commit c3f75f13c2
2 changed files with 45 additions and 0 deletions

View file

@ -337,6 +337,42 @@ int BookmarkManager::removeBookmark( const KUrl& referurl, const KBookmark& bm )
return vp.pageNumber;
}
void BookmarkManager::removeBookmarks( const KUrl& referurl, const KBookmark::List& list )
{
if ( !referurl.isValid() || list.isEmpty() )
return;
KBookmarkGroup thebg;
QHash<KUrl, QString>::iterator it = d->bookmarkFind( referurl, false, &thebg );
if ( it == d->knownFiles.end() )
return;
const QSet<int> oldUrlBookmarks = d->urlBookmarks;
bool deletedAny = false;
foreach ( const KBookmark & bm, list )
{
if ( bm.parentGroup() == thebg )
{
thebg.deleteBookmark( bm );
deletedAny = true;
if ( referurl == d->document->m_url )
{
d->urlBookmarks.remove( DocumentViewport( bm.url().htmlRef() ).pageNumber );
}
}
}
if ( referurl == d->document->m_url )
{
foreach ( int p, oldUrlBookmarks - d->urlBookmarks )
{
foreachObserver( notifyPageChanged( p, DocumentObserver::Bookmark ) );
}
}
if ( deletedAny )
d->manager->emitChanged( thebg );
}
QList< QAction * > BookmarkManager::actionsForUrl( const KUrl& url ) const
{
QList< QAction * > ret;

View file

@ -73,6 +73,15 @@ class OKULAR_EXPORT BookmarkManager : public QObject
*/
int removeBookmark( const KUrl& referurl, const KBookmark& bm );
/**
* Removes the bookmarks in @p list for the @p referurl specified.
*
* @note it will remove only the bookmarks which belong to @p referurl
*
* @since 0.11 (KDE 4.5)
*/
void removeBookmarks( const KUrl& referurl, const KBookmark::List& list );
/**
* Returns whether the given @p page is bookmarked.
*/