Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
qgsmessageviewer.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmessageviewer.cpp - description
3  -------------------
4  begin : Wed Jun 4 2003
5  copyright : (C) 2002 by Gary E.Sherman
6  email : sherman at mrcc.com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 /* $Id$ */
18 
19 #include "qgsmessageviewer.h"
20 #include <QSettings>
21 
22 QgsMessageViewer::QgsMessageViewer( QWidget *parent, Qt::WFlags fl )
23  : QDialog( parent, fl )
24 {
25  setupUi( this );
26  setAttribute( Qt::WA_DeleteOnClose );
27 
28  // Default state for the checkbox
29  setCheckBoxVisible( false );
30  setCheckBoxState( Qt::Unchecked );
31 
33 }
34 
36 {
37 }
38 
39 void QgsMessageViewer::setMessageAsHtml( const QString& msg )
40 {
41  txtMessage->setHtml( msg );
42 }
43 
44 void QgsMessageViewer::setMessageAsPlainText( const QString& msg )
45 {
46  txtMessage->setPlainText( msg );
47 }
48 
49 void QgsMessageViewer::appendMessage( const QString& msg )
50 {
51  txtMessage->append( msg );
52 }
53 
54 
55 void QgsMessageViewer::setMessage( const QString& message, MessageType msgType )
56 {
57  if ( msgType == MessageHtml )
58  setMessageAsHtml( message );
59  else
60  setMessageAsPlainText( message );
61 }
62 
63 void QgsMessageViewer::showMessage( bool blocking )
64 {
65  if ( blocking )
66  {
67  QApplication::setOverrideCursor( Qt::ArrowCursor );
68  exec();
69  QApplication::restoreOverrideCursor();
70  }
71  else
72  {
73  show();
74  }
75 }
76 
77 void QgsMessageViewer::setTitle( const QString& title )
78 {
79  setWindowTitle( title );
80 }
81 
82 void QgsMessageViewer::setCheckBoxText( const QString& text )
83 {
84  checkBox->setText( text );
85 }
86 
88 {
89  checkBox->setVisible( visible );
90 }
91 
92 void QgsMessageViewer::setCheckBoxState( Qt::CheckState state )
93 {
94  checkBox->setCheckState( state );
95 }
96 
98 {
99  return checkBox->checkState();
100 }
101 
103 {
104  mCheckBoxQSettingsLabel = label;
105 }
106 
107 
109 {
110  if ( !mCheckBoxQSettingsLabel.isEmpty() )
111  {
112  QSettings settings;
113  if ( checkBox->checkState() == Qt::Checked )
114  settings.setValue( mCheckBoxQSettingsLabel, false );
115  else
116  settings.setValue( mCheckBoxQSettingsLabel, true );
117  }
118 }