2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Commercial Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** If you are unsure which license is appropriate for your use, please
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 15:08:31 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "cpasterplugin.h"
|
|
|
|
|
|
|
|
|
|
#include "splitter.h"
|
2009-07-13 08:32:46 +02:00
|
|
|
#include "pasteview.h"
|
|
|
|
|
#include "codepasterprotocol.h"
|
|
|
|
|
#include "pastebindotcomprotocol.h"
|
2009-07-31 12:13:37 +02:00
|
|
|
#include "pastebindotcaprotocol.h"
|
2010-04-23 15:06:53 +02:00
|
|
|
#include "fileshareprotocol.h"
|
2010-03-26 12:47:06 +01:00
|
|
|
#include "pasteselectdialog.h"
|
2010-03-24 10:43:01 +01:00
|
|
|
#include "settingspage.h"
|
2010-03-26 12:47:06 +01:00
|
|
|
#include "settings.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-20 11:52:04 +01:00
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
2010-03-18 10:59:06 +01:00
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
|
|
|
|
#include <coreplugin/actionmanager/command.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <coreplugin/coreconstants.h>
|
2009-01-20 11:52:04 +01:00
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
2010-03-25 16:23:37 +01:00
|
|
|
#include <coreplugin/mimedatabase.h>
|
2009-01-20 11:52:04 +01:00
|
|
|
#include <coreplugin/icore.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <coreplugin/messagemanager.h>
|
2010-03-25 16:23:37 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2010-03-29 14:54:25 +02:00
|
|
|
#include <texteditor/basetexteditor.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-19 12:39:20 +01:00
|
|
|
#include <QtCore/QtPlugin>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtCore/QDebug>
|
2010-03-25 16:23:37 +01:00
|
|
|
#include <QtCore/QDir>
|
|
|
|
|
#include <QtCore/QFileInfo>
|
|
|
|
|
#include <QtCore/QTemporaryFile>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtGui/QAction>
|
|
|
|
|
#include <QtGui/QApplication>
|
|
|
|
|
#include <QtGui/QClipboard>
|
|
|
|
|
#include <QtGui/QMenu>
|
|
|
|
|
#include <QtGui/QMainWindow>
|
|
|
|
|
|
|
|
|
|
using namespace CodePaster;
|
|
|
|
|
using namespace Core;
|
|
|
|
|
using namespace TextEditor;
|
|
|
|
|
|
2010-03-30 12:05:24 +02:00
|
|
|
CodepasterPlugin::CodepasterPlugin() :
|
|
|
|
|
m_settings(new Settings),
|
|
|
|
|
m_postEditorAction(0), m_postClipboardAction(0), m_fetchAction(0)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CodepasterPlugin::~CodepasterPlugin()
|
|
|
|
|
{
|
2009-11-04 17:11:35 +01:00
|
|
|
qDeleteAll(m_protocols);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CodepasterPlugin::initialize(const QStringList &arguments, QString *error_message)
|
|
|
|
|
{
|
2009-07-13 17:35:17 +02:00
|
|
|
Q_UNUSED(arguments)
|
|
|
|
|
Q_UNUSED(error_message)
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// Create the globalcontext list to register actions accordingly
|
2010-06-25 17:37:59 +02:00
|
|
|
Core::Context globalcontext(Core::Constants::C_GLOBAL);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// Create the settings Page
|
2010-03-26 12:47:06 +01:00
|
|
|
m_settings->fromSettings(Core::ICore::instance()->settings());
|
|
|
|
|
SettingsPage *settingsPage = new SettingsPage(m_settings);
|
|
|
|
|
addAutoReleasedObject(settingsPage);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-07-13 08:32:46 +02:00
|
|
|
// Create the protocols and append them to the Settings
|
2010-03-30 12:05:24 +02:00
|
|
|
const QSharedPointer<NetworkAccessManagerProxy> networkAccessMgrProxy(new NetworkAccessManagerProxy);
|
2010-04-06 14:40:33 +02:00
|
|
|
Protocol *protos[] = { new PasteBinDotComProtocol(networkAccessMgrProxy),
|
2010-03-30 12:05:24 +02:00
|
|
|
new PasteBinDotCaProtocol(networkAccessMgrProxy),
|
2010-04-23 15:06:53 +02:00
|
|
|
new CodePasterProtocol(networkAccessMgrProxy),
|
|
|
|
|
new FileShareProtocol
|
2010-04-06 14:40:33 +02:00
|
|
|
};
|
|
|
|
|
const int count = sizeof(protos) / sizeof(Protocol *);
|
|
|
|
|
for(int i = 0; i < count; ++i) {
|
2009-07-13 08:32:46 +02:00
|
|
|
connect(protos[i], SIGNAL(pasteDone(QString)), this, SLOT(finishPost(QString)));
|
2009-07-31 11:17:57 +02:00
|
|
|
connect(protos[i], SIGNAL(fetchDone(QString,QString,bool)),
|
|
|
|
|
this, SLOT(finishFetch(QString,QString,bool)));
|
2010-03-26 12:47:06 +01:00
|
|
|
settingsPage->addProtocol(protos[i]->name());
|
2009-07-13 08:32:46 +02:00
|
|
|
if (protos[i]->hasSettings())
|
2009-07-31 17:11:42 +02:00
|
|
|
addAutoReleasedObject(protos[i]->settingsPage());
|
2009-07-13 08:32:46 +02:00
|
|
|
m_protocols.append(protos[i]);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
//register actions
|
2009-01-20 11:52:04 +01:00
|
|
|
Core::ActionManager *actionManager = ICore::instance()->actionManager();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-14 12:39:59 +01:00
|
|
|
Core::ActionContainer *toolsContainer =
|
2008-12-02 12:01:29 +01:00
|
|
|
actionManager->actionContainer(Core::Constants::M_TOOLS);
|
|
|
|
|
|
2009-01-14 12:39:59 +01:00
|
|
|
Core::ActionContainer *cpContainer =
|
2008-12-02 12:01:29 +01:00
|
|
|
actionManager->createMenu(QLatin1String("CodePaster"));
|
2009-10-15 16:25:28 +02:00
|
|
|
cpContainer->menu()->setTitle(tr("&Code Pasting"));
|
2008-12-02 12:01:29 +01:00
|
|
|
toolsContainer->addMenu(cpContainer);
|
|
|
|
|
|
2009-01-14 13:17:53 +01:00
|
|
|
Core::Command *command;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-30 12:05:24 +02:00
|
|
|
m_postEditorAction = new QAction(tr("Paste Snippet..."), this);
|
|
|
|
|
command = actionManager->registerAction(m_postEditorAction, "CodePaster.Post", globalcontext);
|
2008-12-02 12:01:29 +01:00
|
|
|
command->setDefaultKeySequence(QKeySequence(tr("Alt+C,Alt+P")));
|
2010-03-30 12:05:24 +02:00
|
|
|
connect(m_postEditorAction, SIGNAL(triggered()), this, SLOT(postEditor()));
|
|
|
|
|
cpContainer->addAction(command);
|
|
|
|
|
|
|
|
|
|
m_postClipboardAction = new QAction(tr("Paste Clipboard..."), this);
|
|
|
|
|
command = actionManager->registerAction(m_postClipboardAction, "CodePaster.PostClipboard", globalcontext);
|
|
|
|
|
connect(m_postClipboardAction, SIGNAL(triggered()), this, SLOT(postClipboard()));
|
2008-12-02 12:01:29 +01:00
|
|
|
cpContainer->addAction(command);
|
|
|
|
|
|
2009-02-20 17:22:16 +01:00
|
|
|
m_fetchAction = new QAction(tr("Fetch Snippet..."), this);
|
|
|
|
|
command = actionManager->registerAction(m_fetchAction, "CodePaster.Fetch", globalcontext);
|
2008-12-02 12:01:29 +01:00
|
|
|
command->setDefaultKeySequence(QKeySequence(tr("Alt+C,Alt+F")));
|
|
|
|
|
connect(m_fetchAction, SIGNAL(triggered()), this, SLOT(fetch()));
|
|
|
|
|
cpContainer->addAction(command);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CodepasterPlugin::extensionsInitialized()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-28 16:59:03 +02:00
|
|
|
void CodepasterPlugin::aboutToShutdown()
|
2010-03-25 16:23:37 +01:00
|
|
|
{
|
|
|
|
|
// Delete temporary, fetched files
|
|
|
|
|
foreach(const QString &fetchedSnippet, m_fetchedSnippets) {
|
|
|
|
|
QFile file(fetchedSnippet);
|
|
|
|
|
if (file.exists())
|
|
|
|
|
file.remove();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-30 12:05:24 +02:00
|
|
|
void CodepasterPlugin::postEditor()
|
|
|
|
|
{
|
|
|
|
|
const IEditor* editor = EditorManager::instance()->currentEditor();
|
|
|
|
|
const BaseTextEditorEditable *textEditor = qobject_cast<const BaseTextEditorEditable *>(editor);
|
|
|
|
|
if (!textEditor)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QString data = textEditor->selectedText();
|
|
|
|
|
if (data.isEmpty())
|
|
|
|
|
data = textEditor->contents();
|
|
|
|
|
if (!data.isEmpty())
|
|
|
|
|
post(data, textEditor->editor()->mimeType());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CodepasterPlugin::postClipboard()
|
|
|
|
|
{
|
|
|
|
|
QString subtype = QLatin1String("plain");
|
|
|
|
|
const QString text = qApp->clipboard()->text(subtype, QClipboard::Clipboard);
|
|
|
|
|
if (!text.isEmpty())
|
|
|
|
|
post(text, QString());
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-29 14:54:25 +02:00
|
|
|
static inline void fixSpecialCharacters(QString &data)
|
|
|
|
|
{
|
|
|
|
|
QChar *uc = data.data();
|
|
|
|
|
QChar *e = uc + data.size();
|
|
|
|
|
|
|
|
|
|
for (; uc != e; ++uc) {
|
|
|
|
|
switch (uc->unicode()) {
|
|
|
|
|
case 0xfdd0: // QTextBeginningOfFrame
|
|
|
|
|
case 0xfdd1: // QTextEndOfFrame
|
|
|
|
|
case QChar::ParagraphSeparator:
|
|
|
|
|
case QChar::LineSeparator:
|
|
|
|
|
*uc = QLatin1Char('\n');
|
|
|
|
|
break;
|
|
|
|
|
case QChar::Nbsp:
|
|
|
|
|
*uc = QLatin1Char(' ');
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-30 12:05:24 +02:00
|
|
|
void CodepasterPlugin::post(QString data, const QString &mimeType)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-29 14:54:25 +02:00
|
|
|
fixSpecialCharacters(data);
|
2008-12-02 12:01:29 +01:00
|
|
|
FileDataList lst = splitDiffToFiles(data.toLatin1());
|
2010-03-26 12:47:06 +01:00
|
|
|
QString username = m_settings->username;
|
2008-12-02 12:01:29 +01:00
|
|
|
QString description;
|
|
|
|
|
QString comment;
|
2009-07-13 08:32:46 +02:00
|
|
|
QString protocolName;
|
|
|
|
|
|
2010-03-26 17:42:17 +01:00
|
|
|
PasteView view(m_protocols, 0);
|
|
|
|
|
view.setProtocol(m_settings->protocol);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
if (!view.show(username, description, comment, lst))
|
|
|
|
|
return; // User canceled post
|
|
|
|
|
|
2009-08-10 16:31:56 +02:00
|
|
|
username = view.user();
|
|
|
|
|
description = view.description();
|
|
|
|
|
comment = view.comment();
|
|
|
|
|
data = view.content();
|
|
|
|
|
protocolName = view.protocol();
|
2009-07-13 08:32:46 +02:00
|
|
|
foreach(Protocol *protocol, m_protocols) {
|
|
|
|
|
if (protocol->name() == protocolName) {
|
2010-03-30 12:05:24 +02:00
|
|
|
const Protocol::ContentType ct = Protocol::contentType(mimeType);
|
2010-04-23 15:06:53 +02:00
|
|
|
if (Protocol::ensureConfiguration(protocol))
|
|
|
|
|
protocol->paste(data, ct, username, comment, description);
|
2009-07-13 08:32:46 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CodepasterPlugin::fetch()
|
|
|
|
|
{
|
2010-03-26 12:47:06 +01:00
|
|
|
PasteSelectDialog dialog(m_protocols, ICore::instance()->mainWindow());
|
|
|
|
|
dialog.setProtocol(m_settings->protocol);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-26 12:47:06 +01:00
|
|
|
if (dialog.exec() != QDialog::Accepted)
|
2008-12-02 12:01:29 +01:00
|
|
|
return;
|
2010-03-26 12:47:06 +01:00
|
|
|
const QString pasteID = dialog.pasteId();
|
|
|
|
|
if (pasteID.isEmpty())
|
2008-12-02 12:01:29 +01:00
|
|
|
return;
|
2010-04-23 15:06:53 +02:00
|
|
|
Protocol *protocol = m_protocols[dialog.protocolIndex()];
|
|
|
|
|
if (Protocol::ensureConfiguration(protocol))
|
|
|
|
|
protocol->fetch(pasteID);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-07-13 08:32:46 +02:00
|
|
|
void CodepasterPlugin::finishPost(const QString &link)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-26 12:47:06 +01:00
|
|
|
if (m_settings->copyToClipboard)
|
2009-07-13 08:32:46 +02:00
|
|
|
QApplication::clipboard()->setText(link);
|
|
|
|
|
ICore::instance()->messageManager()->printToOutputPane(link,
|
2010-03-26 12:47:06 +01:00
|
|
|
m_settings->displayOutput);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-25 16:23:37 +01:00
|
|
|
// Extract the characters that can be used for a file name from a title
|
|
|
|
|
// "CodePaster.com-34" -> "CodePastercom34".
|
|
|
|
|
static inline QString filePrefixFromTitle(const QString &title)
|
|
|
|
|
{
|
|
|
|
|
QString rc;
|
|
|
|
|
const int titleSize = title.size();
|
|
|
|
|
rc.reserve(titleSize);
|
|
|
|
|
for (int i = 0; i < titleSize; i++)
|
|
|
|
|
if (title.at(i).isLetterOrNumber())
|
|
|
|
|
rc.append(title.at(i));
|
2010-03-26 10:37:36 +01:00
|
|
|
if (rc.isEmpty()) {
|
2010-03-25 16:23:37 +01:00
|
|
|
rc = QLatin1String("qtcreator");
|
2010-03-26 10:37:36 +01:00
|
|
|
} else {
|
|
|
|
|
if (rc.size() > 15)
|
|
|
|
|
rc.truncate(15);
|
|
|
|
|
}
|
2010-03-25 16:23:37 +01:00
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Return a temp file pattern with extension or not
|
|
|
|
|
static inline QString tempFilePattern(const QString &prefix,
|
|
|
|
|
const QString &extension = QString())
|
|
|
|
|
{
|
|
|
|
|
// Get directory
|
|
|
|
|
QString pattern = QDir::tempPath();
|
|
|
|
|
if (!pattern.endsWith(QDir::separator()))
|
|
|
|
|
pattern.append(QDir::separator());
|
|
|
|
|
// Prefix, placeholder, extension
|
|
|
|
|
pattern += prefix;
|
|
|
|
|
pattern += QLatin1String("_XXXXXX");
|
|
|
|
|
if (!extension.isEmpty()) {
|
|
|
|
|
pattern += QLatin1Char('.');
|
|
|
|
|
pattern += extension;
|
|
|
|
|
}
|
|
|
|
|
return pattern;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
typedef QSharedPointer<QTemporaryFile> TemporaryFilePtr;
|
|
|
|
|
|
|
|
|
|
// Write an a temporary file.
|
|
|
|
|
TemporaryFilePtr writeTemporaryFile(const QString &namePattern,
|
|
|
|
|
const QString &contents,
|
|
|
|
|
QString *errorMessage)
|
|
|
|
|
{
|
|
|
|
|
TemporaryFilePtr tempFile(new QTemporaryFile(namePattern));
|
|
|
|
|
if (!tempFile->open()) {
|
|
|
|
|
*errorMessage = QString::fromLatin1("Unable to open temporary file %1").arg(tempFile->errorString());
|
|
|
|
|
return TemporaryFilePtr();
|
|
|
|
|
}
|
|
|
|
|
tempFile->write(contents.toUtf8());
|
|
|
|
|
tempFile->close();
|
|
|
|
|
return tempFile;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-31 11:17:57 +02:00
|
|
|
void CodepasterPlugin::finishFetch(const QString &titleDescription,
|
|
|
|
|
const QString &content,
|
|
|
|
|
bool error)
|
|
|
|
|
{
|
2010-03-25 16:23:37 +01:00
|
|
|
Core::MessageManager *messageManager = ICore::instance()->messageManager();
|
|
|
|
|
// Failure?
|
2009-07-31 11:17:57 +02:00
|
|
|
if (error) {
|
2010-03-25 16:23:37 +01:00
|
|
|
messageManager->printToOutputPane(content, true);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2010-03-26 10:37:36 +01:00
|
|
|
if (content.isEmpty()) {
|
|
|
|
|
messageManager->printToOutputPane(tr("Empty snippet received for \"%1\".").arg(titleDescription), true);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2010-03-25 16:23:37 +01:00
|
|
|
// Write the file out and do a mime type detection on the content. Note
|
|
|
|
|
// that for the initial detection, there must not be a suffix
|
|
|
|
|
// as we want mime type detection to trigger on the content and not on
|
|
|
|
|
// higher-prioritized suffixes.
|
|
|
|
|
const QString filePrefix = filePrefixFromTitle(titleDescription);
|
|
|
|
|
QString errorMessage;
|
|
|
|
|
TemporaryFilePtr tempFile = writeTemporaryFile(tempFilePattern(filePrefix), content, &errorMessage);
|
|
|
|
|
if (tempFile.isNull()) {
|
|
|
|
|
messageManager->printToOutputPane(errorMessage);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// If the mime type has a preferred suffix (cpp/h/patch...), use that for
|
|
|
|
|
// the temporary file. This is to make it more convenient to "Save as"
|
|
|
|
|
// for the user and also to be able to tell a patch or diff in the VCS plugins
|
|
|
|
|
// by looking at the file name of FileManager::currentFile() without expensive checking.
|
2010-03-26 10:37:36 +01:00
|
|
|
// Default to "txt".
|
|
|
|
|
QString suffix;
|
|
|
|
|
if (const Core::MimeType mimeType = Core::ICore::instance()->mimeDatabase()->findByFile(QFileInfo(tempFile->fileName())))
|
|
|
|
|
suffix = mimeType.preferredSuffix();
|
|
|
|
|
if (suffix.isEmpty())
|
|
|
|
|
suffix = QLatin1String("txt");
|
|
|
|
|
// Write out with extension.
|
|
|
|
|
tempFile = writeTemporaryFile(tempFilePattern(filePrefix, suffix), content, &errorMessage);
|
|
|
|
|
if (tempFile.isNull()) {
|
|
|
|
|
messageManager->printToOutputPane(errorMessage);
|
|
|
|
|
return;
|
2009-07-31 11:17:57 +02:00
|
|
|
}
|
2010-03-25 16:23:37 +01:00
|
|
|
// Keep the file and store in list of files to be removed.
|
|
|
|
|
tempFile->setAutoRemove(false);
|
|
|
|
|
const QString fileName = tempFile->fileName();
|
|
|
|
|
m_fetchedSnippets.push_back(fileName);
|
|
|
|
|
// Open editor with title.
|
|
|
|
|
Core::IEditor* editor = EditorManager::instance()->openEditor(fileName);
|
|
|
|
|
QTC_ASSERT(editor, return)
|
|
|
|
|
editor->setDisplayName(titleDescription);
|
|
|
|
|
EditorManager::instance()->activateEditor(editor);
|
2009-07-31 11:17:57 +02:00
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
Q_EXPORT_PLUGIN(CodepasterPlugin)
|