MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / on_pluginsList_currentItemChanged

Method on_pluginsList_currentItemChanged

src/settingsdialogplugins.cpp:283–361  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281}
282
283void PluginsSettingsTab::on_pluginsList_currentItemChanged(QTreeWidgetItem* current,
284 QTreeWidgetItem* previous)
285{
286 storeSettings(previous);
287
288 if (!current->data(0, PluginRole).isValid()) {
289 return;
290 }
291
292 ui->pluginSettingsList->clear();
293 IPlugin* plugin = this->plugin(current);
294 ui->authorLabel->setText(plugin->author());
295 ui->versionLabel->setText(plugin->version().canonicalString());
296 ui->descriptionLabel->setText(plugin->description());
297
298 // Checkbox, do not show for children or game plugins, disable
299 // if the plugin cannot be enabled.
300 ui->enabledCheckbox->setVisible(
301 !m_pluginContainer->implementInterface<IPluginGame>(plugin) &&
302 plugin->master().isEmpty());
303
304 bool enabled = m_pluginContainer->isEnabled(plugin);
305 auto& requirements = m_pluginContainer->requirements(plugin);
306 auto problems = requirements.problems();
307
308 if (m_pluginContainer->requirements(plugin).isCorePlugin()) {
309 ui->enabledCheckbox->setDisabled(true);
310 ui->enabledCheckbox->setToolTip(
311 QObject::tr("This plugin is required for Mod Organizer to work properly and "
312 "cannot be disabled."));
313 }
314 // Plugin is enable or can be enabled.
315 else if (enabled || problems.empty()) {
316 ui->enabledCheckbox->setDisabled(false);
317 ui->enabledCheckbox->setToolTip("");
318 ui->enabledCheckbox->setChecked(enabled);
319 }
320 // Plugin is disable and cannot be enabled.
321 else {
322 ui->enabledCheckbox->setDisabled(true);
323 ui->enabledCheckbox->setChecked(false);
324 if (problems.size() == 1) {
325 ui->enabledCheckbox->setToolTip(problems[0].shortDescription());
326 } else {
327 QStringList descriptions;
328 for (auto& problem : problems) {
329 descriptions.append(problem.shortDescription());
330 }
331 ui->enabledCheckbox->setToolTip("<ul><li>" + descriptions.join("</li><li>") +
332 "</li></ul>");
333 }
334 }
335
336 QVariantMap settings = current->data(0, SettingsRole).toMap();
337 QVariantMap descriptions = current->data(0, DescriptionsRole).toMap();
338 ui->pluginSettingsList->setEnabled(settings.count() != 0);
339 for (auto iter = settings.begin(); iter != settings.end(); ++iter) {
340 QTreeWidgetItem* newItem = new QTreeWidgetItem(QStringList(iter.key()));

Callers

nothing calls this directly

Calls 15

pluginMethod · 0.95
descriptionMethod · 0.80
setVisibleMethod · 0.80
masterMethod · 0.80
problemsMethod · 0.80
isCorePluginMethod · 0.80
countMethod · 0.80
setFlagsMethod · 0.80
isValidMethod · 0.45
dataMethod · 0.45
clearMethod · 0.45
setTextMethod · 0.45

Tested by

no test coverage detected