MCPcopy Create free account
hub / github.com/davy7125/polyphone / attributeFromString

Method attributeFromString

sources/editor/pagetable.cpp:1238–1370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1236}
1237
1238AttributeValue PageTable::attributeFromString(AttributeType champ, bool isPrst, QString strValue, bool &ok)
1239{
1240 AttributeValue value;
1241 value.wValue = 0;
1242 ok = true;
1243
1244 switch (champ)
1245 {
1246 case champ_keyRange: case champ_velRange: {
1247 QRegularExpression regEx("[0-9]-");
1248 int posSeparator = static_cast<int>(strValue.indexOf(regEx)) + 1;
1249 QString txtLeft, txtRight;
1250 if (posSeparator == 0)
1251 txtLeft = txtRight = strValue;
1252 else
1253 {
1254 txtLeft = strValue.left(posSeparator);
1255 txtRight = strValue.right(strValue.size() - posSeparator - 1);
1256 }
1257
1258 int val1 = 0, val2 = 0;
1259 if (champ == champ_velRange)
1260 {
1261 bool tmp;
1262 val1 = txtLeft.toInt(&tmp);
1263 val2 = txtRight.toInt(&ok);
1264 ok &= tmp;
1265 }
1266 else
1267 {
1268 val1 = txtLeft.toInt(&ok);
1269 if (!ok)
1270 {
1271 val1 = ContextManager::keyName()->getKeyNum(txtLeft);
1272 ok = val1 != -1;
1273 }
1274
1275 if (ok)
1276 {
1277 val2 = txtRight.toInt(&ok);
1278 if (!ok)
1279 {
1280 val2 = ContextManager::keyName()->getKeyNum(txtRight);
1281 ok = val2 != -1;
1282 }
1283 }
1284 }
1285
1286 if (txtLeft.isEmpty())
1287 val1 = 0;
1288 if (txtRight.isEmpty())
1289 val2 = 127;
1290
1291 if (val1 < 0)
1292 val1 = 0;
1293 else if (val1 > 127)
1294 val1 = 127;
1295 if (val2 < 0)

Callers

nothing calls this directly

Calls 4

indexOfMethod · 0.80
toIntMethod · 0.80
getKeyNumMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected