move editor creation to plugin

each protocol needed to create the editor on their own.
Instead emit fetchDone and let the plugin instantiate it for
every protocol
This commit is contained in:
Maurice Kalinowski
2009-07-31 11:17:57 +02:00
parent a46e71d0b6
commit 6a91b63af9
5 changed files with 41 additions and 12 deletions

View File

@@ -95,6 +95,8 @@ bool CodepasterPlugin::initialize(const QStringList &arguments, QString *error_m
0};
for(int i=0; protos[i] != 0; ++i) {
connect(protos[i], SIGNAL(pasteDone(QString)), this, SLOT(finishPost(QString)));
connect(protos[i], SIGNAL(fetchDone(QString,QString,bool)),
this, SLOT(finishFetch(QString,QString,bool)));
m_settingsPage->addProtocol(protos[i]->name());
if (protos[i]->hasSettings())
addObject(protos[i]->settingsPage());
@@ -251,4 +253,16 @@ void CodepasterPlugin::finishPost(const QString &link)
m_settingsPage->displayOutput());
}
void CodepasterPlugin::finishFetch(const QString &titleDescription,
const QString &content,
bool error)
{
QString title = titleDescription;
if (error) {
ICore::instance()->messageManager()->printToOutputPane(content, true);
} else {
EditorManager::instance()->newFile(Core::Constants::K_DEFAULT_TEXT_EDITOR, &title, content);
}
}
Q_EXPORT_PLUGIN(CodepasterPlugin)