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

KAlarm Library

  • sources
  • kde-4.12
  • kdepimlibs
  • 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 EventAttribute::EventAttribute()
40  : d(new Private)
41 {
42 }
43 
44 EventAttribute::EventAttribute(const EventAttribute& rhs)
45  : Akonadi::Attribute(rhs),
46  d(new Private(*rhs.d))
47 {
48 }
49 
50 EventAttribute::~EventAttribute()
51 {
52  delete d;
53 }
54 
55 EventAttribute& EventAttribute::operator=(const EventAttribute& other)
56 {
57  if (&other != this)
58  {
59  Attribute::operator=(other);
60  *d = *other.d;
61  }
62  return *this;
63 }
64 
65 KAEvent::CmdErrType EventAttribute::commandError() const
66 {
67  return d->mCommandError;
68 }
69 
70 void EventAttribute::setCommandError(KAEvent::CmdErrType err)
71 {
72  d->mCommandError = err;
73 }
74 
75 QByteArray EventAttribute::type() const
76 {
77  return "KAlarmEvent";
78 }
79 
80 EventAttribute* EventAttribute::clone() const
81 {
82  return new EventAttribute(*this);
83 }
84 
85 QByteArray EventAttribute::serialized() const
86 {
87  QByteArray v = QByteArray::number(d->mCommandError);
88  kDebug() << v;
89  return v;
90 }
91 
92 void EventAttribute::deserialize(const QByteArray& data)
93 {
94  kDebug() << data;
95 
96  // Set default values
97  d->mCommandError = KAEvent::CMD_NO_ERROR;
98 
99  bool ok;
100  int c[1];
101  const QList<QByteArray> items = data.simplified().split(' ');
102  switch (items.count())
103  {
104  case 1:
105  c[0] = items[0].toInt(&ok);
106  if (!ok || (c[0] & ~(KAEvent::CMD_ERROR | KAEvent::CMD_ERROR_PRE | KAEvent::CMD_ERROR_POST)))
107  return;
108  d->mCommandError = static_cast<KAEvent::CmdErrType>(c[0]);
109  break;
110 
111  default:
112  break;
113  }
114 }
115 
116 } // namespace KAlarmCal
117 
118 // vim: et sw=4:
KAlarmCal::EventAttribute::setCommandError
void setCommandError(KAEvent::CmdErrType err)
Set the last command execution error for the item.
Definition: eventattribute.cpp:70
KAlarmCal::KAEvent::CMD_ERROR_POST
post-alarm command execution failed
Definition: kaevent.h:315
KAlarmCal::EventAttribute::type
virtual QByteArray type() const
Reimplemented from Attribute.
Definition: eventattribute.cpp:75
KAlarmCal::KAEvent::CMD_NO_ERROR
no error
Definition: kaevent.h:312
KAlarmCal::KAEvent::CMD_ERROR_PRE
pre-alarm command execution failed
Definition: kaevent.h:314
KAlarmCal::KAEvent::CmdErrType
CmdErrType
Command execution error type for last time the alarm was triggered.
Definition: kaevent.h:310
KAlarmCal::EventAttribute::commandError
KAEvent::CmdErrType commandError() const
Return the last command execution error for the item.
Definition: eventattribute.cpp:65
KAlarmCal::EventAttribute::deserialize
virtual void deserialize(const QByteArray &data)
Reimplemented from Attribute.
Definition: eventattribute.cpp:92
KAlarmCal::KAEvent::CMD_ERROR
command alarm execution failed
Definition: kaevent.h:313
KAlarmCal::EventAttribute::operator=
EventAttribute & operator=(const EventAttribute &other)
Assignment operator.
Definition: eventattribute.cpp:55
KAlarmCal::EventAttribute
An Attribute containing status information for a KAlarm item.
Definition: eventattribute.h:47
KAlarmCal::EventAttribute::clone
virtual EventAttribute * clone() const
Reimplemented from Attribute.
Definition: eventattribute.cpp:80
KAlarmCal::EventAttribute::serialized
virtual QByteArray serialized() const
Reimplemented from Attribute.
Definition: eventattribute.cpp:85
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:01:14 by doxygen 1.8.7 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 API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



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