• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • KDE Home
  • Contact Us
 

mailtransport

sentactionattribute.cpp
00001 /*
00002     Copyright (C) 2010 Klarälvdalens Datakonsult AB,
00003         a KDAB Group company, info@kdab.net,
00004         author Tobias Koenig <tokoe@kdab.com>
00005 
00006     This library is free software; you can redistribute it and/or modify it
00007     under the terms of the GNU Library General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or (at your
00009     option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful, but WITHOUT
00012     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00014     License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to the
00018     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00019     02110-1301, USA.
00020 */
00021 
00022 #include "sentactionattribute.h"
00023 
00024 #include <QtCore/QDataStream>
00025 #include <QtCore/QSharedData>
00026 
00027 using namespace Akonadi;
00028 using namespace MailTransport;
00029 
00030 class SentActionAttribute::Action::Private : public QSharedData
00031 {
00032   public:
00033     Private()
00034       : mType( Invalid )
00035     {
00036     }
00037 
00038     Private( const Private &other )
00039       : QSharedData( other )
00040     {
00041       mType = other.mType;
00042       mValue = other.mValue;
00043     }
00044 
00045     Type mType;
00046     QVariant mValue;
00047 };
00048 
00049 SentActionAttribute::Action::Action()
00050   : d( new Private )
00051 {
00052 }
00053 
00054 SentActionAttribute::Action::Action( Type type, const QVariant &value )
00055   : d( new Private )
00056 {
00057   d->mType = type;
00058   d->mValue = value;
00059 }
00060 
00061 SentActionAttribute::Action::Action( const Action &other )
00062   : d( other.d )
00063 {
00064 }
00065 
00066 SentActionAttribute::Action::~Action()
00067 {
00068 }
00069 
00070 SentActionAttribute::Action::Type SentActionAttribute::Action::type() const
00071 {
00072   return d->mType;
00073 }
00074 
00075 QVariant SentActionAttribute::Action::value() const
00076 {
00077   return d->mValue;
00078 }
00079 
00080 SentActionAttribute::Action& SentActionAttribute::Action::operator=( const Action &other )
00081 {
00082   if ( this != &other )
00083     d = other.d;
00084 
00085   return *this;
00086 }
00087 
00088 bool SentActionAttribute::Action::operator==( const Action &other ) const
00089 {
00090   return ((d->mType == other.d->mType) && (d->mValue == other.d->mValue));
00091 }
00092 
00093 
00094 class SentActionAttribute::Private
00095 {
00096   public:
00097     Action::List mActions;
00098 };
00099 
00100 SentActionAttribute::SentActionAttribute()
00101   : d( new Private )
00102 {
00103 }
00104 
00105 SentActionAttribute::~SentActionAttribute()
00106 {
00107   delete d;
00108 }
00109 
00110 void SentActionAttribute::addAction( Action::Type type, const QVariant &value )
00111 {
00112   d->mActions.append( Action( type, value ) );
00113 }
00114 
00115 SentActionAttribute::Action::List SentActionAttribute::actions() const
00116 {
00117   return d->mActions;
00118 }
00119 
00120 SentActionAttribute *SentActionAttribute::clone() const
00121 {
00122   SentActionAttribute *attribute = new SentActionAttribute;
00123   attribute->d->mActions = d->mActions;
00124 
00125   return attribute;
00126 }
00127 
00128 QByteArray SentActionAttribute::type() const
00129 {
00130   static const QByteArray sType( "SentActionAttribute" );
00131   return sType;
00132 }
00133 
00134 QByteArray SentActionAttribute::serialized() const
00135 {
00136   QVariantList list;
00137   foreach ( const Action &action, d->mActions ) {
00138     QVariantMap map;
00139     map.insert( QString::number( action.type() ), action.value() );
00140 
00141     list << QVariant( map );
00142   }
00143 
00144   QByteArray data;
00145   QDataStream stream( &data, QIODevice::WriteOnly );
00146   stream.setVersion( QDataStream::Qt_4_7 );
00147   stream << list;
00148 
00149   return data;
00150 }
00151 
00152 void SentActionAttribute::deserialize( const QByteArray &data )
00153 {
00154   d->mActions.clear();
00155 
00156   QDataStream stream( data );
00157   stream.setVersion( QDataStream::Qt_4_7 );
00158 
00159   QVariantList list;
00160   stream >> list;
00161 
00162   foreach ( const QVariant &variant, list ) {
00163     const QVariantMap map = variant.toMap();
00164     QMapIterator<QString, QVariant> it( map );
00165     while ( it.hasNext() ) {
00166       it.next();
00167       d->mActions << Action( static_cast<Action::Type>( it.key().toInt() ), it.value() );
00168     }
00169   }
00170 }

mailtransport

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.7.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