settingsview.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 "settingsview.h"
27
28#include <QFileDialog>
29#include <QIntValidator>
30#include <QString>
31
34
35#include <ArmarXGui/gui-plugins/ScenarioManager/gui/ui_settingsview.h>
36
37SettingsView::SettingsView(QWidget* parent) : QDialog(parent), ui(new Ui::SettingsView)
38//deleteButtonDelegate(this)
39{
40 ui->setupUi(this);
41
42 ui->treeView->setModel(model.get());
43 ui->treeView->setSortingEnabled(true);
44
45 ui->treeView->setItemDelegateForColumn(2, &deleteButtonDelegate);
46
47
48 ui->delayChooser->setValidator(new QIntValidator());
49
50 using This = SettingsView;
51 QObject::connect(&deleteButtonDelegate,
52 SIGNAL(buttonClicked(int, int, QModelIndex)),
53 this,
54 SLOT(removeButtonClicked(int, int, QModelIndex)));
55
56 QObject::connect(ui->closeUnavailablePackagesButton,
57 &QPushButton::pressed,
58 this,
59 &This::closeUnavailablePackages);
60}
61
63{
64 delete ui;
65}
66
67void
69{
70 this->model = model;
71 ui->treeView->setModel(model.get());
72 ui->treeView->setColumnWidth(0, 220);
73 ui->treeView->setColumnWidth(1, 220);
74}
75
76void
77SettingsView::on_lineEdit_textEdited(const QString& text)
78{
79 model->setFilterRegExp(QRegExp(text, Qt::CaseInsensitive, QRegExp::FixedString));
80 ui->treeView->expandAll();
81}
82
83void
84SettingsView::removeButtonClicked(int row, int column, QModelIndex parent)
85{
86 emit removePackage(row, column, parent);
87}
88
89void
90SettingsView::on_openButton_clicked()
91{
92 emit openPackageChooser();
93}
94
95void
96SettingsView::on_applicationStopperChooser_currentIndexChanged(const QString& text)
97{
98 if (!text.compare("Stop only"))
99 {
100 ui->delayChooser->setEnabled(false);
101 ui->delayChooser->setText("1000");
102 }
103 else
104 {
105 ui->delayChooser->setEnabled(true);
106 }
107
109 ui->applicationStopperChooser->itemText(ui->applicationStopperChooser->currentIndex())
110 .toStdString(),
111 ui->delayChooser->text().toInt(),
112 ui->stopMethodChooser->itemText(ui->stopMethodChooser->currentIndex()).toStdString());
113
114 //TODO erstelle neue stopstrategy und emitte das event
115}
116
117void
118SettingsView::on_delayChooser_returnPressed()
119{
121 ui->applicationStopperChooser->itemText(ui->applicationStopperChooser->currentIndex())
122 .toStdString(),
123 ui->delayChooser->text().toInt(),
124 ui->stopMethodChooser->itemText(ui->stopMethodChooser->currentIndex()).toStdString());
125}
126
127void
128SettingsView::on_delayChooser_editingFinished()
129{
131 ui->applicationStopperChooser->itemText(ui->applicationStopperChooser->currentIndex())
132 .toStdString(),
133 ui->delayChooser->text().toInt(),
134 ui->stopMethodChooser->itemText(ui->stopMethodChooser->currentIndex()).toStdString());
135}
136
137void
138SettingsView::on_stopMethodChooser_currentIndexChanged(const QString& text)
139{
141 ui->applicationStopperChooser->itemText(ui->applicationStopperChooser->currentIndex())
142 .toStdString(),
143 ui->delayChooser->text().toInt(),
144 ui->stopMethodChooser->itemText(ui->stopMethodChooser->currentIndex()).toStdString());
145}
146
147void
148SettingsView::setExecutorState(int killIndex, int delay, int stopStrategyIndex)
149{
150 ui->applicationStopperChooser->blockSignals(true);
151 ui->stopMethodChooser->blockSignals(true);
152 ui->applicationStopperChooser->setCurrentIndex(stopStrategyIndex);
153 if (stopStrategyIndex == 1)
154 {
155 ui->delayChooser->setEnabled(false);
156 }
157 else
158 {
159 ui->delayChooser->setEnabled(true);
160 }
161 ui->delayChooser->setText(QString::number(delay));
162 ui->stopMethodChooser->setCurrentIndex(killIndex);
163 ui->applicationStopperChooser->blockSignals(false);
164 ui->stopMethodChooser->blockSignals(false);
165}
166
167void
168SettingsView::on_clearPidCache_clicked()
169{
170 emit clearPidCache();
171}
172
173void
174SettingsView::on_clearXmlCache_clicked()
175{
176 emit clearXmlCache();
177}
178
179void
180SettingsView::on_toolButton_clicked()
181{
182 ScenarioManager::Generator::IceGridXmlGenerator generator;
183
184 QString dir = QFileDialog::getExistingDirectory(
185 this,
186 tr("Open Directory"),
187 QString::fromStdString(generator.getDefaultSyncFile()),
188 QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
189
190 ARMARX_INFO_S << dir.toStdString();
191
192 generator.setDefaultSyncFileDir(dir.toStdString());
193}
~SettingsView() override
void openPackageChooser()
void clearXmlCache()
SettingsView(QWidget *parent=0)
void clearPidCache()
void removePackage(int row, int column, QModelIndex parent)
virtual void setModel(FilterableTreeModelSortFilterProxyModelPtr model)
void changeExecutorSettings(std::string killMethod, int delay, std::string stopMethod)
std::shared_ptr< FilterableTreeModelSortFilterProxyModel > FilterableTreeModelSortFilterProxyModelPtr
#define ARMARX_INFO_S
Definition Logging.h:202
ArmarX Headers.