Process a single line from the dataGrid. Right now it seems to not trigger at all after the first adding of the code but that seems to maybe be because whichever field you where just in will show up as nothing to the code.
| 561 | /// </summary> |
| 562 | /// <param name="line"></param> |
| 563 | void FrameSenderWindow::processModifierText(int line) |
| 564 | { |
| 565 | qDebug() << "processModifierText"; |
| 566 | QString modString; |
| 567 | //bool firstOp = true; |
| 568 | bool abort = false; |
| 569 | QString token; |
| 570 | ModifierOp thisOp; |
| 571 | |
| 572 | //Example line: |
| 573 | //d0 = D0 + 1,d1 = id:0x200:d3 + id:0x200:d4 AND 0xF0 - Original version |
| 574 | //D0=D0+1,D1=ID:0x200:D3+ID:0x200:D4&0xF0 |
| 575 | //This is certainly much harder to parse than the trigger definitions. |
| 576 | //the left side of the = has to be D0 to D7. After that there is a string of |
| 577 | //data. Spaces used to be required but no longer are. This makes parsing harder but data entry easier |
| 578 | |
| 579 | //yeah, lots of operations on this one line but it's for a good cause. Removes the convenience English versions of the |
| 580 | //logical operators and replaces them with the math equivs. Also uppercases and removes all superfluous whitespace |
| 581 | modString = ui->tableSender->item(line, 8)->text().toUpper().trimmed().replace("AND", "&").replace("XOR", "^").replace("OR", "|").replace(" ", ""); |
| 582 | if (modString != "") |
| 583 | { |
| 584 | QStringList mods = modString.split(','); |
| 585 | sendingData[line].modifiers.clear(); |
| 586 | sendingData[line].modifiers.reserve(mods.length()); |
| 587 | for (int i = 0; i < mods.length(); i++) |
| 588 | { |
| 589 | Modifier thisMod; |
| 590 | thisMod.destByte = 0; |
| 591 | |
| 592 | QString leftSide = Utility::grabAlphaNumeric(mods[i]); |
| 593 | if (leftSide.startsWith("D") && leftSide.length() == 2) |
| 594 | { |
| 595 | thisMod.destByte = leftSide.right(1).toInt(); |
| 596 | thisMod.operations.clear(); |
| 597 | } |
| 598 | else |
| 599 | { |
| 600 | qDebug() << "Something wrong with lefthand val"; |
| 601 | continue; |
| 602 | } |
| 603 | if (!(Utility::grabOperation(mods[i]) == "=")) |
| 604 | { |
| 605 | qDebug() << "Err: No = after lefthand val"; |
| 606 | continue; |
| 607 | } |
| 608 | abort = false; |
| 609 | |
| 610 | token = Utility::grabAlphaNumeric(mods[i]); |
| 611 | if (token[0] == '~') |
| 612 | { |
| 613 | thisOp.first.notOper = true; |
| 614 | token = token.remove(0, 1); //remove the ~ character |
| 615 | } |
| 616 | else thisOp.first.notOper = false; |
| 617 | parseOperandString(token.split(":"), thisOp.first); |
| 618 | |
| 619 | if (mods[i].length() < 2) { |
| 620 | abort = true; |