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