| 729 | } |
| 730 | |
| 731 | bool MainWindow::readProcessFile() |
| 732 | { |
| 733 | _isPlaying = false; |
| 734 | _timer->stop(); |
| 735 | |
| 736 | QString errorString; |
| 737 | |
| 738 | QString fileName = _currentProcessFileName; |
| 739 | |
| 740 | if(fileName.length() < 1) |
| 741 | { |
| 742 | fileName = _pluginPath + "/_autosave.ipj"; |
| 743 | } |
| 744 | |
| 745 | // read json file |
| 746 | QFile file(fileName); |
| 747 | |
| 748 | if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) |
| 749 | return false; |
| 750 | |
| 751 | QString fileContents; |
| 752 | QTextStream in(&file); |
| 753 | while (!in.atEnd()) { |
| 754 | QString line = in.readLine(); |
| 755 | fileContents.append(line); |
| 756 | } |
| 757 | file.close(); |
| 758 | |
| 759 | // clear current process |
| 760 | _allowChangeActiveProcessStep = false; |
| 761 | |
| 762 | clearScene(); |
| 763 | |
| 764 | // parse file and create process |
| 765 | QJsonParseError error; |
| 766 | QJsonDocument document = QJsonDocument::fromJson(fileContents.toLatin1(), &error); |
| 767 | qWarning() << error.errorString(); |
| 768 | |
| 769 | QJsonObject root = document.object(); |
| 770 | |
| 771 | QMap<long, long> stepIdMap; |
| 772 | |
| 773 | QJsonArray steps = root.value("steps").toArray(); |
| 774 | for(auto it = steps.begin(); it != steps.end(); ++it) |
| 775 | { |
| 776 | QJsonObject stepObject = (*it).toObject(); |
| 777 | |
| 778 | long ID = stepObject.value("ID").toDouble(); |
| 779 | int posX = stepObject.value("posX").toDouble(); |
| 780 | int posY = stepObject.value("posY").toDouble(); |
| 781 | QString type = stepObject.value("type").toString(); |
| 782 | |
| 783 | IPProcessStep* newStep = new IPProcessStep(this, type); |
| 784 | newStep->setPos(QPointF(posX, posY)); |
| 785 | |
| 786 | // check if valid |
| 787 | if(!newStep->process()) |
| 788 | { |
no test coverage detected