20 #include "tdepartsdesignerplugin.h" 22 #include <tdeparts/componentfactory.h> 23 #include <tdeparts/part.h> 24 #include <kmimetype.h> 26 #include <tdeapplication.h> 27 #include <kdemacros.h> 29 KPartsGenericPart::KPartsGenericPart( TQWidget* parentWidget, const char* name ) 30 : TQWidget( parentWidget, name ), m_part( 0 ) 32 TQVBoxLayout* layout = new TQVBoxLayout( this ); 33 layout->setAutoAdd( true ); 36 void KPartsGenericPart::load() 38 if ( m_mimetype.isEmpty() || m_url.isEmpty() ) 44 TQString mimetype = m_mimetype; 45 if ( mimetype == "auto" ) 46 mimetype == KMimeType::findByURL( m_url )->name(); 51 m_part = KParts::ComponentFactory::createPartInstanceFromQuery<KParts::ReadOnlyPart>( mimetype, TQString(), this, 0, this, 0 ); 53 m_part->openURL( m_url ); 54 m_part->widget()->show(); 60 static const char* mykey = "KPartsGenericPart"; 62 TQStringList KPartsWidgetPlugin::keys() const { 63 return TQStringList() << mykey; 66 TQWidget * KPartsWidgetPlugin::create( const TQString & key, TQWidget * parent, const char * name ) { 72 TQString KPartsWidgetPlugin::group( const TQString & key ) const { 74 return "Display (KDE)"; 79 TQIconSet KPartsWidgetPlugin::iconSet( const TQString & key ) const { 84 TQString KPartsWidgetPlugin::includeFile( const TQString & key ) const { 86 return "partplugin.h"; 90 TQString KPartsWidgetPlugin::toolTip( const TQString & key ) const { 92 return "Generic KParts viewer"; 96 TQString KPartsWidgetPlugin::whatsThis( const TQString & key ) const { 98 return "A widget to embed any KParts viewer, given a url and optionally a mimetype"; 102 bool KPartsWidgetPlugin::isContainer( const TQString & ) const { 107 #ifndef KDE_TQ_EXPORT_PLUGIN 108 #define KDE_TQ_EXPORT_PLUGIN(PLUGIN) \ 109 TQ_EXTERN_C KDE_EXPORT const char* qt_ucm_query_verification_data(); \ 110 TQ_EXTERN_C KDE_EXPORT TQUnknownInterface* ucm_instantiate(); \ 111 TQ_EXPORT_PLUGIN(PLUGIN) 116 #include "tdepartsdesignerplugin.moc"
Generic part loader, able to view any kind of file for which a KParts::ReadOnlyPart is available...
|