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

KCal Library

  • sources
  • kde-4.12
  • kdepimlibs
  • kcal
exceptions.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the kcal library.
3 
4  Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
36 #include "exceptions.h"
37 #include "calformat.h"
38 
39 #include <klocalizedstring.h>
40 
41 using namespace KCal;
42 
43 Exception::Exception( const QString &message )
44 {
45  mMessage = message;
46 }
47 
48 Exception::~Exception()
49 {
50 }
51 
52 QString Exception::message()
53 {
54  if ( mMessage.isEmpty() ) {
55  return i18n( "%1 Error", CalFormat::application() );
56  } else {
57  return mMessage;
58  }
59 }
60 
65 //@cond PRIVATE
66 class KCal::ErrorFormat::Private
67 {
68  public:
69  ErrorCodeFormat mCode;
70 };
71 //@endcond
72 
73 ErrorFormat::ErrorFormat( ErrorCodeFormat code, const QString &message )
74  : Exception( message ), d( new KCal::ErrorFormat::Private )
75 {
76  d->mCode = code;
77 }
78 
79 ErrorFormat::~ErrorFormat()
80 {
81  delete d;
82 }
83 
84 QString ErrorFormat::message()
85 {
86  QString message = "";
87 
88  switch ( d->mCode ) {
89  case LoadError:
90  message = i18n( "Load Error" );
91  break;
92  case SaveError:
93  message = i18n( "Save Error" );
94  break;
95  case ParseErrorIcal:
96  message = i18n( "Parse Error in libical" );
97  break;
98  case ParseErrorKcal:
99  message = i18n( "Parse Error in libkcal" );
100  break;
101  case NoCalendar:
102  message = i18n( "No calendar component found." );
103  break;
104  case CalVersion1:
105  message = i18n( "vCalendar Version 1.0 detected." );
106  break;
107  case CalVersion2:
108  message = i18n( "iCalendar Version 2.0 detected." );
109  break;
110  case CalVersionUnknown:
111  message = i18n( "Unknown calendar format detected." );
112  break;
113  case Restriction:
114  message = i18n( "Restriction violation" );
115  break;
116  case NoWritableFound:
117  message = i18n( "No writable resource found" );
118  break;
119  case UserCancel:
120  // no real error; the user canceled the operation
121  break;
122  }
123 
124  if ( !mMessage.isEmpty() ) {
125  message += ": " + mMessage;
126  }
127 
128  return message;
129 }
130 
131 ErrorFormat::ErrorCodeFormat ErrorFormat::errorCode()
132 {
133  return d->mCode;
134 }
KCal::Exception::message
virtual QString message()
Returns the exception message.
Definition: exceptions.cpp:52
KCal::Exception::~Exception
virtual ~Exception()
Destructor.
Definition: exceptions.cpp:48
KCal::ErrorFormat::~ErrorFormat
~ErrorFormat()
Destructor.
Definition: exceptions.cpp:79
KCal::ErrorFormat::errorCode
ErrorCodeFormat errorCode()
Returns the format error code.
Definition: exceptions.cpp:131
KCal::Exception::Exception
Exception(const QString &message=QString())
Construct an exception with a descriptive message.
Definition: exceptions.cpp:43
KCal::ErrorFormat::CalVersion1
vCalendar v1.0 detected
Definition: exceptions.h:94
KCal::ErrorFormat::UserCancel
User canceled the operation.
Definition: exceptions.h:98
KCal::ErrorFormat::CalVersionUnknown
Unknown calendar format detected.
Definition: exceptions.h:96
calformat.h
This file is part of the API for handling calendar data and defines the CalFormat abstract base class...
KCal::ErrorFormat::CalVersion2
iCalendar v2.0 detected
Definition: exceptions.h:95
KCal::Exception::mMessage
QString mMessage
The current exception message.
Definition: exceptions.h:69
KCal::ErrorFormat::message
QString message()
Returns the format error message.
Definition: exceptions.cpp:84
KCal::ErrorFormat::ErrorCodeFormat
ErrorCodeFormat
The different types of Calendar format errors.
Definition: exceptions.h:88
KCal::ErrorFormat::SaveError
Save error.
Definition: exceptions.h:90
KCal::ErrorFormat::ParseErrorKcal
Parse error in libkcal.
Definition: exceptions.h:92
KCal::ErrorFormat::NoCalendar
No calendar component found.
Definition: exceptions.h:93
KCal::CalFormat::application
static const QString & application()
Returns the application name used in unique IDs and error messages.
Definition: calformat.cpp:95
exceptions.h
This file is part of the API for handling calendar data and defines the Exception and ErrorFormat cla...
KCal::ErrorFormat
Calendar format related error class.
Definition: exceptions.h:82
KCal::ErrorFormat::NoWritableFound
No writable resource is available.
Definition: exceptions.h:99
KCal::ErrorFormat::Restriction
Restriction violation.
Definition: exceptions.h:97
KCal::ErrorFormat::ParseErrorIcal
Parse error in libical.
Definition: exceptions.h:91
KCal::ErrorFormat::ErrorFormat
ErrorFormat(ErrorCodeFormat code, const QString &message=QString())
Creates a format error exception.
Definition: exceptions.cpp:73
KCal::Exception
Exceptions base class, currently used as a fancy kind of error code and not as an C++ exception...
Definition: exceptions.h:48
KCal::ErrorFormat::LoadError
Load error.
Definition: exceptions.h:89
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:57 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KCal Library

Skip menu "KCal Library"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • 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