QCodeEdit  2.2
qeditorinputbinding.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2006-2009 fullmetalcoder <fullmetalcoder@hotmail.fr>
4 **
5 ** This file is part of the Edyuk project <http://edyuk.org>
6 **
7 ** This file may be used under the terms of the GNU General Public License
8 ** version 3 as published by the Free Software Foundation and appearing in the
9 ** file GPL.txt included in the packaging of this file.
10 **
11 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13 **
14 ****************************************************************************/
15 
16 #ifndef _QEDITOR_INPUT_BINDING_H_
17 #define _QEDITOR_INPUT_BINDING_H_
18 
19 #include "qeditorinputbindinginterface.h"
20 
21 #include "qdocumentcursor.h"
22 
23 #include <QList>
24 #include <QVector>
25 #include <QString>
26 #include <QKeySequence>
27 
29 {
30  public:
31  class Command
32  {
33  public:
34  virtual ~Command() {}
35 
36  virtual void exec(QEditor *e) = 0;
37  };
38 
39  class MotionCommand : public Command
40  {
41  public:
42  MotionCommand(QDocumentCursor::MoveOperation op, QDocumentCursor::MoveMode m, int n = 1);
43 
44  virtual void exec(QEditor *e);
45 
46  private:
47  int count;
48  QDocumentCursor::MoveMode mode;
49  QDocumentCursor::MoveOperation operation;
50  };
51 
52  class EditCommand : public Command
53  {
54  public:
55  enum Operation
56  {
57  ClearSelection,
58  SelectWord,
59  SelectLine,
60  SelectDocument,
61 
62  DeleteChar,
63  DeletePreviousChar,
64  DeleteSelection,
65  DeleteLine,
66 
67  InsertLine,
68  InsertClipBoard,
69  };
70 
71  EditCommand(Operation op);
72 
73  virtual void exec(QEditor *e);
74 
75  private:
76  Operation operation;
77  };
78 
79  class WriteCommand : public Command
80  {
81  public:
82  WriteCommand(const QString& t);
83 
84  virtual void exec(QEditor *e);
85 
86  private:
87  QString text;
88  };
89 
90  class GroupCommand : public Command
91  {
92  public:
93  void addCommand(Command *c);
94 
95  virtual void exec(QEditor *e);
96 
97  private:
98  QList<Command*> commands;
99  };
100 
103 
104  void setMapping(const QKeySequence& ks, Command *cmd);
105 
106  virtual bool isExclusive() const;
107 
108  virtual bool keyPressEvent(QKeyEvent *event, QEditor *editor);
109  virtual void postKeyPressEvent(QKeyEvent *event, QEditor *editor);
110 
111  virtual bool inputMethodEvent(QInputMethodEvent* event, QEditor *editor);
112  virtual void postInputMethodEvent(QInputMethodEvent *event, QEditor *editor);
113 
114  virtual bool mouseMoveEvent(QMouseEvent *event, QEditor *editor);
115  virtual void postMouseMoveEvent(QMouseEvent *event, QEditor *editor);
116 
117  virtual bool mousePressEvent(QMouseEvent *event, QEditor *editor);
118  virtual void postMousePressEvent(QMouseEvent *event, QEditor *editor);
119 
120  virtual bool mouseReleaseEvent(QMouseEvent *event, QEditor *editor);
121  virtual void postMouseReleaseEvent(QMouseEvent *event, QEditor *editor);
122 
123  virtual bool mouseDoubleClickEvent(QMouseEvent *event, QEditor *editor);
124  virtual void postMouseDoubleClickEvent(QMouseEvent *event, QEditor *editor);
125 
126  virtual bool contextMenuEvent(QContextMenuEvent *event, QEditor *editor);
127 
128  private:
129  QVector<int> m_index;
130  QVector<Command*> m_actions;
131  QVector<QKeySequence> m_keys;
132 };
133 
134 #endif // _QEDITOR_INPUT_BINDING_H_
#define QCE_EXPORT
Macro needed for cross-platform shared libraries creation.
Definition: qce-config.h:40
A "managed" input binding interface.
Definition: qeditorinputbinding.h:28
A text editing widget.
Definition: qeditor.h:55
Definition: qeditorinputbinding.h:52
Definition: qeditorinputbinding.h:79
Definition of the QDocumentCursor class.
A class designed to allow extending user input in a transparent way.
Definition: qeditorinputbindinginterface.h:29
Definition: qeditorinputbinding.h:31
Definition: qeditorinputbinding.h:90
Definition: qeditorinputbinding.h:39