akonadi
itemserializerplugin.cpp
00001 /* 00002 Copyright (c) 2007 Till Adam <adam@kde.org> 00003 Copyright (c) 2007 Volker Krause <vkrause@kde.org> 00004 00005 This library is free software; you can redistribute it and/or modify it 00006 under the terms of the GNU Library General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or (at your 00008 option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, but WITHOUT 00011 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to the 00017 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00018 02110-1301, USA. 00019 */ 00020 00021 #include "itemserializerplugin.h" 00022 #include "item.h" 00023 00024 #include <QtCore/QBuffer> 00025 00026 using namespace Akonadi; 00027 00028 ItemSerializerPlugin::~ItemSerializerPlugin() 00029 { 00030 } 00031 00032 QSet<QByteArray> ItemSerializerPlugin::parts( const Item & item ) const 00033 { 00034 QSet<QByteArray> set; 00035 if ( item.hasPayload() ) 00036 set.insert( Item::FullPayload ); 00037 00038 return set; 00039 } 00040 00041 ItemSerializerPluginV2::~ItemSerializerPluginV2() 00042 { 00043 } 00044 00045 QSet<QByteArray> ItemSerializerPluginV2::availableParts( const Item & item ) const 00046 { 00047 if ( item.hasPayload() ) 00048 return QSet<QByteArray>(); 00049 00050 return QSet<QByteArray>() << Item::FullPayload; 00051 } 00052 00053 void ItemSerializerPluginV2::apply( Item &item, const Item &other ) 00054 { 00055 QBuffer buffer; 00056 QByteArray data( other.payloadData() ); 00057 buffer.setBuffer( &data ); 00058 buffer.open( QIODevice::ReadOnly ); 00059 00060 foreach ( const QByteArray &part, other.loadedPayloadParts() ) { 00061 buffer.seek( 0 ); 00062 deserialize( item, part, buffer, 0 ); 00063 } 00064 00065 buffer.close(); 00066 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu Aug 2 2012 15:25:19 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu Aug 2 2012 15:25:19 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.