libkdepim
embeddedurlpage.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "embeddedurlpage.h"
00025 #include <kparts/componentfactory.h>
00026 #include <kparts/browserextension.h>
00027 #include <kparts/part.h>
00028 #include <kmimetype.h>
00029 #include <klocale.h>
00030 #include <qlayout.h>
00031 #include <qlabel.h>
00032
00033 using namespace KPIM;
00034
00035 EmbeddedURLPage::EmbeddedURLPage( const QString &url, const QString &mimetype,
00036 QWidget *parent, const char *name )
00037 : QWidget( parent, name ), mUri(url), mMimeType( mimetype ), mPart( 0 )
00038 {
00039 initGUI( url, mimetype );
00040 }
00041
00042 void EmbeddedURLPage::initGUI( const QString &url, const QString & )
00043 {
00044 QVBoxLayout *layout = new QVBoxLayout( this );
00045 layout->setAutoAdd( true );
00046 new QLabel( i18n("Showing URL %1").arg( url ), this );
00047 }
00048
00049 void EmbeddedURLPage::loadContents()
00050 {
00051 if ( !mPart ) {
00052 if ( mMimeType.isEmpty() || mUri.isEmpty() )
00053 return;
00054 QString mimetype = mMimeType;
00055 if ( mimetype == "auto" )
00056 mimetype == KMimeType::findByURL( mUri )->name();
00057
00058 mPart = KParts::ComponentFactory::createPartInstanceFromQuery<KParts::ReadOnlyPart>( mimetype, QString::null, this, 0, this, 0 );
00059 if ( mPart ) {
00060 mPart->openURL( mUri );
00061 mPart->widget()->show();
00062 }
00063
00064 KParts::BrowserExtension* be = KParts::BrowserExtension::childObject( mPart );
00065 connect( be, SIGNAL( openURLRequestDelayed( const KURL &, const KParts::URLArgs & ) ),
00066
00067 this, SIGNAL( openURL( const KURL & ) ) );
00068 }
00069 }
00070
00071 #include "embeddedurlpage.moc"
|