QGIS API Documentation  master-3f58142
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, bool deleteOnClose )
00022     : QDialog( parent, fl )
00023 {
00024   setupUi( this );
00025   if ( deleteOnClose )
00026   {
00027     setAttribute( Qt::WA_DeleteOnClose );
00028   }
00029   // Default state for the checkbox
00030   setCheckBoxVisible( false );
00031   setCheckBoxState( Qt::Unchecked );
00032 
00033   mCheckBoxQSettingsLabel = "";
00034 }
00035 
00036 QgsMessageViewer::~QgsMessageViewer()
00037 {
00038 }
00039 
00040 void QgsMessageViewer::setMessageAsHtml( const QString &msg )
00041 {
00042   txtMessage->setHtml( msg );
00043 }
00044 
00045 void QgsMessageViewer::setMessageAsPlainText( const QString &msg )
00046 {
00047   txtMessage->setPlainText( msg );
00048 }
00049 
00050 void QgsMessageViewer::appendMessage( const QString &msg )
00051 {
00052   txtMessage->append( msg );
00053 }
00054 
00055 
00056 void QgsMessageViewer::setMessage( const QString &message, MessageType msgType )
00057 {
00058   if ( msgType == MessageHtml )
00059     setMessageAsHtml( message );
00060   else
00061     setMessageAsPlainText( message );
00062 }
00063 
00064 void QgsMessageViewer::showMessage( bool blocking )
00065 {
00066   if ( blocking )
00067   {
00068     QApplication::setOverrideCursor( Qt::ArrowCursor );
00069     exec();
00070     QApplication::restoreOverrideCursor();
00071   }
00072   else
00073   {
00074     show();
00075   }
00076 }
00077 
00078 void QgsMessageViewer::setTitle( const QString& title )
00079 {
00080   setWindowTitle( title );
00081 }
00082 
00083 void QgsMessageViewer::setCheckBoxText( const QString& text )
00084 {
00085   checkBox->setText( text );
00086 }
00087 
00088 void QgsMessageViewer::setCheckBoxVisible( bool visible )
00089 {
00090   checkBox->setVisible( visible );
00091 }
00092 
00093 void QgsMessageViewer::setCheckBoxState( Qt::CheckState state )
00094 {
00095   checkBox->setCheckState( state );
00096 }
00097 
00098 Qt::CheckState QgsMessageViewer::checkBoxState()
00099 {
00100   return checkBox->checkState();
00101 }
00102 
00103 void QgsMessageViewer::setCheckBoxQSettingsLabel( QString label )
00104 {
00105   mCheckBoxQSettingsLabel = label;
00106 }
00107 
00108 
00109 void QgsMessageViewer::on_checkBox_toggled( bool toggled )
00110 {
00111   Q_UNUSED( toggled );
00112   if ( !mCheckBoxQSettingsLabel.isEmpty() )
00113   {
00114     QSettings settings;
00115     if ( checkBox->checkState() == Qt::Checked )
00116       settings.setValue( mCheckBoxQSettingsLabel, false );
00117     else
00118       settings.setValue( mCheckBoxQSettingsLabel, true );
00119   }
00120 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines