void KEduVocDocumentValidatorTest::testDocumentAboutInfo() { KTemporaryFile temp; temp.setSuffix(".kvtml"); temp.open(); KUrl fileName = KUrl(temp.fileName()); temp.close(); const QString generator = QString::fromLatin1( "Validator Unit Tests" ); const QString author = QString::fromLatin1( "Validator Test" ); const QString license = QString::fromLatin1( "test license" ); const QString comment = QString::fromLatin1( "comment" ); const QString category = QString::fromLatin1( "test document" ); const QString title = QString::fromLatin1( "Validator Test Title" ); KEduVocDocument doc; doc.setAuthor( author ); doc.setLicense( license ); doc.setDocumentComment( comment ); doc.setCategory( category ); doc.setTitle( title ); doc.saveAs(fileName, KEduVocDocument::Kvtml, generator); KEduVocDocument docRead; docRead.open(fileName); QCOMPARE( docRead.generator(), generator ); QCOMPARE( docRead.author(), author ); QCOMPARE( docRead.license(), license ); QCOMPARE( docRead.documentComment(), comment ); QCOMPARE( docRead.category(), category ); QCOMPARE( docRead.title(), title ); }
void VocabEdit::slotSave() { KEduVocDocument *doc = new KEduVocDocument(this); doc->setTitle(txtVocabName->text()); doc->setDocumentComment(txtDescription->text()); KEduVocIdentifier id; doc->appendIdentifier(id); for (int i = 0; i < m_vocabList.size(); i++) { doc->lesson()->appendEntry(&m_vocabList[i]); } QString fileName = txtVocabName->text().toLower().remove(' ') + ".kvtml"; QString path = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/kvtml/" + KanagramSettings::dataLanguage(); QDir dir; dir.mkpath(path); QUrl url = QUrl::fromLocalFile(path + QLatin1Char('/') + fileName); qCDebug(KANAGRAM) << "Saving file as " << url; doc->saveAs(url, KEduVocDocument::Automatic); m_textChanged = false; }