mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-24 18:35:37 +00:00
add a context menu for the top-level items (representing the files), to allow to:
- open that documen (if it is not the current document already) - remove all of its bookmarks svn path=/trunk/KDE/kdegraphics/okular/; revision=1072135
This commit is contained in:
parent
c3f75f13c2
commit
32ccf8593b
|
@ -231,6 +231,8 @@ void BookmarkList::slotContextMenu( const QPoint& p )
|
|||
BookmarkItem* bmItem = item ? dynamic_cast<BookmarkItem*>( item ) : 0;
|
||||
if ( bmItem )
|
||||
contextMenuForBookmarkItem( p, bmItem );
|
||||
else if ( FileItem* fItem = dynamic_cast< FileItem * >( item ) )
|
||||
contextMenuForFileItem( p, fItem );
|
||||
}
|
||||
|
||||
void BookmarkList::contextMenuForBookmarkItem( const QPoint& p, BookmarkItem* bmItem )
|
||||
|
@ -254,6 +256,39 @@ void BookmarkList::contextMenuForBookmarkItem( const QPoint& p, BookmarkItem* bm
|
|||
m_document->bookmarkManager()->removeBookmark( bmItem->url(), bmItem->bookmark() );
|
||||
}
|
||||
|
||||
void BookmarkList::contextMenuForFileItem( const QPoint& p, FileItem* fItem )
|
||||
{
|
||||
if ( !fItem )
|
||||
return;
|
||||
|
||||
const KUrl itemurl = fItem->data( 0, UrlRole ).value< KUrl >();
|
||||
const bool thisdoc = itemurl == m_document->currentDocument();
|
||||
|
||||
KMenu menu( this );
|
||||
QAction * open = 0;
|
||||
if ( !thisdoc )
|
||||
open = menu.addAction( i18nc( "Opens the selected document", "Open Document" ) );
|
||||
QAction * removebm = menu.addAction( KIcon( "list-remove" ), i18n( "Remove Bookmarks" ) );
|
||||
QAction * res = menu.exec( QCursor::pos() );
|
||||
if ( !res )
|
||||
return;
|
||||
|
||||
if ( res == open )
|
||||
{
|
||||
Okular::GotoAction action( itemurl.pathOrUrl(), Okular::DocumentViewport() );
|
||||
m_document->processAction( &action );
|
||||
}
|
||||
else if ( res == removebm )
|
||||
{
|
||||
KBookmark::List list;
|
||||
for ( int i = 0; i < fItem->childCount(); ++i )
|
||||
{
|
||||
list.append( static_cast<BookmarkItem*>( fItem->child( i ) )->bookmark() );
|
||||
}
|
||||
m_document->bookmarkManager()->removeBookmarks( itemurl, list );
|
||||
}
|
||||
}
|
||||
|
||||
void BookmarkList::slotBookmarksChanged( const KUrl& url )
|
||||
{
|
||||
// special case here, as m_currentDocumentItem could represent
|
||||
|
|
|
@ -20,6 +20,7 @@ class QTreeWidgetItem;
|
|||
class KTreeWidgetSearchLine;
|
||||
class KUrl;
|
||||
class BookmarkItem;
|
||||
class FileItem;
|
||||
|
||||
namespace Okular {
|
||||
class Document;
|
||||
|
@ -50,6 +51,7 @@ class BookmarkList : public QWidget, public Okular::DocumentObserver
|
|||
void selectiveUrlUpdate( const KUrl& url, QTreeWidgetItem*& item );
|
||||
QTreeWidgetItem* itemForUrl( const KUrl& url ) const;
|
||||
void contextMenuForBookmarkItem( const QPoint& p, BookmarkItem* bmItem );
|
||||
void contextMenuForFileItem( const QPoint& p, FileItem* fItem );
|
||||
|
||||
Okular::Document * m_document;
|
||||
QTreeWidget * m_tree;
|
||||
|
|
Loading…
Reference in a new issue