58 model->setSourceModel(treemodel.get());
59 settingsDialog.setModel(model);
67 QObject::connect(&settingsDialog,
73 &packageAdderView, SIGNAL(created(std::string)),
this, SLOT(
addPackage(std::string)));
75 QObject::connect(&settingsDialog,
76 SIGNAL(changeExecutorSettings(std::string,
int, std::string)),
80 QObject::connect(
this,
89 QObject::connect(&settingsDialog, SIGNAL(XmlCache()),
this, SLOT(
clearXmlCache()));
91 QObject::connect(&settingsDialog,
94 &This::closeUnavailablePackages);
106 const std::string file =
108 QSettings settings(QString(file.c_str()), QSettings::NativeFormat);
109 QStringList execSettings = settings.value(
"execSettings").toStringList();
111 if (execSettings.size() < 3)
113 execSettings.clear();
114 execSettings <<
"Stop & Kill"
117 settings.setValue(
"execSettings", execSettings);
119 execSettings.at(1).toInt(),
120 execSettings.at(2).toStdString());
125 execSettings.at(1).toInt(),
126 execSettings.at(2).toStdString());
134 const std::string file =
136 QSettings settings(QString(file.c_str()), QSettings::NativeFormat);
137 QStringList execSettings = settings.value(
"execSettings").toStringList();
139 if (execSettings.size() < 3)
141 execSettings.clear();
142 execSettings <<
"Stop & Kill"
145 settings.setValue(
"execSettings", execSettings);
147 execSettings.at(1).toInt(),
148 execSettings.at(2).toStdString());
153 execSettings.at(1).toInt(),
154 execSettings.at(2).toStdString());
157 settingsDialog.exec();
163 packageAdderView.exec();
169 for (
const auto& package : *packages)
171 if (package->getName().compare(name) == 0)
174 QString message(QString::fromStdString(
"Package " + name +
" is already open"));
175 box.setText(message);
181 const std::string file =
183 QSettings settings(QString(file.c_str()), QSettings::NativeFormat);
184 QStringList packages = settings.value(
"packages").toStringList();
185 packages.removeDuplicates();
186 packages.append(QString::fromStdString(name));
188 settings.setValue(
"packages", packages);
201 if (settingsItem ==
nullptr)
206 PackagePtr package = settingsItem->getPackage();
209 const std::string file =
211 QSettings settings(QString(file.c_str()), QSettings::NativeFormat);
212 QStringList settingsPackages = settings.value(
"packages").toStringList();
213 settingsPackages.removeDuplicates();
215 settingsPackages.removeAt(settingsPackages.indexOf(QString::fromStdString(package->getName())));
217 settings.setValue(
"packages", settingsPackages);
220 for (std::vector<PackagePtr>::iterator iter = packages->begin(); iter != packages->end();
223 if (*iter == package)
225 packages->erase(iter);
237 std::string stopMethod)
242 int stopStrategyIndex = 0;
243 if (stopMethod.compare(
"By Id") == 0)
245 applicationStopper = stopperFactory->getPidStopper();
248 else if (stopMethod.compare(
"By Name") == 0)
250 applicationStopper = stopperFactory->getByNameStopper();
254 if (killMethod.compare(
"Stop only") == 0)
256 stopStrategy = stopStrategyFactory.getStopStrategy(applicationStopper);
257 stopStrategyIndex = 1;
259 else if (killMethod.compare(
"Stop & Kill") == 0)
261 stopStrategy = stopStrategyFactory.getStopAndKillStrategy(applicationStopper, delay);
262 stopStrategyIndex = 0;
265 if (stopStrategy.get() ==
nullptr)
270 executor->setDefaultStopStrategy(stopStrategy);
272 const std::string file =
274 QSettings settings(QString(file.c_str()), QSettings::NativeFormat);
275 QStringList execSettings = settings.value(
"execSettings").toStringList();
276 execSettings.clear();
278 execSettings << QString::fromStdString(killMethod) << QString::number(delay)
279 << QString::fromStdString(stopMethod);
280 settings.setValue(
"execSettings", execSettings);
289 for (
const auto& package : *packages)
298 model->setSourceModel(treemodel.get());
299 settingsDialog.setModel(model);
317 const std::string file =
319 QSettings settings(QString(file.c_str()), QSettings::NativeFormat);
320 QStringList packages = settings.value(
"packages").toStringList();
321 packages.removeDuplicates();
324 std::vector<std::string> foundStd;
325 std::vector<std::string> unavailableStd;
326 for (
int i = 0; i < packages.size(); i++)
328 const QString name = packages.at(i);
335 foundStd.push_back(name.toStdString());
339 unavailableStd.push_back(name.toStdString());
343 ARMARX_INFO <<
"Removed " << unavailableStd.size() <<
" from open packages: \n"
344 << unavailableStd <<
"\nFound available packages: \n"
347 settings.setValue(
"packages", found);
Model of the FilterableTreeView.
void packageRemoved()
Emitted when a package gets removed.
void closeUnavailablePackages()
~SettingsController() override
Destructor.
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 showSettings()
Shows the settings dialog.
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...
static std::shared_ptr< StarterFactory > getFactory()
Returns the right StarterFactory for this operatin system.
static std::shared_ptr< StopperFactory > getFactory()
Returns the right StopperFactory for this operating system.
static void clearXmlCacheDir()
void closeUnavailablePackages()
void appendChild(TreeItem *child)
virtual QVariant data(int column) const
static std::string GetDefaultUserConfigPath()
The user config directory of ArmarX.
static CMakePackageFinderCache GlobalCache
The CMakePackageFinder class provides an interface to the CMake Package finder capabilities.
bool packageFound() const
Returns whether or not this package was found with cmake.
#define ARMARX_INFO
The normal logging level.
std::shared_ptr< std::vector< ScenarioManager::Data_Structure::PackagePtr > > PackageVectorPtr
std::shared_ptr< Package > PackagePtr
std::shared_ptr< ApplicationStopper > ApplicationStopperPtr
std::shared_ptr< Executor > ExecutorPtr
std::shared_ptr< StopStrategy > StopStrategyPtr
This file offers overloads of toIce() and fromIce() functions for STL container types.