File indexing completed on 2024-04-21 05:48:17

0001 /**
0002  * SPDX-FileCopyrightText: (C) 2003 Sébastien Laoût <slaout@linux62.org>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef HTMLEXPORTER_H
0008 #define HTMLEXPORTER_H
0009 
0010 #include <QtCore/QString>
0011 #include <QtCore/QTextStream>
0012 
0013 class QProgressDialog;
0014 
0015 class BasketScene;
0016 class Note;
0017 
0018 /**
0019  * @author Sébastien Laoût <slaout@linux62.org>
0020  */
0021 class HTMLExporter
0022 {
0023 public:
0024     explicit HTMLExporter(BasketScene *basket);
0025     ~HTMLExporter();
0026 
0027 private:
0028     void prepareExport(BasketScene *basket, const QString &fullPath);
0029     void exportBasket(BasketScene *basket, bool isSubBasket);
0030     void exportNote(Note *note, int indent);
0031     void writeBasketTree(BasketScene *currentBasket);
0032     void writeBasketTree(BasketScene *currentBasket, BasketScene *basket, int indent);
0033     void saveToFile(const QString &fullPath, const QByteArray &array);
0034 
0035 public:
0036     QString copyIcon(const QString &iconName, int size);
0037     QString copyFile(const QString &srcPath, bool createIt);
0038 
0039 public: // TODO: make private?
0040     // Absolute path of the file name the user chosen:
0041     QString filePath; // eg.: "/home/seb/foo.html"
0042     QString fileName; // eg.: "foo.html"
0043 
0044     // Absolute & relative paths for the current basket to be exported:
0045     QString basketFilePath;    // eg.: "/home/seb/foo.html" or "/home/seb/foo.html_files/baskets/basketN.html"
0046     QString filesFolderPath;   // eg.: "/home/seb/foo.html_files/"
0047     QString filesFolderName;   // eg.: "foo.html_files/" or "../"
0048     QString iconsFolderPath;   // eg.: "/home/seb/foo.html_files/icons/"
0049     QString iconsFolderName;   // eg.: "foo.html_files/icons/" or "../icons/"
0050     QString imagesFolderPath;  // eg.: "/home/seb/foo.html_files/images/"
0051     QString imagesFolderName;  // eg.: "foo.html_files/images/" or "../images/"
0052     QString dataFolderPath;    // eg.: "/home/seb/foo.html_files/data/" or "/home/seb/foo.html_files/baskets/basketN-data/"
0053     QString dataFolderName;    // eg.: "foo.html_files/data/" or "basketN-data/"
0054     QString basketsFolderPath; // eg.: "/home/seb/foo.html_files/baskets/"
0055     QString basketsFolderName; // eg.: "foo.html_files/baskets/" or QString()
0056 
0057     // Various properties of the currently exporting basket:
0058     QString backgroundColorName;
0059 
0060     // Variables used by every export methods:
0061     QTextStream stream;
0062     BasketScene *exportedBasket;
0063     BasketScene *currentBasket;
0064     bool withBasketTree;
0065     QScopedPointer<QProgressDialog> dialog;
0066 };
0067 
0068 #endif // HTMLEXPORTER_H