From 48a772be4b93d7757b9fd402a15e862e4b3ad95a Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Wed, 27 Dec 2006 23:56:38 +0000 Subject: [PATCH] move the ui-related utils functions for annotations in an own utils class svn path=/trunk/playground/graphics/okular/; revision=617097 --- CMakeLists.txt | 1 + core/annotations.cpp | 38 ----------------------------- core/annotations.h | 5 ---- ui/annotationguiutils.cpp | 51 +++++++++++++++++++++++++++++++++++++++ ui/annotationguiutils.h | 27 +++++++++++++++++++++ ui/side_reviews.cpp | 3 ++- 6 files changed, 81 insertions(+), 44 deletions(-) create mode 100644 ui/annotationguiutils.cpp create mode 100644 ui/annotationguiutils.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 43c1e3deb..46d284b12 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/core/annotations.cpp b/core/annotations.cpp index fab38d427..82c2ccb2d 100644 --- a/core/annotations.cpp +++ b/core/annotations.cpp @@ -11,9 +11,6 @@ #include #include -#include -#include - // 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 ) { diff --git a/core/annotations.h b/core/annotations.h index 759c4401c..8eeac3729 100644 --- a/core/annotations.h +++ b/core/annotations.h @@ -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. diff --git a/ui/annotationguiutils.cpp b/ui/annotationguiutils.cpp new file mode 100644 index 000000000..6f5ecbfca --- /dev/null +++ b/ui/annotationguiutils.cpp @@ -0,0 +1,51 @@ +/*************************************************************************** + * Copyright (C) 2006 by Pino Toscano * + * * + * 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 + +// 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; +} + diff --git a/ui/annotationguiutils.h b/ui/annotationguiutils.h new file mode 100644 index 000000000..62667a1b6 --- /dev/null +++ b/ui/annotationguiutils.h @@ -0,0 +1,27 @@ +/*************************************************************************** + * Copyright (C) 2006 by Pino Toscano * + * * + * 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 diff --git a/ui/side_reviews.cpp b/ui/side_reviews.cpp index 5abb9cd81..5c65dd34c 100644 --- a/ui/side_reviews.cpp +++ b/ui/side_reviews.cpp @@ -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( "%1
%2
" ) .arg( i18n( "Author: %1", m_ann->author() ), m_ann->contents() ) );