libtdepim

embeddedurlpage.cpp
1 /*
2  This file is part of libtdepim.
3 
4  Copyright (c) 2005 Reinhold Kainhofer <reinhold@kainhofer.com>
5  Part of loadContents() copied from the tdepartsdesignerplugin:
6  Copyright (C) 2005, David Faure <faure@kde.org>
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public
10  License as published by the Free Software Foundation; either
11  version 2 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Library General Public License for more details.
17 
18  You should have received a copy of the GNU Library General Public License
19  along with this library; see the file COPYING.LIB. If not, write to
20  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  Boston, MA 02110-1301, USA.
22 */
23 
24 #include "embeddedurlpage.h"
25 #include <tdeparts/componentfactory.h>
26 #include <tdeparts/browserextension.h>
27 #include <tdeparts/part.h>
28 #include <kmimetype.h>
29 #include <tdelocale.h>
30 #include <tqlayout.h>
31 #include <tqlabel.h>
32 
33 using namespace KPIM;
34 
35 EmbeddedURLPage::EmbeddedURLPage( const TQString &url, const TQString &mimetype,
36  TQWidget *parent, const char *name )
37  : TQWidget( parent, name ), mUri(url), mMimeType( mimetype ), mPart( 0 )
38 {
39  initGUI( url, mimetype );
40 }
41 
42 void EmbeddedURLPage::initGUI( const TQString &url, const TQString &/*mimetype*/ )
43 {
44  TQVBoxLayout *layout = new TQVBoxLayout( this );
45  layout->setAutoAdd( true );
46  new TQLabel( i18n("Showing URL %1").arg( url ), this );
47 }
48 
49 void EmbeddedURLPage::loadContents()
50 {
51  if ( !mPart ) {
52  if ( mMimeType.isEmpty() || mUri.isEmpty() )
53  return;
54  TQString mimetype = mMimeType;
55  if ( mimetype == "auto" )
56  mimetype == KMimeType::findByURL( mUri )->name();
57  // "this" is both the parent widget and the parent object
58  mPart = KParts::ComponentFactory::createPartInstanceFromQuery<KParts::ReadOnlyPart>( mimetype, TQString(), this, 0, this, 0 );
59  if ( mPart ) {
60  mPart->openURL( mUri );
61  mPart->widget()->show();
62  }
63 //void KParts::BrowserExtension::openURLRequestDelayed( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() )
64  KParts::BrowserExtension* be = KParts::BrowserExtension::childObject( mPart );
65  connect( be, TQ_SIGNAL( openURLRequestDelayed( const KURL &, const KParts::URLArgs & ) ),
66 // mPart, TQ_SLOT( openURL( const KURL & ) ) );
67  this, TQ_SIGNAL( openURL( const KURL & ) ) );
68  }
69 }
70 
71 #include "embeddedurlpage.moc"
TDEPIM classes for drag and drop of mails.