KParts
part.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _KPART_H
00021 #define _KPART_H
00022
00023 #include <qstring.h>
00024 #include <qdom.h>
00025 #include <qguardedptr.h>
00026 #include <kurl.h>
00027
00028 #include <kxmlguiclient.h>
00029
00030 class KInstance;
00031 class QWidget;
00032 class KAction;
00033 class KActionCollection;
00034 class QEvent;
00035 struct QUnknownInterface;
00036
00037 namespace KIO {
00038 class Job;
00039 }
00040
00041 namespace KParts
00042 {
00043
00044 class PartManager;
00045 class Plugin;
00046 class PartPrivate;
00047 class PartActivateEvent;
00048 class PartSelectEvent;
00049 class GUIActivateEvent;
00050 class PartBasePrivate;
00051
00057 class KPARTS_EXPORT PartBase : virtual public KXMLGUIClient
00058 {
00059 friend class PartBasePrivate;
00060 public:
00061
00065 PartBase();
00066
00070 virtual ~PartBase();
00071
00077 void setPartObject( QObject *object );
00078 QObject *partObject() const;
00079
00080 protected:
00087 virtual void setInstance( KInstance *instance );
00088
00095 virtual void setInstance( KInstance *instance, bool loadPlugins );
00096
00102 enum PluginLoadingMode {
00106 DoNotLoadPlugins = 0,
00113 LoadPlugins = 1,
00120 LoadPluginsIfEnabled = 2
00121 };
00122
00143 void loadPlugins( QObject *parent, KXMLGUIClient *parentGUIClient, KInstance *instance );
00144
00149 void setPluginLoadingMode( PluginLoadingMode loadingMode );
00150
00151 private:
00152 PartBasePrivate *d;
00153 QObject *m_obj;
00154 };
00155
00181 class KPARTS_EXPORT Part : public QObject, public PartBase
00182 {
00183 Q_OBJECT
00184
00185 public:
00186
00193 Part( QObject *parent = 0, const char* name = 0 );
00194
00198 virtual ~Part();
00199
00211 virtual void embed( QWidget * parentWidget );
00212
00216 virtual QWidget *widget();
00217
00222 virtual void setManager( PartManager * manager );
00223
00227 PartManager * manager() const;
00228
00237 virtual Part *hitTest( QWidget *widget, const QPoint &globalPos );
00238
00242 virtual void setSelectable( bool selectable );
00243
00247 bool isSelectable() const;
00248
00249 signals:
00254 void setWindowCaption( const QString & caption );
00259 void setStatusBarText( const QString & text );
00260
00261 protected:
00262
00268 virtual void setWidget( QWidget * widget );
00269
00273 virtual void customEvent( QCustomEvent *event );
00274
00280 virtual void partActivateEvent( PartActivateEvent *event );
00281
00288 virtual void partSelectEvent( PartSelectEvent *event );
00289
00296 virtual void guiActivateEvent( GUIActivateEvent *event );
00297
00302 QWidget *hostContainer( const QString &containerName );
00303
00304 private slots:
00305 void slotWidgetDestroyed();
00306
00307 private:
00308 QGuardedPtr<QWidget> m_widget;
00309
00310 PartManager * m_manager;
00311
00312 PartPrivate *d;
00313 };
00314
00315 class ReadWritePart;
00316 class ReadOnlyPartPrivate;
00317
00338 class KPARTS_EXPORT ReadOnlyPart : public Part
00339 {
00340 Q_OBJECT
00341 friend class ReadWritePart;
00342 public:
00347 ReadOnlyPart( QObject *parent = 0, const char *name = 0 );
00348
00352 virtual ~ReadOnlyPart();
00353
00361 void setProgressInfoEnabled( bool show );
00362
00367 bool isProgressInfoEnabled() const;
00368
00369 #ifndef KDE_NO_COMPAT
00370 void showProgressInfo( bool show );
00371 #endif
00372
00373 public slots:
00382 virtual bool openURL( const KURL &url );
00383
00384 public:
00390 KURL url() const { return m_url; }
00391
00400 virtual bool closeURL();
00401
00402 public:
00413 bool openStream( const QString& mimeType, const KURL& url );
00414
00421 bool writeStream( const QByteArray& data );
00422
00428 bool closeStream();
00429
00430 private:
00431
00437 virtual bool doOpenStream( const QString& ) { return false; }
00444 virtual bool doWriteStream( const QByteArray& ) { return false; }
00450 virtual bool doCloseStream() { return false; }
00451
00452 signals:
00458 void started( KIO::Job * );
00459
00465 void completed();
00466
00476 void completed( bool pendingAction );
00477
00482 void canceled( const QString &errMsg );
00483
00484 protected slots:
00485 void slotJobFinished( KIO::Job * job );
00486
00487 protected:
00493 virtual bool openFile() = 0;
00494
00498 void abortLoad();
00499
00510 virtual void guiActivateEvent( GUIActivateEvent *event );
00511
00515 KURL m_url;
00519 QString m_file;
00523 bool m_bTemp;
00524
00525 private:
00526 ReadOnlyPartPrivate *d;
00527 };
00528
00544 class KPARTS_EXPORT ReadWritePart : public ReadOnlyPart
00545 {
00546 Q_OBJECT
00547 public:
00552 ReadWritePart( QObject *parent = 0, const char *name = 0 );
00561 virtual ~ReadWritePart();
00562
00566 bool isReadWrite() const { return m_bReadWrite; }
00567
00572 virtual void setReadWrite ( bool readwrite = true );
00573
00577 bool isModified() const { return m_bModified; }
00578
00589
00590 bool queryClose();
00591
00603 virtual bool closeURL();
00604
00615
00616 bool closeURL( bool promptToSave );
00617
00623 virtual bool saveAs( const KURL &url );
00624
00628 virtual void setModified( bool modified );
00629
00630 signals:
00638 void sigQueryClose(bool *handled, bool* abortClosing);
00639
00640 public slots:
00646 virtual void setModified();
00647
00653 virtual bool save();
00654
00659 bool waitSaveComplete();
00660
00661 protected:
00673 virtual bool saveFile() = 0;
00674
00683 virtual bool saveToURL();
00684
00685 protected slots:
00689 void slotUploadFinished( KIO::Job * job );
00690
00691 private:
00692 void prepareSaving();
00693
00694 private:
00695 bool m_bModified;
00696 bool m_bReadWrite;
00697 bool m_bClosing;
00698 };
00699
00700 }
00701
00702 #endif