VPTissue Reference Manual
Status.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2016 Universiteit Antwerpen
3  *
4  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
5  * the European Commission - subsequent versions of the EUPL (the "Licence");
6  * You may not use this work except in compliance with the Licence.
7  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the Licence is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the Licence for the specific language governing
13  * permissions and limitations under the Licence.
14  */
20 #include "Status.h"
21 
24 
25 #include <QVBoxLayout>
26 #include <QColor>
27 #include <QString>
28 #include <QTextEdit>
29 
30 #include <sstream>
31 
32 namespace SimPT_Parex {
33 
35  : m_progress()
36 {
37  QVBoxLayout* layout = new QVBoxLayout;
38 
39  m_view = new QTextEdit;
40  m_view->setReadOnly(true);
41  m_view->setText("No information");
42 
43  layout->addWidget(m_view);
44 
45  setLayout(layout);
46 }
47 
49 {
50  m_progress.reset();
51  UpdateView();
52 }
53 
54 void Status::UpdateStatus(const std::shared_ptr<const ExplorationProgress> &progress)
55 {
56  m_progress = progress;
57  UpdateView();
58 }
59 
60 void Status::UpdateView()
61 {
62  if (!m_progress) {
63  m_view->setText("No information available");
64  } else {
65  std::stringstream output;
66 
67  output << "Name: " << m_progress->GetExploration().GetName() << std::endl << std::endl;
68  output << "Progress:" << std::endl;
69  output << "\t" << m_progress->GetTaskCount(TaskState::Finished) << "/" << m_progress->GetExploration().GetNumberOfTasks() << std::endl;
70 
71  if (m_progress->IsFinished()) {
72  output << "\t" << "Done" << std::endl;
73  } else {
74  output << "\t" << m_progress->GetTaskCount(TaskState::Running) << " running" << std::endl;
75  }
76 
77  if (m_progress->GetTaskCount(TaskState::Failed) != 0) {
78  output << "An error occurred, check the task overview for more information." << std::endl;
79  }
80 
81  output << std::endl;
82  output << "Tasks canceled: " << m_progress->GetTaskCount(TaskState::Cancelled);
83 
84  m_view->clear();
85  m_view->setText(QString::fromStdString(output.str()));
86  }
87 }
88 
90 {
91  QString text = m_view->toPlainText();
92  m_view->setTextColor(QColor("black"));
93  m_view->setText(text);
94 }
95 
97 {
98  QString text = m_view->toPlainText();
99  m_view->setTextColor(QColor("gray"));
100  m_view->setText(text);
101 }
102 
103 } // namespace
Interface for Exploration.
The task is waiting to be sent for the first time.
The task is being executed.
Interface for Status.
void UpdateStatus(const std::shared_ptr< const ExplorationProgress > &progress)
Update the status of an exploration.
Definition: Status.cpp:54
The task was finished.
void Clear()
Clear the current displayed exploration.
Definition: Status.cpp:48
Namespace for SimPT parameter explorer package.
Definition: Client.cpp:52
Status()
Constructor.
Definition: Status.cpp:34
void Disconnected()
Set font to disconnected state.
Definition: Status.cpp:96
Interface for ExplorationProgress.
The task was cancelled or stopped.
void Connected()
Set font to connected state.
Definition: Status.cpp:89