4 #include "mainwindow.h"
6 extern QString vymName;
7 extern Main *mainWindow;
8 extern Settings settings;
13 filter = "TXT (*.txt);;All (* *.*)";
14 caption = vymName + " -" + QObject::tr("Export as AO report") + " " +
15 QObject::tr("(still experimental)");
18 for (int i = 0; i < 10; i++)
22 void ExportAO::doExport()
25 if (!file.open(QIODevice::WriteOnly)) {
26 QMessageBox::critical(
27 0, QObject::tr("Critical Export Error"),
28 QObject::tr("Could not export as AO to %1").arg(filePath));
29 mainWindow->statusMessage(QString(QObject::tr("Export failed.")));
33 settings.setLocalValue(model->getFilePath(), "/export/last/command",
35 settings.setLocalValue(model->getFilePath(), "/export/last/description",
40 // Main loop over all branches
46 BranchItem *cur = NULL;
47 BranchItem *prev = NULL;
49 model->nextBranch(cur, prev);
52 QString colString = "";
54 QString statusString = "";
57 if (cur->getType() == TreeItem::Branch ||
58 cur->getType() == TreeItem::MapCenter) {
60 curIndent = indent(cur->depth() - 4, true);
62 if (!cur->hasHiddenExportParent()) {
63 col = cur->getHeadingColor();
64 if (col == QColor(255, 0, 0))
66 else if (col == QColor(217, 81, 0))
68 else if (col == QColor(0, 85, 0))
70 else if (cur->depth() == 4)
75 noColString = QString(" ").repeated(colString.length());
78 switch (cur->depth()) {
80 break; // Mapcenter (Ignored)
82 break; // Mainbranch "Archive" (Ignored)
83 case 2: // Title: "Current week number..."
85 out += underline(cur->getHeadingPlain(), QString("="));
88 case 3: // Headings: "Achievement", "Bonus", "Objective", ...
90 out += underline(cur->getHeadingPlain(), "-");
93 default: // depth 4 and higher are the items we need to know
94 Task *task = cur->getTask();
96 // Task status overrides other flags
97 switch (task->getStatus()) {
98 case Task::NotStarted:
99 statusString = "[NOT STARTED]";
102 statusString = "[WIP]";
105 statusString = "[DONE]";
110 if (cur->hasActiveFlag("hook-green"))
111 statusString = "[DONE]";
112 else if (cur->hasActiveFlag("wip"))
113 statusString = "[WIP]";
114 else if (cur->hasActiveFlag("cross-red"))
115 statusString = "[NOT STARTED]";
120 if (cur->depth() > 3)
121 line += cur->getHeadingPlain();
123 // Pad line width before status
124 i = 80 - line.length() - statusString.length() - 1;
125 for (int j = 0; j < i; j++)
127 line += " " + statusString + "\n";
131 // If necessary, write URL
132 if (!cur->getURL().isEmpty())
133 out += noColString + indent(cur->depth() - 4, false) +
134 cur->getURL() + "\n";
136 // If necessary, write note
137 if (!cur->isNoteEmpty()) {
138 curIndent = noColString +
139 indent(cur->depth() - 4, false) + "| ";
140 s = cur->getNoteASCII(curIndent, 80);
147 model->nextBranch(cur, prev);
150 QTextStream ts(&file);
151 ts.setCodec("UTF-8");
155 QClipboard *clipboard = QGuiApplication::clipboard();
156 clipboard->setText(out);
158 displayedDestination = filePath;
160 result = ExportBase::Success;
165 QString ExportAO::underline(const QString &text, const QString &line)
167 QString r = text + "\n";
168 for (int j = 0; j < text.length(); j++)