• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.8.3 API Reference
  • KDE Home
  • Contact Us
 

KParts

browserextension.cpp
Go to the documentation of this file.
00001  /* This file is part of the KDE project
00002    Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
00003              (C) 1999 David Faure <faure@kde.org>
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 #include "browserextension.h"
00021 
00022 #include <QtGui/QApplication>
00023 #include <QtGui/QClipboard>
00024 #include <QtCore/QTimer>
00025 #include <QtCore/QObject>
00026 #include <QtCore/QMap>
00027 #include <QtCore/QMetaEnum>
00028 #include <QtCore/QRegExp>
00029 #include <QtGui/QTextDocument>
00030 
00031 #include <kdebug.h>
00032 #include <klocale.h>
00033 #include <kmessagebox.h>
00034 #include <kurifilter.h>
00035 #include <kglobal.h>
00036 
00037 using namespace KParts;
00038 
00039 
00040 class OpenUrlEvent::OpenUrlEventPrivate
00041 {
00042 public:
00043   OpenUrlEventPrivate( ReadOnlyPart *part,
00044                        const KUrl &url,
00045                        const OpenUrlArguments &args,
00046                        const BrowserArguments &browserArgs )
00047     : m_part( part )
00048     , m_url( url )
00049     , m_args(args)
00050     , m_browserArgs(browserArgs)
00051   {
00052   }
00053   ~OpenUrlEventPrivate()
00054   {
00055   }
00056   static const char *s_strOpenUrlEvent;
00057   ReadOnlyPart *m_part;
00058   KUrl m_url;
00059   OpenUrlArguments m_args;
00060   BrowserArguments m_browserArgs;
00061 };
00062 
00063 const char *OpenUrlEvent::OpenUrlEventPrivate::s_strOpenUrlEvent =
00064                         "KParts/BrowserExtension/OpenURLevent";
00065 
00066 OpenUrlEvent::OpenUrlEvent( ReadOnlyPart *part, const KUrl &url,
00067                             const OpenUrlArguments &args,
00068                             const BrowserArguments &browserArgs )
00069     : Event( OpenUrlEventPrivate::s_strOpenUrlEvent )
00070     , d( new OpenUrlEventPrivate(part, url, args, browserArgs) )
00071 {
00072 }
00073 
00074 OpenUrlEvent::~OpenUrlEvent()
00075 {
00076     delete d;
00077 }
00078 
00079 ReadOnlyPart *OpenUrlEvent::part() const
00080 {
00081     return d->m_part;
00082 }
00083 
00084 KUrl OpenUrlEvent::url() const
00085 {
00086     return d->m_url;
00087 }
00088 
00089 OpenUrlArguments OpenUrlEvent::arguments() const
00090 {
00091     return d->m_args;
00092 }
00093 
00094 BrowserArguments OpenUrlEvent::browserArguments() const
00095 {
00096     return d->m_browserArgs;
00097 }
00098 
00099 bool OpenUrlEvent::test( const QEvent *event )
00100 {
00101     return Event::test( event, OpenUrlEventPrivate::s_strOpenUrlEvent );
00102 }
00103 
00104 namespace KParts
00105 {
00106 
00107 struct BrowserArgumentsPrivate
00108 {
00109     BrowserArgumentsPrivate() {
00110       doPost = false;
00111       redirectedRequest = false;
00112       lockHistory = false;
00113       newTab = false;
00114       forcesNewWindow = false;
00115     }
00116     QString contentType; // for POST
00117     bool doPost;
00118     bool redirectedRequest;
00119     bool lockHistory;
00120     bool newTab;
00121     bool forcesNewWindow;
00122 };
00123 
00124 }
00125 
00126 BrowserArguments::BrowserArguments()
00127 {
00128   softReload = false;
00129   trustedSource = false;
00130   d = 0; // Let's build it on demand for now
00131 }
00132 
00133 BrowserArguments::BrowserArguments( const BrowserArguments &args )
00134 {
00135   d = 0;
00136   (*this) = args;
00137 }
00138 
00139 BrowserArguments &BrowserArguments::operator=(const BrowserArguments &args)
00140 {
00141   if (this == &args) return *this;
00142 
00143   delete d; d= 0;
00144 
00145   softReload = args.softReload;
00146   postData = args.postData;
00147   frameName = args.frameName;
00148   docState = args.docState;
00149   trustedSource = args.trustedSource;
00150 
00151   if ( args.d )
00152       d = new BrowserArgumentsPrivate( * args.d );
00153 
00154   return *this;
00155 }
00156 
00157 BrowserArguments::~BrowserArguments()
00158 {
00159   delete d;
00160   d = 0;
00161 }
00162 
00163 void BrowserArguments::setContentType( const QString & contentType )
00164 {
00165   if (!d)
00166     d = new BrowserArgumentsPrivate;
00167   d->contentType = contentType;
00168 }
00169 
00170 void BrowserArguments::setRedirectedRequest( bool redirected )
00171 {
00172   if (!d)
00173      d = new BrowserArgumentsPrivate;
00174   d->redirectedRequest = redirected;
00175 }
00176 
00177 bool BrowserArguments::redirectedRequest () const
00178 {
00179   return d ? d->redirectedRequest : false;
00180 }
00181 
00182 QString BrowserArguments::contentType() const
00183 {
00184   return d ? d->contentType : QString();
00185 }
00186 
00187 void BrowserArguments::setDoPost( bool enable )
00188 {
00189     if ( !d )
00190         d = new BrowserArgumentsPrivate;
00191     d->doPost = enable;
00192 }
00193 
00194 bool BrowserArguments::doPost() const
00195 {
00196     return d ? d->doPost : false;
00197 }
00198 
00199 void BrowserArguments::setLockHistory( bool lock )
00200 {
00201   if (!d)
00202      d = new BrowserArgumentsPrivate;
00203   d->lockHistory = lock;
00204 }
00205 
00206 bool BrowserArguments::lockHistory() const
00207 {
00208     return d ? d->lockHistory : false;
00209 }
00210 
00211 void BrowserArguments::setNewTab( bool newTab )
00212 {
00213   if (!d)
00214      d = new BrowserArgumentsPrivate;
00215   d->newTab = newTab;
00216 }
00217 
00218 bool BrowserArguments::newTab() const
00219 {
00220     return d ? d->newTab : false;
00221 }
00222 
00223 void BrowserArguments::setForcesNewWindow( bool forcesNewWindow )
00224 {
00225   if (!d)
00226      d = new BrowserArgumentsPrivate;
00227   d->forcesNewWindow = forcesNewWindow;
00228 }
00229 
00230 bool BrowserArguments::forcesNewWindow() const
00231 {
00232     return d ? d->forcesNewWindow : false;
00233 }
00234 
00235 namespace KParts
00236 {
00237 
00238 class WindowArgsPrivate : public QSharedData
00239 {
00240 public:
00241     WindowArgsPrivate()
00242         : x(-1), y(-1), width(-1), height(-1),
00243           fullscreen(false),
00244           menuBarVisible(true),
00245           toolBarsVisible(true),
00246           statusBarVisible(true),
00247           resizable(true),
00248           lowerWindow(false),
00249           scrollBarsVisible(true)
00250     {
00251     }
00252 
00253     // Position
00254     int x;
00255     int y;
00256     // Size
00257     int width;
00258     int height;
00259     bool fullscreen; //defaults to false
00260     bool menuBarVisible; //defaults to true
00261     bool toolBarsVisible; //defaults to true
00262     bool statusBarVisible; //defaults to true
00263     bool resizable; //defaults to true
00264 
00265     bool lowerWindow; //defaults to false
00266     bool scrollBarsVisible; //defaults to true
00267 };
00268 
00269 }
00270 
00271 WindowArgs::WindowArgs()
00272     : d(new WindowArgsPrivate)
00273 {
00274 }
00275 
00276 WindowArgs::WindowArgs( const WindowArgs &args )
00277     : d(args.d)
00278 {
00279 }
00280 
00281 WindowArgs::~WindowArgs()
00282 {
00283 }
00284 
00285 WindowArgs &WindowArgs::operator=( const WindowArgs &args )
00286 {
00287     if ( this == &args ) return *this;
00288 
00289     d = args.d;
00290     return *this;
00291 }
00292 
00293 WindowArgs::WindowArgs( const QRect &_geometry, bool _fullscreen, bool _menuBarVisible,
00294                         bool _toolBarsVisible, bool _statusBarVisible, bool _resizable )
00295     : d(new WindowArgsPrivate)
00296 {
00297     d->x = _geometry.x();
00298     d->y = _geometry.y();
00299     d->width = _geometry.width();
00300     d->height = _geometry.height();
00301     d->fullscreen = _fullscreen;
00302     d->menuBarVisible = _menuBarVisible;
00303     d->toolBarsVisible = _toolBarsVisible;
00304     d->statusBarVisible = _statusBarVisible;
00305     d->resizable = _resizable;
00306     d->lowerWindow = false;
00307 }
00308 
00309 WindowArgs::WindowArgs( int _x, int _y, int _width, int _height, bool _fullscreen,
00310                         bool _menuBarVisible, bool _toolBarsVisible,
00311                         bool _statusBarVisible, bool _resizable )
00312     : d(new WindowArgsPrivate)
00313 {
00314     d->x = _x;
00315     d->y = _y;
00316     d->width = _width;
00317     d->height = _height;
00318     d->fullscreen = _fullscreen;
00319     d->menuBarVisible = _menuBarVisible;
00320     d->toolBarsVisible = _toolBarsVisible;
00321     d->statusBarVisible = _statusBarVisible;
00322     d->resizable = _resizable;
00323     d->lowerWindow = false;
00324 }
00325 
00326 void WindowArgs::setX(int x)
00327 {
00328     d->x = x;
00329 }
00330 
00331 int WindowArgs::x() const
00332 {
00333     return d->x;
00334 }
00335 
00336 void WindowArgs::setY(int y)
00337 {
00338     d->y = y;
00339 }
00340 
00341 int WindowArgs::y() const
00342 {
00343     return d->y;
00344 }
00345 
00346 void WindowArgs::setWidth(int w)
00347 {
00348     d->width = w;
00349 }
00350 
00351 int WindowArgs::width() const
00352 {
00353     return d->width;
00354 }
00355 
00356 void WindowArgs::setHeight(int h)
00357 {
00358     d->height = h;
00359 }
00360 
00361 int WindowArgs::height() const
00362 {
00363     return d->height;
00364 }
00365 
00366 void WindowArgs::setFullScreen(bool fs)
00367 {
00368     d->fullscreen = fs;
00369 }
00370 
00371 bool WindowArgs::isFullScreen() const
00372 {
00373     return d->fullscreen;
00374 }
00375 
00376 void WindowArgs::setMenuBarVisible(bool visible)
00377 {
00378     d->menuBarVisible = visible;
00379 }
00380 
00381 bool WindowArgs::isMenuBarVisible() const
00382 {
00383     return d->menuBarVisible;
00384 }
00385 
00386 void WindowArgs::setToolBarsVisible(bool visible)
00387 {
00388     d->toolBarsVisible = visible;
00389 }
00390 
00391 bool WindowArgs::toolBarsVisible() const
00392 {
00393     return d->toolBarsVisible;
00394 }
00395 
00396 void WindowArgs::setStatusBarVisible(bool visible)
00397 {
00398     d->statusBarVisible = visible;
00399 }
00400 
00401 bool WindowArgs::isStatusBarVisible() const
00402 {
00403     return d->statusBarVisible;
00404 }
00405 
00406 void WindowArgs::setResizable(bool resizable)
00407 {
00408     d->resizable = resizable;
00409 }
00410 
00411 bool WindowArgs::isResizable() const
00412 {
00413     return d->resizable;
00414 }
00415 
00416 void WindowArgs::setLowerWindow(bool lower)
00417 {
00418     d->lowerWindow = lower;
00419 }
00420 
00421 bool WindowArgs::lowerWindow() const
00422 {
00423     return d->lowerWindow;
00424 }
00425 
00426 void WindowArgs::setScrollBarsVisible(bool visible)
00427 {
00428     d->scrollBarsVisible = visible;
00429 }
00430 
00431 bool WindowArgs::scrollBarsVisible() const
00432 {
00433     return d->scrollBarsVisible;
00434 }
00435 
00436 namespace KParts
00437 {
00438 
00439 // Internal class, use to store the status of the actions
00440 class KBitArray
00441 {
00442 public:
00443     int val;
00444     KBitArray() { val = 0; }
00445     bool operator [](int index) { return (val & (1 << index)) ? true : false; }
00446     void setBit(int index, bool value) {
00447         if (value) val = val | (1 << index);
00448         else val = val & ~(1 << index);
00449     }
00450 };
00451 
00452 class BrowserExtension::BrowserExtensionPrivate
00453 {
00454 public:
00455   BrowserExtensionPrivate( KParts::ReadOnlyPart *parent )
00456     : m_urlDropHandlingEnabled(false),
00457       m_browserInterface(0),
00458       m_part( parent )
00459   {}
00460 
00461   struct DelayedRequest {
00462     KUrl m_delayedURL;
00463     KParts::OpenUrlArguments m_delayedArgs;
00464     KParts::BrowserArguments m_delayedBrowserArgs;
00465   };
00466 
00467   QList<DelayedRequest> m_requests;
00468   bool m_urlDropHandlingEnabled;
00469   KBitArray m_actionStatus;
00470   QMap<int, QString> m_actionText;
00471   BrowserInterface *m_browserInterface;
00472 
00473   static void createActionSlotMap();
00474 
00475   KParts::ReadOnlyPart *m_part;
00476     OpenUrlArguments m_args;
00477     BrowserArguments m_browserArgs;
00478 };
00479 
00480 K_GLOBAL_STATIC(BrowserExtension::ActionSlotMap, s_actionSlotMap)
00481 K_GLOBAL_STATIC(BrowserExtension::ActionNumberMap, s_actionNumberMap)
00482 
00483 void BrowserExtension::BrowserExtensionPrivate::createActionSlotMap()
00484 {
00485     s_actionSlotMap->insert( "cut", SLOT(cut()) );
00486     s_actionSlotMap->insert( "copy", SLOT(copy()) );
00487     s_actionSlotMap->insert( "paste", SLOT(paste()) );
00488     s_actionSlotMap->insert( "print", SLOT(print()) );
00489     // Tricky. Those aren't actions in fact, but simply methods that a browserextension
00490     // can have or not. No need to return them here.
00491     //s_actionSlotMap->insert( "reparseConfiguration", SLOT(reparseConfiguration()) );
00492     //s_actionSlotMap->insert( "refreshMimeTypes", SLOT(refreshMimeTypes()) );
00493 
00494     // Create the action-number map
00495     ActionSlotMap::ConstIterator it = s_actionSlotMap->constBegin();
00496     ActionSlotMap::ConstIterator itEnd = s_actionSlotMap->constEnd();
00497     for ( int i=0 ; it != itEnd ; ++it, ++i )
00498     {
00499         //kDebug(1202) << " action " << it.key() << " number " << i;
00500         s_actionNumberMap->insert( it.key(), i );
00501     }
00502 }
00503 
00504 }
00505 
00506 BrowserExtension::BrowserExtension( KParts::ReadOnlyPart *parent )
00507 : QObject( parent ), d( new BrowserExtensionPrivate(parent) )
00508 {
00509   //kDebug() << "BrowserExtension::BrowserExtension() " << this;
00510 
00511   if (s_actionSlotMap->isEmpty())
00512       // Create the action-slot map
00513       BrowserExtensionPrivate::createActionSlotMap();
00514 
00515   // Build list with this extension's slot names.
00516   QList<QByteArray> slotNames;
00517   int methodCount = metaObject()->methodCount();
00518   int methodOffset = metaObject()->methodOffset();
00519   for ( int i=0 ; i < methodCount; ++i )
00520   {
00521       QMetaMethod method = metaObject()->method( methodOffset + i );
00522       if ( method.methodType() == QMetaMethod::Slot )
00523           slotNames.append( method.signature() );
00524   }
00525 
00526   // Set the initial status of the actions depending on whether
00527   // they're supported or not
00528   ActionSlotMap::ConstIterator it = s_actionSlotMap->constBegin();
00529   ActionSlotMap::ConstIterator itEnd = s_actionSlotMap->constEnd();
00530   for ( int i=0 ; it != itEnd ; ++it, ++i )
00531   {
00532       // Does the extension have a slot with the name of this action ?
00533       // ######### KDE4 TODO: use QMetaObject::indexOfMethod() #######
00534       d->m_actionStatus.setBit( i, slotNames.contains( it.key()+"()" ) );
00535   }
00536 
00537   connect( d->m_part, SIGNAL(completed()),
00538            this, SLOT(slotCompleted()) );
00539   connect( this, SIGNAL(openUrlRequest(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)),
00540            this, SLOT(slotOpenUrlRequest(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)) );
00541   connect( this, SIGNAL(enableAction(const char*,bool)),
00542            this, SLOT(slotEnableAction(const char*,bool)) );
00543   connect( this, SIGNAL(setActionText(const char*,QString)),
00544            this, SLOT(slotSetActionText(const char*,QString)) );
00545 }
00546 
00547 BrowserExtension::~BrowserExtension()
00548 {
00549   //kDebug() << "BrowserExtension::~BrowserExtension() " << this;
00550   delete d;
00551 }
00552 
00553 void BrowserExtension::setBrowserArguments( const BrowserArguments &args )
00554 {
00555   d->m_browserArgs = args;
00556 }
00557 
00558 BrowserArguments BrowserExtension::browserArguments() const
00559 {
00560   return d->m_browserArgs;
00561 }
00562 
00563 int BrowserExtension::xOffset()
00564 {
00565   return 0;
00566 }
00567 
00568 int BrowserExtension::yOffset()
00569 {
00570   return 0;
00571 }
00572 
00573 void BrowserExtension::saveState( QDataStream &stream )
00574 {
00575     // TODO add d->m_part->mimeType()
00576   stream << d->m_part->url() << (qint32)xOffset() << (qint32)yOffset();
00577 }
00578 
00579 void BrowserExtension::restoreState( QDataStream &stream )
00580 {
00581   KUrl u;
00582   qint32 xOfs, yOfs;
00583   stream >> u >> xOfs >> yOfs;
00584 
00585     OpenUrlArguments args;
00586     args.setXOffset(xOfs);
00587     args.setYOffset(yOfs);
00588     // TODO add args.setMimeType
00589     d->m_part->setArguments(args);
00590     d->m_part->openUrl(u);
00591 }
00592 
00593 bool BrowserExtension::isURLDropHandlingEnabled() const
00594 {
00595     return d->m_urlDropHandlingEnabled;
00596 }
00597 
00598 void BrowserExtension::setURLDropHandlingEnabled( bool enable )
00599 {
00600     d->m_urlDropHandlingEnabled = enable;
00601 }
00602 
00603 void BrowserExtension::slotCompleted()
00604 {
00605   //empty the argument stuff, to avoid bogus/invalid values when opening a new url
00606     setBrowserArguments( BrowserArguments() );
00607 }
00608 
00609 void BrowserExtension::pasteRequest()
00610 {
00611     QString plain( "plain" );
00612     QString url = QApplication::clipboard()->text(plain, QClipboard::Selection).trimmed();
00613     // Remove linefeeds and any whitespace surrounding it.
00614     url.remove(QRegExp("[\\ ]*\\n+[\\ ]*"));
00615 
00616     // Check if it's a URL
00617     QStringList filters = KUriFilter::self()->pluginNames();
00618     filters.removeAll( "kuriikwsfilter" );
00619     filters.removeAll( "localdomainurifilter" );
00620     KUriFilterData filterData;
00621     filterData.setData( url );
00622     filterData.setCheckForExecutables( false );
00623     if ( KUriFilter::self()->filterUri( filterData, filters ) )
00624     {
00625         switch ( filterData.uriType() )
00626     {
00627         case KUriFilterData::LocalFile:
00628         case KUriFilterData::LocalDir:
00629         case KUriFilterData::NetProtocol:
00630             slotOpenUrlRequest( filterData.uri() );
00631         break;
00632         case KUriFilterData::Error:
00633         KMessageBox::sorry( d->m_part->widget(), filterData.errorMsg() );
00634         break;
00635         default:
00636         break;
00637     }
00638     }
00639     else if ( KUriFilter::self()->filterUri( filterData,
00640                     QStringList( QLatin1String( "kuriikwsfilter" ) ) ) &&
00641               url.length() < 250 )
00642     {
00643         if ( KMessageBox::questionYesNo( d->m_part->widget(),
00644             i18n( "<qt>Do you want to search the Internet for <b>%1</b>?</qt>" ,  Qt::escape(url) ),
00645             i18n( "Internet Search" ), KGuiItem( i18n( "&Search" ), "edit-find"),
00646             KStandardGuiItem::cancel(), "MiddleClickSearch" ) == KMessageBox::Yes)
00647           slotOpenUrlRequest( filterData.uri() );
00648     }
00649 }
00650 
00651 void BrowserExtension::slotOpenUrlRequest( const KUrl &url, const KParts::OpenUrlArguments& args, const KParts::BrowserArguments &browserArgs )
00652 {
00653     //kDebug() << this << " BrowserExtension::slotOpenURLRequest(): url=" << url.url();
00654     BrowserExtensionPrivate::DelayedRequest req;
00655     req.m_delayedURL = url;
00656     req.m_delayedArgs = args;
00657     req.m_delayedBrowserArgs = browserArgs;
00658     d->m_requests.append( req );
00659     QTimer::singleShot( 0, this, SLOT(slotEmitOpenUrlRequestDelayed()) );
00660 }
00661 
00662 void BrowserExtension::slotEmitOpenUrlRequestDelayed()
00663 {
00664     if (d->m_requests.isEmpty()) return;
00665     BrowserExtensionPrivate::DelayedRequest req = d->m_requests.front();
00666     d->m_requests.pop_front();
00667     emit openUrlRequestDelayed( req.m_delayedURL, req.m_delayedArgs, req.m_delayedBrowserArgs );
00668     // tricky: do not do anything here! (no access to member variables, etc.)
00669 }
00670 
00671 void BrowserExtension::setBrowserInterface( BrowserInterface *impl )
00672 {
00673     d->m_browserInterface = impl;
00674 }
00675 
00676 BrowserInterface *BrowserExtension::browserInterface() const
00677 {
00678     return d->m_browserInterface;
00679 }
00680 
00681 void BrowserExtension::slotEnableAction( const char * name, bool enabled )
00682 {
00683     //kDebug() << "BrowserExtension::slotEnableAction " << name << " " << enabled;
00684     ActionNumberMap::ConstIterator it = s_actionNumberMap->constFind( name );
00685     if ( it != s_actionNumberMap->constEnd() )
00686     {
00687         d->m_actionStatus.setBit( it.value(), enabled );
00688         //kDebug() << "BrowserExtension::slotEnableAction setting bit " << it.data() << " to " << enabled;
00689     }
00690     else
00691         kWarning() << "BrowserExtension::slotEnableAction unknown action " << name;
00692 }
00693 
00694 bool BrowserExtension::isActionEnabled( const char * name ) const
00695 {
00696     int actionNumber = (*s_actionNumberMap)[ name ];
00697     return d->m_actionStatus[ actionNumber ];
00698 }
00699 
00700 void BrowserExtension::slotSetActionText( const char * name, const QString& text )
00701 {
00702     //kDebug() << "BrowserExtension::slotSetActionText " << name << " " << text;
00703     ActionNumberMap::ConstIterator it = s_actionNumberMap->constFind( name );
00704     if ( it != s_actionNumberMap->constEnd() )
00705     {
00706         d->m_actionText[ it.value() ] = text;
00707     }
00708     else
00709         kWarning() << "BrowserExtension::slotSetActionText unknown action " << name;
00710 }
00711 
00712 QString BrowserExtension::actionText( const char * name ) const
00713 {
00714     int actionNumber = (*s_actionNumberMap)[ name ];
00715     QMap<int, QString>::ConstIterator it = d->m_actionText.constFind( actionNumber );
00716     if ( it != d->m_actionText.constEnd() )
00717         return *it;
00718     return QString();
00719 }
00720 
00721 // for compatibility
00722 BrowserExtension::ActionSlotMap BrowserExtension::actionSlotMap()
00723 {
00724     return *actionSlotMapPtr();
00725 }
00726 
00727 BrowserExtension::ActionSlotMap * BrowserExtension::actionSlotMapPtr()
00728 {
00729     if (s_actionSlotMap->isEmpty())
00730         BrowserExtensionPrivate::createActionSlotMap();
00731     return s_actionSlotMap;
00732 }
00733 
00734 BrowserExtension *BrowserExtension::childObject( QObject *obj )
00735 {
00736     return KGlobal::findDirectChild<KParts::BrowserExtension *>(obj);
00737 }
00738 
00739 namespace KParts
00740 {
00741 
00742 class BrowserHostExtension::BrowserHostExtensionPrivate
00743 {
00744 public:
00745   BrowserHostExtensionPrivate()
00746   {
00747   }
00748   ~BrowserHostExtensionPrivate()
00749   {
00750   }
00751 
00752   KParts::ReadOnlyPart *m_part;
00753 };
00754 
00755 }
00756 
00757 BrowserHostExtension::BrowserHostExtension( KParts::ReadOnlyPart *parent )
00758  : QObject( parent ), d( new BrowserHostExtensionPrivate )
00759 {
00760   d->m_part = parent;
00761 }
00762 
00763 BrowserHostExtension::~BrowserHostExtension()
00764 {
00765   delete d;
00766 }
00767 
00768 QStringList BrowserHostExtension::frameNames() const
00769 {
00770   return QStringList();
00771 }
00772 
00773 const QList<KParts::ReadOnlyPart*> BrowserHostExtension::frames() const
00774 {
00775   return QList<KParts::ReadOnlyPart*>();
00776 }
00777 
00778 bool BrowserHostExtension::openUrlInFrame( const KUrl &,
00779                                            const KParts::OpenUrlArguments&,
00780                                            const KParts::BrowserArguments & )
00781 {
00782   return false;
00783 }
00784 
00785 BrowserHostExtension *BrowserHostExtension::childObject( QObject *obj )
00786 {
00787     return KGlobal::findDirectChild<KParts::BrowserHostExtension *>(obj);
00788 }
00789 
00790 BrowserHostExtension *
00791 BrowserHostExtension::findFrameParent(KParts::ReadOnlyPart *callingPart, const QString &frame)
00792 {
00793     Q_UNUSED(callingPart);
00794     Q_UNUSED(frame);
00795     return 0;
00796 }
00797 
00798 LiveConnectExtension::LiveConnectExtension( KParts::ReadOnlyPart *parent )
00799  : QObject( parent ), d( 0 ) {}
00800 
00801 LiveConnectExtension::~LiveConnectExtension() {}
00802 
00803 bool LiveConnectExtension::get( const unsigned long, const QString &, Type &, unsigned long &, QString & ) {
00804     return false;
00805 }
00806 
00807 bool LiveConnectExtension::put( const unsigned long, const QString &, const QString & ) {
00808     return false;
00809 }
00810 
00811 bool LiveConnectExtension::call( const unsigned long, const QString &, const QStringList &, Type &, unsigned long &, QString & ) {
00812     return false;
00813 }
00814 
00815 void LiveConnectExtension::unregister( const unsigned long ) {}
00816 
00817 LiveConnectExtension *LiveConnectExtension::childObject( QObject *obj )
00818 {
00819     return KGlobal::findDirectChild<KParts::LiveConnectExtension *>(obj);
00820 }
00821 
00822 #include "browserextension.moc"
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Wed May 2 2012 18:37:09 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KParts

Skip menu "KParts"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs-4.8.3 API Reference

Skip menu "kdelibs-4.8.3 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal