newnotedialog.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef NEWNOTEDIALOG_H
  2. #define NEWNOTEDIALOG_H
  3. #include "scrolldialog.h"
  4. namespace vnotex
  5. {
  6. class Notebook;
  7. class Node;
  8. class NodeInfoWidget;
  9. class NoteTemplateSelector;
  10. class NewNoteDialog : public ScrollDialog
  11. {
  12. Q_OBJECT
  13. public:
  14. // New a note under @p_node.
  15. NewNoteDialog(Node *p_node, QWidget *p_parent = nullptr);
  16. const QSharedPointer<Node> &getNewNode() const;
  17. static QSharedPointer<Node> newNote(Notebook *p_notebook,
  18. Node *p_parentNode,
  19. const QString &p_name,
  20. const QString &p_templateContent,
  21. QString &p_errMsg);
  22. protected:
  23. void acceptedButtonClicked() Q_DECL_OVERRIDE;
  24. private:
  25. void setupUI(const Node *p_node);
  26. void setupNodeInfoWidget(const Node *p_node, QWidget *p_parent);
  27. bool validateInputs();
  28. bool validateNameInput(QString &p_msg);
  29. void initDefaultValues(const Node *p_node);
  30. static QString evaluateTemplateContent(const QString &p_content, const QString &p_name);
  31. NodeInfoWidget *m_infoWidget = nullptr;
  32. NoteTemplateSelector *m_templateSelector = nullptr;
  33. QSharedPointer<Node> m_newNode;
  34. static QString s_lastTemplate;
  35. };
  36. } // ns vnotex
  37. #endif // NEWNOTEDIALOG_H