vcs/cervisia/cervisia_plugin.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
#include <qvbox.h>
00013
#include <qtextedit.h>
00014
#include <klistview.h>
00015
00016
#include <kinstance.h>
00017
#include <klocale.h>
00018
#include <kgenericfactory.h>
00019
#include <kdebug.h>
00020
#include <kaction.h>
00021
#include <kurl.h>
00022
#include <kmessagebox.h>
00023
#include <kmainwindow.h>
00024
00025
#include <kparts/part.h>
00026
#include <klibloader.h>
00027
#include <kparts/componentfactory.h>
00028
00029
#include <kdevmainwindow.h>
00030
#include <kdevcore.h>
00031
#include <kdevproject.h>
00032
00033
#include "cervisia_plugin.h"
00034
00035
#include <kdeversion.h>
00036
#if (KDE_VERSION_MINOR==0) && (KDE_VERSION_MAJOR==3)
00037
#include <kdevkurl.h>
00038
#define KURL KdevKURL
00039
#endif
00040
00041 typedef KGenericFactory<CervisiaPlugin> CervisiaPluginFactory;
00042 K_EXPORT_COMPONENT_FACTORY( libkdevcervisia,
CervisiaPluginFactory(
"kdevcervisia" ) )
00043
00044
CervisiaPlugin::
CervisiaPlugin(
QObject *parent, const
char *name, const
QStringList &arguments )
00045 :
KDevVersionControl( "
CervisiaPlugin", "cervisiaplugin", parent, name ? name : "CervisiaPlugin" ),
00046 m_part( 0 )
00047 {
00048
kdDebug() <<
"CervisiaPlugin::CervisiaPlugin()" <<
endl;
00049
00050 setInstance( CervisiaPluginFactory::instance() );
00051
00052
00053
00054 m_part = KParts::ComponentFactory::createPartInstanceFromLibrary<KParts::ReadOnlyPart>(
00055
"libcervisiapart", 0,
"cervisiapart",
this, 0, arguments );
00056
if (!m_part)
00057 {
00058
00059 KMessageBox::error( mainWindow()->
main()->centralWidget(),
00060 i18n(
"Could not find Cervisia KPart!! This plug-in will be unusable.") );
00061
return;
00062 }
00063
00064
00065 connect( core(), SIGNAL(projectOpened()),
this, SLOT(slotProjectOpened()) );
00066 connect( core(), SIGNAL(projectClosed()),
this, SLOT(slotProjectClosed()) );
00067 }
00068
00069 CervisiaPlugin::~CervisiaPlugin()
00070 {
00071
if (
m_part)
00072 {
00073
mainWindow()->
removeView(
m_part->
widget() );
00074
mainWindow()->
main()->
guiFactory()->
removeClient(
m_part );
00075
m_part->
closeURL();
00076
delete m_part;
00077 }
00078 }
00079
00080 void CervisiaPlugin::slotProjectOpened()
00081 {
00082
if (!
m_part)
00083
return;
00084
00085
00086
mainWindow()->
main()->
guiFactory()->
addClient(
m_part );
00087
mainWindow()->
embedSelectView(
m_part->
widget(), i18n(
"Cervisia"), i18n(
"Provides CVS Access"));
00088
00089
KURL projectUrl = KURL::fromPathOrURL(
project()->projectDirectory() );
00090
m_part->
openURL( projectUrl );
00091 }
00092
00093 void CervisiaPlugin::slotProjectClosed()
00094 {
00095
if (!
m_part)
00096
return;
00097
00098
00099
m_part->
closeURL();
00100
mainWindow()->
removeView(
m_part->
widget() );
00101
mainWindow()->
main()->
guiFactory()->
removeClient(
m_part );
00102 }
00103
00104
#include "cervisia_plugin.moc"
This file is part of the documentation for KDevelop Version 3.0.4.