Implement the canBeMoved() check for an annotation in the Annotation class itself.

Use this new version and remove the one in GuiUtils.

svn path=/trunk/KDE/kdegraphics/okular/; revision=803073
remotes/origin/KDE/4.1
Pino Toscano 18 years ago
parent e8e93ee179
commit d1305c265b
  1. 15
      core/annotations.cpp
  2. 9
      core/annotations.h
  3. 19
      ui/guiutils.cpp
  4. 2
      ui/guiutils.h
  5. 4
      ui/pageview.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 );

@ -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.
*/

@ -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;

@ -33,8 +33,6 @@ namespace GuiUtils
QString prettyToolTip( const Okular::Annotation * annotation );
bool canBeMoved( const Okular::Annotation * annotation );
void setIconLoader( KIconLoader * loader );
KIconLoader* iconLoader();

@ -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 );
}

Loading…
Cancel
Save