kparts Library API Documentation

browserextension.h

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., 59 Temple Place - Suite 330, 00018 Boston, MA 02111-1307, USA. 00019 */ 00020 00021 #ifndef __kparts_browserextension_h__ 00022 #define __kparts_browserextension_h__ 00023 00024 #include <sys/types.h> 00025 00026 #include <qpoint.h> 00027 #include <qptrlist.h> 00028 #include <qdatastream.h> 00029 #include <qstringlist.h> 00030 #include <qpair.h> 00031 00032 #include <kparts/part.h> 00033 #include <kparts/event.h> 00034 00035 class KFileItem; 00036 typedef QPtrList<KFileItem> KFileItemList; 00037 class QString; 00038 00039 namespace KParts { 00040 00041 class BrowserInterface; 00042 00043 struct URLArgsPrivate; 00044 00057 struct KPARTS_EXPORT URLArgs 00058 { 00059 URLArgs(); 00060 URLArgs( const URLArgs &args ); 00061 URLArgs &operator=( const URLArgs &args); 00062 00063 URLArgs( bool reload, int xOffset, int yOffset, const QString &serviceType = QString::null ); 00064 virtual ~URLArgs(); 00065 00070 QStringList docState; 00071 00075 bool reload; 00081 int xOffset; 00085 int yOffset; 00089 QString serviceType; 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 00134 QMap<QString, QString> &metaData(); 00135 00139 QString frameName; 00140 00146 bool trustedSource; 00147 00152 bool redirectedRequest () const; 00153 00160 void setRedirectedRequest(bool redirected); 00161 00166 void setForcesNewWindow( bool forcesNewWindow ); 00167 00172 bool forcesNewWindow() const; 00173 00174 URLArgsPrivate *d; 00175 }; 00176 00177 struct WindowArgsPrivate; 00178 00184 struct KPARTS_EXPORT WindowArgs 00185 { 00186 WindowArgs(); 00187 WindowArgs( const WindowArgs &args ); 00188 WindowArgs &operator=( const WindowArgs &args ); 00189 WindowArgs( const QRect &_geometry, bool _fullscreen, bool _menuBarVisible, 00190 bool _toolBarsVisible, bool _statusBarVisible, bool _resizable ); 00191 WindowArgs( int _x, int _y, int _width, int _height, bool _fullscreen, 00192 bool _menuBarVisible, bool _toolBarsVisible, 00193 bool _statusBarVisible, bool _resizable ); 00194 00195 // Position 00196 int x; 00197 int y; 00198 // Size 00199 int width; 00200 int height; 00201 bool fullscreen; //defaults to false 00202 bool menuBarVisible; //defaults to true 00203 bool toolBarsVisible; //defaults to true 00204 bool statusBarVisible; //defaults to true 00205 bool resizable; //defaults to true 00206 00207 bool lowerWindow; //defaults to false 00208 00209 WindowArgsPrivate *d; // yes, I am paranoid :-) 00210 }; 00211 00212 class KPARTS_EXPORT OpenURLEvent : public Event 00213 { 00214 public: 00215 OpenURLEvent( ReadOnlyPart *part, const KURL &url, const URLArgs &args = URLArgs() ); 00216 virtual ~OpenURLEvent(); 00217 00218 ReadOnlyPart *part() const { return m_part; } 00219 KURL url() const { return m_url; } 00220 URLArgs args() const { return m_args; } 00221 00222 static bool test( const QEvent *event ) { return Event::test( event, s_strOpenURLEvent ); } 00223 00224 private: 00225 static const char *s_strOpenURLEvent; 00226 ReadOnlyPart *m_part; 00227 KURL m_url; 00228 URLArgs m_args; 00229 00230 class OpenURLEventPrivate; 00231 OpenURLEventPrivate *d; 00232 }; 00233 00234 class BrowserExtensionPrivate; 00235 00298 class KPARTS_EXPORT BrowserExtension : public QObject 00299 { 00300 Q_OBJECT 00301 Q_PROPERTY( bool urlDropHandling READ isURLDropHandlingEnabled WRITE setURLDropHandlingEnabled ) 00302 public: 00309 BrowserExtension( KParts::ReadOnlyPart *parent, 00310 const char *name = 0L ); 00311 00312 00313 virtual ~BrowserExtension(); 00314 00315 typedef uint PopupFlags; 00316 00334 enum { DefaultPopupItems=0x0000, ShowNavigationItems=0x0001, 00335 ShowUp=0x0002, ShowReload=0x0004, ShowBookmark=0x0008, 00336 ShowCreateDirectory=0x0010, ShowTextSelectionItems=0x0020, 00337 NoDeletion=0x0040 00338 }; 00339 00340 00346 virtual void setURLArgs( const URLArgs &args ); 00347 00353 URLArgs urlArgs() const; 00354 00360 virtual int xOffset(); 00366 virtual int yOffset(); 00367 00375 virtual void saveState( QDataStream &stream ); 00376 00384 virtual void restoreState( QDataStream &stream ); 00385 00391 bool isURLDropHandlingEnabled() const; 00392 00403 void setURLDropHandlingEnabled( bool enable ); 00404 00405 void setBrowserInterface( BrowserInterface *impl ); 00406 BrowserInterface *browserInterface() const; 00407 00414 bool isActionEnabled( const char * name ) const; 00415 00416 typedef QMap<QCString,QCString> ActionSlotMap; 00445 static ActionSlotMap actionSlotMap(); 00446 00451 static ActionSlotMap * actionSlotMapPtr(); 00452 00457 static BrowserExtension *childObject( QObject *obj ); 00458 00463 void pasteRequest(); 00464 // KDE invents support for public signals... 00465 #undef signals 00466 #define signals public 00467 signals: 00468 #undef signals 00469 #define signals protected 00470 00475 void enableAction( const char * name, bool enabled ); 00476 00483 void openURLRequest( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() ); 00484 00491 void openURLRequestDelayed( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() ); 00492 00508 void openURLNotify(); 00509 00513 void setLocationBarURL( const QString &url ); 00514 00518 void setIconURL( const KURL &url ); 00519 00527 void createNewWindow( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() ); 00528 00536 void createNewWindow( const KURL &url, const KParts::URLArgs &args, 00537 const KParts::WindowArgs &windowArgs, KParts::ReadOnlyPart *&part ); 00538 00547 void loadingProgress( int percent ); 00551 void speedProgress( int bytesPerSecond ); 00552 00553 void infoMessage( const QString & ); 00554 00559 void popupMenu( const QPoint &global, const KFileItemList &items ); 00560 00567 void popupMenu( KXMLGUIClient *client, const QPoint &global, const KFileItemList &items ); 00568 00569 void popupMenu( KXMLGUIClient *client, const QPoint &global, const KFileItemList &items, const KParts::URLArgs &args, KParts::BrowserExtension::PopupFlags i ); 00570 00579 void popupMenu( const QPoint &global, const KURL &url, 00580 const QString &mimeType, mode_t mode = (mode_t)-1 ); 00581 00591 void popupMenu( KXMLGUIClient *client, 00592 const QPoint &global, const KURL &url, 00593 const QString &mimeType, mode_t mode = (mode_t)-1 ); 00594 00604 void popupMenu( KXMLGUIClient *client, 00605 const QPoint &global, const KURL &url, 00606 const KParts::URLArgs &args, KParts::BrowserExtension::PopupFlags i, mode_t mode = (mode_t)-1 ); 00607 00613 void selectionInfo( const KFileItemList &items ); 00618 void selectionInfo( const QString &text ); 00623 void selectionInfo( const KURL::List &urls ); 00624 00629 void mouseOverInfo( const KFileItem* item ); 00630 00635 void addWebSideBar(const KURL &url, const QString& name); 00636 00640 void moveTopLevelWidget( int x, int y ); 00641 00645 void resizeTopLevelWidget( int w, int h ); 00646 00651 void requestFocus(KParts::ReadOnlyPart *part); 00652 00658 void setPageSecurity( int ); 00659 00660 private slots: 00661 void slotCompleted(); 00662 void slotOpenURLRequest( const KURL &url, const KParts::URLArgs &args ); 00663 void slotEmitOpenURLRequestDelayed(); 00664 void slotEnableAction( const char *, bool ); 00665 00666 private: 00667 KParts::ReadOnlyPart *m_part; 00668 URLArgs m_args; 00669 public: 00670 typedef QMap<QCString,int> ActionNumberMap; 00671 00672 private: 00673 static ActionNumberMap * s_actionNumberMap; 00674 static ActionSlotMap * s_actionSlotMap; 00675 static void createActionSlotMap(); 00676 protected: 00677 virtual void virtual_hook( int id, void* data ); 00678 private: 00679 BrowserExtensionPrivate *d; 00680 }; 00681 00687 class KPARTS_EXPORT BrowserHostExtension : public QObject 00688 { 00689 Q_OBJECT 00690 public: 00691 BrowserHostExtension( KParts::ReadOnlyPart *parent, 00692 const char *name = 0L ); 00693 00694 virtual ~BrowserHostExtension(); 00695 00701 virtual QStringList frameNames() const; 00702 00708 virtual const QPtrList<KParts::ReadOnlyPart> frames() const; 00709 00715 BrowserHostExtension *findFrameParent(KParts::ReadOnlyPart *callingPart, const QString &frame); 00716 00721 virtual bool openURLInFrame( const KURL &url, const KParts::URLArgs &urlArgs ); 00722 00727 static BrowserHostExtension *childObject( QObject *obj ); 00728 00729 protected: 00735 enum { VIRTUAL_FIND_FRAME_PARENT = 0x10 }; 00736 struct FindFrameParentParams 00737 { 00738 BrowserHostExtension *parent; 00739 KParts::ReadOnlyPart *callingPart; 00740 QString frame; 00741 }; 00742 00743 virtual void virtual_hook( int id, void* data ); 00744 private: 00745 class BrowserHostExtensionPrivate; 00746 BrowserHostExtensionPrivate *d; 00747 }; 00748 00755 class KPARTS_EXPORT LiveConnectExtension : public QObject 00756 { 00757 Q_OBJECT 00758 public: 00759 enum Type { 00760 TypeVoid=0, TypeBool, TypeFunction, TypeNumber, TypeObject, TypeString 00761 }; 00762 typedef QValueList<QPair<Type, QString> > ArgList; 00763 00764 LiveConnectExtension( KParts::ReadOnlyPart *parent, const char *name = 0L ); 00765 00766 virtual ~LiveConnectExtension() {} 00770 virtual bool get( const unsigned long objid, const QString & field, Type & type, unsigned long & retobjid, QString & value ); 00774 virtual bool put( const unsigned long objid, const QString & field, const QString & value ); 00778 virtual bool call( const unsigned long objid, const QString & func, const QStringList & args, Type & type, unsigned long & retobjid, QString & value ); 00782 virtual void unregister( const unsigned long objid ); 00783 00784 static LiveConnectExtension *childObject( QObject *obj ); 00785 signals: 00789 virtual void partEvent( const unsigned long objid, const QString & event, const ArgList & args ); 00790 }; 00791 00792 } 00793 00794 #endif 00795
KDE Logo
This file is part of the documentation for kparts Library Version 3.4.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Apr 14 00:31:29 2005 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003