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