22#include <QGraphicsSceneContextMenuEvent>
26#include <QGraphicsView>
32#include "private/style_p.h"
33#include "private/themedwidgetinterface_p.h"
40class TextEditPrivate :
public ThemedWidgetInterface<TextEdit>
43 TextEditPrivate(TextEdit *textEdit)
44 : ThemedWidgetInterface<TextEdit>(textEdit)
52 Plasma::Style::Ptr style;
57 d(new TextEditPrivate(this))
60 d->style = Plasma::Style::sharedStyle();
67 Plasma::Style::doneWithSharedStyle();
70void TextEdit::setText(
const QString &text)
75QString TextEdit::text()
const
77 return static_cast<KTextEdit*
>(widget())->toHtml();
80void TextEdit::setReadOnly(
bool readOnly)
85bool TextEdit::isReadOnly()
const
87 return static_cast<KTextEdit*
>(widget())->
isReadOnly();
90void TextEdit::setStyleSheet(
const QString &stylesheet)
92 widget()->setStyleSheet(stylesheet);
95QString TextEdit::styleSheet()
97 return widget()->styleSheet();
100void TextEdit::setNativeWidget(KTextEdit *nativeWidget)
103 widget()->deleteLater();
116 nativeWidget->verticalScrollBar()->setStyle(d->style.data());
117 nativeWidget->horizontalScrollBar()->setStyle(d->style.data());
120KTextEdit *TextEdit::nativeWidget()
const
122 return static_cast<KTextEdit*
>(widget());
125void TextEdit::append(
const QString &text)
137 foreach (
const QVariant &v, data) {
138 if (v.canConvert(QVariant::String)) {
139 te->append(v.toString() +
'\n');
144void TextEdit::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
147 popup->exec(event->screenPos());
151void TextEdit::resizeEvent(QGraphicsSceneResizeEvent *event)
153 QGraphicsProxyWidget::resizeEvent(event);
156void TextEdit::changeEvent(QEvent *event)
158 d->changeEvent(event);
159 QGraphicsProxyWidget::changeEvent(event);
162void TextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event)
167 while (!applet && widget) {
168 widget = widget->parentWidget();
169 applet = qobject_cast<Plasma::Applet *>(widget);
175 QGraphicsProxyWidget::mousePressEvent(event);
178void TextEdit::focusOutEvent(QFocusEvent *event)
183 while (!applet && widget) {
184 widget = widget->parentWidget();
185 applet = qobject_cast<Plasma::Applet *>(widget);
192 QEvent closeEvent(QEvent::CloseSoftwareInputPanel);
194 if (
QGraphicsView *view = qobject_cast<QGraphicsView*>(qApp->focusWidget())) {
195 if (view->scene() && view->scene() == scene()) {
196 QApplication::sendEvent(view, &closeEvent);
201 QGraphicsProxyWidget::focusOutEvent(event);
206#include <textedit.moc>
void setStatus(const ItemStatus stat)
sets the status for this applet
QHash< QString, QVariant > Data
void setReadOnly(bool readOnly)
Sets the text area to be read only or interactive.
void setText(const QString &text)
Sets the display text for this TextEdit.
void setNativeWidget(KTextEdit *nativeWidget)
Sets the text edit wrapped by this TextEdit (widget must inherit KTextEdit), ownership is transferred...
QGraphicsWidget * parentWidget
Namespace for everything in libplasma.
@ AcceptingInputStatus
The Item is accepting input.
@ UnknownStatus
The status is unknown.