bool ValueAnimation::Save(Serializer& dest) const { XMLFile xmlFile(context_); XMLElement rootElem = xmlFile.CreateRoot("valueanimation"); if (!SaveXML(rootElem)) return false; return xmlFile.Save(dest); }
bool MatrixGraph::readXml(const char* path) { char* data = nullptr; xml_document<> doc; try { file<> xmlFile(path); data = new char[xmlFile.size()]; memcpy(data, xmlFile.data(), xmlFile.size() * sizeof(char)); } catch (runtime_error e) { cout << "Nie mozna otworzyc pliku: " << path << endl; if (data) delete[] data; cin.get(); cin.ignore(); return false; } bool retVal = false; doc.parse<0>(data); xml_node<>* node = doc.first_node("travellingSalesmanProblemInstance"); if (node) { node = node->first_node("graph"); if (node) { uint vNum = count_children(node); reserve(vNum); node = node->first_node("vertex"); for (uint vertex = 0; node != nullptr; node = node->next_sibling("vertex"), ++vertex) { xml_node<>* edge = node->first_node("edge"); for (; edge != nullptr; edge = edge->next_sibling("edge")) { matrix[vertex][atoi(edge->value())] = int(atof(edge->first_attribute("cost")->value())); retVal = true; } } for (uint i = 0; i < vertexNumber; i++) { matrix[i][i] = -1; } } } if (data) delete[] data; return retVal; }
Monster* MonsterFactory::parseXmlMonster(char* monsterPath) { rapidxml::file<> xmlFile(monsterPath); rapidxml::xml_document<> doc; doc.parse<0>(xmlFile.data()); std::string xmlRootNodeName = std::string(doc.first_node()->name()); rapidxml::xml_node<> *rootNode = doc.first_node(); Monster* parsedMonster = NULL; if (xmlRootNodeName == MONSTERS_ROOT_NODE) { MonsterType type = this->findMonsterType(rootNode->first_node()); if (type == MonsterType::BASIC) { BasicMonster* basicMonster = new BasicMonster(); this->fillBasicMonsterAttributes(basicMonster, rootNode->first_node()); this->fillGenericMonsterAttributes(basicMonster, rootNode->first_node()); parsedMonster = basicMonster; } else if (type == MonsterType::GENERIC) { Monster* genericMonster = new Monster(); this->fillGenericMonsterAttributes(genericMonster, rootNode->first_node()); parsedMonster = genericMonster; } else if (type == MonsterType::TURRET) { TurretMonster* turretMonster = new TurretMonster(); this->fillTurretMonsterAttributes(turretMonster, rootNode->first_node()); this->fillGenericMonsterAttributes(turretMonster, rootNode->first_node()); parsedMonster = turretMonster; } else if (type == MonsterType::DISTANCE) { DistanceMonster* distanceMonster = new DistanceMonster(); this->fillDistanceMonsterAttributes(distanceMonster, rootNode->first_node()); this->fillTurretMonsterAttributes(distanceMonster, rootNode->first_node()); this->fillBasicMonsterAttributes(distanceMonster, rootNode->first_node()); this->fillGenericMonsterAttributes(distanceMonster, rootNode->first_node()); parsedMonster = distanceMonster; } else if (type == MonsterType::BOMBER) { BomberMonster* bomberMonster = new BomberMonster(); this->fillBomberMonsterAttributes(bomberMonster, rootNode->first_node()); this->fillBasicMonsterAttributes(bomberMonster, rootNode->first_node()); this->fillGenericMonsterAttributes(bomberMonster, rootNode->first_node()); parsedMonster = bomberMonster; } } return parsedMonster; }
Teuchos::RCP<Teuchos::ParameterList> Teuchos::getParametersFromXmlFile( const std::string &xmlFileName, RCP<DependencySheet> depSheet) { XMLParameterListReader xmlPLReader; xmlPLReader.setAllowsDuplicateSublists( false ); FileInputSource xmlFile(xmlFileName); XMLObject xmlParams = xmlFile.getObject(); return xmlPLReader.toParameterList(xmlParams, depSheet); }
//read data from xml file Team* TeamData::readTeamData(QString filename){ QFile xmlFile(filename); QXmlInputSource source(xmlFile); QXmlSimpleReader reader; TeamParser *handler = new TeamParser(); reader.setContentHandler(handler); reader.parse(source); return(handler->teamData()); }
void Teuchos::updateParametersFromXmlFile( const std::string &xmlFileName, const Ptr<ParameterList> ¶mList ) { XMLParameterListReader xmlPLReader; xmlPLReader.setAllowsDuplicateSublists( false ); FileInputSource xmlFile(xmlFileName); XMLObject xmlParams = xmlFile.getObject(); paramList->setParameters(xmlPLReader.toParameterList(xmlParams)); }
TEUCHOS_UNIT_TEST( XMLParameterListReader, XMLDuplicatedSublistsThrowsError ) { FileInputSource xmlFile(filename); XMLObject xmlParams = xmlFile.getObject(); XMLParameterListReader xmlPLReader; TEST_EQUALITY_CONST( xmlPLReader.getAllowsDuplicateSublists(), true ); out << "Changing policy to disallow duplicate sublists" << std::endl; xmlPLReader.setAllowsDuplicateSublists( false ); TEST_EQUALITY_CONST( xmlPLReader.getAllowsDuplicateSublists(), false ); TEST_THROW( xmlPLReader.toParameterList(xmlParams), DuplicateParameterSublist ); }
// // Set up the XML file for reading, then start the parse. The XML parse // proceeds and calls the callback functions below. Return false if the // parser detected an error. // bool CDCConfig::ReadConfigFile(wchar_t *configFileName) { // Create a file, an XML input source and a simple reader QFile xmlFile( QString::fromUcs2((const short unsigned int*)configFileName) ) ; QXmlInputSource source( xmlFile ) ; QXmlSimpleReader reader ; // Connect this object's handler interface to the XML reader reader.setContentHandler( this ) ; // Return true if the parse succeeds and no XML semantic errors return( reader.parse( source ) && (!m_xmlSemanticError) ) ; }
void Remote::loadFromFile(const QString &fileName) { charBuffer = ""; curRB = 0; QFile xmlFile(fileName); QXmlInputSource source(&xmlFile); QXmlSimpleReader reader; reader.setContentHandler(this); reader.parse(source); }
bool CompoundHandler::parseXML(const char *compId) { QFile xmlFile(m_xmlDir+"/"+compId+".xml"); if (!xmlFile.exists()) return FALSE; CompoundErrorHandler errorHandler; QXmlInputSource source( xmlFile ); QXmlSimpleReader reader; reader.setContentHandler( this ); reader.setErrorHandler( &errorHandler ); reader.parse( source ); return TRUE; }
void KMibwalker::setupActions() { QAction* clearAction = new QAction ( this ); clearAction->setText ( i18n ( "&Clear" ) ); clearAction->setIcon ( QIcon::fromTheme ( "document-new" ) ); actionCollection()->setDefaultShortcut ( clearAction, Qt::CTRL + Qt::Key_W ); actionCollection()->addAction ( "clear", clearAction ); //connect ( clearAction, SIGNAL ( triggered ( bool ) ), textArea, SLOT ( clear() ) ); KStandardAction::quit ( qApp, SLOT ( quit() ), actionCollection() ); setupGUI ( Default, "kmibwalkerui.rc" ); qDebug() << "xml file: " << xmlFile(); }
void MainWindow::on_itemListSave_clicked() { QFile xmlFile(ui->lineEditItemFile->text()); if(!xmlFile.open(QIODevice::WriteOnly)) { QMessageBox::warning(this,tr("Error"),tr("Unable to open the file %1:\n%2").arg(xmlFile.fileName()).arg(xmlFile.errorString())); return; } xmlFile.write(domDocument.toByteArray(4)); xmlFile.close(); QMessageBox::information(this,tr("Saved"),tr("The file have been correctly saved")); }
bool XMLWriter::saveToFile(QString fileName) { if ((m_doc->childNodes().count()==0)||fileName.isEmpty()) return false; QFile xmlFile(fileName); if (xmlFile.open(QFile::WriteOnly)) { QTextStream buffer(&xmlFile); m_doc->save(buffer,2); xmlFile.close(); return true; } return false; }
void QtSEnaMainWindow::apri() { QFile xmlFile(_apriFile->selectedFiles().at(0)); if(xmlFile.open(QIODevice::ReadOnly)) { QXmlStreamReader xmlStream(&xmlFile); while(!xmlStream.atEnd()) { xmlStream.readNext(); if(xmlStream.isStartElement() && xmlStream.name().toAscii() == "Elementi") { QStringList sElementi = QString(xmlStream.readElementText().toAscii()).split(QChar(',')); _grigliaNumeri->deselezionaTutti(); for (quint8 i = 0; i < sElementi.count(); i++) { _grigliaNumeri->selezionaValore(sElementi.at(i).toUShort() - 1); } } if(xmlStream.isStartElement() && xmlStream.name().toAscii() == "Somma") { ui->maxSum->setValue(xmlStream.attributes().value("max").toAscii().toInt()); ui->minSum->setValue(xmlStream.attributes().value("min").toAscii().toInt()); } if(xmlStream.isStartElement() && xmlStream.name().toAscii() == "Consecutivi") { QStringList sConsecutivi = QString(xmlStream.readElementText().toAscii()).split(QChar(',')); for (quint8 i = 0; i <= _NUMERO_ELEMENTI_COLONNA; i++) _consecutivi.at(i)->setChecked(false); for (quint8 i = 0; i < sConsecutivi.count(); i++) { _consecutivi.at(sConsecutivi.at(i).toUShort())->setChecked(true); } } if(xmlStream.isStartElement() && xmlStream.name().toAscii() == "Gemelli") { QStringList sGemelli = QString(xmlStream.readElementText().toAscii()).split(QChar(',')); for (quint8 i = 0; i <= _NUMERO_ELEMENTI_COLONNA; i++) _gemelli.at(i)->setChecked(false); for (quint8 i = 0; i < sGemelli.count(); i++) { _gemelli.at(sGemelli.at(i).toUShort())->setChecked(true); } } if(xmlStream.isStartElement() && xmlStream.name().toAscii() == "Pari") { QStringList sPari = QString(xmlStream.readElementText().toAscii()).split(QChar(',')); for (quint8 i = 0; i <= _NUMERO_ELEMENTI_COLONNA; i++) _pari.at(i)->setChecked(false); for (quint8 i = 0; i < sPari.count(); i++) { _pari.at(sPari.at(i).toUShort())->setChecked(true); } } } xmlFile.close(); #ifdef _DEBUG_FLAG_ENABLED if (xmlStream.hasError()){ qWarning() << "[QTSENAMAINWINDOW] - on_actionApri_triggered() - Errore: " << xmlStream.errorString(); } } else { qWarning() << "[QTSENAMAINWINDOW] - on_actionApri_triggered() - Impossibile leggere dal file " << _nomeFile; #endif //_DEBUG_FLAG_ENABLED } }
bool PropertyDict::readXmlFile( const QString &fileName ) { PropertyParser *handler = new PropertyParser( this, fileName ); checkmem( __FILE__, __LINE__, handler, "PropertyParser handler", 1 ); QFile xmlFile( fileName ); QXmlInputSource source( &xmlFile ); QXmlSimpleReader reader; reader.setContentHandler( handler ); reader.setErrorHandler( handler ); bool result = reader.parse( &source ); delete handler; return( result ); }
void XmlStore::load( Object * _obj ) { QDomDocument doc; QFile xmlFile( m_file.isEmpty() ? configurationFilePath() : m_file ); if( !xmlFile.open( QFile::ReadOnly ) || !doc.setContent( &xmlFile ) ) { qWarning() << "Could not open" << xmlFile.fileName(); return; } QDomElement root = doc.documentElement(); loadXmlTree( _obj, root, QString() ); }
void ReviewedTestSerializator::saveTest(const ReviewedTest &test, const QString &filename) throw (Exception) { QFile xmlFile(filename); if (!xmlFile.open(QIODevice::WriteOnly)) { throw Exception(Exception::FileOperationError, QString("Couldn't open file - " + filename)); } xmlFile.write(getTestXML(test).toByteArray()); xmlFile.close(); }
bool ConvertXml::load(QString fileName) { MusicXMLErrorHandler errHndlr; QFile xmlFile(fileName); QXmlInputSource source(&xmlFile); QXmlSimpleReader reader; reader.setContentHandler(this); reader.setErrorHandler(&errHndlr); errHndlr.setParser(this); reader.parse(source); return TRUE; }
// // EventsFile::Open() // Open XML file and set up handler to parse the XML file // bool //EventsFile::Open(const wchar_t *events_file_path ) EventsFile::Open(QString strEventsFile) { QFile xmlFile(strEventsFile); QXmlInputSource source(&xmlFile); QXmlSimpleReader reader; /* set our xml handler to do work on the data */ reader.setContentHandler(this); return reader.parse(source); }
std::auto_ptr<Project> ProjectFileParser::Parse(std::string file) { std::auto_ptr<Project> ret; try { rapidxml::file<> xmlFile(file.c_str()); rapidxml::xml_document<> doc; doc.parse<0>(xmlFile.data()); rapidxml::xml_node<>* projNode = doc.first_node(); if (projNode == NULL) return ret; if (std::string(projNode->name()) != "Project") return ret; ret.reset(new Project()); m_project = ret.get(); rapidxml::xml_node<>* node = projNode->first_node(); while (node) { switch (GetNodeType(node)) { case eItemGroup: ReadItemGroup(node); break; case ePropertyGroup: ReadPropertyGroup(node); break; case eImportGroup: ReadImportGroup(node); break; case eImport: ReadImport(node); break; case eItemDefinitionGroup: ReadItemDefinitionGroup(node); break; case eUnknown: break; default: // any node at this level should be handled break; } node = node->next_sibling(); } } catch (...) { ret.reset(); } m_project = NULL; return ret; }
void ImageWindow::setupActions() { setupStandardActions(); // Provides a menu entry that allows showing/hiding the toolbar(s) setStandardToolBarMenuEnabled(true); // Provides a menu entry that allows showing/hiding the statusbar createStandardStatusBarAction(); d->toMainWindowAction = new KAction(KIcon("view-list-icons"), i18nc("@action Finish editing, close editor, back to main window", "Close Editor"), this); connect(d->toMainWindowAction, SIGNAL(triggered()), this, SLOT(slotToMainWindow())); actionCollection()->addAction("imageview_tomainwindow", d->toMainWindowAction); // -- Special Delete actions --------------------------------------------------------------- // Pop up dialog to ask user whether to permanently delete d->fileDeletePermanentlyAction = new KAction(KIcon("edit-delete"), i18n("Delete File Permanently"), this); d->fileDeletePermanentlyAction->setShortcut(KShortcut(Qt::SHIFT+Qt::Key_Delete)); connect(d->fileDeletePermanentlyAction, SIGNAL(triggered()), this, SLOT(slotDeleteCurrentItemPermanently())); actionCollection()->addAction("image_delete_permanently", d->fileDeletePermanentlyAction); // These two actions are hidden, no menu entry, no toolbar entry, no shortcut. // Power users may add them. d->fileDeletePermanentlyDirectlyAction = new KAction(KIcon("edit-delete"), i18n("Delete Permanently without Confirmation"), this); connect(d->fileDeletePermanentlyDirectlyAction, SIGNAL(triggered()), this, SLOT(slotDeleteCurrentItemPermanentlyDirectly())); actionCollection()->addAction("image_delete_permanently_directly", d->fileDeletePermanentlyDirectlyAction); d->fileTrashDirectlyAction = new KAction(KIcon("user-trash"), i18n("Move to Trash without Confirmation"), this); connect(d->fileTrashDirectlyAction, SIGNAL(triggered()), this, SLOT(slotTrashCurrentItemDirectly())); actionCollection()->addAction("image_trash_directly", d->fileTrashDirectlyAction); // --------------------------------------------------------------------------------- d->dbStatAction = new KAction(KIcon("network-server-database"), i18n("Database Statistics"), this); connect(d->dbStatAction, SIGNAL(triggered()), this, SLOT(slotDBStat())); actionCollection()->addAction("editorwindow_dbstat", d->dbStatAction); // --------------------------------------------------------------------------------- createGUI(xmlFile()); }
TypeDescription::TypeDescription(QString type, QWidget *parent) : QWidget(parent), type(type) { QFile xmlFile(":/MBTI.xml"); if (!xmlFile.open(QIODevice::ReadOnly)) { QMessageBox::critical(this, tr("Impossible d'ouvrir le fichier XML"), tr("Impossible d'ouvrir le fichier XML MBTI.xml")); return; } QDomDocument xml; if (!xml.setContent(&xmlFile)) { xmlFile.close(); QMessageBox::critical(this, tr("Fichier XML invalide"), tr("Le fichier MBTI.xml n'est pas un fichier XML valide")); return; } xmlFile.close(); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->setSpacing(0); mainLayout->setMargin(5); setLayout(mainLayout); //we can't use directly QDomNode description = new QDomNode(xml.elementById(type.toLower())) because elementById return always null //Because that don't work currently : //"Since the QDomClasses do not know which attributes are element IDs, this function returns always a null element. //This may change in a future version." QDomNodeList *descriptions = new QDomNodeList(xml.elementsByTagName("description")); QDomNode description; for (int i = 0; i < descriptions->size(); i++) { QDomNode candidate = descriptions->at(i); if (candidate.attributes().namedItem("id").nodeValue() == type.toLower()) { description = candidate; break; } } if (description.isNull()) { QLabel *errorText = new QLabel(tr("Il n'y a pas de description disponible pour le type : <strong>%1</strong>").arg(type)); mainLayout->addWidget(errorText); return; } QPushButton *typeButton = new QPushButton(type); mainLayout->addWidget(typeButton); connect(typeButton, SIGNAL(clicked()), this, SLOT(openWikipedia())); QTextEdit *descriptionText = new QTextEdit; descriptionText->setReadOnly(true); descriptionText->setPlainText(description.firstChild().nodeValue()); mainLayout->addWidget(descriptionText); }
void COptionTreeWrapper::Init(const StdString &fileName) { StdString xmlFile( m_szBasePath ); xmlFile += fileName; if (!m_ControlSchema.ReadXML(xmlFile)) { std::string szText; szText = "Failed to load xml format file: "; szText += fileName; ::MessageBox(NULL, szText.c_str(), "Warning!", MB_OK|MB_ICONEXCLAMATION); } }
void QtSEnaMainWindow::salva() { QFile xmlFile(_salvaFile->selectedFiles().at(0)); if(xmlFile.open(QIODevice::WriteOnly)) { QXmlStreamWriter xmlStream(&xmlFile); xmlStream.setAutoFormatting(true); xmlStream.writeStartDocument(); xmlStream.writeStartElement("Sistema"); QString sElementi = ""; for(quint8 i = 0; i < _grigliaNumeri->listaElementi().count(); i++) { sElementi.append(QString("%1,").arg(_grigliaNumeri->listaElementi().at(i))); } sElementi.chop(1); xmlStream.writeTextElement("Elementi", sElementi); xmlStream.writeStartElement("Condizionamento"); xmlStream.writeStartElement("Somma"); xmlStream.writeAttribute("max", QString("%1").arg(ui->maxSum->value())); xmlStream.writeAttribute("min", QString("%1").arg(ui->minSum->value())); xmlStream.writeEndElement(); // Somma QString sConsecutivi = ""; for (quint8 i = 0; i <= _NUMERO_ELEMENTI_COLONNA; i++) { if(_consecutivi.at(i)->isChecked()) sConsecutivi += QString("%1,").arg(i); } sConsecutivi.chop(1); xmlStream.writeTextElement("Consecutivi", sConsecutivi); QString sGemelli = ""; for (quint8 i = 0; i <= _NUMERO_ELEMENTI_COLONNA; i++) { if(_gemelli.at(i)->isChecked()) sGemelli += QString("%1,").arg(i); } sGemelli.chop(1); xmlStream.writeTextElement("Gemelli", sGemelli); QString sPari = ""; for (quint8 i = 0; i <= _NUMERO_ELEMENTI_COLONNA; i++) { if(_pari.at(i)->isChecked()) sPari += QString("%1,").arg(i); } sPari.chop(1); xmlStream.writeTextElement("Pari", sPari); xmlStream.writeEndElement(); // Condizionamento xmlStream.writeEndElement(); // Sistema xmlStream.writeEndDocument(); xmlFile.close(); #ifdef _DEBUG_FLAG_ENABLED } else { qWarning() << "[QTSENAMAINWINDOW] - on_actionSave_triggered() - Impossibile scrivere sul file " << _nomeFile; #endif //_DEBUG_FLAG_ENABLED } }
void ConfigFile::parseDescriptionFiles() { bool okay = false; while (!okay) { delete generator_; generator_ = new Miro::CFG::Generator; delete handler_; handler_ = new Miro::CFG::Parser(*generator_); QStringList::Iterator first, last = descriptionFiles_.end(); for (first = descriptionFiles_.begin(); first != last ; ++first) { // kill previous namespace nesting generator_->clearNamespace(); QString fileName = *first; QFile xmlFile( fileName ); if (!xmlFile.exists()) { QString infoText("Error parsing behaviour description file: \n" + fileName + "\n" + "File not found."); QMessageBox::information(0, "Policy Editor", infoText); descriptionFiles_.remove(first); break; } QXmlInputSource source( xmlFile ); QXmlSimpleReader reader; Miro::CFG::TextErrorHandler errorHandler; reader.setContentHandler( handler_ ); reader.setErrorHandler( &errorHandler); if (!reader.parse( source )) { QString infoText("Error parsing behaviour description file:\n" + fileName + "\n" + errorHandler.errorString()); QMessageBox::information(0, "Policy Editor", infoText); descriptionFiles_.remove(first); break; } } // parsing successfull okay = true; // cout << "parsing complete. known types: " << endl; // cout << *generator_ << endl; } }
void DiskCache::loadLocallyOrRemotely(QString localFileName, QUrl remoteUrl, std::function<void(QString)> load, int numberOfDaysBeforeDownloadingAgain) { QFile xmlFile(localFileName); if(!xmlFile.exists() || (numberOfDaysBeforeDownloadingAgain!=-1 && QFileInfo(xmlFile).lastModified().daysTo(QDateTime::currentDateTime())>=numberOfDaysBeforeDownloadingAgain)) { xmlFile.close(); QNetworkReply* reply=mNetworkAccessManager->get(QNetworkRequest(remoteUrl)); connect(reply, &QNetworkReply::finished,[localFileName,load,reply](){ QString xmlContent=reply->readAll(); QFile xmlFile(localFileName); xmlFile.open(QIODevice::WriteOnly|QIODevice::Text); QTextStream out(&xmlFile); out <<xmlContent; xmlFile.close(); load(xmlContent); }); } else { xmlFile.open(QIODevice::ReadOnly|QIODevice::Text); load(xmlFile.readAll()); xmlFile.close(); } }
int main(int argc, char *argv[]) { Q_INIT_RESOURCE(RobotTreeModel); QFile xmlFile(":/defaultRobot.xml"); RobotIO robotBuilder(&xmlFile); robotBuilder.build(); LOG_DEBUG("Robot build finished!"); QApplication app(argc, argv); MainWindow window(robotBuilder.getRobotPointer()); #if defined(Q_OS_SYMBIAN) window.showMaximized(); #else window.show(); #endif return app.exec(); }
void parseTagFile(Entry *root,const char *fullName,const char *tagName) { QFileInfo fi(fullName); if (!fi.exists()) return; TagFileParser handler( tagName ); handler.setFileName(fullName); TagFileErrorHandler errorHandler; QFile xmlFile( fullName ); QXmlInputSource source( xmlFile ); QXmlSimpleReader reader; reader.setContentHandler( &handler ); reader.setErrorHandler( &errorHandler ); reader.parse( source ); handler.buildLists(root); handler.addIncludes(); }
TipsOfTheDay::TipsOfTheDay(QString xmlPath, QObject *parent) : QAbstractListModel(parent) { tipList = new QList<TipOfTheDay>; QFile xmlFile(xmlPath); QTextStream errorStream(stderr); if (!QFile::exists(xmlPath)) { errorStream << tr("File does not exist.\n"); return; } else if (!xmlFile.open(QIODevice::ReadOnly)) { errorStream << tr("Failed to open file.\n"); return; } QXmlStreamReader reader(&xmlFile); while (!reader.atEnd()) { if (reader.readNext() == QXmlStreamReader::EndElement) { break; } if (reader.name() == "tip") { QString title, content, imagePath; QDate date; reader.readNext(); while (!reader.atEnd()) { if (reader.readNext() == QXmlStreamReader::EndElement) { break; } if (reader.name() == "title") { title = reader.readElementText(); } else if (reader.name() == "text") { content = reader.readElementText(); } else if (reader.name() == "image") { imagePath = "theme:tips/images/" + reader.readElementText(); } else if (reader.name() == "date") { date = QDate::fromString(reader.readElementText(), Qt::ISODate); } else { // unkown element, do nothing } } tipList->append(TipOfTheDay(title, content, imagePath, date)); } } }
Score::FileError importMusicXml(Score* score, const QString& name) { qDebug("importMusicXml(%p, %s)", score, qPrintable(name)); // open the MusicXML file QFile xmlFile(name); if (!xmlFile.exists()) return Score::FileError::FILE_NOT_FOUND; if (!xmlFile.open(QIODevice::ReadOnly)) { qDebug("importMusicXml() could not open MusicXML file '%s'", qPrintable(name)); MScore::lastError = QObject::tr("Could not open MusicXML file\n%1").arg(name); return Score::FileError::FILE_OPEN_ERROR; } // and import it return doValidateAndImport(score, name, &xmlFile); }