Quantum GIS API Documentation  1.7.4
src/gui/qgsmessageviewer.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                           qgsmessageviewer.cpp  -  description
00003                              -------------------
00004     begin                : Wed Jun 4 2003
00005     copyright            : (C) 2002 by Gary E.Sherman
00006     email                : sherman at mrcc.com
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 /* $Id$ */
00018 
00019 #include "qgsmessageviewer.h"
00020 #include <QSettings>
00021 
00022 QgsMessageViewer::QgsMessageViewer( QWidget *parent, Qt::WFlags fl )
00023     : QDialog( parent, fl )
00024 {
00025   setupUi( this );
00026   setAttribute( Qt::WA_DeleteOnClose );
00027 
00028   // Default state for the checkbox
00029   setCheckBoxVisible( false );
00030   setCheckBoxState( Qt::Unchecked );
00031 
00032   mCheckBoxQSettingsLabel = "";
00033 }
00034 
00035 QgsMessageViewer::~QgsMessageViewer()
00036 {
00037 }
00038 
00039 void QgsMessageViewer::setMessageAsHtml( const QString& msg )
00040 {
00041   txtMessage->setHtml( msg );
00042 }
00043 
00044 void QgsMessageViewer::setMessageAsPlainText( const QString& msg )
00045 {
00046   txtMessage->setPlainText( msg );
00047 }
00048 
00049 void QgsMessageViewer::appendMessage( const QString& msg )
00050 {
00051   txtMessage->append( msg );
00052 }
00053 
00054 
00055 void QgsMessageViewer::setMessage( const QString& message, MessageType msgType )
00056 {
00057   if ( msgType == MessageHtml )
00058     setMessageAsHtml( message );
00059   else
00060     setMessageAsPlainText( message );
00061 }
00062 
00063 void QgsMessageViewer::showMessage( bool blocking )
00064 {
00065   if ( blocking )
00066   {
00067     QApplication::setOverrideCursor( Qt::ArrowCursor );
00068     exec();
00069     QApplication::restoreOverrideCursor();
00070   }
00071   else
00072   {
00073     show();
00074   }
00075 }
00076 
00077 void QgsMessageViewer::setTitle( const QString& title )
00078 {
00079   setWindowTitle( title );
00080 }
00081 
00082 void QgsMessageViewer::setCheckBoxText( const QString& text )
00083 {
00084   checkBox->setText( text );
00085 }
00086 
00087 void QgsMessageViewer::setCheckBoxVisible( bool visible )
00088 {
00089   checkBox->setVisible( visible );
00090 }
00091 
00092 void QgsMessageViewer::setCheckBoxState( Qt::CheckState state )
00093 {
00094   checkBox->setCheckState( state );
00095 }
00096 
00097 Qt::CheckState QgsMessageViewer::checkBoxState()
00098 {
00099   return checkBox->checkState();
00100 }
00101 
00102 void QgsMessageViewer::setCheckBoxQSettingsLabel( QString label )
00103 {
00104   mCheckBoxQSettingsLabel = label;
00105 }
00106 
00107 
00108 void QgsMessageViewer::on_checkBox_toggled( bool toggled )
00109 {
00110   if ( !mCheckBoxQSettingsLabel.isEmpty() )
00111   {
00112     QSettings settings;
00113     if ( checkBox->checkState() == Qt::Checked )
00114       settings.setValue( mCheckBoxQSettingsLabel, false );
00115     else
00116       settings.setValue( mCheckBoxQSettingsLabel, true );
00117   }
00118 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines