/*! Copy text without images, but textual representations of the smileys. */ void InputTextWidget::copyPlainText() { QTextDocumentFragment selection = textCursor().selection(); if (!selection.isEmpty()) { QClipboard *clipboard = QApplication::clipboard(); clipboard->setText(Smileypack::desmilify(selection.toHtml())); } }
/*! Cut text without images, but textual representations of the smileys. */ void InputTextWidget::cutPlainText() { QTextDocumentFragment selection = textCursor().selection(); if(!selection.isEmpty()) { QClipboard *clipboard = QApplication::clipboard(); clipboard->setText(EmoticonMenu::desmile(selection.toHtml())); textCursor().removeSelectedText(); } }
void EditWidget::insertTextFragment(const QTextDocumentFragment &AFragment) { if (!AFragment.isEmpty()) { if (isRichTextEnabled()) ui.medEditor->textCursor().insertFragment(prepareTextFragment(AFragment)); else ui.medEditor->textCursor().insertText(prepareTextFragment(AFragment).toPlainText()); } }
static PyObject *meth_QTextDocumentFragment_isEmpty(PyObject *sipSelf, PyObject *sipArgs) { PyObject *sipParseErr = NULL; { QTextDocumentFragment *sipCpp; if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QTextDocumentFragment, &sipCpp)) { bool sipRes; Py_BEGIN_ALLOW_THREADS sipRes = sipCpp->isEmpty(); Py_END_ALLOW_THREADS return PyBool_FromLong(sipRes); } }
QTextDocumentFragment EditWidget::prepareTextFragment(const QTextDocumentFragment &AFragment) { QTextDocumentFragment fragment; if (!AFragment.isEmpty()) { QMimeData data; data.setHtml(AFragment.toHtml()); QTextDocument doc; QMap<int,IMessageEditContentsHandler *> handlers = FMessageWidgets->editContentsHandlers(); for (QMap<int,IMessageEditContentsHandler *>::const_iterator it = handlers.constBegin(); it!=handlers.constEnd(); ++it) if (it.value()->messageEditContentsInsert(it.key(),this,&data,&doc)) break; if (isRichTextEnabled()) fragment = QTextDocumentFragment::fromHtml(doc.toHtml()); else fragment = QTextDocumentFragment::fromPlainText(doc.toPlainText()); } return fragment; }