50 void setMaxTextLength(int length); |
51 void setMaxTextLength(int length); |
51 void selectAll(); |
52 void selectAll(); |
52 void unselect(); |
53 void unselect(); |
53 qreal textWidth(); |
54 qreal textWidth(); |
54 void setCursorPosition(int pos); |
55 void setCursorPosition(int pos); |
|
56 bool event(QEvent* event); |
55 bool hasSelection() { return (cursorX()!= anchorX()); } |
57 bool hasSelection() { return (cursorX()!= anchorX()); } |
56 Qt::InputMethodHints inputMethodHints() const { return m_hints; } |
58 Qt::InputMethodHints inputMethodHints() const { return m_hints; } |
57 void setInputMethodHints(Qt::InputMethodHints hints); |
59 void setInputMethodHints(Qt::InputMethodHints hints); |
58 void setSpecificButton(QString& commitString, QString& buttonIconPath); |
60 void setSpecificButton(QString& commitString, QString& buttonIconPath); |
59 void launchVKB(); |
61 void launchVKB(); |
60 void sendInputPanelEvent(QEvent::Type type); |
62 void sendInputPanelEvent(QEvent::Type type); |
|
63 void cut(); |
|
64 void copy(); |
|
65 void paste(); |
|
66 void setContextMenuStatus(bool on) { m_isContextMenuOn = on; } |
|
67 bool contextMenuOn() { return m_isContextMenuOn; } |
|
68 bool eventFilter(QObject* o, QEvent* e); |
61 |
69 |
62 protected: |
70 protected: |
63 virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget); |
71 virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget); |
64 virtual void keyPressEvent(QKeyEvent * event); |
72 virtual void keyPressEvent(QKeyEvent * event); |
65 virtual void keyReleaseEvent(QKeyEvent * event); |
73 virtual void keyReleaseEvent(QKeyEvent * event); |
67 virtual void mousePressEvent(QGraphicsSceneMouseEvent * event); |
75 virtual void mousePressEvent(QGraphicsSceneMouseEvent * event); |
68 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent * event); |
76 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent * event); |
69 virtual void focusInEvent(QFocusEvent * event); |
77 virtual void focusInEvent(QFocusEvent * event); |
70 virtual void focusOutEvent(QFocusEvent * event); |
78 virtual void focusOutEvent(QFocusEvent * event); |
71 virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); |
79 virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); |
|
80 bool handleQStmGesture(QStm_Gesture* gesture); |
72 |
81 |
73 private slots: |
82 private slots: |
74 void contentsChange(int position, int charsRemoved, int charsAdded); |
83 void contentsChange(int position, int charsRemoved, int charsAdded); |
75 void specificBtnTriggered(bool checked); |
84 void specificBtnTriggered(bool checked); |
76 |
85 |
77 signals: |
86 signals: |
78 void cursorXChanged(qreal newx); |
87 void cursorXChanged(qreal newx); |
79 void textMayChanged(); |
88 void textMayChanged(); |
80 void focusChanged(bool focusIn); |
89 void focusChanged(bool focusIn); |
81 void tapped(QPointF& pos); |
90 void tapped(QPointF& pos); |
|
91 void contextEvent(bool isContentSelected); |
82 |
92 |
83 private: |
93 private: |
84 QTextLine m_textLine; |
94 QTextLine m_textLine; |
85 int m_defaultStartDragDistance; |
95 int m_defaultStartDragDistance; |
86 int m_maxTextLength; |
96 int m_maxTextLength; |
87 Qt::InputMethodHints m_hints; |
97 Qt::InputMethodHints m_hints; |
88 bool m_setSpecificBtn; |
98 bool m_setSpecificBtn; |
89 QString m_spBtnCommitString; |
99 QString m_spBtnCommitString; |
90 QString m_spBtnIconPath; |
100 QString m_spBtnIconPath; |
|
101 bool m_isContextMenuOn; // don't unselect text or change cursor position when context menu is showing |
91 }; |
102 }; |
92 |
103 |
93 class GLineEditor : public QGraphicsWidget |
104 class GLineEditor : public QGraphicsWidget |
94 { |
105 { |
95 Q_OBJECT |
106 Q_OBJECT |
117 bool hasSelection() { return m_editor->hasSelection(); } |
128 bool hasSelection() { return m_editor->hasSelection(); } |
118 Qt::InputMethodHints inputMethodHints() { return m_editor->inputMethodHints(); } |
129 Qt::InputMethodHints inputMethodHints() { return m_editor->inputMethodHints(); } |
119 // Calling this function will overwrite the existing hints |
130 // Calling this function will overwrite the existing hints |
120 void setInputMethodHints(Qt::InputMethodHints hints) { m_editor->setInputMethodHints(hints); } |
131 void setInputMethodHints(Qt::InputMethodHints hints) { m_editor->setInputMethodHints(hints); } |
121 void setMaxTextLength(int length) { m_editor->setMaxTextLength(length);} |
132 void setMaxTextLength(int length) { m_editor->setMaxTextLength(length);} |
|
133 void setContextMenuStatus(bool on) { m_editor->setContextMenuStatus(on); } |
|
134 void setFocusForEditor() { m_editor->setFocus(); } |
122 #ifdef BROWSER_LAYOUT_TENONE |
135 #ifdef BROWSER_LAYOUT_TENONE |
123 void changeEditorMode(bool edit); |
136 void changeEditorMode(bool edit); |
124 void setTitle(const QString & text); |
137 void setTitle(const QString & text); |
125 void setTitleColor(QColor & color); |
138 void setTitleColor(QColor & color); |
126 void setTitleFont(QFont & font); |
139 void setTitleFont(QFont & font); |
127 |
140 void setTextFont(QFont & font); |
128 #endif |
141 #endif |
129 void setSpecificButton(QString commitString, QString buttonIcon) { m_editor->setSpecificButton(commitString, buttonIcon);} |
142 void setSpecificButton(QString commitString, QString buttonIcon) { m_editor->setSpecificButton(commitString, buttonIcon);} |
130 void closeVKB(); |
143 void closeVKB(); |
131 void openVKB(); |
144 void openVKB(); |
|
145 void cut() { m_editor->cut();} |
|
146 void copy() { m_editor->copy(); } |
|
147 void paste() { m_editor->paste(); } |
132 |
148 |
133 protected: |
149 protected: |
134 virtual bool eventFilter(QObject * object, QEvent * event); |
150 virtual bool eventFilter(QObject * object, QEvent * event); |
135 virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget); |
151 virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget); |
136 virtual void resizeEvent(QGraphicsSceneResizeEvent * event); |
152 virtual void resizeEvent(QGraphicsSceneResizeEvent * event); |
140 void textMayChanged(); |
156 void textMayChanged(); |
141 void contentsChange(int position, int charsRemoved, int charsAdded); |
157 void contentsChange(int position, int charsRemoved, int charsAdded); |
142 void focusChanged(bool focusIn); |
158 void focusChanged(bool focusIn); |
143 void tapped(QPointF& pos); |
159 void tapped(QPointF& pos); |
144 void titleMouseEvent(QPointF& pos); |
160 void titleMouseEvent(QPointF& pos); |
|
161 void contextEvent(bool isContentSelected); |
145 |
162 |
146 private slots: |
163 private slots: |
147 void makeVisible(qreal cursorX); |
164 void makeVisible(qreal cursorX); |
148 |
165 |
149 public slots: |
166 public slots: |
224 TextEditItem(ChromeSnippet * snippet, ChromeWidget * chrome, QGraphicsItem * parent = 0); |
241 TextEditItem(ChromeSnippet * snippet, ChromeWidget * chrome, QGraphicsItem * parent = 0); |
225 virtual ~TextEditItem(); |
242 virtual ~TextEditItem(); |
226 GTextEditor * editor() { return m_textEditor; } |
243 GTextEditor * editor() { return m_textEditor; } |
227 QString text() { return m_textEditor->text(); } |
244 QString text() { return m_textEditor->text(); } |
228 void setText(const QString & text){ m_textEditor->setText(text); } |
245 void setText(const QString & text){ m_textEditor->setText(text); } |
|
246 #ifdef BROWSER_LAYOUT_TENONE |
|
247 void setTextFont(QFont & font){ m_textEditor->setTextFont(font); } |
|
248 #endif |
229 int characterCount() { return m_textEditor->characterCount(); } |
249 int characterCount() { return m_textEditor->characterCount(); } |
230 void setCursorPosition(int pos) { m_textEditor->setCursorPosition(pos); } |
250 void setCursorPosition(int pos) { m_textEditor->setCursorPosition(pos); } |
231 void selectAll() { m_textEditor->selectAll(); } |
251 void selectAll() { m_textEditor->selectAll(); } |
232 void unselect() { m_textEditor->unselect(); } |
252 void unselect() { m_textEditor->unselect(); } |
233 int getTextOptions() { return (int) m_textEditor->inputMethodHints(); } |
253 int getTextOptions() { return (int) m_textEditor->inputMethodHints(); } |
234 // Calling this function will overwrite the existing options |
254 // Calling this function will overwrite the existing options |
235 void setTextOptions (int flag); |
255 void setTextOptions (int flag); |
236 void setMaxTextLength(int length) { m_textEditor->setMaxTextLength(length); } |
256 void setMaxTextLength(int length) { m_textEditor->setMaxTextLength(length); } |
237 |
257 void cut() { m_textEditor->cut(); } |
|
258 void copy() { m_textEditor->copy(); } |
|
259 void paste() { m_textEditor->paste(); } |
|
260 void setContextMenuStatus(bool on) { m_textEditor->setContextMenuStatus(on); } |
|
261 |
|
262 Q_SIGNALS: |
|
263 void contextEvent(bool); |
|
264 |
238 private slots: |
265 private slots: |
239 void tapped(QPointF&); |
266 void tapped(QPointF&); |
240 void focusChanged(bool focusIn); |
267 void focusChanged(bool focusIn); |
241 |
268 |
242 protected: |
269 protected: |
243 virtual void resizeEvent(QGraphicsSceneResizeEvent * ev); |
270 virtual void resizeEvent(QGraphicsSceneResizeEvent * ev); |
244 private: |
271 private: |
245 GTextEditor * m_textEditor; |
272 GTextEditor * m_textEditor; |
246 bool m_justFocusIn; |
273 bool m_justFocusIn; |
247 }; |
274 }; |
248 |
275 |
249 } // namespace GVA |
276 } // namespace GVA |
250 |
277 |
251 #endif // __EDITOR_WIDGET_H__ |
278 #endif // __EDITOR_WIDGET_H__ |