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

KAlarm Library

eventattribute.cpp
00001 /*
00002  *  eventattribute.cpp  -  per-user attributes for individual events
00003  *  This file is part of kalarmcal library, which provides access to KAlarm
00004  *  calendar data.
00005  *  Copyright © 2010-2011 by David Jarvie <djarvie@kde.org>
00006  *
00007  *  This library is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU Library General Public License as published
00009  *  by the Free Software Foundation; either version 2 of the License, or (at
00010  *  your option) any later version.
00011  *
00012  *  This library is distributed in the hope that it will be useful, but WITHOUT
00013  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014  *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00015  *  License for more details.
00016  *
00017  *  You should have received a copy of the GNU Library General Public License
00018  *  along with this library; see the file COPYING.LIB.  If not, write to the
00019  *  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00020  *  MA 02110-1301, USA.
00021  */
00022 
00023 #include "eventattribute.h"
00024 
00025 #include <QList>
00026 #include <QByteArray>
00027 
00028 namespace KAlarmCal
00029 {
00030 
00031 class EventAttribute::Private
00032 {
00033     public:
00034         Private() : mCommandError(KAEvent::CMD_NO_ERROR) {}
00035 
00036         KAEvent::CmdErrType mCommandError;         // the last command execution error for the alarm
00037 };
00038 
00039 
00040 EventAttribute::EventAttribute()
00041     : d(new Private)
00042 {
00043 }
00044 
00045 EventAttribute::EventAttribute(const EventAttribute& rhs)
00046     : Akonadi::Attribute(rhs),
00047       d(new Private(*rhs.d))
00048 {
00049 }
00050 
00051 EventAttribute::~EventAttribute()
00052 {
00053     delete d;
00054 }
00055 
00056 EventAttribute& EventAttribute::operator=(const EventAttribute& other)
00057 {
00058     if (&other != this)
00059     {
00060         Attribute::operator=(other);
00061         *d = *other.d;
00062     }
00063     return *this;
00064 }
00065 
00066 KAEvent::CmdErrType EventAttribute::commandError() const
00067 {
00068     return d->mCommandError;
00069 }
00070 
00071 void EventAttribute::setCommandError(KAEvent::CmdErrType err)
00072 {
00073     d->mCommandError = err;
00074 }
00075 
00076 QByteArray EventAttribute::type() const
00077 {
00078     return "KAlarmEvent";
00079 }
00080 
00081 EventAttribute* EventAttribute::clone() const
00082 {
00083     return new EventAttribute(*this);
00084 }
00085 
00086 QByteArray EventAttribute::serialized() const
00087 {
00088     QByteArray v = QByteArray::number(d->mCommandError);
00089     kDebug() << v;
00090     return v;
00091 }
00092 
00093 void EventAttribute::deserialize(const QByteArray& data)
00094 {
00095     kDebug() << data;
00096 
00097     // Set default values
00098     d->mCommandError = KAEvent::CMD_NO_ERROR;
00099 
00100     bool ok;
00101     int c[1];
00102     const QList<QByteArray> items = data.simplified().split(' ');
00103     switch (items.count())
00104     {
00105         case 1:
00106             c[0] = items[0].toInt(&ok);
00107             if (!ok  ||  (c[0] & ~(KAEvent::CMD_ERROR | KAEvent::CMD_ERROR_PRE | KAEvent::CMD_ERROR_POST)))
00108                 return;
00109             d->mCommandError = static_cast<KAEvent::CmdErrType>(c[0]);
00110             break;
00111 
00112         default:
00113             break;
00114     }
00115 }
00116 
00117 } // namespace KAlarmCal
00118 
00119 // vim: et sw=4:

KAlarm Library

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • 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.6.1
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