MCPcopy Create free account
hub / github.com/cpvrlab/ImagePlay / writeProcessFile

Method writeProcessFile

ImagePlay/src/MainWindow.cpp:902–1009  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

900}
901
902bool MainWindow::writeProcessFile()
903{
904 QString fileName = _currentProcessFileName;
905
906 if(fileName.length() < 1)
907 {
908 fileName = _pluginPath + "/_autosave.ipj";
909 }
910
911 QJsonDocument document;
912 QJsonObject root;
913
914 QDateTime now = QDateTime::currentDateTime();
915 root.insert("timestamp", QJsonValue::fromVariant(now.toTime_t()));
916
917 QString username = QString::fromLatin1(getenv("USERNAME"));
918 root.insert("author", QJsonValue::fromVariant(username));
919
920 // collect steps
921 QJsonArray steps;
922 for(int i=0; i<_scene->steps()->length(); i++)
923 {
924 IPProcessStep* s = _scene->steps()->at(i);
925 QJsonObject step;
926 step.insert("ID", QJsonValue::fromVariant(s->stepID()));
927 step.insert("type", QJsonValue::fromVariant(QString::fromStdString(s->process()->className())));
928 step.insert("posX", QJsonValue::fromVariant(s->pos().x()));
929 step.insert("posY", QJsonValue::fromVariant(s->pos().y()));
930
931 QJsonArray properties;
932 IPLProcessPropertyMap* propertyMap = s->process()->properties();
933 for(auto it = propertyMap->begin(); it != propertyMap->end(); ++it)
934 {
935 QString key = QString::fromStdString(it->first);
936
937 auto &p = it->second;
938 QString propertyJsonString;
939 {
940 IPLProcessProperty::SerializedData data = p->serialize();
941 std::ostringstream json;
942 json << "{\n";
943 json << " \"type\": \"" << data.type << "\",\n";
944 json << " \"widget\": \"" << data.widget << "\",\n";
945 json << " \"widgetName\": \"" << data.widgetName << "\",\n";
946 json << " \"value\": \"" << data.value << "\"\n";
947 json << "}";
948 propertyJsonString = QString::fromStdString(json.str());
949 }
950
951 QJsonParseError error;
952 QJsonDocument tmp = QJsonDocument::fromJson(propertyJsonString.toLatin1(), &error);
953 if(tmp.isObject())
954 {
955 QJsonObject property = tmp.object();
956 property.insert("key", key);
957 properties.append(property);
958 }
959 }

Callers

nothing calls this directly

Calls 15

lengthMethod · 0.80
stepsMethod · 0.80
stepIDMethod · 0.80
propertiesMethod · 0.80
serializeMethod · 0.80
edgesMethod · 0.80
fromMethod · 0.80
toMethod · 0.80
indexFromMethod · 0.80
indexToMethod · 0.80
toJsonMethod · 0.80
insertMethod · 0.45

Tested by

no test coverage detected