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 | |
23 | #include "errorhandler.h" |
24 | |
25 | #include <kdebug.h> |
26 | #include <klocalizedstring.h> |
27 | #include <kmessagebox.h> |
28 | |
29 | #include <QApplication> |
30 | |
31 | using namespace KABC; |
32 | |
33 | ErrorHandler::~ErrorHandler() |
34 | { |
35 | } |
36 | |
37 | ConsoleErrorHandler::ConsoleErrorHandler() |
38 | : d( 0 ) |
39 | { |
40 | } |
41 | |
42 | ConsoleErrorHandler::~ConsoleErrorHandler() |
43 | { |
44 | } |
45 | |
46 | void ConsoleErrorHandler::error( const QString &msg ) |
47 | { |
48 | // no debug area is ok here |
49 | kError( 5700 ) << msg; |
50 | } |
51 | |
52 | class GuiErrorHandler::Private |
53 | { |
54 | public: |
55 | Private( QWidget *widget ) |
56 | : mWidget( widget ) |
57 | { |
58 | } |
59 | |
60 | QWidget *mWidget; |
61 | }; |
62 | |
63 | GuiErrorHandler::GuiErrorHandler( QWidget *widget ) |
64 | : d( new Private( widget ) ) |
65 | { |
66 | } |
67 | |
68 | GuiErrorHandler::~GuiErrorHandler() |
69 | { |
70 | delete d; |
71 | } |
72 | |
73 | void GuiErrorHandler::error( const QString &msg ) |
74 | { |
75 | if ( qApp ) { |
76 | KMessageBox::error( d->mWidget, msg ); |
77 | } |
78 | } |
79 | |