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 }
58 
60 {
61  delete ui;
62 }
63 
65 {
66  this->model = model;
67  ui->treeView->setModel(model.get());
68  ui->treeView->setColumnWidth(0, 220);
69  ui->treeView->setColumnWidth(1, 220);
70 }
71 
72 void SettingsView::on_lineEdit_textEdited(const QString& text)
73 {
74  model->setFilterRegExp(QRegExp(text, Qt::CaseInsensitive, QRegExp::FixedString));
75  ui->treeView->expandAll();
76 }
77 
78 void SettingsView::removeButtonClicked(int row, int column, QModelIndex parent)
79 {
80  emit removePackage(row, column, parent);
81 }
82 
83 void SettingsView::on_openButton_clicked()
84 {
85  emit openPackageChooser();
86 }
87 
88 void SettingsView::on_applicationStopperChooser_currentIndexChanged(const QString& text)
89 {
90  if (!text.compare("Stop only"))
91  {
92  ui->delayChooser->setEnabled(false);
93  ui->delayChooser->setText("1000");
94  }
95  else
96  {
97  ui->delayChooser->setEnabled(true);
98  }
99 
100  emit changeExecutorSettings(ui->applicationStopperChooser->itemText(ui->applicationStopperChooser->currentIndex()).toStdString(),
101  ui->delayChooser->text().toInt(),
102  ui->stopMethodChooser->itemText(ui->stopMethodChooser->currentIndex()).toStdString());
103 
104  //TODO erstelle neue stopstrategy und emitte das event
105 }
106 
107 void SettingsView::on_delayChooser_returnPressed()
108 {
109  emit changeExecutorSettings(ui->applicationStopperChooser->itemText(ui->applicationStopperChooser->currentIndex()).toStdString(),
110  ui->delayChooser->text().toInt(),
111  ui->stopMethodChooser->itemText(ui->stopMethodChooser->currentIndex()).toStdString());
112 }
113 
114 void SettingsView::on_delayChooser_editingFinished()
115 {
116  emit changeExecutorSettings(ui->applicationStopperChooser->itemText(ui->applicationStopperChooser->currentIndex()).toStdString(),
117  ui->delayChooser->text().toInt(),
118  ui->stopMethodChooser->itemText(ui->stopMethodChooser->currentIndex()).toStdString());
119 }
120 
121 void SettingsView::on_stopMethodChooser_currentIndexChanged(const QString& text)
122 {
123  emit changeExecutorSettings(ui->applicationStopperChooser->itemText(ui->applicationStopperChooser->currentIndex()).toStdString(),
124  ui->delayChooser->text().toInt(),
125  ui->stopMethodChooser->itemText(ui->stopMethodChooser->currentIndex()).toStdString());
126 }
127 
128 void SettingsView::setExecutorState(int killIndex, int delay, int stopStrategyIndex)
129 {
130  ui->applicationStopperChooser->blockSignals(true);
131  ui->stopMethodChooser->blockSignals(true);
132  ui->applicationStopperChooser->setCurrentIndex(stopStrategyIndex);
133  if (stopStrategyIndex == 1)
134  {
135  ui->delayChooser->setEnabled(false);
136  }
137  else
138  {
139  ui->delayChooser->setEnabled(true);
140  }
141  ui->delayChooser->setText(QString::number(delay));
142  ui->stopMethodChooser->setCurrentIndex(killIndex);
143  ui->applicationStopperChooser->blockSignals(false);
144  ui->stopMethodChooser->blockSignals(false);
145 }
146 
147 void SettingsView::on_clearPidCache_clicked()
148 {
149  emit clearPidCache();
150 }
151 
152 void SettingsView::on_clearXmlCache_clicked()
153 {
154  emit clearXmlCache();
155 }
156 
157 void SettingsView::on_toolButton_clicked()
158 {
160 
161  QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
162  QString::fromStdString(generator.getDefaultSyncFile()),
163  QFileDialog::ShowDirsOnly
164  | QFileDialog::DontResolveSymlinks);
165 
166  ARMARX_INFO_S << dir.toStdString();
167 
168  generator.setDefaultSyncFileDir(dir.toStdString());
169 }
settingsview.h
SettingsView::~SettingsView
~SettingsView() override
Definition: settingsview.cpp:59
ScenarioManager::Generator::IceGridXmlGenerator::setDefaultSyncFileDir
void setDefaultSyncFileDir(std::string path)
Definition: IceGridXmlGenerator.cpp:362
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:64
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:398