From kde-commits Sun Nov 30 22:53:30 2003 From: Jason Kivlighn Date: Sun, 30 Nov 2003 22:53:30 +0000 To: kde-commits Subject: kdenonbeta/krecipes/src/exporters X-MARC-Message: https://marc.info/?l=kde-commits&m=107023286608937 CVS commit by jkivlighn: -Export authors -Fix doctype -Delete temporary photo created immediately M +15 -3 cookmlexporter.cpp 1.3 --- kdenonbeta/krecipes/src/exporters/cookmlexporter.cpp #1.2:1.3 @@ -36,5 +36,5 @@ QString CookMLExporter::createContent( c { QDomImplementation dom_imp; - QDomDocument doc = dom_imp.createDocument( QString::null, "cookml", dom_imp.createDocumentType( "cookml", "SYSTEM", "cookml.dtd") ); + QDomDocument doc = dom_imp.createDocument( QString::null, "cookml", dom_imp.createDocumentType( "cookml", QString::null, "cookml.dtd") ); QDomElement cookml_tag = doc.documentElement(); @@ -60,5 +60,5 @@ QString CookMLExporter::createContent( c head_tag.setAttribute("servingqty",recipe->persons); head_tag.setAttribute("servingtype",i18n("Persons")); - head_tag.setAttribute("rid",i18n("")); + head_tag.setAttribute("rid",i18n("")); //FIXME:what's this...recipe ID?? recipe_tag.appendChild( head_tag ); @@ -73,8 +73,19 @@ QString CookMLExporter::createContent( c } + QPtrListIterator author_it( recipe->authorList ); + Element *author; + while ( (author = author_it.current()) != 0 ) + { + ++author_it; + QDomElement sourceline_tag = doc.createElement("sourceline"); + sourceline_tag.appendChild( doc.createTextNode(author->name) ); + head_tag.appendChild(sourceline_tag); + } + QDomElement picbin_tag = doc.createElement( "picbin"); picbin_tag.setAttribute("format","JPG"); - KTempFile* fn = new KTempFile(locateLocal("tmp", "kre"), ".jpg", 0600); + KTempFile* fn = new KTempFile(locateLocal("tmp", "cml"), ".jpg", 0600); + fn->setAutoDelete(true); recipe->photo.save(fn->name(), "JPEG"); QByteArray data; @@ -83,4 +94,5 @@ QString CookMLExporter::createContent( c data = (fn->file())->readAll(); fn->close(); + delete fn; } picbin_tag.appendChild( doc.createTextNode( KCodecs::base64Encode(data, true) ) );