forked from qt-creator/qt-creator
Refactor text retrieval of the code paster plugin.
Try to obtain text via ITextEditorDocument. Task-number: QTCREATORBUG-9669 Change-Id: Ie3816d84ea715691256f757fdd9a7b666fb6c27c Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -205,15 +205,17 @@ ExtensionSystem::IPlugin::ShutdownFlag CodepasterPlugin::aboutToShutdown()
|
|||||||
|
|
||||||
void CodepasterPlugin::postEditor()
|
void CodepasterPlugin::postEditor()
|
||||||
{
|
{
|
||||||
|
IEditor *editor = EditorManager::currentEditor();
|
||||||
|
if (!editor)
|
||||||
|
return;
|
||||||
|
const IDocument *document = editor->document();
|
||||||
|
const QString mimeType = document->mimeType();
|
||||||
QString data;
|
QString data;
|
||||||
QString mimeType;
|
if (const ITextEditor *textEditor = qobject_cast<const ITextEditor *>(editor))
|
||||||
if (IEditor *editor = EditorManager::currentEditor()) {
|
data = textEditor->selectedText();
|
||||||
if (ITextEditor *textEditor = qobject_cast<ITextEditor *>(editor)) {
|
if (data.isEmpty()) {
|
||||||
data = textEditor->selectedText();
|
if (const ITextEditorDocument *textDocument = qobject_cast<const ITextEditorDocument *>(document))
|
||||||
if (data.isEmpty())
|
data = textDocument->plainText();
|
||||||
data = textEditor->textDocument()->plainText();
|
|
||||||
mimeType = textEditor->document()->mimeType();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
post(data, mimeType);
|
post(data, mimeType);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user