• 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
kresult.cpp
Go to the documentation of this file.
1 /*
2  This file is part of KDE.
3 
4  Copyright (c) 2005 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 */
34 #include "kresult.h"
35 
36 #include <klocalizedstring.h>
37 #include <kdebug.h>
38 
39 using namespace KCal;
40 
45 //@cond PRIVATE
46 class KCal::KResult::Private
47 {
48  public:
49  Private()
50  : mType( Ok ),
51  mErrorType( NotAnError ),
52  mChainedResult( 0 )
53  {
54  }
55 
56  Private( Type type )
57  : mType( type ),
58  mChainedResult( 0 )
59  {
60  if ( mType == Error ) {
61  mErrorType = Undefined;
62  } else {
63  mErrorType = NotAnError;
64  }
65  }
66 
67  Private( ErrorType error, const QString &details )
68  : mType( Error ),
69  mErrorType( error ),
70  mDetails( details ),
71  mChainedResult( 0 )
72  {
73  }
74 
75  Type mType;
76  ErrorType mErrorType;
77  QString mDetails;
78  KResult *mChainedResult;
79 };
80 //@endcond
81 
82 KResult::KResult()
83  : d( new KCal::KResult::Private )
84 {
85 }
86 
87 KResult::KResult( Type type )
88  : d( new KCal::KResult::Private( type ) )
89 {
90 }
91 
92 KResult::KResult( ErrorType error, const QString &details )
93  : d( new KCal::KResult::Private( error, details ) )
94 {
95 }
96 
97 KResult::~KResult()
98 {
99  delete d->mChainedResult;
100  delete d;
101 }
102 
103 KResult::KResult( const KResult &o ) : d( new KCal::KResult::Private )
104 {
105  d->mType = o.d->mType;
106  d->mErrorType = o.d->mErrorType;
107  d->mDetails = o.d->mDetails;
108  if ( o.d->mChainedResult ) {
109  d->mChainedResult = new KResult( *o.d->mChainedResult );
110  } else {
111  d->mChainedResult = 0;
112  }
113 }
114 
115 KResult::operator bool() const
116 {
117  return !isError();
118 }
119 
120 bool KResult::isOk() const
121 {
122  return d->mType == Ok;
123 }
124 
125 bool KResult::isInProgress() const
126 {
127  return d->mType == InProgress;
128 }
129 
130 bool KResult::isError() const
131 {
132  return d->mType == Error;
133 }
134 
135 KResult::ErrorType KResult::error() const
136 {
137  return d->mErrorType;
138 }
139 
140 QString KResult::message() const
141 {
142  switch ( d->mType ) {
143  case Ok:
144  return i18n( "OK" );
145  case InProgress:
146  return i18n( "In progress" );
147  case Error:
148  switch ( d->mErrorType ) {
149  case NotAnError:
150  return i18n( "Not an error" );
151  case Undefined:
152  return i18n( "Error" );
153  case InvalidUrl:
154  return i18n( "Invalid URL" );
155  case ConnectionFailed:
156  return i18n( "Connection failed" );
157  case WriteError:
158  return i18n( "Write error" );
159  case ReadError:
160  return i18n( "Read error" );
161  case WrongParameter:
162  return i18n( "Wrong Parameter" );
163  case ParseError:
164  return i18n( "Parse Error" );
165  case WrongSchemaRevision:
166  return i18n( "Wrong revision of schema" );
167  }
168  }
169 
170  kError() << "Unhandled case";
171  return QString();
172 }
173 
174 void KResult::setDetails( const QString &details )
175 {
176  d->mDetails = details;
177 }
178 
179 QString KResult::details() const
180 {
181  return d->mDetails;
182 }
183 
184 KResult &KResult::chain( const KResult &result )
185 {
186  d->mChainedResult = new KResult( result );
187  return *this;
188 }
189 
190 bool KResult::hasChainedResult() const
191 {
192  return d->mChainedResult;
193 }
194 
195 KResult KResult::chainedResult() const
196 {
197  return *d->mChainedResult;
198 }
199 
200 QString KResult::fullMessage() const
201 {
202  QString msg = message();
203  if ( !details().isEmpty() ) {
204  msg += ": " + details();
205  }
206  return msg;
207 }
208 
209 QString KResult::chainedMessage() const
210 {
211  QString msg = fullMessage();
212  if ( hasChainedResult() ) {
213  msg += '\n' + chainedResult().chainedMessage();
214  }
215  return msg;
216 }
kresult.h
This file is part of the API for handling calendar data and defines the CalendarLocal class...
KCal::KResult::~KResult
~KResult()
Destroys the result.
Definition: kresult.cpp:97
KCal::KResult::Type
Type
The different types of results.
Definition: kresult.h:115
KCal::KResult::Ok
Operation successfully completed.
Definition: kresult.h:116
KCal::KResult::KResult
KResult()
Constructs a KResult object.
Definition: kresult.cpp:82
KCal::KResult::message
QString message() const
Returns a translated string describing the result corresponding to Type and ErrorType.
Definition: kresult.cpp:140
KCal::KResult
This class represents the result of an operation.
Definition: kresult.h:109
KCal::KResult::ParseError
Parse error.
Definition: kresult.h:132
KCal::KResult::isOk
bool isOk() const
Returns true if the result is Ok.
Definition: kresult.cpp:120
KCal::KResult::isError
bool isError() const
Returns true if the result is Error.
Definition: kresult.cpp:130
KCal::KResult::setDetails
void setDetails(const QString &details)
Sets a detailed error message.
Definition: kresult.cpp:174
KCal::KResult::WriteError
Write error.
Definition: kresult.h:130
KCal::KResult::chainedMessage
QString chainedMessage() const
Returns an error message including full details of all chained messages.
Definition: kresult.cpp:209
KCal::KResult::WrongSchemaRevision
Invalid schema revision.
Definition: kresult.h:133
KCal::KResult::isInProgress
bool isInProgress() const
Returns true if the result is InProgress.
Definition: kresult.cpp:125
KCal::KResult::ErrorType
ErrorType
The different types of error conditions.
Definition: kresult.h:124
KCal::KResult::NotAnError
Not an error.
Definition: kresult.h:125
KCal::KResult::InvalidUrl
Invalid URL.
Definition: kresult.h:127
KCal::KResult::Error
Operation failed.
Definition: kresult.h:118
KCal::KResult::fullMessage
QString fullMessage() const
Returns the full error message.
Definition: kresult.cpp:200
KCal::KResult::ReadError
Read error.
Definition: kresult.h:131
KCal::KResult::chain
KResult & chain(const KResult &result)
Chains result objects.
Definition: kresult.cpp:184
KCal::KResult::error
ErrorType error() const
Returns the specific result ErrorType.
Definition: kresult.cpp:135
KCal::KResult::details
QString details() const
Returns the detailed error message.
Definition: kresult.cpp:179
KCal::KResult::Undefined
Undefined error.
Definition: kresult.h:126
KCal::KResult::hasChainedResult
bool hasChainedResult() const
Returns true if the KResult object has a chained KResult object; else returns false.
Definition: kresult.cpp:190
KCal::KResult::InProgress
Operation still in-progress.
Definition: kresult.h:117
KCal::KResult::WrongParameter
Invalid parameter.
Definition: kresult.h:128
KCal::KResult::chainedResult
KResult chainedResult() const
Returns a chained KResult object.
Definition: kresult.cpp:195
KCal::KResult::ConnectionFailed
unable to establish a connection
Definition: kresult.h:129
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:58 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