MCPcopy Create free account
hub / github.com/altairwei/WizNotePlus / validateMenuTypeModule

Method validateMenuTypeModule

src/jsplugin/JSPluginSpec.cpp:243–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241}
242
243bool JSPluginModuleSpec::validateMenuTypeModule()
244{
245 QVector<QString> buttonLocationOptions = {
246 "Main", "Document"
247 };
248 if (!buttonLocationOptions.contains(m_buttonLocation)) {
249 warn(QString("Unknown ButtonLocation '%1'").arg(m_buttonLocation));
250 return false;
251 }
252
253 if (m_actionIndexes.isEmpty()) {
254 warn("Empty menu actions");
255 return false;
256 }
257
258 JSPluginSpec *spec = parentSpec();
259 bool isAllActionValid = std::all_of(m_actionIndexes.begin(), m_actionIndexes.end(),
260 [spec, this](const int &index) {
261 if (index > spec->moduleCount()) {
262 warn("menu action index out of range");
263 return false;
264 }
265 JSPluginModuleSpec *ms = spec->module(index);
266 if (ms->moduleType() != "Action") {
267 warn("menu module must be action type");
268 return false;
269 }
270 if (ms->buttonLocation() != "Menu") {
271 warn("menu module must be located at Menu");
272 return false;
273 }
274 return true;
275 });
276
277 return isAllActionValid;
278}
279
280bool JSPluginModuleSpec::validate()
281{

Callers

nothing calls this directly

Calls 8

isEmptyMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
moduleCountMethod · 0.80
moduleTypeMethod · 0.80
buttonLocationMethod · 0.80
QStringClass · 0.50
moduleMethod · 0.45

Tested by

no test coverage detected