1/*
2 This file is part of libkabc.
3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public 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
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21*/
22#ifndef KABC_ERRORHANDLER_H
23#define KABC_ERRORHANDLER_H
24
25#include "kabc_export.h"
26#include <QtCore/QString>
27
28class QWidget;
29
30namespace KABC {
31
32/**
33 Abstract class that provides displaying of error messages.
34 We need this to make libkabc gui independent on the one side
35 and provide user friendly error messages on the other side.
36 Use @p ConsoleErrorHandler or @p GuiErrorHandler in your
37 application or provide your own ErrorHandler.
38*/
39class KABC_EXPORT ErrorHandler
40{
41 public:
42 /**
43 Destroys the handler instance.
44 */
45 virtual ~ErrorHandler();
46
47 /**
48 Show error message.
49
50 @param msg The error message to show
51 */
52 virtual void error( const QString &msg ) = 0;
53};
54
55/**
56 This class prints the error messages to stderr via kError().
57*/
58class KABC_EXPORT ConsoleErrorHandler : public ErrorHandler
59{
60 public:
61 /**
62 Create an error handler for console output.
63
64 Uses kError() to write the error messages.
65 */
66 ConsoleErrorHandler();
67
68 /**
69 Destroys the handler instance.
70 */
71 virtual ~ConsoleErrorHandler();
72
73 virtual void error( const QString &msg );
74
75 private:
76 class Private;
77 Private *const d;
78
79 Q_DISABLE_COPY( ConsoleErrorHandler )
80};
81
82/**
83 This class shows messages boxes for every
84 error message.
85*/
86class KABC_EXPORT GuiErrorHandler : public ErrorHandler
87{
88 public:
89 /**
90 Create error handler.
91
92 Uses KMessageBox::error() to display the error messages.
93
94 @param parent Widget which is used as parent for the error dialogs.
95 */
96 GuiErrorHandler( QWidget *parent = 0 );
97
98 /**
99 Destroys the handler instance.
100 */
101 virtual ~GuiErrorHandler();
102
103 virtual void error( const QString &msg );
104
105 private:
106 class Private;
107 Private *const d;
108
109 Q_DISABLE_COPY( GuiErrorHandler )
110};
111
112}
113
114#endif
115