move the ui-related utils functions for annotations in an own utils class

svn path=/trunk/playground/graphics/okular/; revision=617097
This commit is contained in:
Pino Toscano 2006-12-27 23:56:38 +00:00
parent 8add3d7863
commit 48a772be4b
6 changed files with 81 additions and 44 deletions

View file

@ -78,6 +78,7 @@ set(okularpart_SRCS
conf/dlgpresentation.cpp
ui/embeddedfilesdialog.cpp
ui/annotwindow.cpp
ui/annotationguiutils.cpp
ui/annotationpropertiesdialog.cpp
ui/annotationtools.cpp
ui/annotationwidgets.cpp

View file

@ -11,9 +11,6 @@
#include <QtGui/QApplication>
#include <QtGui/QColor>
#include <kdebug.h>
#include <klocale.h>
// local includes
#include "annotations.h"
@ -81,41 +78,6 @@ QDomElement AnnotationUtils::findChildElement( const QDomNode & parentNode,
return QDomElement();
}
QString AnnotationUtils::captionForAnnotation( Annotation * ann )
{
if ( !ann )
return QString();
QString ret;
switch( ann->subType() )
{
case Okular::Annotation::AText:
if( ( (Okular::TextAnnotation*)ann )->textType() == Okular::TextAnnotation::Linked )
ret = i18n( "Note" );
else
ret = i18n( "FreeText" );
break;
case Okular::Annotation::ALine:
ret = i18n( "Line" );
break;
case Okular::Annotation::AGeom:
ret = i18n( "Geom" );
break;
case Okular::Annotation::AHighlight:
ret = i18n( "Highlight" );
break;
case Okular::Annotation::AStamp:
ret = i18n( "Stamp" );
break;
case Okular::Annotation::AInk:
ret = i18n( "Ink" );
break;
case Okular::Annotation::A_BASE:
break;
}
return ret;
}
QRect AnnotationUtils::annotationGeometry( const Annotation * ann,
double scaledWidth, double scaledHeight )
{

View file

@ -52,11 +52,6 @@ class OKULAR_EXPORT AnnotationUtils
static QDomElement findChildElement( const QDomNode & parentNode,
const QString & name );
/**
* Returns the translated string with the type of the given @p annotation.
*/
static QString captionForAnnotation( Annotation * annotation );
/**
* Returns the geometry of the given @p annotation scaled by
* @p scaleX and @p scaleY.

51
ui/annotationguiutils.cpp Normal file
View file

@ -0,0 +1,51 @@
/***************************************************************************
* Copyright (C) 2006 by Pino Toscano <pino@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
// qt/kde includes
#include <klocale.h>
// local includes
#include "annotationguiutils.h"
#include "core/annotations.h"
QString AnnotationGuiUtils::captionForAnnotation( Okular::Annotation * ann )
{
if ( !ann )
return QString();
QString ret;
switch( ann->subType() )
{
case Okular::Annotation::AText:
if( ( (Okular::TextAnnotation*)ann )->textType() == Okular::TextAnnotation::Linked )
ret = i18n( "Note" );
else
ret = i18n( "FreeText" );
break;
case Okular::Annotation::ALine:
ret = i18n( "Line" );
break;
case Okular::Annotation::AGeom:
ret = i18n( "Geom" );
break;
case Okular::Annotation::AHighlight:
ret = i18n( "Highlight" );
break;
case Okular::Annotation::AStamp:
ret = i18n( "Stamp" );
break;
case Okular::Annotation::AInk:
ret = i18n( "Ink" );
break;
case Okular::Annotation::A_BASE:
break;
}
return ret;
}

27
ui/annotationguiutils.h Normal file
View file

@ -0,0 +1,27 @@
/***************************************************************************
* Copyright (C) 2006 by Pino Toscano <pino@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef ANNOTATIONGUIUTILS_H
#define ANNOTATIONGUIUTILS_H
namespace Okular {
class Annotation;
}
class AnnotationGuiUtils
{
public:
/**
* Returns the translated string with the type of the given @p annotation.
*/
static QString captionForAnnotation( Okular::Annotation * annotation );
};
#endif

View file

@ -25,6 +25,7 @@
#include "core/document.h"
#include "core/page.h"
#include "settings.h"
#include "annotationguiutils.h"
#include "side_reviews.h"
@ -186,7 +187,7 @@ class AnnotationItem : public QTreeWidgetItem
void init()
{
setText( 0, Okular::AnnotationUtils::captionForAnnotation( m_ann ) );
setText( 0, AnnotationGuiUtils::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() ) );