Quantum GIS API Documentation  1.8
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 
00018 #include "qgsmessageviewer.h"
00019 #include <QSettings>
00020 
00021 QgsMessageViewer::QgsMessageViewer( QWidget *parent, Qt::WFlags fl )
00022     : QDialog( parent, fl )
00023 {
00024   setupUi( this );
00025   setAttribute( Qt::WA_DeleteOnClose );
00026 
00027   // Default state for the checkbox
00028   setCheckBoxVisible( false );
00029   setCheckBoxState( Qt::Unchecked );
00030 
00031   mCheckBoxQSettingsLabel = "";
00032 }
00033 
00034 QgsMessageViewer::~QgsMessageViewer()
00035 {
00036 }
00037 
00038 void QgsMessageViewer::setMessageAsHtml( const QString &msg )
00039 {
00040   txtMessage->setHtml( msg );
00041 }
00042 
00043 void QgsMessageViewer::setMessageAsPlainText( const QString &msg )
00044 {
00045   txtMessage->setPlainText( msg );
00046 }
00047 
00048 void QgsMessageViewer::appendMessage( const QString &msg )
00049 {
00050   txtMessage->append( msg );
00051 }
00052 
00053 
00054 void QgsMessageViewer::setMessage( const QString &message, MessageType msgType )
00055 {
00056   if ( msgType == MessageHtml )
00057     setMessageAsHtml( message );
00058   else
00059     setMessageAsPlainText( message );
00060 }
00061 
00062 void QgsMessageViewer::showMessage( bool blocking )
00063 {
00064   if ( blocking )
00065   {
00066     QApplication::setOverrideCursor( Qt::ArrowCursor );
00067     exec();
00068     QApplication::restoreOverrideCursor();
00069   }
00070   else
00071   {
00072     show();
00073   }
00074 }
00075 
00076 void QgsMessageViewer::setTitle( const QString& title )
00077 {
00078   setWindowTitle( title );
00079 }
00080 
00081 void QgsMessageViewer::setCheckBoxText( const QString& text )
00082 {
00083   checkBox->setText( text );
00084 }
00085 
00086 void QgsMessageViewer::setCheckBoxVisible( bool visible )
00087 {
00088   checkBox->setVisible( visible );
00089 }
00090 
00091 void QgsMessageViewer::setCheckBoxState( Qt::CheckState state )
00092 {
00093   checkBox->setCheckState( state );
00094 }
00095 
00096 Qt::CheckState QgsMessageViewer::checkBoxState()
00097 {
00098   return checkBox->checkState();
00099 }
00100 
00101 void QgsMessageViewer::setCheckBoxQSettingsLabel( QString label )
00102 {
00103   mCheckBoxQSettingsLabel = label;
00104 }
00105 
00106 
00107 void QgsMessageViewer::on_checkBox_toggled( bool toggled )
00108 {
00109   Q_UNUSED( toggled );
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