KDEUI
kmessageboxmessagehandler.cpp
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2006 Michaƫl Larouche <michael.larouche@kdemail.net> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; version 2 00007 of the License. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 #include "kmessageboxmessagehandler.h" 00020 00021 #include <kmessagebox.h> 00022 00023 class KMessageBoxMessageHandlerPrivate 00024 { 00025 public: 00026 KMessageBoxMessageHandlerPrivate(KMessageBoxMessageHandler *q) 00027 : q(q) 00028 { 00029 } 00030 00031 void showMessageBox(KMessage::MessageType messageType, const QString &text, const QString &caption); 00032 QWidget *parentWidget(); 00033 00034 KMessageBoxMessageHandler *q; 00035 }; 00036 00037 00038 KMessageBoxMessageHandler::KMessageBoxMessageHandler(QWidget *parent) 00039 : QObject(parent), d(new KMessageBoxMessageHandlerPrivate(this)) 00040 { 00041 } 00042 00043 KMessageBoxMessageHandler::~KMessageBoxMessageHandler() 00044 { 00045 delete d; 00046 } 00047 00048 void KMessageBoxMessageHandler::message(KMessage::MessageType messageType, const QString &text, const QString &caption) 00049 { 00050 d->showMessageBox(messageType, text, caption); 00051 } 00052 00053 void KMessageBoxMessageHandlerPrivate::showMessageBox(KMessage::MessageType messageType, 00054 const QString &text, const QString &caption) 00055 { 00056 KMessageBox::DialogType dlgType; 00057 00058 switch (messageType) 00059 { 00060 case KMessage::Information: 00061 default: 00062 dlgType = KMessageBox::Information; 00063 break; 00064 case KMessage::Error: 00065 case KMessage::Fatal: 00066 dlgType = KMessageBox::Error; 00067 break; 00068 case KMessage::Warning: 00069 case KMessage::Sorry: 00070 dlgType = KMessageBox::Sorry; 00071 break; 00072 } 00073 00074 KMessageBox::queuedMessageBox(parentWidget(), dlgType, text, caption); 00075 } 00076 00077 QWidget *KMessageBoxMessageHandlerPrivate::parentWidget() 00078 { 00079 return qobject_cast<QWidget*>(q->parent()); 00080 } 00081 00082 #include "kmessageboxmessagehandler.moc" 00083 // kate: space-indent on; indent-width 4; encoding utf-8; replace-tabs on;
KDE 4.6 API Reference