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 
37 SettingsView::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 
67 void
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 
76 void
77 SettingsView::on_lineEdit_textEdited(const QString& text)
78 {
79  model->setFilterRegExp(QRegExp(text, Qt::CaseInsensitive, QRegExp::FixedString));
80  ui->treeView->expandAll();
81 }
82 
83 void
84 SettingsView::removeButtonClicked(int row, int column, QModelIndex parent)
85 {
86  emit removePackage(row, column, parent);
87 }
88 
89 void
90 SettingsView::on_openButton_clicked()
91 {
92  emit openPackageChooser();
93 }
94 
95 void
96 SettingsView::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 
117 void
118 SettingsView::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 
127 void
128 SettingsView::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 
137 void
138 SettingsView::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 
147 void
148 SettingsView::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 
167 void
168 SettingsView::on_clearPidCache_clicked()
169 {
170  emit clearPidCache();
171 }
172 
173 void
174 SettingsView::on_clearXmlCache_clicked()
175 {
176  emit clearXmlCache();
177 }
178 
179 void
180 SettingsView::on_toolButton_clicked()
181 {
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.h
SettingsView::~SettingsView
~SettingsView() override
Definition: settingsview.cpp:62
ScenarioManager::Generator::IceGridXmlGenerator::setDefaultSyncFileDir
void setDefaultSyncFileDir(std::string path)
Definition: IceGridXmlGenerator.cpp:417
SettingsView::changeExecutorSettings
void changeExecutorSettings(std::string killMethod, int delay, std::string stopMethod)
Ui
ArmarX Headers.
Definition: ArmarXMainWindow.h:54
SettingsView::openPackageChooser
void openPackageChooser()
SettingsView::setModel
virtual void setModel(FilterableTreeModelSortFilterProxyModelPtr model)
Definition: settingsview.cpp:68
FilterableTreeModelSortFilterProxyModelPtr
std::shared_ptr< FilterableTreeModelSortFilterProxyModel > FilterableTreeModelSortFilterProxyModelPtr
Definition: filterabletreemodelsortfilterproxymodel.h:68
SettingsView
Definition: settingsview.h:39
IceGridXmlGenerator.h
SettingsView::SettingsView
SettingsView(QWidget *parent=0)
Definition: settingsview.cpp:37
SettingsView::clearPidCache
void clearPidCache()
SettingsView::removePackage
void removePackage(int row, int column, QModelIndex parent)
ScenarioManager::Generator::IceGridXmlGenerator
Definition: IceGridXmlGenerator.h:39
SettingsView::clearXmlCache
void clearXmlCache()
ARMARX_INFO_S
#define ARMARX_INFO_S
Definition: Logging.h:202
Logging.h
armarx::RemoteGui::buttonClicked
bool buttonClicked(RemoteGui::ValueMap const &newValues, RemoteGui::ValueMap const &oldValues, std::string const &name)
Definition: Storage.cpp:7
ScenarioManager::Generator::IceGridXmlGenerator::getDefaultSyncFile
std::string getDefaultSyncFile()
Definition: IceGridXmlGenerator.cpp:456