35 } |
35 } |
36 |
36 |
37 EditorSnippet * EditorSnippet::instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element) |
37 EditorSnippet * EditorSnippet::instance(const QString& elementId, ChromeWidget * chrome, const QWebElement & element) |
38 { |
38 { |
39 EditorSnippet* that = new EditorSnippet(elementId, chrome, 0, element); |
39 EditorSnippet* that = new EditorSnippet(elementId, chrome, 0, element); |
40 that->setChromeWidget( new TextEditItem( that, chrome ) ); |
40 TextEditItem * textEditItem = new TextEditItem(that, chrome); |
|
41 that->setChromeWidget(textEditItem); |
|
42 connect(textEditItem, SIGNAL(contextEvent(bool)), that, SLOT(sendContextMenuEvent(bool))); |
|
43 |
|
44 #ifdef BROWSER_LAYOUT_TENONE |
|
45 QFont textFont; |
|
46 //textFont = QFont(QApplication::font()); |
|
47 textFont = QFont("Series 60 Sans"); |
|
48 //textFont.setPointSize(7); |
|
49 that->setTextFont(textFont); |
|
50 #endif |
|
51 |
41 return that; |
52 return that; |
42 } |
53 } |
43 |
54 |
44 void EditorSnippet::connectAll(){ |
55 void EditorSnippet::connectAll(){ |
45 if(m_widget){ |
56 if(m_widget){ |
46 GTextEditor * editor = static_cast<TextEditItem*>(m_widget)->editor(); |
57 GTextEditor * editor = static_cast<TextEditItem*>(m_widget)->editor(); |
47 connect(editor, SIGNAL(textMayChanged()), this, SIGNAL(textChanged())); |
58 connect(editor, SIGNAL(textMayChanged()), this, SIGNAL(textChanged())); |
48 connect(editor, SIGNAL(activated()), this, SIGNAL(activated())); |
59 connect(editor, SIGNAL(activated()), this, SIGNAL(activated())); |
49 connect(editor, SIGNAL(focusChanged(bool)), this, SLOT(onFocusChanged(bool))); |
60 connect(editor, SIGNAL(focusChanged(bool)), this, SLOT(onFocusChanged(bool))); |
50 connect(editor, SIGNAL(tapped(QPointF&)), this, SLOT(onTapped(QPointF&))); |
|
51 } |
61 } |
|
62 } |
|
63 |
|
64 TextEditItem * EditorSnippet::textEditItem() |
|
65 { |
|
66 return qobject_cast<TextEditItem*>(m_widget); |
|
67 } |
|
68 |
|
69 void EditorSnippet::sendContextMenuEvent(bool isContentSelected) |
|
70 { |
|
71 emit contextEvent(isContentSelected, elementId()); |
52 } |
72 } |
53 |
73 |
54 void EditorSnippet::onFocusChanged(bool in) |
74 void EditorSnippet::onFocusChanged(bool in) |
55 { |
75 { |
56 if(in) |
76 if(in) |
57 emit gainedFocus(); |
77 emit gainedFocus(); |
58 else |
78 else |
59 emit lostFocus(); |
79 emit lostFocus(); |
60 } |
80 } |
61 |
81 |
62 void EditorSnippet::onTapped(QPointF& /*pos*/){ |
82 #ifdef BROWSER_LAYOUT_TENONE |
63 emit gainedFocus(); |
83 void EditorSnippet::setTextFont( QFont & font ) |
|
84 { |
|
85 textEditItem()->setTextFont(font); |
64 } |
86 } |
|
87 #endif |
65 |
88 |
66 void EditorSnippet::setText( const QString & text ) |
89 void EditorSnippet::setText( const QString & text ) |
67 { |
90 { |
68 static_cast<TextEditItem*>(m_widget)->setText(text); |
91 textEditItem()->setText(text); |
69 } |
92 } |
70 |
93 |
71 QString EditorSnippet::text() |
94 QString EditorSnippet::text() |
72 { |
95 { |
73 return static_cast<TextEditItem*>(m_widget)->text(); |
96 return textEditItem()->text(); |
74 } |
97 } |
75 |
98 |
76 void EditorSnippet::setCursorPosition(int pos) |
99 void EditorSnippet::setCursorPosition(int pos) |
77 { |
100 { |
78 static_cast<TextEditItem*>(m_widget)->setCursorPosition(pos); |
101 textEditItem()->setCursorPosition(pos); |
79 } |
102 } |
80 |
103 |
81 int EditorSnippet::charCount(){ |
104 int EditorSnippet::charCount() |
82 return static_cast<TextEditItem*>(m_widget)->characterCount(); |
105 { |
|
106 return textEditItem()->characterCount(); |
83 } |
107 } |
84 |
108 |
85 void EditorSnippet::selectAll(){ |
109 void EditorSnippet::selectAll() |
86 return static_cast<TextEditItem*>(m_widget)->selectAll(); |
110 { |
|
111 return textEditItem()->selectAll(); |
87 } |
112 } |
88 |
113 |
89 void EditorSnippet::unselect(){ |
114 void EditorSnippet::unselect() |
90 return static_cast<TextEditItem*>(m_widget)->unselect(); |
115 { |
|
116 return textEditItem()->unselect(); |
91 } |
117 } |
92 |
118 |
93 int EditorSnippet::getTextOptions(){ |
119 int EditorSnippet::getTextOptions() |
94 return (int) static_cast<TextEditItem*>(m_widget)->getTextOptions(); |
120 { |
|
121 return (int) textEditItem()->getTextOptions(); |
95 } |
122 } |
96 |
123 |
97 void EditorSnippet::setTextOptions(int flag){ |
124 void EditorSnippet::setTextOptions(int flag) |
98 return static_cast<TextEditItem*>(m_widget)->setTextOptions(flag); |
125 { |
|
126 return textEditItem()->setTextOptions(flag); |
99 } |
127 } |
100 |
128 |
101 void EditorSnippet::setMaxTextLength(int length){ |
129 void EditorSnippet::setMaxTextLength(int length) |
102 return static_cast<TextEditItem*>(m_widget)->setMaxTextLength(length); |
130 { |
|
131 return textEditItem()->setMaxTextLength(length); |
|
132 } |
|
133 |
|
134 void EditorSnippet::cut() |
|
135 { |
|
136 textEditItem()->cut(); |
|
137 } |
|
138 |
|
139 void EditorSnippet::copy() |
|
140 { |
|
141 textEditItem()->copy(); |
|
142 } |
|
143 |
|
144 void EditorSnippet::paste() |
|
145 { |
|
146 textEditItem()->paste(); |
|
147 } |
|
148 |
|
149 void EditorSnippet::setContextMenuStatus(bool on) |
|
150 { |
|
151 textEditItem()->setContextMenuStatus(on); |
103 } |
152 } |
104 } |
153 } |