Attention une mise à jour du service Gitlab va être effectuée le mardi 14 décembre entre 13h30 et 14h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes.

Commit 09cf0fea authored by Kevin Coulomb's avatar Kevin Coulomb
Browse files

Forgotten

parent b24f21c3
#include "Command_window.hpp"
using namespace std;
Command_window::Command_window( QWidget *parent, Interface_graphic * i) : QMainWindow(parent){
setupUi(this);
// _trace = T;
// CKFP(_ui_layout = qFindChild<QVBoxLayout *>(this,"verticalLayout_5"),"Cannot find the vertical layout in the ui file");
_console = i;
CKFP(_ui_cmd_box = qFindChild<QLineEdit*>(this, "command"), "Cannot find the command box in the .ui file");
CKFP(_ui_start_box = qFindChild<QLineEdit*>(this, "startTime"), "Cannot find the beginning argument box in the .ui file");
CKFP(_ui_end_box = qFindChild<QLineEdit*>(this, "endTime"), "Cannot find the end argument box in the .ui file");
CKFP(_ui_tree_box = qFindChild<QTreeWidget*>(this, "_nodes_selected"), "Cannot find the tree argument box in the .ui file");
// CKFP(_ui_arg4_box = qFindChild<QLineEdit*>(this, "lineEdit_4"), "Cannot find the fourth argument in the .ui file");
// CKFP(_ui_arg5_box = qFindChild<QLineEdit*>(this, "lineEdit_2"), "Cannot find the fifth argument box in the .ui file");
}
void Command_window::set_trace( Trace * t){
_trace = t;
}
void Command_window::init_window() {
// We set the names of the containers for the tree widget
_nodes_selected->clear();
set_container_names();
}
// By default, cmd = useless
void Command_window::on_execute_button_clicked(){
const QString cmd = _ui_cmd_box->text();
QString start_time = _ui_start_box->text();
QString end_time = _ui_end_box->text();
if(_ui_start_box->text()== "" || _ui_start_box->text()=="t0")
start_time = "0";
if(_ui_end_box->text() == "" || _ui_end_box->text()=="t1")
end_time = QString::fromStdString(_trace->get_max_date().to_string());
set_selected_nodes();
_trace->set_selected_container(&_selected_containers);
_trace->set_interval_constrained(new Interval(start_time.toDouble(),end_time.toDouble()));
_console->get_console()->draw_trace(_console->get_filename(),Interface_console::_DRAW_OPENGL_PARTIAL);
// if(_ui_tree_box->text() !="" )
// arg<< _ui_tree_box->text();
/* if(_ui_arg4_box->text() !="" )
arg << _ui_arg4_box->text();
if(_ui_arg5_box->text()!="" )
arg <<_ui_arg5_box->text();*/
/*
std::cout <<"Valeur cmd: "<< _ui_cmd_box->text().toStdString () <<std::endl;
std::cout <<"Valeur 1: "<< _ui_arg1_box->text().toStdString () <<std::endl;
std::cout <<"Valeur 2: "<< _ui_arg2_box->text().toStdString () <<std::endl;
std::cout <<"Valeur 3: "<< _ui_arg3_box->text().toStdString () <<std::endl;
std::cout <<"Valeur 4: "<< _ui_arg4_box->text().toStdString () <<std::endl;
std::cout <<"Valeur 5: "<< _ui_arg5_box->text().toStdString () <<std::endl;
*/
/*
QProcess * proc =new QProcess();
proc->execute(cmd,arg);
delete proc;
//proc.*/
//Envoyer un signal pour dire de dessiner
}
void Command_window::set_container_names() {
const list <Container *> *root_containers = _trace->get_root_containers();
if(root_containers->empty()) {
*Message::get_instance() << "No containers in this trace" << Message::ende;
return;
}
// Add the root container names
QList<QTreeWidgetItem *> items;
QFlags<Qt::ItemFlag> flg=Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsTristate;
for (list<Container *>::const_iterator it = root_containers->begin();
it != root_containers->end();
it ++) {
string name = (*it)->get_name().to_string();
QStringList temp(QString::fromStdString(name));
QTreeWidgetItem *current_node = new QTreeWidgetItem((QTreeWidgetItem *)0, temp);
current_node->setFlags(flg);
current_node->setCheckState(0,Qt::Unchecked);
items.append(current_node);
// Recursivity to add the children names
set_container_names_rec(current_node, (*it));
}
(*(items.begin()))->setExpanded(true);
_nodes_selected->insertTopLevelItems(0, items);
}
void Command_window::set_container_names_rec(QTreeWidgetItem *current_node, Container *current_container) {
const list<Container *> *children = current_container->get_children();
QFlags<Qt::ItemFlag> flg = Qt::ItemIsUserCheckable | Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsTristate;
for (list<Container *>::const_iterator it = children->begin();
it != children->end();
it ++) {
// We create the node and we do the recursivity
string name = (*it)->get_name().to_string();
QStringList temp(QString::fromStdString(name));
QTreeWidgetItem *node = new QTreeWidgetItem(current_node, temp);
node->setFlags(flg);
node->setCheckState(0,Qt::Unchecked);
set_container_names_rec(node ,(*it));
}
}
void Command_window::set_selected_nodes(){
// We delete the previous selected containers
if(!_selected_containers.empty()) {
_selected_containers.clear();
}
// We fill the new selected containers
// TODO : Use the tree instead of the list
QTreeWidgetItemIterator it(_nodes_selected);
while (*it) {
if ((*it)->checkState(0) == Qt::Checked){
_selected_containers.push_back(_trace->search_container((*it)->text(0).toStdString()));
}
it ++;
}
// _number_of_selected_container = _selected_containers.size();
}
/*!
* \file command_window.hpp
*/
#ifndef _COMMAND_WINDOW_HPP
#define _COMMAND_WINDOW_HPP
class Command_window;
#include <iostream>
#include <QGLWidget>
#include <map>
#include <QProcess>
#include <QStringList>
#include <QTreeWidget>
#include "../message/Message.hpp"
#include "../trace/Trace.hpp"
#include "../ui_global_cmd.h"
#include "../interface/interface_console.hpp"
#include "../interface/resource.hpp"
#include "../info/info.hpp"
#include "../trace/Trace.hpp"
//#include "../interfa
/*!
* \brief Class that is used to execute an exterior command on the trace
*/
class Command_window : public QMainWindow, protected Ui::Execution{
Q_OBJECT
private :
// QVBoxLayout * _ui_cmd_layout;
Trace* _trace;
// _node_selected;
QStringList _cmd;
QProcess * _process;
QVBoxLayout * _ui_layout;
QLineEdit* _ui_cmd_box;
QLineEdit* _ui_start_box;
QLineEdit* _ui_end_box;
QTreeWidget* _ui_tree_box;
std::vector<Container *> _selected_containers;
Interface_graphic *_console;
// QLineEdit* _ui_arg4_box;
// QLineEdit* _ui_arg5_box;
// void set_option(QString s);
void set_container_names();
void set_container_names_rec(QTreeWidgetItem *current_node, Container *current_container);
public :
void set_selected_nodes();
Command_window( QWidget *parent, Interface_graphic * i);
void init_window();
void set_trace(Trace * t);
private slots :
void on_execute_button_clicked();
};
#endif
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