• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.10.5 API Reference
  • KDE Home
  • Contact Us
 

KAlarm Library

  • kalarmcal
eventattribute.cpp
1 /*
2  * eventattribute.cpp - per-user attributes for individual events
3  * This file is part of kalarmcal library, which provides access to KAlarm
4  * calendar data.
5  * Copyright © 2010-2011 by David Jarvie <djarvie@kde.org>
6  *
7  * This library is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Library General Public License as published
9  * by the Free Software Foundation; either version 2 of the License, or (at
10  * your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
15  * License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public License
18  * along with this library; see the file COPYING.LIB. If not, write to the
19  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20  * MA 02110-1301, USA.
21  */
22 
23 #include "eventattribute.h"
24 
25 #include <QList>
26 #include <QByteArray>
27 
28 namespace KAlarmCal
29 {
30 
31 class EventAttribute::Private
32 {
33  public:
34  Private() : mCommandError(KAEvent::CMD_NO_ERROR) {}
35 
36  KAEvent::CmdErrType mCommandError; // the last command execution error for the alarm
37 };
38 
39 
40 EventAttribute::EventAttribute()
41  : d(new Private)
42 {
43 }
44 
45 EventAttribute::EventAttribute(const EventAttribute& rhs)
46  : Akonadi::Attribute(rhs),
47  d(new Private(*rhs.d))
48 {
49 }
50 
51 EventAttribute::~EventAttribute()
52 {
53  delete d;
54 }
55 
56 EventAttribute& EventAttribute::operator=(const EventAttribute& other)
57 {
58  if (&other != this)
59  {
60  Attribute::operator=(other);
61  *d = *other.d;
62  }
63  return *this;
64 }
65 
66 KAEvent::CmdErrType EventAttribute::commandError() const
67 {
68  return d->mCommandError;
69 }
70 
71 void EventAttribute::setCommandError(KAEvent::CmdErrType err)
72 {
73  d->mCommandError = err;
74 }
75 
76 QByteArray EventAttribute::type() const
77 {
78  return "KAlarmEvent";
79 }
80 
81 EventAttribute* EventAttribute::clone() const
82 {
83  return new EventAttribute(*this);
84 }
85 
86 QByteArray EventAttribute::serialized() const
87 {
88  QByteArray v = QByteArray::number(d->mCommandError);
89  kDebug() << v;
90  return v;
91 }
92 
93 void EventAttribute::deserialize(const QByteArray& data)
94 {
95  kDebug() << data;
96 
97  // Set default values
98  d->mCommandError = KAEvent::CMD_NO_ERROR;
99 
100  bool ok;
101  int c[1];
102  const QList<QByteArray> items = data.simplified().split(' ');
103  switch (items.count())
104  {
105  case 1:
106  c[0] = items[0].toInt(&ok);
107  if (!ok || (c[0] & ~(KAEvent::CMD_ERROR | KAEvent::CMD_ERROR_PRE | KAEvent::CMD_ERROR_POST)))
108  return;
109  d->mCommandError = static_cast<KAEvent::CmdErrType>(c[0]);
110  break;
111 
112  default:
113  break;
114  }
115 }
116 
117 } // namespace KAlarmCal
118 
119 // vim: et sw=4:
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:30:13 by doxygen 1.8.3.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KAlarm Library

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

kdepimlibs-4.10.5 API Reference

Skip menu "kdepimlibs-4.10.5 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal