SettingsController.h
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#pragma once
27
28#include <string>
29#include <vector>
30
31#include <QObject>
32
38
40#include "../gui/settingsitem.h"
42#include "../gui/settingsview.h"
43#include "../gui/treemodel.h"
44
46{
47 /**
48 * @class SettingsController
49 * @ingroup controller
50 * @brief This controller manages the signals and model of the SettingsView.
51 * Any signals involving the settings need to be connected to the corresponding slots in this controller.
52 * This controller also manages settings that get saved between sessions, as well as the Executor configuration.
53 */
54 class SettingsController : public QObject
55 {
56 Q_OBJECT
57 public:
58 /**
59 * Constructor that sets the data structure this controller operates on, the executor which gets configured by this controller
60 * and optionally the parent object.
61 * @param packages list of packages. Need to contain the Packages displayed in the SettingsView.
62 * @param executor executor which gets configured by the settings
63 * @param parent standard QT option to specify a parent
64 */
66 Exec::ExecutorPtr executor,
67 QObject* parent = 0);
68
69 void init();
70
71 /**
72 * Destructor.
73 */
74 ~SettingsController() override;
75
76 signals:
77 /**
78 * Emitted when a package gets added in the settings. Allows other controllers to update their models
79 * with the new package.
80 * @param name name of the new package
81 */
82 void packageAdded(std::string name);
83
84 /**
85 * Emitted when a package gets removed. Other packages need to update their models.
86 */
88
89 void setExecutorState(int killMethodIndex, int delay, int stopStrategyIndex);
90
91
92 public slots:
93 /**
94 * Shows the settings dialog.
95 */
96 void showSettings();
97
98 /**
99 * Shows a view that allows the user to add new packages.
100 */
102
103 /**
104 * Adds a new package to the settings.
105 */
106 void addPackage(std::string name);
107
108 /**
109 * Removes a package from the settings.
110 * @param row row of the package
111 * @param column column of the package
112 * @param parent index of the package to be removed
113 */
114 void removePackage(int row, int column, QModelIndex parent);
115
116 /**
117 * Configures the Executor.
118 * @param killMethod "StopAndKill" or "Stop"
119 * @param delay length of the delay in the StopAndKill stop-method
120 * @param stopMethod "By Name" or "By Pid"
121 */
122 void setExecutorStopStrategy(std::string killMethod, int delay, std::string stopMethod);
123
124 /**
125 * Updates the packages displayed in the settingsview by reloading all packages into the model.
126 */
127 void updateModel();
128
129 void clearXmlCache();
130 void clearPidCache();
132
133
134 private:
138
139 SettingsModelPtr treemodel;
142 Exec::ExecutorPtr executor;
143 SettingsView settingsDialog;
144 PackageAdderView packageAdderView;
145 };
146} // namespace ScenarioManager::Controller
View that allows the user to find and add new packages.
void packageRemoved()
Emitted when a package gets removed.
void setExecutorState(int killMethodIndex, int delay, int stopStrategyIndex)
void setExecutorStopStrategy(std::string killMethod, int delay, std::string stopMethod)
Configures the Executor.
void showPackageAdderView()
Shows a view that allows the user to add new packages.
void updateModel()
Updates the packages displayed in the settingsview by reloading all packages into the model.
void removePackage(int row, int column, QModelIndex parent)
Removes a package from the settings.
void addPackage(std::string name)
Adds a new package to the settings.
void packageAdded(std::string name)
Emitted when a package gets added in the settings.
SettingsController(Data_Structure::PackageVectorPtr packages, Exec::ExecutorPtr executor, QObject *parent=0)
Constructor that sets the data structure this controller operates on, the executor which gets configu...
Creates different instances of StopStrategy.
std::shared_ptr< FilterableTreeModelSortFilterProxyModel > FilterableTreeModelSortFilterProxyModelPtr
std::shared_ptr< std::vector< ScenarioManager::Data_Structure::PackagePtr > > PackageVectorPtr
Definition Package.h:123
std::shared_ptr< Executor > ExecutorPtr
Definition Executor.h:175
std::shared_ptr< ScenarioManager::Exec::StopperFactory > StopperFactoryPtr
std::shared_ptr< ScenarioManager::Exec::StarterFactory > StarterFactoryPtr
std::shared_ptr< SettingsModel > SettingsModelPtr