diff --git a/core/annotations.cpp b/core/annotations.cpp index 4f6e0fceb..3432ca8e9 100644 --- a/core/annotations.cpp +++ b/core/annotations.cpp @@ -722,6 +722,21 @@ void Annotation::setDisposeDataFunction( DisposeDataFunction func ) d->m_disposeFunc = func; } +bool Annotation::canBeMoved() const +{ + Q_D( const Annotation ); + // for now, it is pointless moving external annotations + // as we cannot change them anyway + if ( d->m_flags & External ) + return false; + + // highlight "requires" to be "bounded" to text, and that's tricky for now + if ( subType() == AHighlight ) + return false; + + return true; +} + void Annotation::store( QDomNode & annNode, QDomDocument & document ) const { Q_D( const Annotation ); diff --git a/core/annotations.h b/core/annotations.h index 400306747..cc1127828 100644 --- a/core/annotations.h +++ b/core/annotations.h @@ -273,6 +273,8 @@ class OKULAR_EXPORT Annotation /** * Move the annotation by the specified coordinates. + * + * @see canBeMoved() */ void translate( const NormalizedPoint &coord ); @@ -613,6 +615,13 @@ class OKULAR_EXPORT Annotation */ void setDisposeDataFunction( DisposeDataFunction func ); + /** + * Returns whether the annotation can be moved. + * + * @since 0.7 (KDE 4.1) + */ + bool canBeMoved() const; + /** * Returns the sub type of the annotation. */ diff --git a/ui/guiutils.cpp b/ui/guiutils.cpp index e761126fb..26a73a7f2 100644 --- a/ui/guiutils.cpp +++ b/ui/guiutils.cpp @@ -134,25 +134,6 @@ QString prettyToolTip( const Okular::Annotation * ann ) return tooltip; } -bool canBeMoved( const Okular::Annotation * ann ) -{ - Q_ASSERT( ann ); - - switch( ann->subType() ) - { - case Okular::Annotation::ALine: - case Okular::Annotation::AStamp: - case Okular::Annotation::AGeom: - case Okular::Annotation::AInk: - case Okular::Annotation::AText: - return true; - break; - default: - break; - } - return false; -} - void setIconLoader( KIconLoader * loader ) { s_data->il = loader; diff --git a/ui/guiutils.h b/ui/guiutils.h index 3cdb540c1..10fee6ab9 100644 --- a/ui/guiutils.h +++ b/ui/guiutils.h @@ -33,8 +33,6 @@ namespace GuiUtils QString prettyToolTip( const Okular::Annotation * annotation ); - bool canBeMoved( const Okular::Annotation * annotation ); - void setIconLoader( KIconLoader * loader ); KIconLoader* iconLoader(); diff --git a/ui/pageview.cpp b/ui/pageview.cpp index baceb1175..0e47835ea 100644 --- a/ui/pageview.cpp +++ b/ui/pageview.cpp @@ -1593,7 +1593,7 @@ void PageView::contentsMousePressEvent( QMouseEvent * e ) if ( orect ) d->mouseAnn = ( (Okular::AnnotationObjectRect *)orect )->annotation(); // consider no annotation caught if its type is not movable - if ( d->mouseAnn && !GuiUtils::canBeMoved( d->mouseAnn ) ) + if ( d->mouseAnn && !d->mouseAnn->canBeMoved() ) d->mouseAnn = 0; } if ( !d->mouseAnn ) @@ -2583,7 +2583,7 @@ void PageView::updateCursor( const QPoint &p ) d->mouseOnRect = false; if ( annotobj && ( QApplication::keyboardModifiers() & Qt::ControlModifier ) - && GuiUtils::canBeMoved( static_cast< const Okular::AnnotationObjectRect * >( annotobj )->annotation() ) ) + && static_cast< const Okular::AnnotationObjectRect * >( annotobj )->annotation()->canBeMoved() ) { setCursor( Qt::OpenHandCursor ); }