KIO
kfilewriteplugin.cpp
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries 00002 00003 Copyright (c) 2007 Jos van den Oever <jos@vandenoever.info> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License (LGPL) as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library 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 GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #include "kfilewriteplugin.h" 00022 #include "kfilewriteplugin_p.h" 00023 #include "kglobal.h" 00024 #include "kservicetypetrader.h" 00025 #include <QHash> 00026 #include <QDebug> 00027 00028 KFileWritePlugin::KFileWritePlugin(QObject* parent, const QStringList&) 00029 :QObject(parent), d(0) 00030 { 00031 } 00032 00033 KFileWritePlugin::~KFileWritePlugin() { 00034 } 00035 00036 K_GLOBAL_STATIC(KFileWriterProvider, staticKFileWriterProvider) 00037 00038 KFileWriterProvider* 00039 KFileWriterProvider::self() { 00040 return staticKFileWriterProvider; 00041 } 00042 00043 KFileWriterProvider::~KFileWriterProvider() { 00044 qDeleteAll(plugins); 00045 plugins.clear(); 00046 } 00047 00048 KFileWritePlugin* 00049 KFileWriterProvider::loadPlugin(const QString& key) { 00050 //kDebug() << "loading writer for key " << key; 00051 const QString constraint = QString::fromLatin1("'%1' in MetaDataKeys") 00052 .arg(key); 00053 const KService::List offers = KServiceTypeTrader::self()->query( 00054 "KFileWrite", constraint); 00055 if (offers.isEmpty()) { 00056 return 0; 00057 } 00058 return offers.first()->createInstance<KFileWritePlugin>(); 00059 } 00060 00061 #include "kfilewriteplugin.moc" 00062
KDE 4.6 API Reference