• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.10 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
28namespace KAlarmCal
29{
30
31class 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
39EventAttribute::EventAttribute()
40 : d(new Private)
41{
42}
43
44EventAttribute::EventAttribute(const EventAttribute& rhs)
45 : Akonadi::Attribute(rhs),
46 d(new Private(*rhs.d))
47{
48}
49
50EventAttribute::~EventAttribute()
51{
52 delete d;
53}
54
55EventAttribute& 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
65KAEvent::CmdErrType EventAttribute::commandError() const
66{
67 return d->mCommandError;
68}
69
70void EventAttribute::setCommandError(KAEvent::CmdErrType err)
71{
72 d->mCommandError = err;
73}
74
75QByteArray EventAttribute::type() const
76{
77 static const QByteArray attType("KAlarmEvent");
78 return attType;
79}
80
81EventAttribute* EventAttribute::clone() const
82{
83 return new EventAttribute(*this);
84}
85
86QByteArray EventAttribute::serialized() const
87{
88 const QByteArray v = QByteArray::number(d->mCommandError);
89 kDebug() << v;
90 return v;
91}
92
93void 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:
KAlarmCal::EventAttribute
An Attribute containing status information for a KAlarm item.
Definition: eventattribute.h:48
KAlarmCal::EventAttribute::deserialize
virtual void deserialize(const QByteArray &data)
Reimplemented from Attribute.
Definition: eventattribute.cpp:93
KAlarmCal::EventAttribute::clone
virtual EventAttribute * clone() const
Reimplemented from Attribute.
Definition: eventattribute.cpp:81
KAlarmCal::EventAttribute::type
virtual QByteArray type() const
Reimplemented from Attribute.
Definition: eventattribute.cpp:75
KAlarmCal::EventAttribute::operator=
EventAttribute & operator=(const EventAttribute &other)
Assignment operator.
Definition: eventattribute.cpp:55
KAlarmCal::EventAttribute::serialized
virtual QByteArray serialized() const
Reimplemented from Attribute.
Definition: eventattribute.cpp:86
KAlarmCal::EventAttribute::commandError
KAEvent::CmdErrType commandError() const
Return the last command execution error for the item.
Definition: eventattribute.cpp:65
KAlarmCal::EventAttribute::setCommandError
void setCommandError(KAEvent::CmdErrType err)
Set the last command execution error for the item.
Definition: eventattribute.cpp:70
KAlarmCal::KAEvent::CmdErrType
CmdErrType
Command execution error type for last time the alarm was triggered.
Definition: kaevent.h:310
KAlarmCal::KAEvent::CMD_ERROR_PRE
@ CMD_ERROR_PRE
pre-alarm command execution failed
Definition: kaevent.h:313
KAlarmCal::KAEvent::CMD_ERROR
@ CMD_ERROR
command alarm execution failed
Definition: kaevent.h:312
KAlarmCal::KAEvent::CMD_ERROR_POST
@ CMD_ERROR_POST
post-alarm command execution failed
Definition: kaevent.h:314
KAlarmCal::KAEvent::CMD_NO_ERROR
@ CMD_NO_ERROR
no error
Definition: kaevent.h:311
Akonadi
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jul 21 2022 00:00:00 by doxygen 1.9.5 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.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 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