insilmaril@0: #include "exports.h" insilmaril@0: insilmaril@131: #include insilmaril@131: insilmaril@0: #include "linkablemapobj.h" insilmaril@131: #include "texteditor.h" insilmaril@0: insilmaril@0: insilmaril@0: Export::Export() insilmaril@0: { insilmaril@0: indentPerDepth=" "; insilmaril@0: } insilmaril@0: insilmaril@0: void Export::setPath (const QString &p) insilmaril@0: { insilmaril@0: filepath=p; insilmaril@0: } insilmaril@0: insilmaril@0: void Export::setMapCenter(MapCenterObj *mc) insilmaril@0: { insilmaril@0: mapCenter=mc; insilmaril@0: } insilmaril@0: insilmaril@0: void Export::exportMap() insilmaril@0: { insilmaril@0: QFile file (filepath); insilmaril@0: if ( !file.open( IO_WriteOnly ) ) insilmaril@0: { insilmaril@131: // FIXME experimental, testing insilmaril@0: cout << "Export::exportMap couldn't open "<first(); insilmaril@0: while (bo) insilmaril@0: { insilmaril@0: // Make indentstring insilmaril@0: for (i=0;igetDepth();i++) actIndent+= indentPerDepth; insilmaril@0: insilmaril@0: // Write heading insilmaril@0: // write (actIndent + getSectionString(bo) + bo->getHeading()+ "\n"); insilmaril@131: if (bo->getDepth()==0) insilmaril@131: { insilmaril@131: ts << (bo->getHeading()+ "\n"); insilmaril@131: for (i=0;igetHeading().length();i++) ts<<"="; insilmaril@131: ts << "\n"; insilmaril@131: } else if (bo->getDepth()==1) insilmaril@131: ts << ("\n"+getSectionString(bo) + bo->getHeading()+ "\n"); insilmaril@131: else if (bo->getDepth()==2) insilmaril@131: ts << (actIndent + " o " + bo->getHeading()+ "\n"); insilmaril@0: else insilmaril@0: ts << (actIndent + " - " + bo->getHeading()+ "\n"); insilmaril@0: insilmaril@0: // If necessary, write note insilmaril@0: if (!bo->getNote().isEmpty()) insilmaril@0: { insilmaril@131: s =textConvertToASCII(bo->getNote()); insilmaril@131: s=s.replace ("\n","\n"+actIndent); insilmaril@131: ts << (s+"\n\n"); insilmaril@0: } insilmaril@0: insilmaril@0: bo=bo->next(); insilmaril@0: actIndent=""; insilmaril@0: } insilmaril@0: file.close(); insilmaril@0: } insilmaril@0: insilmaril@0: QString Export::getSectionString(BranchObj *bostart) insilmaril@0: { insilmaril@0: QString r; insilmaril@0: BranchObj *bo=bostart; insilmaril@0: int depth=bo->getDepth(); insilmaril@0: while (depth>0) insilmaril@0: { insilmaril@0: r=QString("%1").arg(1+bo->getNum(),0,10)+"." + r; insilmaril@0: bo=(BranchObj*)(bo->getParObj()); insilmaril@0: depth=bo->getDepth(); insilmaril@0: } insilmaril@0: if (r.isEmpty()) insilmaril@0: return r; insilmaril@0: else insilmaril@0: return r + " "; insilmaril@0: } insilmaril@0: