MCPcopy Create free account
hub / github.com/KDE/kdevelop / deleteStyle

Method deleteStyle

kdevplatform/shell/sourceformatterselectionedit.cpp:1055–1102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1053}
1054
1055void SourceFormatterSelectionEdit::deleteStyle()
1056{
1057 Q_D(SourceFormatterSelectionEdit);
1058
1059 const auto& currentStyle = d->validCurrentStyle();
1060
1061 QStringList otherLanguageNames;
1062 std::vector<LanguageSettings*> otherLanguages;
1063 for (auto& lang : d->languages) {
1064 if (&lang != &d->currentLanguage() && lang.selectedStyle() == &currentStyle) {
1065 otherLanguageNames.push_back(lang.name());
1066 otherLanguages.push_back(&lang);
1067 }
1068 }
1069 // The deleted style can be used in other sessions or projects. But we show the warning dialog only if it
1070 // is selected for another language in the current session or project model (!otherLanguageNames.empty()).
1071 // Checking style selections in all other sessions is complicated, in all other projects - impossible.
1072 // Showing the warning dialog every time a style is deleted, even if the user just created it, can be
1073 // annoying. So the current behavior makes sense.
1074 if (!otherLanguageNames.empty()
1075 && KMessageBox::warningContinueCancel(
1076 this,
1077 i18n("The style %1 is also used for the following languages:\n%2.\nAre you sure you want to delete it?",
1078 currentStyle.caption(), otherLanguageNames.join(QLatin1Char('\n'))),
1079 i18nc("@title:window", "Deleting Style"))
1080 != KMessageBox::Continue) {
1081 return;
1082 }
1083
1084 const auto* const currentStyleItem = d->ui.styleList->currentItem();
1085 d->assertValidSelectedStyleItem(currentStyleItem);
1086 {
1087 const QSignalBlocker blocker(d->ui.styleList);
1088 delete currentStyleItem;
1089 // QListWidget selects the next item in the list when the currently selected item is destroyed.
1090 // Clear the selection for consistency with other languages where the deleted style was selected.
1091 d->ui.styleList->clearSelection();
1092 }
1093
1094 d->currentLanguage().unselectStyle(currentStyle);
1095 for (auto* lang : otherLanguages) {
1096 lang->unselectStyle(currentStyle);
1097 }
1098 d->currentFormatter().removeStyle(currentStyle);
1099
1100 d->updateUiForCurrentStyle();
1101 emit changed();
1102}
1103
1104void SourceFormatterSelectionEdit::editStyle()
1105{

Callers

nothing calls this directly

Calls 11

selectedStyleMethod · 0.80
emptyMethod · 0.80
joinMethod · 0.80
unselectStyleMethod · 0.80
removeStyleMethod · 0.80
push_backMethod · 0.45
nameMethod · 0.45
captionMethod · 0.45
currentItemMethod · 0.45

Tested by

no test coverage detected