QGIS API Documentation  2.3.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgserrordialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgserrordialog.cpp - error description
3  -------------------
4  begin : October 2012
5  copyright : (C) October 2012 Radim Blazek
6  email : radim dot blazek at gmail dot 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 #include "qgserrordialog.h"
18 
19 #include <QMessageBox>
20 #include <QSettings>
21 
22 QgsErrorDialog::QgsErrorDialog( const QgsError & theError, const QString & theTitle, QWidget *parent, Qt::WindowFlags fl )
23  : QDialog( parent, fl )
24  , mError( theError )
25 {
26  setupUi( this );
27  QString title = theTitle;
28  if ( title.isEmpty() ) title = tr( "Error" );
29  setWindowTitle( title );
30 
31  // QMessageBox has static standardIcon( Icon icon ), but it is marked as obsolete
32  QMessageBox messageBox( QMessageBox::Critical, "", "" );
33  mIconLabel->setPixmap( messageBox.iconPixmap() );
34  mSummaryTextBrowser->setOpenExternalLinks( true );
35  mDetailTextBrowser->setOpenExternalLinks( true );
36  mDetailTextBrowser->hide();
37 
38  QPalette p = palette();
39  p.setColor( QPalette::Base, Qt::transparent );
40  mSummaryTextBrowser->setPalette( p );
41 
42  mDetailCheckBox->hide();
43 
44  mSummaryTextBrowser->setText( mError.summary() );
45  mDetailTextBrowser->setText( mError.message( QgsErrorMessage::Html ) );
46 
47  resize( width(), 150 );
48 
49  QSettings settings;
50  Qt::CheckState state = ( Qt::CheckState ) settings.value( "/Error/dialog/detail", 0 ).toInt();
51  mDetailCheckBox->setCheckState( state );
52  if ( state == Qt::Checked ) on_mDetailPushButton_clicked();
53 }
54 
56 {
57 }
58 
59 void QgsErrorDialog::show( const QgsError & theError, const QString & theTitle, QWidget *parent, Qt::WindowFlags fl )
60 {
61  QgsErrorDialog d( theError, theTitle, parent, fl );
62  d.exec();
63 }
64 
66 {
67  mSummaryTextBrowser->hide();
68  mDetailTextBrowser->show();
69  mDetailCheckBox->show();
70  mDetailPushButton->hide();
71  resize( width(), 400 );
72 }
73 
75 {
76  QSettings settings;
77  settings.setValue( "/Error/dialog/detail", state );
78 }
79 
static void show(const QgsError &theError, const QString &theTitle, QWidget *parent=0, Qt::WindowFlags fl=QgisGui::ModalDialogFlags)
Show dialog with error.
void on_mDetailCheckBox_stateChanged(int state)
QgsErrorDialog(const QgsError &theError, const QString &theTitle, QWidget *parent=0, Qt::WindowFlags fl=QgisGui::ModalDialogFlags)
QString message(QgsErrorMessage::Format theFormat=QgsErrorMessage::Html) const
Full error messages description.
Definition: qgserror.cpp:50
QgsError is container for error messages (report).
Definition: qgserror.h:77
void on_mDetailPushButton_clicked()
QString summary() const
Short error descriprion, usually the first error in chain, the real error.
Definition: qgserror.cpp:126
#define tr(sourceText)