00001
00002
00003
00004
00005
00006
00007 #include "DlgErrorReportNetworking.h"
00008 #include <QCheckBox>
00009 #include <QCommonStyle>
00010 #include <QFile>
00011 #include <QHBoxLayout>
00012 #include <QLabel>
00013 #include <QPushButton>
00014 #include <QTextStream>
00015 #include <QVBoxLayout>
00016
00017 const int MAX_BTN_WIDTH = 80;
00018
00019 DlgErrorReportNetworking::DlgErrorReportNetworking(const QString &xml,
00020 QWidget *parent) :
00021 DlgErrorReportAbstractBase (parent),
00022 m_xmlOriginal (xml),
00023 m_xmlAnonymized (xml)
00024 {
00025 QVBoxLayout *layout = new QVBoxLayout;
00026 layout->setSizeConstraint (QLayout::SetFixedSize);
00027 setLayout (layout);
00028
00029 QCommonStyle style;
00030 setModal(true);
00031 setWindowTitle (tr ("Error Report"));
00032 setWindowIcon(style.standardIcon (QStyle::SP_MessageBoxCritical));
00033
00034 QLabel *lblMessage = new QLabel (tr ("An unrecoverable error has occurred. Would you like to send an error report to "
00035 "the Engauge developers?\n\n"
00036 "The original document can be sent as part of the error report, which increases the "
00037 "chances of finding and fixing the problem(s). However, if any information is private "
00038 "then an anonymized version of the document will be sent."));
00039 lblMessage->setWordWrap(true);
00040 layout->addWidget (lblMessage);
00041
00042 m_chkOriginal = new QCheckBox (tr ("Include original document information, otherwise anonymize the information"));
00043 m_chkOriginal->setChecked (true);
00044 updateFile ();
00045 layout->addWidget (m_chkOriginal);
00046 connect (m_chkOriginal, SIGNAL (stateChanged (int)), this, SLOT (slotDocumentCheckboxChanged (int)));
00047
00048 QHBoxLayout *layoutButtons = new QHBoxLayout;
00049
00050 QWidget *panelButtons = new QWidget;
00051 panelButtons->setLayout (layoutButtons);
00052 layout->addWidget (panelButtons);
00053
00054 m_btnSend = new QPushButton(tr ("Send"));
00055 m_btnSend->setMaximumWidth (MAX_BTN_WIDTH);
00056 layoutButtons->addWidget (m_btnSend);
00057 connect (m_btnSend, SIGNAL (released ()), this, SLOT (slotSend()));
00058
00059 m_btnCancel = new QPushButton(tr ("Cancel"));
00060 m_btnCancel->setMaximumWidth (MAX_BTN_WIDTH);
00061 layoutButtons->addWidget (m_btnCancel);
00062 connect (m_btnCancel, SIGNAL (released ()), this, SLOT (reject ()));
00063 }
00064
00065 DlgErrorReportNetworking::~DlgErrorReportNetworking()
00066 {
00067 removeFile();
00068 }
00069
00070 void DlgErrorReportNetworking::removeFile() const
00071 {
00072 QFile::remove (errorFile ());
00073 }
00074
00075 void DlgErrorReportNetworking::slotDocumentCheckboxChanged(int )
00076 {
00077 updateFile();
00078 }
00079
00080 void DlgErrorReportNetworking::slotSend()
00081 {
00082
00083 if (m_chkOriginal->isChecked()) {
00084 m_xmlToUpload = m_xmlOriginal;
00085 } else {
00086 m_xmlToUpload = m_xmlAnonymized;
00087 }
00088
00089 done (QDialog::Accepted);
00090
00091 close();
00092 }
00093
00094 void DlgErrorReportNetworking::updateFile()
00095 {
00096 if (m_chkOriginal->isChecked()) {
00097 saveFile (m_xmlOriginal);
00098 } else {
00099 saveFile (m_xmlAnonymized);
00100 }
00101 }
00102
00103 QString DlgErrorReportNetworking::xmlToUpload() const
00104 {
00105 return m_xmlToUpload;
00106 }