AstRawDark
Manage your astrophoto dark frames
 All Classes Functions Variables Enumerations Enumerator Pages
commandReportDisplay.cpp
1 /*
2  * AstRawDark
3  *
4  * Copyright (C) 2015 - Frédéric CORNU
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #include "commandReportDisplay.h"
21 #include "commands/abstractCommand.h"
22 #include "ui_commandReportDisplay.h"
23 #include "commands/signalDispatcher.h"
24 
25 #include <QListWidget>
26 
28  QDialog(parent),
29  ui(new Ui::CommandReportDisplay),
30  _command(command)
31 {
32  ui->setupUi(this);
33 
34  ui->lblSerial->setText(QString::number(_command->getSerial() +1));
35  ui->lblDescription->setText(_command->getDescription());
36  ui->grpReports->setLayout(new QVBoxLayout());
37 
38  setWindowTitle(tr("Details for command N°%1").arg(_command->getSerial() +1));
39 
40  updateDisplay();
41 
44  this,
46 }
47 
49 {
50  delete ui;
51 }
52 
54 {
56  switch (e->type()) {
57  case QEvent::LanguageChange:
58  ui->retranslateUi(this);
59  break;
60  default:
61  break;
62  }
63 }
64 
65 void CommandReportDisplay::updateDisplay()
66 {
67  ui->lblStatus->setText(_command->getStatusString());
68  ui->lblProgress->setText(_command->getProgessMessage());
69 
70  /*
71  * If command is complete
72  * We add command reports if not already done
73  */
74  if ( AbstractCommand::COMPLETE == _command->getStatus() && ui->grpReports->layout()->count() == 0 ) {
75 
76  for ( int i=0; i<_command->getCommandReport()->getHeaders().count(); i++ ) {
77 
78  ui->grpReports->layout()->addWidget(new QLabel(_command->getCommandReport()->getHeaders().at(i), this));
79 
80  QStringList currentContent = _command->getCommandReport()->getContents().at(i);
81 
82  /*
83  * some report sections may only have headers
84  */
85  if ( currentContent.count() > 0 ) {
86 
87  QListWidget* list = new QListWidget(this);
88  list->addItems(currentContent);
89  ui->grpReports->layout()->addWidget(list);
90  }
91  }
92  }
93 }
94 
96 {
97  if ( command == _command ) {
98 
99  updateDisplay();
100  }
101 }