• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • kdegraphics
  • Sitemap
  • Contact Us
 

okular

form.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007 by Pino Toscano <pino@kde.org>                     *
00003  *                                                                         *
00004  *   This program is free software; you can redistribute it and/or modify  *
00005  *   it under the terms of the GNU General Public License as published by  *
00006  *   the Free Software Foundation; either version 2 of the License, or     *
00007  *   (at your option) any later version.                                   *
00008  ***************************************************************************/
00009 
00010 #include "form.h"
00011 #include "form_p.h"
00012 
00013 // qt includes
00014 #include <QtCore/QVariant>
00015 
00016 using namespace Okular;
00017 
00018 FormFieldPrivate::FormFieldPrivate( FormField::FieldType type )
00019     : m_type( type )
00020 {
00021 }
00022 
00023 FormFieldPrivate::~FormFieldPrivate()
00024 {
00025 }
00026 
00027 void FormFieldPrivate::setDefault()
00028 {
00029     m_default = value();
00030 }
00031 
00032 
00033 FormField::FormField( FormFieldPrivate &dd )
00034     : d_ptr( &dd )
00035 {
00036     d_ptr->q_ptr = this;
00037 }
00038 
00039 FormField::~FormField()
00040 {
00041     delete d_ptr;
00042 }
00043 
00044 FormField::FieldType FormField::type() const
00045 {
00046     Q_D( const FormField );
00047     return d->m_type;
00048 }
00049 
00050 bool FormField::isReadOnly() const
00051 {
00052     return false;
00053 }
00054 
00055 bool FormField::isVisible() const
00056 {
00057     return true;
00058 }
00059 
00060 
00061 class Okular::FormFieldTextPrivate : public Okular::FormFieldPrivate
00062 {
00063     public:
00064         FormFieldTextPrivate()
00065             : FormFieldPrivate( FormField::FormText )
00066         {
00067         }
00068 
00069         Q_DECLARE_PUBLIC( FormFieldText )
00070 
00071         void setValue( const QString& v )
00072         {
00073             Q_Q( FormFieldText );
00074             q->setText( v );
00075         }
00076 
00077         QString value() const
00078         {
00079             Q_Q( const FormFieldText );
00080             return q->text();
00081         }
00082 };
00083 
00084 
00085 FormFieldText::FormFieldText()
00086     : FormField( *new FormFieldTextPrivate() )
00087 {
00088 }
00089 
00090 FormFieldText::~FormFieldText()
00091 {
00092 }
00093 
00094 void FormFieldText::setText( const QString& )
00095 {
00096 }
00097 
00098 bool FormFieldText::isPassword() const
00099 {
00100     return false;
00101 }
00102 
00103 bool FormFieldText::isRichText() const
00104 {
00105     return false;
00106 }
00107 
00108 int FormFieldText::maximumLength() const
00109 {
00110     return -1;
00111 }
00112 
00113 Qt::Alignment FormFieldText::textAlignment() const
00114 {
00115     return Qt::AlignVCenter | Qt::AlignLeft;
00116 }
00117 
00118 bool FormFieldText::canBeSpellChecked() const
00119 {
00120     return false;
00121 }
00122 
00123 
00124 class Okular::FormFieldChoicePrivate : public Okular::FormFieldPrivate
00125 {
00126     public:
00127         FormFieldChoicePrivate()
00128             : FormFieldPrivate( FormField::FormChoice )
00129         {
00130         }
00131 
00132         Q_DECLARE_PUBLIC( FormFieldChoice )
00133 
00134         void setValue( const QString& v )
00135         {
00136             Q_Q( FormFieldChoice );
00137             QStringList choices = v.split( ';', QString::SkipEmptyParts );
00138             QList<int> newchoices;
00139             foreach ( const QString& str, choices )
00140             {
00141                 bool ok = true;
00142                 int val = str.toInt( &ok );
00143                 if ( ok )
00144                     newchoices.append( val );
00145             }
00146             if ( !newchoices.isEmpty() )
00147                 q->setCurrentChoices( newchoices );
00148         }
00149 
00150         QString value() const
00151         {
00152             Q_Q( const FormFieldChoice );
00153             QList<int> choices = q->currentChoices();
00154             qSort( choices );
00155             QStringList list;
00156             foreach ( int c, choices )
00157             {
00158                 list.append( QString::number( c ) );
00159             }
00160             return list.join( QLatin1String( ";" ) );
00161         }
00162 };
00163 
00164 
00165 FormFieldChoice::FormFieldChoice()
00166     : FormField( *new FormFieldChoicePrivate() )
00167 {
00168 }
00169 
00170 FormFieldChoice::~FormFieldChoice()
00171 {
00172 }
00173 
00174 bool FormFieldChoice::isEditable() const
00175 {
00176     return false;
00177 }
00178 
00179 bool FormFieldChoice::multiSelect() const
00180 {
00181     return false;
00182 }
00183 
00184 void FormFieldChoice::setCurrentChoices( const QList< int >& )
00185 {
00186 }
00187 
00188 Qt::Alignment FormFieldChoice::textAlignment() const
00189 {
00190     return Qt::AlignVCenter | Qt::AlignLeft;
00191 }
00192 
00193 bool FormFieldChoice::canBeSpellChecked() const
00194 {
00195     return false;
00196 }
00197 

okular

Skip menu "okular"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdegraphics

Skip menu "kdegraphics"
  • okular
Generated for kdegraphics by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal