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 exec(); 00067 else 00068 show(); 00069 } 00070 00071 void QgsMessageViewer::setTitle( const QString& title ) 00072 { 00073 setWindowTitle( title ); 00074 } 00075 00076 void QgsMessageViewer::setCheckBoxText( const QString& text ) 00077 { 00078 checkBox->setText( text ); 00079 } 00080 00081 void QgsMessageViewer::setCheckBoxVisible( bool visible ) 00082 { 00083 checkBox->setVisible( visible ); 00084 } 00085 00086 void QgsMessageViewer::setCheckBoxState( Qt::CheckState state ) 00087 { 00088 checkBox->setCheckState( state ); 00089 } 00090 00091 Qt::CheckState QgsMessageViewer::checkBoxState() 00092 { 00093 return checkBox->checkState(); 00094 } 00095 00096 void QgsMessageViewer::setCheckBoxQSettingsLabel( QString label ) 00097 { 00098 mCheckBoxQSettingsLabel = label; 00099 } 00100 00101 00102 void QgsMessageViewer::on_checkBox_toggled( bool toggled ) 00103 { 00104 if ( !mCheckBoxQSettingsLabel.isEmpty() ) 00105 { 00106 QSettings settings; 00107 if ( checkBox->checkState() == Qt::Checked ) 00108 settings.setValue( mCheckBoxQSettingsLabel, false ); 00109 else 00110 settings.setValue( mCheckBoxQSettingsLabel, true ); 00111 } 00112 }