vnote.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. class VMainWindow;
  15. class VFile;
  16. class VNote : public QObject
  17. {
  18. Q_OBJECT
  19. public:
  20. VNote(QObject *parent = 0);
  21. const QVector<VNotebook *> &getNotebooks() const;
  22. QVector<VNotebook *> &getNotebooks();
  23. void initTemplate();
  24. static QString s_markdownTemplate;
  25. static QString s_markdownTemplatePDF;
  26. // Hoedown
  27. static const QString c_hoedownJsFile;
  28. // Marked
  29. static const QString c_markedJsFile;
  30. static const QString c_markedExtraFile;
  31. // Markdown-it
  32. static const QString c_markdownitJsFile;
  33. static const QString c_markdownitExtraFile;
  34. static const QString c_markdownitAnchorExtraFile;
  35. static const QString c_markdownitTaskListExtraFile;
  36. static const QString c_markdownitSubExtraFile;
  37. static const QString c_markdownitSupExtraFile;
  38. static const QString c_markdownitFootnoteExtraFile;
  39. // Showdown
  40. static const QString c_showdownJsFile;
  41. static const QString c_showdownExtraFile;
  42. static const QString c_showdownAnchorExtraFile;
  43. // Mermaid
  44. static const QString c_mermaidApiJsFile;
  45. static const QString c_mermaidCssFile;
  46. static const QString c_mermaidDarkCssFile;
  47. static const QString c_mermaidForestCssFile;
  48. // flowchart.js
  49. static const QString c_flowchartJsFile;
  50. static const QString c_raphaelJsFile;
  51. // Mathjax
  52. static const QString c_mathjaxJsFile;
  53. static const QString c_shortcutsDocFile_en;
  54. static const QString c_shortcutsDocFile_zh;
  55. static const QString c_markdownGuideDocFile_en;
  56. static const QString c_markdownGuideDocFile_zh;
  57. const QVector<QPair<QString, QString> > &getPalette() const;
  58. void initPalette(QPalette palette);
  59. QString getColorFromPalette(const QString &p_name) const;
  60. VMainWindow *getMainWindow() const;
  61. QString getNavigationLabelStyle(const QString &p_str) const;
  62. // Given the path of an external file, create a VFile struct.
  63. VFile *getOrphanFile(const QString &p_path, bool p_modifiable,
  64. bool p_systemFile = false);
  65. // Given the path of a file, try to find it in all notebooks.
  66. // Returns a VFile struct if it is a note in one notebook.
  67. // Otherwise, returns NULL.
  68. VFile *getInternalFile(const QString &p_path);
  69. public slots:
  70. void updateTemplate();
  71. private:
  72. const QString &getMonospacedFont() const;
  73. // Maintain all the notebooks. Other holder should use QPointer.
  74. QVector<VNotebook *> m_notebooks;
  75. QVector<QPair<QString, QString> > m_palette;
  76. VMainWindow *m_mainWindow;
  77. // Hold all external file: Orphan File.
  78. // Need to clean up periodly.
  79. QList<VFile *> m_externalFiles;
  80. };
  81. inline const QVector<QPair<QString, QString> >& VNote::getPalette() const
  82. {
  83. return m_palette;
  84. }
  85. inline VMainWindow *VNote::getMainWindow() const
  86. {
  87. return m_mainWindow;
  88. }
  89. #endif // VNOTE_H