From 32d3dff232ed3d4e90a3b1aaafd954f54e6943d9 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Tue, 3 Jul 2007 17:20:38 +0000 Subject: [PATCH] d_ptr structure for the FormField classes, easier to expand in the future svn path=/trunk/KDE/kdegraphics/okular/; revision=682922 --- core/form.cpp | 43 ++++++++++++++++++++++++++++++++++++++----- core/form.h | 18 +++++++++++++++--- 2 files changed, 53 insertions(+), 8 deletions(-) diff --git a/core/form.cpp b/core/form.cpp index dc2515b14..2777dface 100644 --- a/core/form.cpp +++ b/core/form.cpp @@ -12,18 +12,31 @@ using namespace Okular; -FormField::FormField( FormField::FieldType t ) - : m_type( t ) +class Okular::FormFieldPrivate +{ + public: + FormFieldPrivate( FormField::FieldType type ) + : m_type( type ) + { + } + + FormField::FieldType m_type; +}; + +FormField::FormField( FormFieldPrivate &dd ) + : d_ptr( &dd ) { } FormField::~FormField() { + delete d_ptr; } FormField::FieldType FormField::type() const { - return m_type; + Q_D( const FormField ); + return d->m_type; } bool FormField::isReadOnly() const @@ -37,8 +50,18 @@ bool FormField::isVisible() const } +class Okular::FormFieldTextPrivate : public Okular::FormFieldPrivate +{ + public: + FormFieldTextPrivate() + : FormFieldPrivate( FormField::FormText ) + { + } +}; + + FormFieldText::FormFieldText() - : FormField( FormField::FormText ) + : FormField( *new FormFieldTextPrivate() ) { } @@ -76,8 +99,18 @@ bool FormFieldText::canBeSpellChecked() const } +class Okular::FormFieldChoicePrivate : public Okular::FormFieldPrivate +{ + public: + FormFieldChoicePrivate() + : FormFieldPrivate( FormField::FormChoice ) + { + } +}; + + FormFieldChoice::FormFieldChoice() - : FormField( FormField::FormChoice ) + : FormField( *new FormFieldChoicePrivate() ) { } diff --git a/core/form.h b/core/form.h index c8412cbc2..9ae53bae6 100644 --- a/core/form.h +++ b/core/form.h @@ -17,6 +17,10 @@ namespace Okular { +class FormFieldPrivate; +class FormFieldTextPrivate; +class FormFieldChoicePrivate; + /** * @short The base interface of a form field. * @@ -79,11 +83,11 @@ class OKULAR_EXPORT FormField virtual bool isVisible() const; protected: - FormField( FieldType t ); + FormField( FormFieldPrivate &dd ); + Q_DECLARE_PRIVATE( FormField ) + FormFieldPrivate *d_ptr; private: - FieldType m_type; - Q_DISABLE_COPY( FormField ) }; @@ -162,6 +166,10 @@ class OKULAR_EXPORT FormFieldText : public FormField protected: FormFieldText(); + + private: + Q_DECLARE_PRIVATE( FormFieldText ) + Q_DISABLE_COPY( FormFieldText ) }; @@ -239,6 +247,10 @@ class OKULAR_EXPORT FormFieldChoice : public FormField protected: FormFieldChoice(); + + private: + Q_DECLARE_PRIVATE( FormFieldChoice ) + Q_DISABLE_COPY( FormFieldChoice ) }; }