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()
|
||||
{
|
||||
IEditor *editor = EditorManager::currentEditor();
|
||||
if (!editor)
|
||||
return;
|
||||
const IDocument *document = editor->document();
|
||||
const QString mimeType = document->mimeType();
|
||||
QString data;
|
||||
QString mimeType;
|
||||
if (IEditor *editor = EditorManager::currentEditor()) {
|
||||
if (ITextEditor *textEditor = qobject_cast<ITextEditor *>(editor)) {
|
||||
if (const ITextEditor *textEditor = qobject_cast<const ITextEditor *>(editor))
|
||||
data = textEditor->selectedText();
|
||||
if (data.isEmpty())
|
||||
data = textEditor->textDocument()->plainText();
|
||||
mimeType = textEditor->document()->mimeType();
|
||||
}
|
||||
if (data.isEmpty()) {
|
||||
if (const ITextEditorDocument *textDocument = qobject_cast<const ITextEditorDocument *>(document))
|
||||
data = textDocument->plainText();
|
||||
}
|
||||
post(data, mimeType);
|
||||
}
|
||||
|
Reference in New Issue
Block a user