CodePaster: Register type safe service object

Use Q_DECLARE_INTERFACE et al.
This provides a way to have the dependency on code pasting
optional in the using plugins (VCS, diff editor), while
still being able to use a nice API to perform the pasting itself.

Change-Id: Ia61e0066d552e45031f4aa7fd1f6693b68f92384
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
This commit is contained in:
Eike Ziller
2015-06-29 14:22:17 +02:00
parent 81272a9fdb
commit ce96a8b80a
11 changed files with 135 additions and 64 deletions

View File

@@ -70,32 +70,29 @@ using namespace TextEditor;
namespace CodePaster {
/*!
\class CodePaster::CodePasterService
\brief The CodePasterService class is a service registered with PluginManager
\class CodePaster::Service
\brief The CodePaster::Service class is a service registered with PluginManager
that provides CodePaster \c post() functionality.
\sa ExtensionSystem::PluginManager::getObjectByClassName, ExtensionSystem::invoke
\sa VcsBase::VcsBaseEditorWidget
*/
CodePasterService::CodePasterService(QObject *parent) :
CodePasterServiceImpl::CodePasterServiceImpl(QObject *parent) :
QObject(parent)
{
}
void CodePasterService::postText(const QString &text, const QString &mimeType)
void CodePasterServiceImpl::postText(const QString &text, const QString &mimeType)
{
QTC_ASSERT(CodepasterPlugin::instance(), return);
CodepasterPlugin::instance()->post(text, mimeType);
}
void CodePasterService::postCurrentEditor()
void CodePasterServiceImpl::postCurrentEditor()
{
QTC_ASSERT(CodepasterPlugin::instance(), return);
CodepasterPlugin::instance()->post(CodepasterPlugin::PasteEditor);
}
void CodePasterService::postClipboard()
void CodePasterServiceImpl::postClipboard()
{
QTC_ASSERT(CodepasterPlugin::instance(), return);
CodepasterPlugin::instance()->post(CodepasterPlugin::PasteClipboard);
@@ -176,7 +173,7 @@ bool CodepasterPlugin::initialize(const QStringList &arguments, QString *errorMe
connect(m_fetchUrlAction, &QAction::triggered, this, &CodepasterPlugin::fetchUrl);
cpContainer->addAction(command);
addAutoReleasedObject(new CodePasterService);
addAutoReleasedObject(new CodePasterServiceImpl);
return true;
}