00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "tdepartsdesignerplugin.h"
00021
00022 #include <tdeparts/componentfactory.h>
00023 #include <tdeparts/part.h>
00024 #include <kmimetype.h>
00025 #include <tqlayout.h>
00026 #include <tdeapplication.h>
00027 #include <tdepimmacros.h>
00028
00029 KPartsGenericPart::KPartsGenericPart( TQWidget* parentWidget, const char* name )
00030 : TQWidget( parentWidget, name ), m_part( 0 )
00031 {
00032 TQVBoxLayout* layout = new TQVBoxLayout( this );
00033 layout->setAutoAdd( true );
00034 }
00035
00036 void KPartsGenericPart::load()
00037 {
00038 if ( m_mimetype.isEmpty() || m_url.isEmpty() )
00039 return;
00040
00041
00042 if ( !kapp )
00043 return;
00044 TQString mimetype = m_mimetype;
00045 if ( mimetype == "auto" )
00046 mimetype == KMimeType::findByURL( m_url )->name();
00047 if ( m_part ) {
00048 delete m_part;
00049 }
00050
00051 m_part = KParts::ComponentFactory::createPartInstanceFromQuery<KParts::ReadOnlyPart>( mimetype, TQString(), TQT_TQWIDGET(this), 0, TQT_TQOBJECT(this), 0 );
00052 if ( m_part ) {
00053 m_part->openURL( m_url );
00054 m_part->widget()->show();
00055 }
00056 }
00057
00059
00060 static const char* mykey = "KPartsGenericPart";
00061
00062 TQStringList KPartsWidgetPlugin::keys() const {
00063 return TQStringList() << mykey;
00064 }
00065
00066 TQWidget * KPartsWidgetPlugin::create( const TQString & key, TQWidget * parent, const char * name ) {
00067 if ( key == mykey )
00068 return new KPartsGenericPart( parent, name );
00069 return 0;
00070 }
00071
00072 TQString KPartsWidgetPlugin::group( const TQString & key ) const {
00073 if ( key == mykey )
00074 return "Display (KDE)";
00075 return TQString();
00076 }
00077
00078 #if 0
00079 TQIconSet KPartsWidgetPlugin::iconSet( const TQString & key ) const {
00080 return TQIconSet();
00081 }
00082 #endif
00083
00084 TQString KPartsWidgetPlugin::includeFile( const TQString & key ) const {
00085 if ( key == mykey )
00086 return "partplugin.h";
00087 return TQString();
00088 }
00089
00090 TQString KPartsWidgetPlugin::toolTip( const TQString & key ) const {
00091 if ( key == mykey )
00092 return "Generic KParts viewer";
00093 return TQString();
00094 }
00095
00096 TQString KPartsWidgetPlugin::whatsThis( const TQString & key ) const {
00097 if ( key == mykey )
00098 return "A widget to embed any KParts viewer, given a url and optionally a mimetype";
00099 return TQString();
00100 }
00101
00102 bool KPartsWidgetPlugin::isContainer( const TQString & ) const {
00103 return false;
00104 }
00105
00107 #ifndef KDE_TQ_EXPORT_PLUGIN
00108 #define KDE_TQ_EXPORT_PLUGIN(PLUGIN) \
00109 TQ_EXTERN_C KDE_EXPORT const char* qt_ucm_query_verification_data(); \
00110 TQ_EXTERN_C KDE_EXPORT TQUnknownInterface* ucm_instantiate(); \
00111 TQ_EXPORT_PLUGIN(PLUGIN)
00112 #endif
00113
00114 KDE_TQ_EXPORT_PLUGIN( KPartsWidgetPlugin )
00115
00116 #include "tdepartsdesignerplugin.moc"
00117