X-Git-Url: https://git.sven.stormbind.net/?a=blobdiff_plain;f=src%2Fexport-orgmode.cpp;fp=src%2Fexport-orgmode.cpp;h=0334a973f138309c61e4bb49f4a0b77867fab8b7;hb=d483bd8e6523c23c6f1d8908a2e0611c2bc9ff4f;hp=0000000000000000000000000000000000000000;hpb=7dfa3fe589d1722d49681f42cdb0bf1e6efb5223;p=sven%2Fvym.git diff --git a/src/export-orgmode.cpp b/src/export-orgmode.cpp new file mode 100644 index 0000000..0334a97 --- /dev/null +++ b/src/export-orgmode.cpp @@ -0,0 +1,55 @@ +#include "export-orgmode.h" + +#include "mainwindow.h" +#include + +extern Main *mainWindow; + +ExportOrgMode::ExportOrgMode() +{ + exportName = "OrgMode"; + filter = "org-mode (*.org);;All (* *.*)"; +} + +void ExportOrgMode::doExport() +{ + // Exports a map to an org-mode file. + // This file needs to be read + // by EMACS into an org mode buffer + QFile file(filePath); + if (!file.open(QIODevice::WriteOnly)) { + QMessageBox::critical( + 0, QObject::tr("Critical Export Error"), + QObject::tr("Could not export as OrgMode to %1").arg(filePath)); + mainWindow->statusMessage(QString(QObject::tr("Export failed."))); + return; + } + QTextStream ts(&file); + ts.setCodec("UTF-8"); + + // Main loop over all branches + QString s; + int i; + BranchItem *cur = NULL; + BranchItem *prev = NULL; + model->nextBranch(cur, prev); + while (cur) { + if (!cur->hasHiddenExportParent()) { + for (i = 0; i <= cur->depth(); i++) + ts << ("*"); + ts << (" " + cur->getHeadingPlain() + "\n"); + // If necessary, write note + if (!cur->isNoteEmpty()) { + ts << (cur->getNoteASCII(0, 80)); + ts << ("\n"); + } + } + model->nextBranch(cur, prev); + } + file.close(); + + result = ExportBase::Success; + + displayedDestination = filePath; + completeExport(); +}