Commit 38861f5f authored by Tobias Koenig's avatar Tobias Koenig Committed by Fabio D'Urso

Hide widget annotations from the user

Widget annotations are not meant to behave like "regular" annotations.
In particular, they must not be listed in the review panel or when the
user right-clicks on form fields.
parent 4a1c43df
...@@ -36,6 +36,20 @@ struct AnnItem ...@@ -36,6 +36,20 @@ struct AnnItem
int page; int page;
}; };
static QLinkedList< Okular::Annotation* > filterOutWidgetAnnotations( const QLinkedList< Okular::Annotation* > &annotations )
{
QLinkedList< Okular::Annotation* > result;
foreach ( Okular::Annotation *annotation, annotations )
{
if ( annotation->subType() == Okular::Annotation::AWidget )
continue;
result.append( annotation );
}
return result;
}
class AnnotationModelPrivate : public Okular::DocumentObserver class AnnotationModelPrivate : public Okular::DocumentObserver
{ {
...@@ -115,7 +129,7 @@ void AnnotationModelPrivate::notifyPageChanged( int page, int flags ) ...@@ -115,7 +129,7 @@ void AnnotationModelPrivate::notifyPageChanged( int page, int flags )
if ( !(flags & Okular::DocumentObserver::Annotations ) ) if ( !(flags & Okular::DocumentObserver::Annotations ) )
return; return;
QLinkedList< Okular::Annotation* > annots = document->page( page )->annotations(); const QLinkedList< Okular::Annotation* > annots = filterOutWidgetAnnotations( document->page( page )->annotations() );
int annItemIndex = -1; int annItemIndex = -1;
AnnItem *annItem = findItem( page, &annItemIndex ); AnnItem *annItem = findItem( page, &annItemIndex );
// case 1: the page has no more annotations // case 1: the page has no more annotations
...@@ -231,7 +245,7 @@ void AnnotationModelPrivate::rebuildTree( const QVector< Okular::Page * > &pages ...@@ -231,7 +245,7 @@ void AnnotationModelPrivate::rebuildTree( const QVector< Okular::Page * > &pages
emit q->layoutAboutToBeChanged(); emit q->layoutAboutToBeChanged();
for ( int i = 0; i < pages.count(); ++i ) for ( int i = 0; i < pages.count(); ++i )
{ {
QLinkedList< Okular::Annotation* > annots = pages.at( i )->annotations(); const QLinkedList< Okular::Annotation* > annots = filterOutWidgetAnnotations( pages.at( i )->annotations() );
if ( annots.isEmpty() ) if ( annots.isEmpty() )
continue; continue;
......
...@@ -2057,7 +2057,7 @@ void PageView::mousePressEvent( QMouseEvent * e ) ...@@ -2057,7 +2057,7 @@ void PageView::mousePressEvent( QMouseEvent * e )
foreach ( const Okular::ObjectRect * orect, orects ) foreach ( const Okular::ObjectRect * orect, orects )
{ {
Okular::Annotation * ann = ( (Okular::AnnotationObjectRect *)orect )->annotation(); Okular::Annotation * ann = ( (Okular::AnnotationObjectRect *)orect )->annotation();
if ( ann ) if ( ann && (ann->subType() != Okular::Annotation::AWidget) )
popup.addAnnotation( ann, pageItem->pageNumber() ); popup.addAnnotation( ann, pageItem->pageNumber() );
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment