Version: 0.5.81 (using KDE Devel) Installed from: Compiled sources OS: Linux The Reviews Sidetab contains a list of annotations (as in: Popup notes, highlights ...) that exist in a PDF file, neatly ordered by page and/or author - however, clicking on one of those items, nothing really happens. Suggested behaviour would be to jump to the position of the annotation and maybe open the corresponding text
SVN commit 606817 by pino: Smootly move the viewer area to the annotation when an annotation item in the review tab is double-clicked. BUG: 137631 M +41 -11 side_reviews.cpp M +3 -0 side_reviews.h --- trunk/playground/graphics/okular/ui/side_reviews.cpp #606816:606817 @@ -85,6 +85,7 @@ m_listView->header()->setResizeMode( QHeaderView::Stretch ); m_listView->header()->hide(); m_listView->setIndentation( 16 ); + connect( m_listView, SIGNAL( itemDoubleClicked( QTreeWidgetItem *, int ) ), this, SLOT( itemDoubleClicked( QTreeWidgetItem *, int ) ) ); } //BEGIN DocumentObserver Notifies -> requestListViewUpdate @@ -171,36 +172,65 @@ class AnnotationItem : public QTreeWidgetItem { public: - AnnotationItem( QTreeWidget * parent, Okular::Annotation * ann ) - : QTreeWidgetItem( parent ) + AnnotationItem( QTreeWidget * parent, Okular::Annotation * ann, int page ) + : QTreeWidgetItem( parent ), m_ann( ann ), m_page( page ) { - init( ann ); + init(); } - AnnotationItem( QTreeWidgetItem * parent, Okular::Annotation * ann ) - : QTreeWidgetItem( parent ) + AnnotationItem( QTreeWidgetItem * parent, Okular::Annotation * ann, int page ) + : QTreeWidgetItem( parent ), m_ann( ann ), m_page( page ) { - init( ann ); + init(); } - void init( Okular::Annotation * ann ) + void init() { - m_ann = ann; setText( 0, Okular::AnnotationUtils::captionForAnnotation( m_ann ) ); setIcon( 0, KIcon( "okular" ) ); setToolTip( 0, QString( "<qt><b>%1</b><hr>%2</qt>" ) .arg( i18n( "Author: %1", m_ann->author ), m_ann->contents ) ); } - Okular::Annotation * anotation() + Okular::Annotation * annotation() { return m_ann; } + int page() const + { + return m_page; + } + private: Okular::Annotation * m_ann; + int m_page; }; +void Reviews::itemDoubleClicked( QTreeWidgetItem * item, int /*column*/ ) +{ + AnnotationItem * annItem = dynamic_cast< AnnotationItem * >( item ); + if ( !annItem ) + return; + + int pageNumber = annItem->page(); + Okular::Annotation * ann = annItem->annotation(); + const Okular::Page * page = m_document->page( pageNumber ); + // calculating the right coordinates to center the view on the annotation + QRect rect = Okular::AnnotationUtils::annotationGeometry( ann, page->width(), page->height() ); + Okular::NormalizedRect nr( rect, (int)page->width(), (int)page->height() ); + // set the viewport parameters + Okular::DocumentViewport vp; + vp.pageNumber = pageNumber; + vp.rePos.enabled = true; + vp.rePos.pos = Okular::DocumentViewport::Center; + vp.rePos.normalizedX = ( nr.right + nr.left ) / 2.0; + vp.rePos.normalizedY = ( nr.bottom + nr.top ) / 2.0; + // setting the viewport + m_document->setViewport( vp, -1, true ); +} + + void Reviews::slotUpdateListView() { // reset listview to default @@ -294,8 +324,8 @@ // create Annotation subnode QTreeWidgetItem * singleItem = authorItem ? - new AnnotationItem( authorItem, annotation ) : - new AnnotationItem( m_listView, annotation ); + new AnnotationItem( authorItem, annotation, page->number() ) : + new AnnotationItem( m_listView, annotation, page->number() ); Q_UNUSED( singleItem ); } } --- trunk/playground/graphics/okular/ui/side_reviews.h #606816:606817 @@ -45,6 +45,9 @@ void slotCurrentPageOnly( bool ); void slotUpdateListView(); + private slots: + void itemDoubleClicked( QTreeWidgetItem *, int ); + private: // add all annotations of a page to the listView taking care of grouping void addContents( const Okular::Page * page );
*** Bug 238707 has been marked as a duplicate of this bug. ***