From b0245bd01d5560b30fe67e2dfcc960f5158d0d12 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Mon, 14 Jan 2008 13:59:30 +0000 Subject: [PATCH] Allow the selection of more than annotation in the annotation tree, so they can be deleted at once using the popup menu. FEATURE: 155668 svn path=/trunk/KDE/kdegraphics/okular/; revision=761323 --- ui/side_reviews.cpp | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/ui/side_reviews.cpp b/ui/side_reviews.cpp index 58204afd3..09993a3f1 100644 --- a/ui/side_reviews.cpp +++ b/ui/side_reviews.cpp @@ -92,6 +92,7 @@ Reviews::Reviews( QWidget * parent, Okular::Document * document ) m_view = new TreeView( m_document, this ); m_view->setAlternatingRowColors( true ); + m_view->setSelectionMode( QAbstractItemView::ExtendedSelection ); m_view->header()->hide(); QToolBar *toolBar = new QToolBar( this ); @@ -213,28 +214,26 @@ void Reviews::activated( const QModelIndex &index ) void Reviews::contextMenuRequested( const QPoint &pos ) { - const QModelIndex index = m_view->indexAt( pos ); - if ( !index.isValid() ) - return; - - const QModelIndex authorIndex = m_authorProxy->mapToSource( index ); - const QModelIndex filterIndex = m_groupProxy->mapToSource( authorIndex ); - const QModelIndex annotIndex = m_filterProxy->mapToSource( filterIndex ); - - Okular::Annotation *annotation = m_model->annotationForIndex( annotIndex ); - if ( annotation ) { - int pageNumber = m_model->data( annotIndex, AnnotationModel::PageRole ).toInt(); - - AnnotationPopup popup( m_document, this ); - popup.addAnnotation( annotation, pageNumber ); - - connect( &popup, SIGNAL( setAnnotationWindow( Okular::Annotation* ) ), - this, SIGNAL( setAnnotationWindow( Okular::Annotation* ) ) ); - connect( &popup, SIGNAL( removeAnnotationWindow( Okular::Annotation* ) ), - this, SIGNAL( removeAnnotationWindow( Okular::Annotation* ) ) ); - - popup.exec( m_view->viewport()->mapToGlobal( pos ) ); + AnnotationPopup popup( m_document, this ); + connect( &popup, SIGNAL( setAnnotationWindow( Okular::Annotation* ) ), + this, SIGNAL( setAnnotationWindow( Okular::Annotation* ) ) ); + connect( &popup, SIGNAL( removeAnnotationWindow( Okular::Annotation* ) ), + this, SIGNAL( removeAnnotationWindow( Okular::Annotation* ) ) ); + + QModelIndexList indexes = m_view->selectionModel()->selectedIndexes(); + Q_FOREACH ( const QModelIndex &index, indexes ) + { + const QModelIndex authorIndex = m_authorProxy->mapToSource( index ); + const QModelIndex filterIndex = m_groupProxy->mapToSource( authorIndex ); + const QModelIndex annotIndex = m_filterProxy->mapToSource( filterIndex ); + Okular::Annotation *annotation = m_model->annotationForIndex( annotIndex ); + if ( annotation ) { + const int pageNumber = m_model->data( annotIndex, AnnotationModel::PageRole ).toInt(); + popup.addAnnotation( annotation, pageNumber ); + } } + + popup.exec( m_view->viewport()->mapToGlobal( pos ) ); } #include "side_reviews.moc"