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 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 
00162   URLArgsPrivate *d;
00163 };
00164 
00165 struct WindowArgsPrivate;
00166 
00172 struct WindowArgs
00173 {
00174     WindowArgs();
00175     WindowArgs( const WindowArgs &args );
00176     WindowArgs &operator=( const WindowArgs &args );
00177     WindowArgs( const QRect &_geometry, bool _fullscreen, bool _menuBarVisible,
00178                 bool _toolBarsVisible, bool _statusBarVisible, bool _resizable );
00179     WindowArgs( int _x, int _y, int _width, int _height, bool _fullscreen,
00180                 bool _menuBarVisible, bool _toolBarsVisible,
00181                 bool _statusBarVisible, bool _resizable );
00182 
00183     // Position
00184     int x;
00185     int y;
00186     // Size
00187     int width;
00188     int height;
00189     bool fullscreen; //defaults to false
00190     bool menuBarVisible; //defaults to true
00191     bool toolBarsVisible; //defaults to true
00192     bool statusBarVisible; //defaults to true
00193     bool resizable; //defaults to true
00194 
00195     bool lowerWindow; //defaults to false
00196 
00197     WindowArgsPrivate *d; // yes, I am paranoid :-)
00198 };
00199 
00200 class OpenURLEvent : public Event
00201 {
00202 public:
00203   OpenURLEvent( ReadOnlyPart *part, const KURL &url, const URLArgs &args = URLArgs() );
00204   virtual ~OpenURLEvent();
00205 
00206   ReadOnlyPart *part() const { return m_part; }
00207   KURL url() const { return m_url; }
00208   URLArgs args() const { return m_args; }
00209 
00210   static bool test( const QEvent *event ) { return Event::test( event, s_strOpenURLEvent ); }
00211 
00212 private:
00213   static const char *s_strOpenURLEvent;
00214   ReadOnlyPart *m_part;
00215   KURL m_url;
00216   URLArgs m_args;
00217 
00218   class OpenURLEventPrivate;
00219   OpenURLEventPrivate *d;
00220 };
00221 
00222 class BrowserExtensionPrivate;
00223 
00285 class BrowserExtension : public QObject
00286 {
00287   Q_OBJECT
00288   Q_PROPERTY( bool urlDropHandling READ isURLDropHandlingEnabled WRITE setURLDropHandlingEnabled )
00289 public:
00296   BrowserExtension( KParts::ReadOnlyPart *parent,
00297                     const char *name = 0L );
00298 
00299 
00300   virtual ~BrowserExtension();
00301 
00302   typedef uint PopupFlags;
00303 
00314   enum { DefaultPopupItems=0x0000, ShowNavigationItems=0x0001,
00315          ShowUp=0x0002, ShowReload=0x0004, ShowBookmark=0x0008,
00316          ShowCreateDirectory=0x0010 };
00317 
00318 
00324   virtual void setURLArgs( const URLArgs &args );
00325 
00331   URLArgs urlArgs() const;
00332 
00338   virtual int xOffset();
00344   virtual int yOffset();
00345 
00353   virtual void saveState( QDataStream &stream );
00354 
00362   virtual void restoreState( QDataStream &stream );
00363 
00369   bool isURLDropHandlingEnabled() const;
00370 
00381   void setURLDropHandlingEnabled( bool enable );
00382 
00383   void setBrowserInterface( BrowserInterface *impl );
00384   BrowserInterface *browserInterface() const;
00385 
00392   bool isActionEnabled( const char * name ) const;
00393 
00394   typedef QMap<QCString,QCString> ActionSlotMap;
00423   static ActionSlotMap actionSlotMap();
00424 
00429   static ActionSlotMap * actionSlotMapPtr();
00430 
00435   static BrowserExtension *childObject( QObject *obj );
00436 
00441   void pasteRequest(); 
00442 // KDE invents support for public signals...
00443 #undef signals
00444 #define signals public
00445 signals:
00446 #undef signals
00447 #define signals protected
00448 
00453   void enableAction( const char * name, bool enabled );
00454 
00461   void openURLRequest( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() );
00462 
00469   void openURLRequestDelayed( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() );
00470 
00486   void openURLNotify();
00487 
00491   void setLocationBarURL( const QString &url );
00492 
00496   void setIconURL( const KURL &url );
00497 
00505   void createNewWindow( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() );
00506 
00514   void createNewWindow( const KURL &url, const KParts::URLArgs &args,
00515                         const KParts::WindowArgs &windowArgs, KParts::ReadOnlyPart *&part );
00516 
00525   void loadingProgress( int percent );
00529   void speedProgress( int bytesPerSecond );
00530 
00531   void infoMessage( const QString & );
00532 
00537   void popupMenu( const QPoint &global, const KFileItemList &items );
00538 
00545   void popupMenu( KXMLGUIClient *client, const QPoint &global, const KFileItemList &items );
00546 
00547   void popupMenu( KXMLGUIClient *client, const QPoint &global, const KFileItemList &items, const KParts::URLArgs &args, KParts::BrowserExtension::PopupFlags i );
00548 
00557   void popupMenu( const QPoint &global, const KURL &url,
00558                   const QString &mimeType, mode_t mode = (mode_t)-1 );
00559 
00569   void popupMenu( KXMLGUIClient *client,
00570                   const QPoint &global, const KURL &url,
00571                   const QString &mimeType, mode_t mode = (mode_t)-1 );
00572 
00582   void popupMenu( KXMLGUIClient *client,
00583                   const QPoint &global, const KURL &url,
00584                   const KParts::URLArgs &args, KParts::BrowserExtension::PopupFlags i, mode_t mode = (mode_t)-1 );
00585 
00591   void selectionInfo( const KFileItemList &items );
00596   void selectionInfo( const QString &text );
00601   void selectionInfo( const KURL::List &urls );
00602 
00607   void mouseOverInfo( const KFileItem* item );
00608 
00613   void addWebSideBar(const KURL &url, const QString& name);
00614 
00618   void moveTopLevelWidget( int x, int y );
00619 
00623   void resizeTopLevelWidget( int w, int h );
00624 
00625 
00626 private slots:
00627   void slotCompleted();
00628   void slotOpenURLRequest( const KURL &url, const KParts::URLArgs &args );
00629   void slotEmitOpenURLRequestDelayed();
00630   void slotEnableAction( const char *, bool );
00631 
00632 private:
00633   KParts::ReadOnlyPart *m_part;
00634   URLArgs m_args;
00635 public:
00636   typedef QMap<QCString,int> ActionNumberMap;
00637 
00638 private:
00639   static ActionNumberMap * s_actionNumberMap;
00640   static ActionSlotMap * s_actionSlotMap;
00641   static void createActionSlotMap();
00642 protected:
00643   virtual void virtual_hook( int id, void* data );
00644 private:
00645   BrowserExtensionPrivate *d;
00646 };
00647 
00653 class BrowserHostExtension : public QObject
00654 {
00655   Q_OBJECT
00656 public:
00657   BrowserHostExtension( KParts::ReadOnlyPart *parent,
00658                         const char *name = 0L );
00659 
00660   virtual ~BrowserHostExtension();
00661 
00667   virtual QStringList frameNames() const;
00668 
00675   virtual const QPtrList<KParts::ReadOnlyPart> frames() const;
00676 
00681   virtual bool openURLInFrame( const KURL &url, const KParts::URLArgs &urlArgs );
00682 
00687   static BrowserHostExtension *childObject( QObject *obj );
00688 
00689 protected:
00690   virtual void virtual_hook( int id, void* data );
00691 private:
00692   class BrowserHostExtensionPrivate;
00693   BrowserHostExtensionPrivate *d;
00694 };
00695 
00702 class LiveConnectExtension : public QObject
00703 {
00704   Q_OBJECT
00705 public:
00706   enum Type {
00707       TypeVoid=0, TypeBool, TypeFunction, TypeNumber, TypeObject, TypeString
00708   };
00709   typedef QValueList<QPair<Type, QString> > ArgList;
00710 
00711   LiveConnectExtension( KParts::ReadOnlyPart *parent, const char *name = 0L );
00712 
00713   virtual ~LiveConnectExtension() {}
00717   virtual bool get( const unsigned long objid, const QString & field, Type & type, unsigned long & retobjid, QString & value );
00721   virtual bool put( const unsigned long objid, const QString & field, const QString & value );
00725   virtual bool call( const unsigned long objid, const QString & func, const QStringList & args, Type & type, unsigned long & retobjid, QString & value );
00729   virtual void unregister( const unsigned long objid );
00730 
00731   static LiveConnectExtension *childObject( QObject *obj );
00732 signals:
00736   virtual void partEvent( const unsigned long objid, const QString & event, const ArgList & args );
00737 };
00738 
00739 }
00740 
00741 #endif
00742 
KDE Logo
This file is part of the documentation for kparts Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Aug 4 05:27:01 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2003