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 00286 class BrowserExtension : public QObject 00287 { 00288 Q_OBJECT 00289 Q_PROPERTY( bool urlDropHandling READ isURLDropHandlingEnabled WRITE setURLDropHandlingEnabled ) 00290 public: 00297 BrowserExtension( KParts::ReadOnlyPart *parent, 00298 const char *name = 0L ); 00299 00300 00301 virtual ~BrowserExtension(); 00302 00303 typedef uint PopupFlags; 00304 00315 enum { DefaultPopupItems=0x0000, ShowNavigationItems=0x0001, 00316 ShowUp=0x0002, ShowReload=0x0004, ShowBookmark=0x0008, 00317 ShowCreateDirectory=0x0010, ShowTextSelectionItems=0x0020}; 00318 00319 00325 virtual void setURLArgs( const URLArgs &args ); 00326 00332 URLArgs urlArgs() const; 00333 00339 virtual int xOffset(); 00345 virtual int yOffset(); 00346 00354 virtual void saveState( QDataStream &stream ); 00355 00363 virtual void restoreState( QDataStream &stream ); 00364 00370 bool isURLDropHandlingEnabled() const; 00371 00382 void setURLDropHandlingEnabled( bool enable ); 00383 00384 void setBrowserInterface( BrowserInterface *impl ); 00385 BrowserInterface *browserInterface() const; 00386 00393 bool isActionEnabled( const char * name ) const; 00394 00395 typedef QMap<QCString,QCString> ActionSlotMap; 00424 static ActionSlotMap actionSlotMap(); 00425 00430 static ActionSlotMap * actionSlotMapPtr(); 00431 00436 static BrowserExtension *childObject( QObject *obj ); 00437 00442 void pasteRequest(); 00443 // KDE invents support for public signals... 00444 #undef signals 00445 #define signals public 00446 signals: 00447 #undef signals 00448 #define signals protected 00449 00454 void enableAction( const char * name, bool enabled ); 00455 00462 void openURLRequest( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() ); 00463 00470 void openURLRequestDelayed( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() ); 00471 00487 void openURLNotify(); 00488 00492 void setLocationBarURL( const QString &url ); 00493 00497 void setIconURL( const KURL &url ); 00498 00506 void createNewWindow( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() ); 00507 00515 void createNewWindow( const KURL &url, const KParts::URLArgs &args, 00516 const KParts::WindowArgs &windowArgs, KParts::ReadOnlyPart *&part ); 00517 00526 void loadingProgress( int percent ); 00530 void speedProgress( int bytesPerSecond ); 00531 00532 void infoMessage( const QString & ); 00533 00538 void popupMenu( const QPoint &global, const KFileItemList &items ); 00539 00546 void popupMenu( KXMLGUIClient *client, const QPoint &global, const KFileItemList &items ); 00547 00548 void popupMenu( KXMLGUIClient *client, const QPoint &global, const KFileItemList &items, const KParts::URLArgs &args, KParts::BrowserExtension::PopupFlags i ); 00549 00558 void popupMenu( const QPoint &global, const KURL &url, 00559 const QString &mimeType, mode_t mode = (mode_t)-1 ); 00560 00570 void popupMenu( KXMLGUIClient *client, 00571 const QPoint &global, const KURL &url, 00572 const QString &mimeType, mode_t mode = (mode_t)-1 ); 00573 00583 void popupMenu( KXMLGUIClient *client, 00584 const QPoint &global, const KURL &url, 00585 const KParts::URLArgs &args, KParts::BrowserExtension::PopupFlags i, mode_t mode = (mode_t)-1 ); 00586 00592 void selectionInfo( const KFileItemList &items ); 00597 void selectionInfo( const QString &text ); 00602 void selectionInfo( const KURL::List &urls ); 00603 00608 void mouseOverInfo( const KFileItem* item ); 00609 00614 void addWebSideBar(const KURL &url, const QString& name); 00615 00619 void moveTopLevelWidget( int x, int y ); 00620 00624 void resizeTopLevelWidget( int w, int h ); 00625 00630 void requestFocus(KParts::ReadOnlyPart *part); 00631 00632 private slots: 00633 void slotCompleted(); 00634 void slotOpenURLRequest( const KURL &url, const KParts::URLArgs &args ); 00635 void slotEmitOpenURLRequestDelayed(); 00636 void slotEnableAction( const char *, bool ); 00637 00638 private: 00639 KParts::ReadOnlyPart *m_part; 00640 URLArgs m_args; 00641 public: 00642 typedef QMap<QCString,int> ActionNumberMap; 00643 00644 private: 00645 static ActionNumberMap * s_actionNumberMap; 00646 static ActionSlotMap * s_actionSlotMap; 00647 static void createActionSlotMap(); 00648 protected: 00649 virtual void virtual_hook( int id, void* data ); 00650 private: 00651 BrowserExtensionPrivate *d; 00652 }; 00653 00659 class BrowserHostExtension : public QObject 00660 { 00661 Q_OBJECT 00662 public: 00663 BrowserHostExtension( KParts::ReadOnlyPart *parent, 00664 const char *name = 0L ); 00665 00666 virtual ~BrowserHostExtension(); 00667 00673 virtual QStringList frameNames() const; 00674 00680 virtual const QPtrList<KParts::ReadOnlyPart> frames() const; 00681 00687 BrowserHostExtension *findFrameParent(KParts::ReadOnlyPart *callingPart, const QString &frame); 00688 00693 virtual bool openURLInFrame( const KURL &url, const KParts::URLArgs &urlArgs ); 00694 00699 static BrowserHostExtension *childObject( QObject *obj ); 00700 00701 protected: 00707 enum { VIRTUAL_FIND_FRAME_PARENT = 0x10 }; 00708 struct FindFrameParentParams 00709 { 00710 BrowserHostExtension *parent; 00711 KParts::ReadOnlyPart *callingPart; 00712 QString frame; 00713 }; 00714 00715 virtual void virtual_hook( int id, void* data ); 00716 private: 00717 class BrowserHostExtensionPrivate; 00718 BrowserHostExtensionPrivate *d; 00719 }; 00720 00727 class LiveConnectExtension : public QObject 00728 { 00729 Q_OBJECT 00730 public: 00731 enum Type { 00732 TypeVoid=0, TypeBool, TypeFunction, TypeNumber, TypeObject, TypeString 00733 }; 00734 typedef QValueList<QPair<Type, QString> > ArgList; 00735 00736 LiveConnectExtension( KParts::ReadOnlyPart *parent, const char *name = 0L ); 00737 00738 virtual ~LiveConnectExtension() {} 00742 virtual bool get( const unsigned long objid, const QString & field, Type & type, unsigned long & retobjid, QString & value ); 00746 virtual bool put( const unsigned long objid, const QString & field, const QString & value ); 00750 virtual bool call( const unsigned long objid, const QString & func, const QStringList & args, Type & type, unsigned long & retobjid, QString & value ); 00754 virtual void unregister( const unsigned long objid ); 00755 00756 static LiveConnectExtension *childObject( QObject *obj ); 00757 signals: 00761 virtual void partEvent( const unsigned long objid, const QString & event, const ArgList & args ); 00762 }; 00763 00764 } 00765 00766 #endif 00767
KDE Logo
This file is part of the documentation for kparts Library Version 3.3.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun Oct 17 11:31:36 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003