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
43
44void
45CreateScenarioView::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
68void
69CreateScenarioView::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
85void
86CreateScenarioView::on_cancelButton_clicked()
87{
88 reject();
89}
uint8_t index
~CreateScenarioView() override
Destructor.
void setPackages(QVector< QPair< QString, bool > > const &packages)
Sets the packages which are shown in the view.
CreateScenarioView(QWidget *parent=0)
Constructor that sets up the UI.
void created(std::string name, std::string package)
ArmarX Headers.