MCPcopy Create free account
hub / github.com/OpenOrienteering/mapper / updateContextMenuState

Method updateContextMenuState

src/gui/widgets/symbol_render_widget.cpp:1078–1133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1076}
1077
1078void SymbolRenderWidget::updateContextMenuState()
1079{
1080 bool have_selection = selectedSymbolsCount() > 0;
1081 bool single_selection = selectedSymbolsCount() == 1 && current_symbol_index >= 0;
1082 const Symbol* single_symbol = singleSelectedSymbol();
1083 bool all_symbols_hidden = have_selection;
1084 bool all_symbols_protected = have_selection;
1085 for (auto symbol_index : selected_symbols)
1086 {
1087 if (!map->getSymbol(symbol_index)->isHidden())
1088 all_symbols_hidden = false;
1089 if (!map->getSymbol(symbol_index)->isProtected())
1090 all_symbols_protected = false;
1091 if (!all_symbols_hidden && !all_symbols_protected)
1092 break;
1093 }
1094
1095 bool single_symbol_compatible;
1096 bool single_symbol_different;
1097 map->getSelectionToSymbolCompatibility(single_symbol, single_symbol_compatible, single_symbol_different);
1098
1099 edit_action->setEnabled(single_selection);
1100 scale_action->setEnabled(have_selection);
1101 copy_action->setEnabled(have_selection);
1102 paste_action->setEnabled(QApplication::clipboard()->mimeData()->hasFormat(MimeType::OpenOrienteeringSymbols()));
1103 switch_symbol_action->setEnabled(single_symbol_compatible && single_symbol_different);
1104 fill_border_action->setEnabled(single_symbol_compatible && single_symbol_different);
1105 hide_action->setEnabled(have_selection);
1106 hide_action->setChecked(all_symbols_hidden);
1107 protect_action->setEnabled(have_selection);
1108 protect_action->setChecked(all_symbols_protected);
1109 duplicate_action->setEnabled(single_selection);
1110 delete_action->setEnabled(have_selection);
1111
1112 if (single_selection)
1113 {
1114 select_objects_action->setText(tr("Select all objects with this symbol"));
1115 select_objects_additionally_action->setText(tr("Add all objects with this symbol to selection"));
1116 deselect_objects_action->setText(tr("Remove all objects with this symbol from selection"));
1117 hide_action->setText(tr("Hide objects with this symbol"));
1118 protect_action->setText(tr("Protect objects with this symbol"));
1119 }
1120 else
1121 {
1122 select_objects_action->setText(tr("Select all objects with selected symbols"));
1123 select_objects_additionally_action->setText(tr("Add all objects with selected symbols to selection"));
1124 deselect_objects_action->setText(tr("Remove all objects with selected symbols from selection"));
1125 hide_action->setText(tr("Hide objects with selected symbols"));
1126 protect_action->setText(tr("Protect objects with selected symbols"));
1127 }
1128 select_objects_action->setEnabled(have_selection);
1129 select_objects_additionally_action->setEnabled(have_selection);
1130 deselect_objects_action->setEnabled(have_selection);
1131
1132 show_custom_icons->setChecked(Settings::getInstance().getSetting(Settings::SymbolWidget_ShowCustomIcons).toBool());
1133}
1134
1135bool SymbolRenderWidget::newSymbol(Symbol* prototype)

Callers

nothing calls this directly

Calls 8

OpenOrienteeringSymbolsFunction · 0.85
isHiddenMethod · 0.80
isProtectedMethod · 0.80
getSymbolMethod · 0.45
setEnabledMethod · 0.45
setTextMethod · 0.45
getSettingMethod · 0.45

Tested by

no test coverage detected