1 #include "mainwindow.h"
4 #include "export-csv.h"
6 extern QString vymName;
7 extern Main *mainWindow;
12 filter = "CSV (*.csv);;All (* *.*)";
13 caption = vymName + " -" + QObject::tr("Export as CSV");
16 void ExportCSV::doExport()
19 if (!file.open(QIODevice::WriteOnly)) {
20 QMessageBox::critical(
21 0, QObject::tr("Critical Export Error"),
22 QObject::tr("Could not export as CSV to %1").arg(filePath));
23 mainWindow->statusMessage(QString(QObject::tr("Export failed.")));
32 // Main loop over all branches
34 QString curIndent("");
36 BranchItem *cur = NULL;
37 BranchItem *prev = NULL;
38 model->nextBranch(cur, prev);
40 if (!cur->hasHiddenExportParent()) {
41 // If necessary, write note
42 if (!cur->isNoteEmpty()) {
43 s = cur->getNoteASCII(0, 0);
44 s = s.replace("\n", "\n" + curIndent);
45 out += ("\"" + s + "\",");
51 for (i = 0; i < cur->depth(); i++)
55 out += curIndent + "\"" + cur->getHeadingPlain() + "\"\n";
58 model->nextBranch(cur, prev);
61 QTextStream ts(&file);
66 QClipboard *clipboard = QGuiApplication::clipboard();
67 clipboard->setText(out);
69 displayedDestination = filePath;
71 result = ExportBase::Success;