• 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.14
  • 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  static const QByteArray attType("KAlarmEvent");
78  return attType;
79 }
80 
81 EventAttribute* EventAttribute::clone() const
82 {
83  return new EventAttribute(*this);
84 }
85 
86 QByteArray EventAttribute::serialized() const
87 {
88  const 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:
QByteArray::split
QList< QByteArray > split(char sep) const
KAlarmCal::EventAttribute::setCommandError
void setCommandError(KAEvent::CmdErrType err)
Set the last command execution error for the item.
Definition: eventattribute.cpp:70
QByteArray
KAlarmCal::KAEvent::CMD_ERROR_POST
post-alarm command execution failed
Definition: kaevent.h:314
KAlarmCal::EventAttribute::type
virtual QByteArray type() const
Reimplemented from Attribute.
Definition: eventattribute.cpp:75
QList::count
int count(const T &value) const
KAlarmCal::KAEvent::CMD_NO_ERROR
no error
Definition: kaevent.h:311
QByteArray::number
QByteArray number(int n, int base)
KAlarmCal::KAEvent::CMD_ERROR_PRE
pre-alarm command execution failed
Definition: kaevent.h:313
QList
KAlarmCal::KAEvent::CmdErrType
CmdErrType
Command execution error type for last time the alarm was triggered.
Definition: kaevent.h:309
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:93
QByteArray::simplified
QByteArray simplified() const
KAlarmCal::KAEvent::CMD_ERROR
command alarm execution failed
Definition: kaevent.h:312
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:81
KAlarmCal::EventAttribute::serialized
virtual QByteArray serialized() const
Reimplemented from Attribute.
Definition: eventattribute.cpp:86
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:38:49 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
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2

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