vnote.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #ifndef VNOTE_H
  2. #define VNOTE_H
  3. #include <QString>
  4. #include <QVector>
  5. #include <QList>
  6. #include <QSettings>
  7. #include <QFont>
  8. #include <QObject>
  9. #include <QPair>
  10. #include <QHash>
  11. #include <QPalette>
  12. #include "vnotebook.h"
  13. #include "vconstants.h"
  14. #include "utils/vmetawordmanager.h"
  15. class VOrphanFile;
  16. class VNoteFile;
  17. class VNote : public QObject
  18. {
  19. Q_OBJECT
  20. public:
  21. VNote(QObject *parent = 0);
  22. const QVector<VNotebook *> &getNotebooks() const;
  23. QVector<VNotebook *> &getNotebooks();
  24. void initTemplate();
  25. static QString s_sloganTemplate;
  26. static QString s_simpleHtmlTemplate;
  27. static QString s_markdownTemplate;
  28. // Hoedown
  29. static const QString c_hoedownJsFile;
  30. // Marked
  31. static const QString c_markedJsFile;
  32. static const QString c_markedExtraFile;
  33. // Markdown-it
  34. static const QString c_markdownitJsFile;
  35. static const QString c_markdownitExtraFile;
  36. static const QString c_markdownitAnchorExtraFile;
  37. static const QString c_markdownitTaskListExtraFile;
  38. static const QString c_markdownitSubExtraFile;
  39. static const QString c_markdownitSupExtraFile;
  40. static const QString c_markdownitFootnoteExtraFile;
  41. // Showdown
  42. static const QString c_showdownJsFile;
  43. static const QString c_showdownExtraFile;
  44. static const QString c_showdownAnchorExtraFile;
  45. // Mermaid
  46. static const QString c_mermaidApiJsFile;
  47. static const QString c_mermaidForestCssFile;
  48. // flowchart.js
  49. static const QString c_flowchartJsFile;
  50. static const QString c_raphaelJsFile;
  51. // PlantUML
  52. static const QString c_plantUMLJsFile;
  53. static const QString c_plantUMLZopfliJsFile;
  54. // Highlight.js line number plugin
  55. static const QString c_highlightjsLineNumberExtraFile;
  56. static const QString c_docFileFolder;
  57. static const QString c_shortcutsDocFile;
  58. static const QString c_markdownGuideDocFile;
  59. // Get the label style in Navigation mode.
  60. QString getNavigationLabelStyle(const QString &p_str) const;
  61. // Given the path of a file, first try to open it as note file,
  62. // then try to open it as orphan file.
  63. VFile *getFile(const QString &p_path);
  64. // Given the path of an external file, create a VOrphanFile struct.
  65. VOrphanFile *getOrphanFile(const QString &p_path,
  66. bool p_modifiable,
  67. bool p_systemFile = false);
  68. // Given the path of a file, try to find it in all notebooks.
  69. // Returns a VNoteFile struct if it is a note in one notebook.
  70. // Otherwise, returns NULL.
  71. VNoteFile *getInternalFile(const QString &p_path);
  72. // Given the path of a folder, try to find it in all notebooks.
  73. // Returns a VDirectory struct if it is a folder in one notebook.
  74. // Otherwise, returns NULL.
  75. VDirectory *getInternalDirectory(const QString &p_path);
  76. // Given the path of a file, try to find it in all notebooks.
  77. // Returns a VNotebook struct if it is the root folder of a notebook.
  78. VNotebook *getNotebook(const QString &p_path);
  79. void freeOrphanFiles();
  80. // @p_renderBg: background color, empty to not specify given color.
  81. static QString generateHtmlTemplate(const QString &p_renderBg,
  82. const QString &p_renderStyleUrl,
  83. const QString &p_codeBlockStyleUrl,
  84. bool p_isPDF);
  85. // @p_renderBg: background color, empty to not specify given color.
  86. static QString generateExportHtmlTemplate(const QString &p_renderBg);
  87. static QString generateMathJaxPreviewTemplate();
  88. public slots:
  89. void updateTemplate();
  90. void updateSimpletHtmlTemplate();
  91. private:
  92. const QString &getMonospacedFont() const;
  93. // Maintain all the notebooks. Other holder should use QPointer.
  94. QVector<VNotebook *> m_notebooks;
  95. VMetaWordManager m_metaWordMgr;
  96. // Hold all external file: Orphan File.
  97. // Need to clean up periodly.
  98. QList<VOrphanFile *> m_externalFiles;
  99. };
  100. #endif // VNOTE_H