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 
28 #include <QMessageBox>
29 
30 #include <ArmarXGui/gui-plugins/ScenarioManager/gui/ui_createscenarioview.h>
31 
33  QDialog(parent), ui(new Ui::CreateScenarioView)
34 {
35  ui->setupUi(this);
36  ui->okButton->setDefault(true);
37 }
38 
40 {
41  delete ui;
42 }
43 
44 void
45 CreateScenarioView::setPackages(const QVector<QPair<QString, bool>>& packages)
46 {
47  ui->packageBox->clear();
48  int i = 0;
49  for (QPair<QString, bool> const& pair : packages)
50  {
51  ui->packageBox->addItem(pair.first);
52  if (!pair.second)
53  {
54  ui->packageBox->setItemText(i, pair.first + " (read-only)");
55  // Get the index of the value to disable
56  QModelIndex index = ui->packageBox->model()->index(i, 0);
57 
58  // This is the effective 'disable' flag
59  QVariant v(0);
60 
61  // the magic
62  ui->packageBox->model()->setData(index, v, Qt::UserRole - 1);
63  }
64  i++;
65  }
66 }
67 
68 void
69 CreateScenarioView::on_okButton_clicked()
70 {
71  if (ui->lineEdit->text() != "")
72  {
73  emit created(ui->lineEdit->text().toStdString(),
74  ui->packageBox->itemText(ui->packageBox->currentIndex()).toStdString());
75  accept();
76  }
77  else
78  {
79  QMessageBox messageBox;
80  messageBox.setText("Please enter an Scenario name");
81  messageBox.exec();
82  }
83 }
84 
85 void
86 CreateScenarioView::on_cancelButton_clicked()
87 {
88  reject();
89 }
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:45
Ui
ArmarX Headers.
Definition: ArmarXMainWindow.h:54
CreateScenarioView::CreateScenarioView
CreateScenarioView(QWidget *parent=0)
Constructor that sets up the UI.
Definition: createscenarioview.cpp:32
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:42