Commit 875f106b authored by Mathieu Faverge's avatar Mathieu Faverge
Browse files

Choose StateType in statistics

parent dd9eb993
......@@ -63,6 +63,13 @@
<property name="fieldGrowthPolicy" >
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Start time</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="_start_time_widget" />
</item>
......@@ -102,13 +109,17 @@
</item>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="label" >
<item row="3" column="0" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>Start time</string>
<string>States Type</string>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QComboBox" name="_kind_of_state_box" >
</widget>
</item>
</layout>
</item>
<item row="2" column="1" >
......
......@@ -67,7 +67,21 @@ void Stats_window::set_filename(string filename){
void Stats_window::set_trace(Trace *trace) {
const list<StateType *> *states_types_list;
list<StateType *>::const_iterator it;
list<StateType *>::const_iterator end;
_trace = trace;
states_types_list = _trace->get_state_types();
end = states_types_list->end();
for (it = states_types_list->begin();
it != end;
it++){
string name = (*it)->get_name().to_string();
QString temp(QString::fromStdString(name));
_kind_of_state_box->addItem(temp);
}
}
......@@ -91,7 +105,23 @@ void Stats_window::init_window() {
}
void Stats_window::set_selected_nodes(){
void Stats_window::set_selected_nodes(string kind_of_state){
const list<StateType *> *states_types_list;
list<StateType *>::const_iterator itstat;
list<StateType *>::const_iterator endstat;
const ContainerType *kind_of_container = NULL;
states_types_list = _trace->get_state_types();
endstat = states_types_list->end();
for (itstat = states_types_list->begin();
itstat != endstat;
itstat++){
if ((*itstat)->get_name().to_string() == kind_of_state){
kind_of_container = (*itstat)->get_container_type();
continue;
}
}
// We delete the previous selected containers
if(!_selected_containers.empty()) {
_selected_containers.clear();
......@@ -102,7 +132,9 @@ void Stats_window::set_selected_nodes(){
QTreeWidgetItemIterator it(_nodes_selected);
while (*it) {
if ((*it)->checkState(0) == Qt::Checked){
_selected_containers.push_back(_trace->search_container((*it)->text(0).toStdString()));
Container *cont = _trace->search_container((*it)->text(0).toStdString());
if (cont->get_type() == kind_of_container)
_selected_containers.push_back(cont);
}
it ++;
}
......@@ -117,9 +149,10 @@ void Stats_window::set_selected_nodes(){
void Stats_window::on_reload_button_clicked() {
int kind_of_diagram = _kind_of_diagram_box->currentIndex();
int kind_of_diagram = _kind_of_diagram_box->currentIndex();
QString kind_of_state = _kind_of_state_box->currentText();
set_selected_nodes();
set_selected_nodes(kind_of_state.toStdString());
if(_selected_containers.empty()) {
*Message::get_instance() << "You must select at least one container to view the stats" << Message::ende;
......@@ -156,9 +189,10 @@ void Stats_window::on_reload_button_clicked() {
}
void Stats_window::on_export_button_clicked(){
int kind_of_diagram = _kind_of_diagram_box->currentIndex();
int kind_of_diagram = _kind_of_diagram_box->currentIndex();
QString kind_of_state = _kind_of_state_box->currentText();
set_selected_nodes();
set_selected_nodes(kind_of_state.toStdString());
if(_selected_containers.empty()) {
*Message::get_instance() << "You must select at least one container to export the stats" << Message::ende;
......
......@@ -10,6 +10,7 @@ class Stats_window;
#include <iostream>
#include "../trace/Trace.hpp"
#include "../trace/Container.hpp"
#include "../trace/ContainerType.hpp"
#include "Statistic.hpp"
#include <QGLWidget>
#include <map>
......@@ -112,7 +113,7 @@ private:
/*!
* \brief Fill the vector of selected containers depending on the ones chosen in the tree widget
*/
void set_selected_nodes();
void set_selected_nodes(std::string);
private slots:
void on_reload_button_clicked();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment