krita

kis_filter_registry.cc

00001 /*
00002  *  Copyright (c) 2003 Patrick Julien  <freak@codepimps.org>
00003  *  Copyright (c) 2004 Cyrille Berger <cberger@cberger.net>
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018  */
00019 #include <qstring.h>
00020 #include <qptrlist.h>
00021 
00022 #include <kaction.h>
00023 #include <kdebug.h>
00024 #include <klocale.h>
00025 #include <kparts/plugin.h>
00026 #include <kservice.h>
00027 #include <ktrader.h>
00028 #include <kparts/componentfactory.h>
00029 #include "kis_debug_areas.h"
00030 #include <math.h>
00031 #include "kis_types.h"
00032 #include "kis_filter_registry.h"
00033 #include "kis_paint_device.h"
00034 #include "kis_filter.h"
00035 
00036 KisFilterRegistry *KisFilterRegistry::m_singleton = 0;
00037 
00038 KisFilterRegistry::KisFilterRegistry()
00039 {
00040     Q_ASSERT(KisFilterRegistry::m_singleton == 0);
00041     KisFilterRegistry::m_singleton = this;
00042 
00043     KTrader::OfferList offers = KTrader::self()->query(QString::fromLatin1("Krita/Filter"),
00044                                                          QString::fromLatin1("(Type == 'Service') and "
00045                                                                              "([X-Krita-Version] == 2)"));
00046 
00047     KTrader::OfferList::ConstIterator iter;
00048 
00049     for(iter = offers.begin(); iter != offers.end(); ++iter)
00050     {
00051         KService::Ptr service = *iter;
00052         int errCode = 0;
00053         KParts::Plugin* plugin =
00054              KParts::ComponentFactory::createInstanceFromService<KParts::Plugin> ( service, this, 0, QStringList(), &errCode);
00055         if ( plugin )
00056             kdDebug(DBG_AREA_PLUGINS) << "found plugin " << service->property("Name").toString() << "\n";
00057         else {
00058             kdDebug(41006) << "found plugin " << service->property("Name").toString() << ", " << errCode << "\n";
00059             if( errCode == KParts::ComponentFactory::ErrNoLibrary)
00060             {
00061                 kdWarning(41006) << " Error loading plugin was : ErrNoLibrary " << KLibLoader::self()->lastErrorMessage() << endl;
00062             }
00063         }
00064 
00065     }
00066 
00067 }
00068 
00069 KisFilterRegistry::~KisFilterRegistry()
00070 {
00071 }
00072 
00073 KisFilterRegistry* KisFilterRegistry::instance()
00074 {
00075     if(KisFilterRegistry::m_singleton == 0)
00076     {
00077         KisFilterRegistry::m_singleton = new KisFilterRegistry();
00078     }
00079     return KisFilterRegistry::m_singleton;
00080 }
00081 
00082 #include "kis_filter_registry.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys