createscenarioview.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package ArmarXCore::core
19  * @author Cedric Seehausen (usdnr at kit dot edu)
20  * @date 2016
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 
26 #include "createscenarioview.h"
27 #include <ArmarXGui/gui-plugins/ScenarioManager/gui/ui_createscenarioview.h>
28 
29 #include <QMessageBox>
30 
32  QDialog(parent),
33  ui(new Ui::CreateScenarioView)
34 {
35  ui->setupUi(this);
36  ui->okButton->setDefault(true);
37 }
38 
40 {
41  delete ui;
42 }
43 
44 void CreateScenarioView::setPackages(const QVector<QPair<QString, bool> >& packages)
45 {
46  ui->packageBox->clear();
47  int i = 0;
48  for (QPair<QString, bool> const& pair : packages)
49  {
50  ui->packageBox->addItem(pair.first);
51  if (!pair.second)
52  {
53  ui->packageBox->setItemText(i, pair.first + " (read-only)");
54  // Get the index of the value to disable
55  QModelIndex index = ui->packageBox->model()->index(i, 0);
56 
57  // This is the effective 'disable' flag
58  QVariant v(0);
59 
60  // the magic
61  ui->packageBox->model()->setData(index, v, Qt::UserRole - 1);
62  }
63  i++;
64  }
65 }
66 
67 void CreateScenarioView::on_okButton_clicked()
68 {
69  if (ui->lineEdit->text() != "")
70  {
71  emit created(ui->lineEdit->text().toStdString(), ui->packageBox->itemText(ui->packageBox->currentIndex()).toStdString());
72  accept();
73  }
74  else
75  {
76  QMessageBox messageBox;
77  messageBox.setText("Please enter an Scenario name");
78  messageBox.exec();
79  }
80 }
81 
82 void CreateScenarioView::on_cancelButton_clicked()
83 {
84  reject();
85 }
index
uint8_t index
Definition: EtherCATFrame.h:59
CreateScenarioView::created
void created(std::string name, std::string package)
CreateScenarioView::setPackages
void setPackages(QVector< QPair< QString, bool >> const &packages)
Sets the packages which are shown in the view.
Definition: createscenarioview.cpp:44
Ui
ArmarX Headers.
Definition: ArmarXMainWindow.h:58
CreateScenarioView::CreateScenarioView
CreateScenarioView(QWidget *parent=0)
Constructor that sets up the UI.
Definition: createscenarioview.cpp:31
CreateScenarioView::~CreateScenarioView
~CreateScenarioView() override
Destructor.
Definition: createscenarioview.cpp:39
armarx::ctrlutil::v
double v(double t, double v0, double a0, double j)
Definition: CtrlUtil.h:39
createscenarioview.h
CreateScenarioView
View that allows user to create a new scenario.
Definition: createscenarioview.h:43