00001 /*************************************************************************** 00002 qgsmessageoutput.h - interface for showing messages 00003 ---------------------- 00004 begin : April 2006 00005 copyright : (C) 2006 by Martin Dobias 00006 email : wonder.sk at gmail dot com 00007 *************************************************************************** 00008 * * 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; either version 2 of the License, or * 00012 * (at your option) any later version. * 00013 * * 00014 ***************************************************************************/ 00015 00016 #include "qgsmessageoutput.h" 00017 #include "qgslogger.h" 00018 00019 static QgsMessageOutput* messageOutputConsole_() 00020 { 00021 return new QgsMessageOutputConsole; 00022 } 00023 00024 // default output creator - console 00025 MESSAGE_OUTPUT_CREATOR QgsMessageOutput::mMessageOutputCreator = messageOutputConsole_; 00026 00027 00028 void QgsMessageOutput::setMessageOutputCreator( MESSAGE_OUTPUT_CREATOR f ) 00029 { 00030 mMessageOutputCreator = f; 00031 } 00032 00033 QgsMessageOutput* QgsMessageOutput::createMessageOutput() 00034 { 00035 return mMessageOutputCreator(); 00036 } 00037 00038 QgsMessageOutput::~QgsMessageOutput() 00039 { 00040 } 00041 00043 // QgsMessageOutputConsole 00044 00045 QgsMessageOutputConsole::QgsMessageOutputConsole() 00046 : mMessage( "" ) 00047 { 00048 } 00049 00050 void QgsMessageOutputConsole::setMessage( const QString& message, MessageType ) 00051 { 00052 mMessage = message; 00053 } 00054 00055 void QgsMessageOutputConsole::appendMessage( const QString& message ) 00056 { 00057 mMessage += message; 00058 } 00059 00060 void QgsMessageOutputConsole::showMessage( bool ) 00061 { 00062 // show title if provided 00063 if ( !mTitle.isNull() ) 00064 { 00065 QgsDebugMsg( QString( "%1:" ).arg( mTitle ) ); 00066 } 00067 00068 // show the message 00069 QgsDebugMsg( mMessage ); 00070 emit destroyed(); 00071 delete this; 00072 } 00073 00074 void QgsMessageOutputConsole::setTitle( const QString& title ) 00075 { 00076 mTitle = title; 00077 }
1.5.6