void PoseEditor::loadProject() { QString filename = QFileDialog::getOpenFileName(this, tr("Load File"), QDir::currentPath(), tr("rcss3dPoseProject : ppj (*.ppj);;AllFiles(*.*)")); if(filename.isEmpty()) { qDebug() << "PoseEditor:loadProject : filename is empty"; return; } if(!filename.endsWith(".ppj")) { qDebug() << "PoseEditor:loadProject : file type isn't \"ppj\""; return; } std::ifstream ifs(filename.toStdString().c_str()); std::string str; while(std::getline(ifs, str)) { // for all line in file std::vector<std::string> splitLine; boost::algorithm::split(splitLine, str, boost::is_any_of("\t")); /* for(std::vector<std::string>::iterator it = splitLine.begin(); it != splitLine.end(); it++){ std::cout << *it << ":"; } std::cout << std::endl; */ std::vector<std::string>::iterator it = splitLine.begin(); if(*it == "pose") { it++; int i = boost::lexical_cast<int>(*it); it++; if(*it == "name") { it++; std::string nameStr = *it; QString nameQStr(nameStr.c_str()); posesList->item(i)->setText(nameQStr); } else if(*it == "gain") { it++; double gain = boost::lexical_cast<double>(*it); Pose p = posesList->item(i)->data(Qt::UserRole).value<Pose>(); p.setGain(gain); posesList->item(i)->setData(Qt::UserRole, QVariant::fromValue(p)); } else if(*it == "joint") { it++; int jointNum = boost::lexical_cast<int>(*it); it++; double target = boost::lexical_cast<double>(*it); Pose p = posesList->item(i)->data(Qt::UserRole).value<Pose>(); p.setTarget(jointNum, target); posesList->item(i)->setData(Qt::UserRole, QVariant::fromValue(p)); // posesList->item(i)->data(Qt::UserRole).value<Pose>().setTarget(jointNum, target); // not works } } } changePoseListRow(posesList->currentRow()); }