Added Annotation::BeingMoved flag to avoid refreshing pixmaps while moving annotations

remotes/origin/KDE/4.9
Fabio D'Urso 14 years ago committed by Albert Astals Cid
parent 80c26f5bb9
commit 157638f2f9
  1. 4
      core/annotations.cpp
  2. 3
      core/annotations.h
  3. 14
      core/document.cpp
  4. 5
      core/document_p.h
  5. 20
      generators/poppler/annots.cpp
  6. 20
      ui/pageview.cpp

@ -768,8 +768,8 @@ void Annotation::store( QDomNode & annNode, QDomDocument & document ) const
e.setAttribute( "creationDate", d->m_creationDate.toString(Qt::ISODate) );
// store -other- attributes
if ( d->m_flags ) // Strip ExternallyDrawn flag because it's an implementation detail
e.setAttribute( "flags", d->m_flags & ~Annotation::ExternallyDrawn );
if ( d->m_flags ) // Strip internal flags
e.setAttribute( "flags", d->m_flags & ~(External | ExternallyDrawn | BeingMoved) );
if ( d->m_style.color().isValid() )
e.setAttribute( "color", d->m_style.color().name() );
if ( d->m_style.opacity() != 1.0 )

@ -128,7 +128,8 @@ class OKULAR_EXPORT Annotation
DenyDelete = 32, ///< Cannot be deleted
ToggleHidingOnMouse = 64, ///< Can be hidden/shown by mouse click
External = 128, ///< Is stored external
ExternallyDrawn = 256 ///< Is drawn externally (eg the generator which povided it) @since 0.10 (KDE 4.4)
ExternallyDrawn = 256, ///< Is drawn externally (by the generator which provided it) @since 0.10 (KDE 4.4)
BeingMoved = 512 ///< Is being moved (mouse drag and drop). If ExternallyDrawn, the generator must not draw it @since 0.15 (KDE 4.9)
};
/**

@ -2409,6 +2409,20 @@ void Document::modifyPageAnnotation( int page, Annotation * annotation, bool app
if ( appearanceChanged && (annotation->flags() & Annotation::ExternallyDrawn) )
{
/* When an annotation is being moved, the generator will not render it.
* Therefore there's no need to refresh pixmaps after the first time */
if ( annotation->flags() & Annotation::BeingMoved )
{
if ( d->m_annotationBeingMoved )
return;
else // First time: take note
d->m_annotationBeingMoved = true;
}
else
{
d->m_annotationBeingMoved = false;
}
// Redraw everything, including ExternallyDrawn annotations
d->refreshPixmaps( page );
}

@ -85,7 +85,8 @@ class DocumentPrivate
m_scripter( 0 ),
m_archiveData( 0 ),
m_fontsCached( false ),
m_documentInfo( 0 )
m_documentInfo( 0 ),
m_annotationBeingMoved( false )
{
calculateMaxTextPages();
}
@ -229,6 +230,8 @@ class DocumentPrivate
FontInfo::List m_fontsCache;
QSet< View * > m_views;
bool m_annotationBeingMoved; // is an annotation currently being moved?
};
}

@ -45,6 +45,18 @@ static QRectF normRectToRectF( const Okular::NormalizedRect& rect )
return QRectF( QPointF(rect.left, rect.top), QPointF(rect.right, rect.bottom) );
}
// Poppler and Okular share the same flag values, but we don't want to export internal flags
static int maskExportedFlags(int flags)
{
return flags & ( Okular::Annotation::Hidden |
Okular::Annotation::FixedSize |
Okular::Annotation::FixedRotation |
Okular::Annotation::DenyPrint |
Okular::Annotation::DenyWrite |
Okular::Annotation::DenyDelete |
Okular::Annotation::ToggleHidingOnMouse );
}
//BEGIN PopplerAnnotationProxy implementation
PopplerAnnotationProxy::PopplerAnnotationProxy( Poppler::Document *doc )
: ppl_doc ( doc )
@ -129,10 +141,18 @@ void PopplerAnnotationProxy::notifyModification( const Okular::Annotation *okl_a
if ( !ppl_ann ) // Ignore non-native annotations
return;
if ( okl_ann->flags() & Okular::Annotation::BeingMoved )
{
// Okular ui already renders the annotation on its own
ppl_ann->setFlags( Poppler::Annotation::Hidden );
return;
}
// Set basic properties
ppl_ann->setBoundary(normRectToRectF( okl_ann->boundingRectangle() ));
ppl_ann->setAuthor( okl_ann->author() );
ppl_ann->setContents( okl_ann->contents() );
ppl_ann->setFlags(maskExportedFlags( okl_ann->flags() ));
// Set style
Poppler::Annotation::Style s;

@ -132,6 +132,7 @@ public:
bool mouseOnRect;
Okular::Annotation * mouseAnn;
QPoint mouseAnnPos;
int mouseAnnPageNum;
// table selection
QList<double> tableSelectionCols;
@ -1793,7 +1794,7 @@ void PageView::mouseMoveEvent( QMouseEvent * e )
}
d->mouseAnn->translate( Okular::NormalizedPoint( pf.x(), pf.y() ) );
d->mouseAnnPos = newpos;
d->document->modifyPageAnnotation( pageItem->pageNumber(), d->mouseAnn );
d->document->modifyPageAnnotation( d->mouseAnnPageNum, d->mouseAnn );
}
}
// drag page
@ -1965,11 +1966,17 @@ void PageView::mousePressEvent( QMouseEvent * e )
if ( d->mouseAnn && !d->mouseAnn->canBeMoved() )
d->mouseAnn = 0;
}
if ( !d->mouseAnn )
if ( d->mouseAnn )
{
d->mouseAnn->setFlags( d->mouseAnn->flags() | Okular::Annotation::BeingMoved );
d->mouseAnnPageNum = pageItem->pageNumber();
d->document->modifyPageAnnotation( d->mouseAnnPageNum, d->mouseAnn );
}
else
{
d->mouseGrabPos = d->mouseOnRect ? QPoint() : d->mousePressPos;
if ( !d->mouseOnRect )
d->leftClickTimer.start( QApplication::doubleClickInterval() + 10 );
d->mouseGrabPos = d->mouseOnRect ? QPoint() : d->mousePressPos;
if ( !d->mouseOnRect )
d->leftClickTimer.start( QApplication::doubleClickInterval() + 10 );
}
}
else if ( rightButton )
@ -2145,6 +2152,9 @@ void PageView::mouseReleaseEvent( QMouseEvent * e )
if ( d->mouseAnn )
{
// Just finished to move the annotation
d->mouseAnn->setFlags( d->mouseAnn->flags() & ~Okular::Annotation::BeingMoved );
d->document->modifyPageAnnotation( d->mouseAnnPageNum, d->mouseAnn );
setCursor( Qt::ArrowCursor );
d->mouseAnn = 0;
}

Loading…
Cancel
Save