koQueryTrader.h
00001 /* This file is part of the KDE project 00002 Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00017 Boston, MA 02111-1307, USA. 00018 */ 00019 00020 #ifndef __ko_query_trader_h__ 00021 #define __ko_query_trader_h__ 00022 00023 #include <kservice.h> 00024 #include <ksharedptr.h> 00025 #include <qvaluelist.h> 00026 #include <koffice_export.h> 00027 00028 class QObject; 00029 class QStringList; 00030 class KoDocument; 00031 class KoFilter; 00032 class KoFilterChain; 00033 00038 class KOFFICECORE_EXPORT KoDocumentEntry 00039 { 00040 00041 public: 00042 KoDocumentEntry() { m_service = 0L; } // for QValueList 00043 KoDocumentEntry( KService::Ptr service ); 00044 ~KoDocumentEntry() { } 00045 00046 KService::Ptr service() const { return m_service; } 00047 00051 bool isEmpty() const { return m_service == 0L; } 00052 00056 QString name() const { return m_service->name(); } 00057 00061 QStringList mimeTypes() const { return m_service->serviceTypes(); } 00062 00066 bool supportsMimeType( const QString & _mimetype ) const 00067 { return mimeTypes().contains( _mimetype ); } 00068 00073 KoDocument* createDoc( KoDocument* parent = 0, const char* name = 0 ) const; 00074 00083 static QValueList<KoDocumentEntry> query( const QString & _constr = QString::null ); 00084 00096 // ### TODO: MERGE WITH ABOVE METHODE WHEN BIC+SIC CHANGES ARE ALLOWED 00097 static QValueList<KoDocumentEntry> query( bool _onlyDocEmb,const QString& _constr); 00098 /* this is how the signature should be looking after merging 00099 static QValueList<KoDocumentEntry> query( bool _onlyDocEmb =true, const QString& _constr = QString::null ); 00100 or better: use an enum for the first arg. 00101 */ 00102 00103 00110 static KoDocumentEntry queryByMimeType( const QString & mimetype ); 00111 00112 private: 00113 KService::Ptr m_service; 00114 }; 00115 00119 class KoFilterEntry : public KShared 00120 { 00121 00122 public: 00123 typedef KSharedPtr<KoFilterEntry> Ptr; 00124 00125 KoFilterEntry() : weight( 0 ) { m_service = 0L; } // for QValueList 00126 KoFilterEntry( KService::Ptr service ); 00127 ~KoFilterEntry() { } 00128 00129 KoFilter* createFilter( KoFilterChain* chain, QObject* parent = 0, const char* name = 0 ); 00130 00134 QStringList import; 00135 00139 QStringList export_; 00140 00144 unsigned int weight; 00145 00149 QString available; 00150 00154 bool imports( const QString& _mimetype ) const 00155 { return ( import.contains( _mimetype ) ); } 00156 00160 bool exports( const QString& _m ) const 00161 { return ( export_.contains( _m ) ); } 00162 00170 static QValueList<KoFilterEntry::Ptr> query( const QString& _constr = QString::null ); 00171 00172 KService::Ptr service() const { return m_service; } 00173 00174 private: 00175 KService::Ptr m_service; 00176 }; 00177 00178 #endif