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 
00031 #include <kparts/part.h>
00032 #include <kparts/event.h>
00033 
00034 class KFileItem;
00035 typedef QPtrList<KFileItem> KFileItemList;
00036 class QString;
00037 
00038 namespace KParts {
00039 
00040 class BrowserInterface;
00041 
00042 struct URLArgsPrivate;
00043 
00056 struct URLArgs
00057 {
00058   URLArgs();
00059   URLArgs( const URLArgs &args );
00060   URLArgs &operator=( const URLArgs &args);
00061 
00062   URLArgs( bool reload, int xOffset, int yOffset, const QString &serviceType = QString::null );
00063   virtual ~URLArgs();
00064 
00069   QStringList docState;
00070 
00074   bool reload;
00080   int xOffset;
00084   int yOffset;
00088   QString serviceType;
00089 
00093   QByteArray postData;
00097   void setContentType( const QString & contentType );
00101   QString contentType() const;
00106   void setDoPost( bool enable );
00111   bool doPost() const;
00112 
00118   void setLockHistory( bool lock );
00119   bool lockHistory() const;
00120 
00124   void setNewTab( bool newTab );
00125   bool newTab() const;
00126 
00131   QMap<QString, QString> &metaData();
00132 
00136   QString frameName;
00137 
00143   bool trustedSource;
00144 
00148   bool redirectedRequest () const;
00149 
00153   void setRedirectedRequest(bool redirected);
00154 
00155   URLArgsPrivate *d;
00156 };
00157 
00158 struct WindowArgsPrivate;
00159 
00165 struct WindowArgs
00166 {
00167     WindowArgs();
00168     WindowArgs( const WindowArgs &args );
00169     WindowArgs &operator=( const WindowArgs &args );
00170     WindowArgs( const QRect &_geometry, bool _fullscreen, bool _menuBarVisible,
00171                 bool _toolBarsVisible, bool _statusBarVisible, bool _resizable );
00172     WindowArgs( int _x, int _y, int _width, int _height, bool _fullscreen,
00173                 bool _menuBarVisible, bool _toolBarsVisible,
00174                 bool _statusBarVisible, bool _resizable );
00175 
00176     // Position
00177     int x;
00178     int y;
00179     // Size
00180     int width;
00181     int height;
00182     bool fullscreen; //defaults to false
00183     bool menuBarVisible; //defaults to true
00184     bool toolBarsVisible; //defaults to true
00185     bool statusBarVisible; //defaults to true
00186     bool resizable; //defaults to true
00187 
00188     bool lowerWindow; //defaults to false
00189 
00190     WindowArgsPrivate *d; // yes, I am paranoid :-)
00191 };
00192 
00193 class OpenURLEvent : public Event
00194 {
00195 public:
00196   OpenURLEvent( ReadOnlyPart *part, const KURL &url, const URLArgs &args = URLArgs() );
00197   virtual ~OpenURLEvent();
00198 
00199   ReadOnlyPart *part() const { return m_part; }
00200   KURL url() const { return m_url; }
00201   URLArgs args() const { return m_args; }
00202 
00203   static bool test( const QEvent *event ) { return Event::test( event, s_strOpenURLEvent ); }
00204 
00205 private:
00206   static const char *s_strOpenURLEvent;
00207   ReadOnlyPart *m_part;
00208   KURL m_url;
00209   URLArgs m_args;
00210 
00211   class OpenURLEventPrivate;
00212   OpenURLEventPrivate *d;
00213 };
00214 
00215 class BrowserExtensionPrivate;
00216 
00278 class BrowserExtension : public QObject
00279 {
00280   Q_OBJECT
00281   Q_PROPERTY( bool urlDropHandling READ isURLDropHandlingEnabled WRITE setURLDropHandlingEnabled )
00282 public:
00289   BrowserExtension( KParts::ReadOnlyPart *parent,
00290                     const char *name = 0L );
00291 
00292 
00293   virtual ~BrowserExtension();
00294 
00300   virtual void setURLArgs( const URLArgs &args );
00301 
00307   URLArgs urlArgs() const;
00308 
00314   virtual int xOffset();
00320   virtual int yOffset();
00321 
00329   virtual void saveState( QDataStream &stream );
00330 
00338   virtual void restoreState( QDataStream &stream );
00339 
00345   bool isURLDropHandlingEnabled() const;
00346 
00357   void setURLDropHandlingEnabled( bool enable );
00358 
00359   void setBrowserInterface( BrowserInterface *impl );
00360   BrowserInterface *browserInterface() const;
00361 
00368   bool isActionEnabled( const char * name ) const;
00369 
00370   typedef QMap<QCString,QCString> ActionSlotMap;
00399   static ActionSlotMap actionSlotMap();
00400 
00405   static ActionSlotMap * actionSlotMapPtr();
00406 
00411   static BrowserExtension *childObject( QObject *obj );
00412 
00413 // KDE invents support for public signals...
00414 #undef signals
00415 #define signals public
00416 signals:
00417 #undef signals
00418 #define signals protected
00419 
00424   void enableAction( const char * name, bool enabled );
00425 
00432   void openURLRequest( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() );
00433 
00440   void openURLRequestDelayed( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() );
00441 
00457   void openURLNotify();
00458 
00462   void setLocationBarURL( const QString &url );
00463 
00467   void setIconURL( const KURL &url );
00468 
00476   void createNewWindow( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() );
00477 
00485   void createNewWindow( const KURL &url, const KParts::URLArgs &args,
00486                         const KParts::WindowArgs &windowArgs, KParts::ReadOnlyPart *&part );
00487 
00496   void loadingProgress( int percent );
00500   void speedProgress( int bytesPerSecond );
00501 
00502   void infoMessage( const QString & );
00503 
00508   void popupMenu( const QPoint &global, const KFileItemList &items );
00509 
00516   void popupMenu( KXMLGUIClient *client, const QPoint &global, const KFileItemList &items );
00517 
00526   void popupMenu( const QPoint &global, const KURL &url,
00527                   const QString &mimeType, mode_t mode = (mode_t)-1 );
00528 
00538   void popupMenu( KXMLGUIClient *client,
00539                   const QPoint &global, const KURL &url,
00540                   const QString &mimeType, mode_t mode = (mode_t)-1 );
00541 
00547   void selectionInfo( const KFileItemList &items );
00552   void selectionInfo( const QString &text );
00557   void selectionInfo( const KURL::List &urls );
00558 
00563   void mouseOverInfo( const KFileItem* item );
00564 
00565 private slots:
00566   void slotCompleted();
00567   void slotOpenURLRequest( const KURL &url, const KParts::URLArgs &args );
00568   void slotEmitOpenURLRequestDelayed();
00569   void slotEnableAction( const char *, bool );
00570 
00571 private:
00572   KParts::ReadOnlyPart *m_part;
00573   URLArgs m_args;
00574 public:
00575   typedef QMap<QCString,int> ActionNumberMap;
00576 
00577 private:
00578   static ActionNumberMap * s_actionNumberMap;
00579   static ActionSlotMap * s_actionSlotMap;
00580   static void createActionSlotMap();
00581 protected:
00582   virtual void virtual_hook( int id, void* data );
00583 private:
00584   BrowserExtensionPrivate *d;
00585 };
00586 
00592 class BrowserHostExtension : public QObject
00593 {
00594   Q_OBJECT
00595 public:
00596   BrowserHostExtension( KParts::ReadOnlyPart *parent,
00597                         const char *name = 0L );
00598 
00599   virtual ~BrowserHostExtension();
00600 
00606   virtual QStringList frameNames() const;
00607 
00613   virtual const QPtrList<KParts::ReadOnlyPart> frames() const;
00614 
00620   BrowserHostExtension *findFrameParent(KParts::ReadOnlyPart *callingPart, const QString &frame);
00621 
00626   virtual bool openURLInFrame( const KURL &url, const KParts::URLArgs &urlArgs );
00627 
00632   static BrowserHostExtension *childObject( QObject *obj );
00633 
00634 protected:
00640   enum { VIRTUAL_FIND_FRAME_PARENT = 0x10 };
00641   struct FindFrameParentParams
00642   {
00643       BrowserHostExtension *parent;
00644       KParts::ReadOnlyPart *callingPart;
00645       QString frame;
00646   };
00647                                                     
00648   virtual void virtual_hook( int id, void* data );
00649 private:
00650   class BrowserHostExtensionPrivate;
00651   BrowserHostExtensionPrivate *d;
00652 };
00653 
00660 class LiveConnectExtension : public QObject
00661 {
00662   Q_OBJECT
00663 public:
00664   enum Type {
00665       TypeVoid=0, TypeBool, TypeFunction, TypeNumber, TypeObject, TypeString
00666   };
00667   typedef QValueList<QPair<Type, QString> > ArgList;
00668 
00669   LiveConnectExtension( KParts::ReadOnlyPart *parent, const char *name = 0L );
00670 
00671   virtual ~LiveConnectExtension() {}
00675   virtual bool get( const unsigned long objid, const QString & field, Type & type, unsigned long & retobjid, QString & value );
00679   virtual bool put( const unsigned long objid, const QString & field, const QString & value );
00683   virtual bool call( const unsigned long objid, const QString & func, const QStringList & args, Type & type, unsigned long & retobjid, QString & value );
00687   virtual void unregister( const unsigned long objid );
00688 
00689   static LiveConnectExtension *childObject( QObject *obj );
00690 signals:
00694   virtual void partEvent( const unsigned long objid, const QString & event, const ArgList & args );
00695 };
00696 
00697 }
00698 
00699 #endif
00700 
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 27 22:15:44 2005 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001