29 #include <QMessageBox>
32 #include <QStringList>
44 using namespace Controller;
45 using namespace Data_Structure;
52 packages(packages), executor(executor)
54 model->setSourceModel(treemodel.get());
56 stopperFactory = StopperFactory::getFactory();
57 starterFactory = StarterFactory::getFactory();
60 QObject::connect(&settingsDialog, SIGNAL(openPackageChooser()),
63 QObject::connect(&settingsDialog, SIGNAL(
removePackage(
int,
int, QModelIndex)),
66 QObject::connect(&packageAdderView, SIGNAL(created(std::string)),
69 QObject::connect(&settingsDialog, SIGNAL(changeExecutorSettings(std::string,
int, std::string)),
81 QObject::connect(&settingsDialog, SIGNAL(XmlCache()),
85 this, &This::closeUnavailablePackages);
98 QSettings settings(QString(file.c_str()), QSettings::NativeFormat);
99 QStringList execSettings = settings.value(
"execSettings").toStringList();
101 if (execSettings.size() < 3)
103 execSettings.clear();
104 execSettings <<
"Stop & Kill" <<
"1000" <<
"By Id";
105 settings.setValue(
"execSettings", execSettings);
106 setExecutorStopStrategy(execSettings.at(0).toStdString(), execSettings.at(1).toInt(), execSettings.at(2).toStdString());
110 setExecutorStopStrategy(execSettings.at(0).toStdString(), execSettings.at(1).toInt(), execSettings.at(2).toStdString());
118 QSettings settings(QString(file.c_str()), QSettings::NativeFormat);
119 QStringList execSettings = settings.value(
"execSettings").toStringList();
121 if (execSettings.size() < 3)
123 execSettings.clear();
124 execSettings <<
"Stop & Kill" <<
"1000" <<
"By Id";
125 settings.setValue(
"execSettings", execSettings);
126 setExecutorStopStrategy(execSettings.at(0).toStdString(), execSettings.at(1).toInt(), execSettings.at(2).toStdString());
130 setExecutorStopStrategy(execSettings.at(0).toStdString(), execSettings.at(1).toInt(), execSettings.at(2).toStdString());
133 settingsDialog.exec();
138 packageAdderView.exec();
143 for (
const auto& package : *packages)
145 if (package->getName().compare(name) == 0)
148 QString
message(QString::fromStdString(
"Package " + name +
" is already open"));
156 QSettings settings(QString(file.c_str()), QSettings::NativeFormat);
157 QStringList packages = settings.value(
"packages").toStringList();
158 packages.removeDuplicates();
159 packages.append(QString::fromStdString(name));
161 settings.setValue(
"packages", packages);
172 if (settingsItem ==
nullptr)
177 PackagePtr package = settingsItem->getPackage();
181 QSettings settings(QString(file.c_str()), QSettings::NativeFormat);
182 QStringList settingsPackages = settings.value(
"packages").toStringList();
183 settingsPackages.removeDuplicates();
185 settingsPackages.removeAt(settingsPackages.indexOf(QString::fromStdString(package->getName())));
187 settings.setValue(
"packages", settingsPackages);
190 for (std::vector<PackagePtr>::iterator iter = packages->begin(); iter != packages->end(); ++iter)
192 if (*iter == package)
194 packages->erase(iter);
208 int stopStrategyIndex = 0;
209 if (stopMethod.compare(
"By Id") == 0)
211 applicationStopper = stopperFactory->getPidStopper();
214 else if (stopMethod.compare(
"By Name") == 0)
216 applicationStopper = stopperFactory->getByNameStopper();
220 if (killMethod.compare(
"Stop only") == 0)
222 stopStrategy = stopStrategyFactory.
getStopStrategy(applicationStopper);
223 stopStrategyIndex = 1;
225 else if (killMethod.compare(
"Stop & Kill") == 0)
228 stopStrategyIndex = 0;
231 if (stopStrategy.get() ==
nullptr)
236 executor->setDefaultStopStrategy(stopStrategy);
239 QSettings settings(QString(file.c_str()), QSettings::NativeFormat);
240 QStringList execSettings = settings.value(
"execSettings").toStringList();
241 execSettings.clear();
243 execSettings << QString::fromStdString(killMethod) << QString::number(delay) << QString::fromStdString(stopMethod);
244 settings.setValue(
"execSettings", execSettings);
252 for (
const auto& package : *packages)
261 model->setSourceModel(treemodel.get());
279 QSettings settings(QString(file.c_str()), QSettings::NativeFormat);
280 QStringList packages = settings.value(
"packages").toStringList();
281 packages.removeDuplicates();
284 std::vector<std::string> foundStd;
285 std::vector<std::string> unavailableStd;
286 for (
int i = 0; i < packages.size(); i++)
288 const QString name = packages.at(i);
295 foundStd.push_back(name.toStdString());
299 unavailableStd.push_back(name.toStdString());
303 ARMARX_INFO <<
"Removed " << unavailableStd.size() <<
" from open packages: \n" << unavailableStd
304 <<
"\nFound available packages: \n" << foundStd;
306 settings.setValue(
"packages", found);