kivio
kivio_plugin_stencil_spawner.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <config.h>
00021 #include "kivio_plugin_stencil_spawner.h"
00022 #include <kparts/part.h>
00023 #include <kparts/componentfactory.h>
00024 #include "kiviostencilfactory.h"
00025 #include "kivio_intra_stencil_data.h"
00026 #include "kivio_common.h"
00027 #include "kivio_stencil.h"
00028
00029 #include <qdom.h>
00030 #include <qfileinfo.h>
00031 #include <kdebug.h>
00032
00033 KivioPluginStencilSpawner::KivioPluginStencilSpawner( KivioStencilSpawnerSet *pSet )
00034 : KivioStencilSpawner( pSet ),
00035 m_handle(NULL)
00036 {
00037 pNewStencil = NULL;
00038 }
00039
00040 KivioPluginStencilSpawner::~KivioPluginStencilSpawner()
00041 {
00042 }
00043
00044 bool KivioPluginStencilSpawner::load( const QString &f )
00045 {
00046 QFileInfo lib(f);
00047
00048 if( lib.exists())
00049 {
00050 m_fileName = lib.baseName();
00051 } else {
00052 return false;
00053 }
00054
00055 fac = KParts::ComponentFactory::createInstanceFromLibrary<KivioStencilFactory>(m_fileName.local8Bit());
00056
00057 if( !fac)
00058 {
00059 kdDebug(43000) << "Failed to load: " << m_fileName << endl;
00060 return false;
00061 }
00062
00063
00064 m_pIcon = fac->GetIcon();
00065
00066
00067 m_pSInfo = fac->GetSpawnerInfo();
00068
00069 return true;
00070 }
00071
00072 QDomElement KivioPluginStencilSpawner::saveXML( QDomDocument &doc )
00073 {
00074 QDomElement spawnE = doc.createElement("KivioPluginStencilSpawner");
00075
00076 XmlWriteString( spawnE, "id", m_pInfo->id() );
00077
00078 return spawnE;
00079 }
00080
00081 KivioStencil *KivioPluginStencilSpawner::newStencil()
00082 {
00083 KivioStencil *pStencil = fac->NewStencil();
00084
00085 pStencil->setSpawner(this);
00086 return pStencil;
00087 }
00088
00089
00090 KivioStencil *KivioPluginStencilSpawner::newStencil(const QString& arg)
00091 {
00092 KivioStencil *pStencil = fac->NewStencil(arg);
00093
00094 pStencil->setSpawner(this);
00095 return pStencil;
00096 }
00097 KivioStencilSpawnerInfo *KivioPluginStencilSpawner::info()
00098 {
00099 return m_pSInfo;
00100 }
|