part.h00001
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
00335 class KPARTS_EXPORT ReadOnlyPart : public Part
00336 {
00337 Q_OBJECT
00338 friend class ReadWritePart;
00339 public:
00344 ReadOnlyPart( QObject *parent = 0, const char *name = 0 );
00345
00349 virtual ~ReadOnlyPart();
00350
00358 void setProgressInfoEnabled( bool show );
00359
00364 bool isProgressInfoEnabled() const;
00365
00366 #ifndef KDE_NO_COMPAT
00367 void showProgressInfo( bool show );
00368 #endif
00369
00370 public slots:
00378 virtual bool openURL( const KURL &url );
00379
00380 public:
00386 KURL url() const { return m_url; }
00387
00396 virtual bool closeURL();
00397
00398 public:
00409 bool openStream( const QString& mimeType, const KURL& url );
00410
00417 bool writeStream( const QByteArray& data );
00418
00424 bool closeStream();
00425
00426 private:
00427
00433 virtual bool doOpenStream( const QString& ) { return false; }
00440 virtual bool doWriteStream( const QByteArray& ) { return false; }
00446 virtual bool doCloseStream() { return false; }
00447
00448 signals:
00454 void started( KIO::Job * );
00455
00461 void completed();
00462
00472 void completed( bool pendingAction );
00473
00478 void canceled( const QString &errMsg );
00479
00480 protected slots:
00481 void slotJobFinished( KIO::Job * job );
00482
00483 protected:
00489 virtual bool openFile() = 0;
00490
00494 void abortLoad();
00495
00506 virtual void guiActivateEvent( GUIActivateEvent *event );
00507
00511 KURL m_url;
00515 QString m_file;
00519 bool m_bTemp;
00520
00521 private:
00522 ReadOnlyPartPrivate *d;
00523 };
00524
00540 class KPARTS_EXPORT ReadWritePart : public ReadOnlyPart
00541 {
00542 Q_OBJECT
00543 public:
00548 ReadWritePart( QObject *parent = 0, const char *name = 0 );
00557 virtual ~ReadWritePart();
00558
00562 bool isReadWrite() const { return m_bReadWrite; }
00563
00568 virtual void setReadWrite ( bool readwrite = true );
00569
00573 bool isModified() const { return m_bModified; }
00574
00585
00586 bool queryClose();
00587
00599 virtual bool closeURL();
00600
00611
00612 bool closeURL( bool promptToSave );
00613
00619 virtual bool saveAs( const KURL &url );
00620
00624 virtual void setModified( bool modified );
00625
00626 signals:
00634 void sigQueryClose(bool *handled, bool* abortClosing);
00635
00636 public slots:
00642 virtual void setModified();
00643
00649 virtual bool save();
00650
00655 bool waitSaveComplete();
00656
00657 protected:
00669 virtual bool saveFile() = 0;
00670
00679 virtual bool saveToURL();
00680
00681 protected slots:
00685 void slotUploadFinished( KIO::Job * job );
00686
00687 private:
00688 void prepareSaving();
00689
00690 private:
00691 bool m_bModified;
00692 bool m_bReadWrite;
00693 bool m_bClosing;
00694 };
00695
00696 }
00697
00698 #endif
|