Quantum GIS API Documentation  1.7.4
src/core/qgsmessageoutput.cpp
Go to the documentation of this file.
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 /* $Id$ */
00016 
00017 #include "qgsmessageoutput.h"
00018 #include "qgslogger.h"
00019 
00020 static QgsMessageOutput* messageOutputConsole_()
00021 {
00022   return new QgsMessageOutputConsole;
00023 }
00024 
00025 // default output creator - console
00026 MESSAGE_OUTPUT_CREATOR QgsMessageOutput::mMessageOutputCreator = messageOutputConsole_;
00027 
00028 
00029 void QgsMessageOutput::setMessageOutputCreator( MESSAGE_OUTPUT_CREATOR f )
00030 {
00031   mMessageOutputCreator = f;
00032 }
00033 
00034 QgsMessageOutput* QgsMessageOutput::createMessageOutput()
00035 {
00036   return mMessageOutputCreator();
00037 }
00038 
00039 QgsMessageOutput::~QgsMessageOutput()
00040 {
00041 }
00042 
00044 // QgsMessageOutputConsole
00045 
00046 QgsMessageOutputConsole::QgsMessageOutputConsole()
00047     : mMessage( "" )
00048 {
00049 }
00050 
00051 void QgsMessageOutputConsole::setMessage( const QString& message, MessageType )
00052 {
00053   mMessage = message;
00054 }
00055 
00056 void QgsMessageOutputConsole::appendMessage( const QString& message )
00057 {
00058   mMessage += message;
00059 }
00060 
00061 void QgsMessageOutputConsole::showMessage( bool )
00062 {
00063   // show title if provided
00064   if ( !mTitle.isNull() )
00065   {
00066     QgsDebugMsg( QString( "%1:" ).arg( mTitle ) );
00067   }
00068 
00069   // show the message
00070   QgsDebugMsg( mMessage );
00071   emit destroyed();
00072   delete this;
00073 }
00074 
00075 void QgsMessageOutputConsole::setTitle( const QString& title )
00076 {
00077   mTitle = title;
00078 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines