diff -r 000000000000 -r 30cd58b70d02 exports.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/exports.cpp Tue Jul 19 15:57:49 2005 +0000 @@ -0,0 +1,132 @@ +#include "exports.h" + +#include "linkablemapobj.h" + + +Export::Export() +{ + indentPerDepth=" "; +} + +bool Export::setOutputDir(QString dirname) +{ + outdir.setPath (dirname); + if ( outdir.exists() ) + { + // FIXME + // ask for confirmation + // then delete outdir + return true; + } else + { + // try to create directory + //return outdir.mkdir (outdir.absPath()); + // FIXME + return true; + } +} + +void Export::setPath (const QString &p) +{ + filepath=p; +} + +void Export::setMapCenter(MapCenterObj *mc) +{ + mapCenter=mc; +} + +void Export::exportMap() +{ + QFile file (filepath); + if ( !file.open( IO_WriteOnly ) ) + { + // FIXME + cout << "Export::exportMap couldn't open "<first(); + while (bo) + { + // Make indentstring + for (i=0;igetDepth();i++) actIndent+= indentPerDepth; + + // Write heading + // write (actIndent + getSectionString(bo) + bo->getHeading()+ "\n"); + if (bo->getDepth()==1) + ts << (getSectionString(bo) + bo->getHeading()+ "\n"); + else + ts << (actIndent + " - " + bo->getHeading()+ "\n"); + + // If necessary, write note + if (!bo->getNote().isEmpty()) + { + ts << ("-------------------Begin of Note-----------------\n"); + ts << (bo->getNote()); + ts << ("\n"); + ts << ("-------------------End of Note-------------------\n"); + } + + bo=bo->next(); + actIndent=""; + } + file.close(); +} + +QString Export::getSectionString(BranchObj *bostart) +{ + QString r; + BranchObj *bo=bostart; + int depth=bo->getDepth(); + while (depth>0) + { + r=QString("%1").arg(1+bo->getNum(),0,10)+"." + r; + bo=(BranchObj*)(bo->getParObj()); + depth=bo->getDepth(); + } + if (r.isEmpty()) + return r; + else + return r + " "; +} + +void Export::exportAsHTML() +{ + // FIXME just testing... + // Main loop over all branches + QString s; + QString actIndent(""); + int i; + BranchObj *bo; + bo=mapCenter->first(); + while (bo) + { + // Make indentstring + for (i=0;igetDepth();i++) actIndent+= indentPerDepth; + + // Write heading + write (actIndent + getSectionString(bo) + bo->getHeading()+ "\n"); + + // If necessary, write note + if (!bo->getNote().isEmpty()) + { + write (bo->getNote()); + } + + bo=bo->next(); + actIndent=""; + } +} + +void Export::write(QString s) +{ + cout << s; +} +