KParts
browserextension.h
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 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 00021 #ifndef __kparts_browserextension_h__ 00022 #define __kparts_browserextension_h__ 00023 00024 #include <sys/types.h> 00025 00026 #include <kparts/part.h> 00027 #include <kparts/event.h> 00028 00029 #include <QtCore/QSharedDataPointer> 00030 00031 template <class T1, class T2> struct QPair; 00032 template<typename T> class Q3PtrList; 00033 template <class Key, class T> class QMap; 00034 template<typename T> class QList; 00035 00036 class KFileItem; 00037 class KFileItemList; 00038 class QDataStream; 00039 class QPoint; 00040 class QString; 00041 class QStringList; 00042 00043 namespace KParts { 00044 00045 class BrowserInterface; 00046 00047 struct BrowserArgumentsPrivate; 00048 00064 struct KPARTS_EXPORT BrowserArguments 00065 { 00066 BrowserArguments(); 00067 BrowserArguments( const BrowserArguments &args ); 00068 BrowserArguments &operator=( const BrowserArguments &args); 00069 00070 virtual ~BrowserArguments(); 00071 00072 // KDE4: a struct has the problem that the stuff added after BC-freeze uses methods 00073 // so it looks inconsistent with the member vars. -> better use methods for everything, 00074 // even if they are inline. 00075 00076 00081 QStringList docState; 00082 00089 bool softReload; 00090 00094 QByteArray postData; 00095 00099 void setContentType( const QString & contentType ); 00103 QString contentType() const; 00108 void setDoPost( bool enable ); 00109 00114 bool doPost() const; 00115 00121 void setLockHistory( bool lock ); 00122 bool lockHistory() const; 00123 00127 void setNewTab( bool newTab ); 00128 bool newTab() const; 00129 00133 QString frameName; 00134 00140 bool trustedSource; 00141 00146 bool redirectedRequest () const; 00147 00154 void setRedirectedRequest(bool redirected); 00155 00174 void setForcesNewWindow( bool forcesNewWindow ); 00175 00179 bool forcesNewWindow() const; 00180 00181 private: 00182 BrowserArgumentsPrivate *d; 00183 }; 00184 00185 class WindowArgsPrivate; 00186 00192 class KPARTS_EXPORT WindowArgs 00193 { 00194 public: 00195 WindowArgs(); 00196 ~WindowArgs(); 00197 WindowArgs( const WindowArgs &args ); 00198 WindowArgs &operator=( const WindowArgs &args ); 00199 WindowArgs( const QRect &_geometry, bool _fullscreen, bool _menuBarVisible, 00200 bool _toolBarsVisible, bool _statusBarVisible, bool _resizable ); 00201 WindowArgs( int _x, int _y, int _width, int _height, bool _fullscreen, 00202 bool _menuBarVisible, bool _toolBarsVisible, 00203 bool _statusBarVisible, bool _resizable ); 00204 00205 void setX(int x); 00206 int x() const; 00207 00208 void setY(int y); 00209 int y() const; 00210 00211 void setWidth(int w); 00212 int width() const; 00213 00214 void setHeight(int h); 00215 int height() const; 00216 00217 void setFullScreen(bool fs); 00218 bool isFullScreen() const; 00219 00220 void setMenuBarVisible(bool visible); 00221 bool isMenuBarVisible() const; 00222 00223 void setToolBarsVisible(bool visible); 00224 bool toolBarsVisible() const; 00225 00226 void setStatusBarVisible(bool visible); 00227 bool isStatusBarVisible() const; 00228 00229 void setResizable(bool resizable); 00230 bool isResizable() const; 00231 00232 void setLowerWindow(bool lower); 00233 bool lowerWindow() const; 00234 00235 void setScrollBarsVisible(bool visible); 00236 bool scrollBarsVisible() const; 00237 00238 private: 00239 QSharedDataPointer<WindowArgsPrivate> d; 00240 }; 00241 00249 class KPARTS_EXPORT OpenUrlEvent : public Event 00250 { 00251 public: 00252 OpenUrlEvent( ReadOnlyPart *part, const KUrl &url, 00253 const OpenUrlArguments& args = OpenUrlArguments(), 00254 const BrowserArguments& browserArgs = BrowserArguments() ); 00255 virtual ~OpenUrlEvent(); 00256 00257 ReadOnlyPart *part() const; 00258 KUrl url() const; 00259 OpenUrlArguments arguments() const; 00260 BrowserArguments browserArguments() const; 00261 00262 static bool test( const QEvent *event ); 00263 00264 private: 00265 class OpenUrlEventPrivate; 00266 OpenUrlEventPrivate * const d; 00267 }; 00268 00320 class KPARTS_EXPORT BrowserExtension : public QObject 00321 { 00322 Q_OBJECT 00323 Q_PROPERTY( bool urlDropHandling READ isURLDropHandlingEnabled WRITE setURLDropHandlingEnabled ) 00324 public: 00330 explicit BrowserExtension( KParts::ReadOnlyPart *parent ); 00331 00332 00333 virtual ~BrowserExtension(); 00334 00338 enum PopupFlag { 00339 DefaultPopupItems=0x0000, 00340 ShowNavigationItems=0x0001, 00341 ShowUp=0x0002, 00342 ShowReload=0x0004, 00343 ShowBookmark=0x0008, 00344 ShowCreateDirectory=0x0010, 00346 ShowTextSelectionItems=0x0020, 00347 NoDeletion=0x0040, 00349 IsLink=0x0080, 00350 ShowUrlOperations=0x0100, 00351 ShowProperties=0x200 00352 }; 00353 00354 Q_DECLARE_FLAGS( PopupFlags, PopupFlag ) 00355 00356 00361 virtual void setBrowserArguments( const BrowserArguments &args ); 00362 00368 BrowserArguments browserArguments() const; 00369 00375 virtual int xOffset(); 00381 virtual int yOffset(); 00382 00390 virtual void saveState( QDataStream &stream ); 00391 00399 virtual void restoreState( QDataStream &stream ); 00400 00406 bool isURLDropHandlingEnabled() const; 00407 00418 void setURLDropHandlingEnabled( bool enable ); 00419 00420 void setBrowserInterface( BrowserInterface *impl ); 00421 BrowserInterface *browserInterface() const; 00422 00429 bool isActionEnabled( const char * name ) const; 00430 00437 QString actionText( const char * name ) const; 00438 00439 typedef QMap<QByteArray,QByteArray> ActionSlotMap; 00468 static ActionSlotMap actionSlotMap(); 00469 00474 static ActionSlotMap * actionSlotMapPtr(); 00475 00480 static BrowserExtension *childObject( QObject *obj ); 00481 00485 void pasteRequest(); 00486 00493 typedef QMap<QString, QList<QAction *> > ActionGroupMap; 00494 00495 Q_SIGNALS: 00496 #if !defined(Q_MOC_RUN) && !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(IN_IDE_PARSER) 00497 public: // yes, those signals are public; don't tell moc, doxygen or kdevelop :) 00498 #endif 00499 00504 void enableAction( const char * name, bool enabled ); 00505 00512 void setActionText( const char * name, const QString& text ); 00513 00520 void openUrlRequest( const KUrl &url, 00521 const KParts::OpenUrlArguments& arguments = KParts::OpenUrlArguments(), 00522 const KParts::BrowserArguments &browserArguments = KParts::BrowserArguments() ); 00523 00530 void openUrlRequestDelayed( const KUrl &url, 00531 const KParts::OpenUrlArguments& arguments, 00532 const KParts::BrowserArguments &browserArguments ); 00533 00549 void openUrlNotify(); 00550 00554 void setLocationBarUrl( const QString &url ); 00555 00559 void setIconUrl( const KUrl &url ); 00560 00575 void createNewWindow( const KUrl &url, 00576 const KParts::OpenUrlArguments& arguments = KParts::OpenUrlArguments(), 00577 const KParts::BrowserArguments &browserArguments = KParts::BrowserArguments(), 00578 const KParts::WindowArgs &windowArgs = KParts::WindowArgs(), 00579 KParts::ReadOnlyPart** part = 0 ); // TODO consider moving to BrowserHostExtension? 00580 00589 void loadingProgress( int percent ); 00593 void speedProgress( int bytesPerSecond ); 00594 00595 void infoMessage( const QString & ); 00596 00607 void popupMenu( const QPoint &global, const KFileItemList &items, 00608 const KParts::OpenUrlArguments &args = KParts::OpenUrlArguments(), 00609 const KParts::BrowserArguments &browserArgs = KParts::BrowserArguments(), 00610 KParts::BrowserExtension::PopupFlags flags = KParts::BrowserExtension::DefaultPopupItems, 00611 const KParts::BrowserExtension::ActionGroupMap& actionGroups = ActionGroupMap() ); 00612 00627 void popupMenu( const QPoint &global, const KUrl &url, 00628 mode_t mode = static_cast<mode_t>(-1), 00629 const KParts::OpenUrlArguments &args = KParts::OpenUrlArguments(), 00630 const KParts::BrowserArguments &browserArgs = KParts::BrowserArguments(), 00631 KParts::BrowserExtension::PopupFlags flags = KParts::BrowserExtension::DefaultPopupItems, 00632 const KParts::BrowserExtension::ActionGroupMap& actionGroups = ActionGroupMap() ); 00633 00639 void selectionInfo( const KFileItemList& items ); 00644 void selectionInfo( const QString &text ); 00649 void selectionInfo( const KUrl::List &urls ); 00650 00655 void mouseOverInfo( const KFileItem& item ); 00656 00661 void addWebSideBar(const KUrl &url, const QString& name); 00662 00666 void moveTopLevelWidget( int x, int y ); 00667 00671 void resizeTopLevelWidget( int w, int h ); 00672 00676 void requestFocus(KParts::ReadOnlyPart *part); 00677 00682 void setPageSecurity( int ); 00683 00687 void itemsRemoved( const KFileItemList &items ); 00688 00689 private Q_SLOTS: 00690 void slotCompleted(); 00691 void slotOpenUrlRequest( const KUrl &url, 00692 const KParts::OpenUrlArguments& arguments = KParts::OpenUrlArguments(), 00693 const KParts::BrowserArguments &browserArguments = KParts::BrowserArguments() ); 00694 00695 void slotEmitOpenUrlRequestDelayed(); 00696 void slotEnableAction( const char *, bool ); 00697 void slotSetActionText( const char*, const QString& ); 00698 00699 public: 00700 typedef QMap<QByteArray,int> ActionNumberMap; 00701 00702 private: 00703 class BrowserExtensionPrivate; 00704 BrowserExtensionPrivate * const d; 00705 }; 00706 00712 class KPARTS_EXPORT BrowserHostExtension : public QObject 00713 { 00714 Q_OBJECT 00715 public: 00716 BrowserHostExtension( KParts::ReadOnlyPart *parent ); 00717 00718 virtual ~BrowserHostExtension(); 00719 00725 virtual QStringList frameNames() const; 00726 00732 virtual const QList<KParts::ReadOnlyPart*> frames() const; 00733 00738 virtual BrowserHostExtension *findFrameParent(KParts::ReadOnlyPart *callingPart, const QString &frame); 00739 00744 virtual bool openUrlInFrame( const KUrl &url, 00745 const KParts::OpenUrlArguments& arguments, 00746 const KParts::BrowserArguments &browserArguments ); 00747 00752 static BrowserHostExtension *childObject( QObject *obj ); 00753 00754 private: 00755 class BrowserHostExtensionPrivate; 00756 BrowserHostExtensionPrivate * const d; 00757 }; 00758 00765 class KPARTS_EXPORT LiveConnectExtension : public QObject 00766 { 00767 Q_OBJECT 00768 public: 00769 enum Type { 00770 TypeVoid=0, TypeBool, TypeFunction, TypeNumber, TypeObject, TypeString 00771 }; 00772 typedef QList<QPair<Type, QString> > ArgList; 00773 00774 LiveConnectExtension( KParts::ReadOnlyPart *parent ); 00775 00776 virtual ~LiveConnectExtension(); 00780 virtual bool get( const unsigned long objid, const QString & field, Type & type, unsigned long & retobjid, QString & value ); 00784 virtual bool put( const unsigned long objid, const QString & field, const QString & value ); 00788 virtual bool call( const unsigned long objid, const QString & func, const QStringList & args, Type & type, unsigned long & retobjid, QString & value ); 00792 virtual void unregister( const unsigned long objid ); 00793 00794 static LiveConnectExtension *childObject( QObject *obj ); 00795 Q_SIGNALS: 00796 #if !defined(Q_MOC_RUN) && !defined(DOXYGEN_SHOULD_SKIP_THIS) && !defined(IN_IDE_PARSER) 00797 public: // yes, those signals are public; don't tell moc, doxygen or kdevelop :) 00798 #endif 00799 00802 void partEvent( const unsigned long objid, const QString & event, const KParts::LiveConnectExtension::ArgList & args ); 00803 00804 private: 00805 class LiveConnectExtensionPrivate; 00806 LiveConnectExtensionPrivate * const d; 00807 }; 00808 00809 } 00810 00811 Q_DECLARE_OPERATORS_FOR_FLAGS( KParts::BrowserExtension::PopupFlags ) 00812 00813 #endif 00814
KDE 4.6 API Reference