kdatatool.h
00001 /* This file is part of the KDE project 00002 Copyright (C) 1998, 1999, 2000 Torben Weis <weis@kde.org> 00003 Copyright (C) 2001 David Faure <david@mandrakesoft.com> 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 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 #ifndef KDATATOOL_H 00022 #define KDATATOOL_H 00023 00024 #include <tqobject.h> 00025 #include <tqvaluelist.h> 00026 00027 #include <kaction.h> 00028 #include <kservice.h> 00029 00030 class KDataTool; 00031 class TQPixmap; 00032 class TQStringList; 00033 class KInstance; 00034 00035 // If you're only looking at implementing a data-tool, skip directly to the last 00036 // class definition, KDataTool. 00037 00047 class KIO_EXPORT KDataToolInfo 00048 { 00049 public: 00053 KDataToolInfo(); 00059 KDataToolInfo( const KService::Ptr& service, KInstance* instance ); 00063 KDataToolInfo( const KDataToolInfo& info ); 00067 KDataToolInfo& operator= ( const KDataToolInfo& info ); 00068 00075 TQString dataType() const; 00087 TQStringList mimeTypes() const; 00088 00093 bool isReadOnly() const; 00094 00100 TQPixmap icon() const KDE_DEPRECATED; 00106 TQPixmap miniIcon() const KDE_DEPRECATED; 00111 TQString iconName() const; 00125 TQStringList userCommands() const; 00137 TQStringList commands() const; 00138 00145 KDataTool* createTool( TQObject* parent = 0, const char* name = 0 ) const; 00146 00151 KService::Ptr service() const; 00152 00157 KInstance* instance() const { return m_instance; } 00158 00164 bool isValid() const; 00165 00174 static TQValueList<KDataToolInfo> query( const TQString& datatype, const TQString& mimetype, KInstance * instance ); 00175 00176 private: 00177 KService::Ptr m_service; 00178 KInstance* m_instance; 00179 private: 00180 class KDataToolInfoPrivate* d; 00181 }; 00182 00183 00194 class KIO_EXPORT KDataToolAction : public KAction 00195 { 00196 Q_OBJECT 00197 TQ_OBJECT 00198 public: 00208 KDataToolAction( const TQString & text, const KDataToolInfo & info, const TQString & command, TQObject * parent = 0, const char * name = 0); 00209 00220 static TQPtrList<KAction> dataToolActionList( const TQValueList<KDataToolInfo> & tools, const TQObject *receiver, const char* slot ); 00221 00222 signals: 00228 void toolActivated( const KDataToolInfo & info, const TQString & command ); 00229 00230 protected: 00231 virtual void slotActivated(); 00232 00233 private: 00234 TQString m_command; 00235 KDataToolInfo m_info; 00236 protected: 00237 virtual void virtual_hook( int id, void* data ); 00238 private: 00239 class KDataToolActionPrivate* d; 00240 00241 }; 00242 00254 class KIO_EXPORT KDataTool : public TQObject 00255 { 00256 Q_OBJECT 00257 TQ_OBJECT 00258 public: 00265 KDataTool( TQObject* parent = 0, const char* name = 0 ); 00266 00270 void setInstance( KInstance* instance ) { m_instance = instance; } 00271 00277 KInstance* instance() const; 00278 00292 virtual bool run( const TQString& command, void* data, const TQString& datatype, const TQString& mimetype) = 0; 00293 00294 private: 00295 KInstance * m_instance; 00296 protected: 00297 virtual void virtual_hook( int id, void* data ); 00298 private: 00299 class KDataToolPrivate; 00300 KDataToolPrivate * d; 00301 }; 00302 00303 #endif