vmdeditoperations.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef VMDEDITOPERATIONS_H
  2. #define VMDEDITOPERATIONS_H
  3. #include <QObject>
  4. #include <QString>
  5. #include <QUrl>
  6. #include <QImage>
  7. #include "veditoperations.h"
  8. class QTimer;
  9. // Editor operations for Markdown
  10. class VMdEditOperations : public VEditOperations
  11. {
  12. Q_OBJECT
  13. public:
  14. VMdEditOperations(VEdit *p_editor, VFile *p_file);
  15. bool insertImageFromMimeData(const QMimeData *source) Q_DECL_OVERRIDE;
  16. bool insertURLFromMimeData(const QMimeData *source) Q_DECL_OVERRIDE;
  17. bool insertImage() Q_DECL_OVERRIDE;
  18. bool handleKeyPressEvent(QKeyEvent *p_event) Q_DECL_OVERRIDE;
  19. private slots:
  20. void pendingTimerTimeout();
  21. private:
  22. bool insertImageFromURL(const QUrl &imageUrl);
  23. void insertImageFromPath(const QString &title, const QString &path, const QString &oriImagePath);
  24. void insertImageFromQImage(const QString &title, const QString &path, const QImage &image);
  25. void setKeyState(KeyState p_state);
  26. // Key press handlers.
  27. bool handleKeyTab(QKeyEvent *p_event);
  28. bool handleKeyBackTab(QKeyEvent *p_event);
  29. bool handleKeyB(QKeyEvent *p_event);
  30. bool handleKeyD(QKeyEvent *p_event);
  31. bool handleKeyH(QKeyEvent *p_event);
  32. bool handleKeyI(QKeyEvent *p_event);
  33. bool handleKeyO(QKeyEvent *p_event);
  34. bool handleKeyU(QKeyEvent *p_event);
  35. bool handleKeyW(QKeyEvent *p_event);
  36. bool handleKeyEsc(QKeyEvent *p_event);
  37. bool handleKeyPressVim(QKeyEvent *p_event);
  38. bool handleKeyBracketLeft(QKeyEvent *p_event);
  39. bool shouldTriggerVimMode(QKeyEvent *p_event);
  40. int keySeqToNumber(const QList<QString> &p_seq);
  41. bool suffixNumAllowed(const QList<QString> &p_seq);
  42. QTimer *m_pendingTimer;
  43. static const QString c_defaultImageTitle;
  44. };
  45. #endif // VMDEDITOPERATIONS_H