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 <QtXml/qdom.h>
00024 #include <QtCore/QPointer>
00025 #include <QtCore/QEvent>
00026 #include <QtCore/QSharedDataPointer>
00027
00028 #include <kurl.h>
00029 #include <kxmlguiclient.h>
00030
00031 #include <kparts/kparts_export.h>
00032
00033 #define KPARTS_DECLARE_PRIVATE(Class) \
00034 inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(PartBase::d_ptr); } \
00035 inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(PartBase::d_ptr); } \
00036 friend class Class##Private;
00037
00038 class KIconLoader;
00039 class KComponentData;
00040 class QWidget;
00041 class QEvent;
00042 class QPoint;
00043 struct QUnknownInterface;
00044
00045 class KJob;
00046 namespace KIO {
00047 class Job;
00048 }
00049
00050 namespace KParts
00051 {
00052
00053 class PartManager;
00054 class Plugin;
00055 class PartPrivate;
00056 class PartActivateEvent;
00057 class PartSelectEvent;
00058 class GUIActivateEvent;
00059 class PartBasePrivate;
00060
00066 class KPARTS_EXPORT PartBase : virtual public KXMLGUIClient
00067 {
00068 KPARTS_DECLARE_PRIVATE(PartBase)
00069
00070 public:
00071
00075 PartBase();
00076
00080 virtual ~PartBase();
00081
00087 void setPartObject( QObject *object );
00088 QObject *partObject() const;
00089
00090 protected:
00097 virtual void setComponentData(const KComponentData &componentData);
00098
00105 virtual void setComponentData(const KComponentData &componentData, bool loadPlugins);
00106
00112 enum PluginLoadingMode {
00116 DoNotLoadPlugins = 0,
00123 LoadPlugins = 1,
00130 LoadPluginsIfEnabled = 2
00131 };
00132
00149 void loadPlugins(QObject *parent, KXMLGUIClient *parentGUIClient, const KComponentData &componentData);
00150
00158 void setPluginLoadingMode( PluginLoadingMode loadingMode );
00159
00172 void setPluginInterfaceVersion( int version );
00173
00174 protected:
00175 PartBase(PartBasePrivate &dd);
00176
00177 PartBasePrivate *d_ptr;
00178
00179 private:
00180 Q_DISABLE_COPY(PartBase)
00181 };
00182
00208 class KPARTS_EXPORT Part : public QObject, public PartBase
00209 {
00210 Q_OBJECT
00211
00212 KPARTS_DECLARE_PRIVATE(Part)
00213
00214 public:
00215
00221 explicit Part( QObject *parent = 0 );
00222
00226 virtual ~Part();
00227
00239 virtual void embed( QWidget * parentWidget );
00240
00244 virtual QWidget *widget();
00245
00250 virtual void setManager( PartManager * manager );
00251
00255 PartManager * manager() const;
00256
00265 void setAutoDeleteWidget(bool autoDeleteWidget);
00266
00275 void setAutoDeletePart(bool autoDeletePart);
00276
00285 virtual Part *hitTest( QWidget *widget, const QPoint &globalPos );
00286
00290 virtual void setSelectable( bool selectable );
00291
00295 bool isSelectable() const;
00296
00304 KIconLoader* iconLoader();
00305
00306 Q_SIGNALS:
00311 void setWindowCaption( const QString & caption );
00316 void setStatusBarText( const QString & text );
00317
00318 protected:
00324 virtual void setWidget( QWidget * widget );
00325
00329 virtual void customEvent( QEvent *event );
00330
00336 virtual void partActivateEvent( PartActivateEvent *event );
00337
00344 virtual void partSelectEvent( PartSelectEvent *event );
00345
00352 virtual void guiActivateEvent( GUIActivateEvent *event );
00353
00358 QWidget *hostContainer( const QString &containerName );
00359
00360 protected Q_SLOTS:
00364 void slotWidgetDestroyed();
00365
00366 protected:
00367 Part(PartPrivate &dd, QObject *parent);
00368
00369 private:
00370 Q_DISABLE_COPY(Part)
00371 };
00372
00373 class ReadWritePart;
00374 class ReadOnlyPartPrivate;
00375 class BrowserExtension;
00376 class OpenUrlArgumentsPrivate;
00377
00388 class KPARTS_EXPORT OpenUrlArguments
00389 {
00390 public:
00391 OpenUrlArguments();
00392 OpenUrlArguments(const OpenUrlArguments &other);
00393 OpenUrlArguments &operator=( const OpenUrlArguments &other);
00394 ~OpenUrlArguments();
00395
00400 bool reload() const;
00405 void setReload(bool b);
00406
00412 int xOffset() const;
00413 void setXOffset(int x);
00414
00420 int yOffset() const;
00421 void setYOffset(int y);
00422
00426 QString mimeType() const;
00427 void setMimeType(const QString& mime);
00428
00434 QMap<QString, QString> &metaData();
00435 const QMap<QString, QString> &metaData() const;
00436
00437 private:
00438 QSharedDataPointer<OpenUrlArgumentsPrivate> d;
00439 };
00440
00441
00462 class KPARTS_EXPORT ReadOnlyPart : public Part
00463 {
00464 Q_OBJECT
00465
00466 Q_PROPERTY( KUrl url READ url )
00467
00468 KPARTS_DECLARE_PRIVATE(ReadOnlyPart)
00469
00470 public:
00475 explicit ReadOnlyPart( QObject *parent = 0 );
00476
00480 virtual ~ReadOnlyPart();
00481
00489 void setProgressInfoEnabled( bool show );
00490
00495 bool isProgressInfoEnabled() const;
00496
00497 #ifndef KDE_NO_COMPAT
00498 void showProgressInfo( bool show );
00499 #endif
00500
00501 public Q_SLOTS:
00510 virtual bool openUrl( const KUrl &url );
00511
00512 public:
00518 KUrl url() const;
00519
00528 virtual bool closeUrl();
00529
00534 BrowserExtension* browserExtension() const;
00535
00539 void setArguments(const OpenUrlArguments& arguments);
00540
00541
00542
00543
00544
00548 OpenUrlArguments arguments() const;
00549
00550 public:
00561 bool openStream( const QString& mimeType, const KUrl& url );
00562
00569 bool writeStream( const QByteArray& data );
00570
00576 bool closeStream();
00577
00578 private:
00579
00585 virtual bool doOpenStream( const QString& ) { return false; }
00592 virtual bool doWriteStream( const QByteArray& ) { return false; }
00598 virtual bool doCloseStream() { return false; }
00599
00600 Q_SIGNALS:
00606 void started( KIO::Job * );
00607
00613 void completed();
00614
00624 void completed( bool pendingAction );
00625
00630 void canceled( const QString &errMsg );
00631
00632 protected:
00638 virtual bool openFile() = 0;
00639
00643 void abortLoad();
00644
00655 virtual void guiActivateEvent( GUIActivateEvent *event );
00656
00660 KDE_DEPRECATED bool isLocalFileTemporary() const;
00661
00665 KDE_DEPRECATED void setLocalFileTemporary( bool temp );
00666
00670 void setUrl(const KUrl &url);
00671
00675 QString localFilePath() const;
00676
00680 void setLocalFilePath( const QString &localFilePath );
00681
00682 protected:
00683 ReadOnlyPart(ReadOnlyPartPrivate &dd, QObject *parent);
00684
00685 private:
00686 Q_PRIVATE_SLOT(d_func(), void _k_slotJobFinished( KJob * job ))
00687 Q_PRIVATE_SLOT(d_func(), void _k_slotGotMimeType(KIO::Job *job, const QString &mime))
00688
00689 Q_DISABLE_COPY(ReadOnlyPart)
00690 };
00691 class ReadWritePartPrivate;
00692
00708 class KPARTS_EXPORT ReadWritePart : public ReadOnlyPart
00709 {
00710 Q_OBJECT
00711
00712 KPARTS_DECLARE_PRIVATE(ReadWritePart)
00713
00714 public:
00719 explicit ReadWritePart( QObject *parent = 0 );
00728 virtual ~ReadWritePart();
00729
00733 bool isReadWrite() const;
00734
00739 virtual void setReadWrite ( bool readwrite = true );
00740
00744 bool isModified() const;
00745
00754 virtual bool queryClose();
00755
00767 virtual bool closeUrl();
00768
00777 virtual bool closeUrl( bool promptToSave );
00778
00784 virtual bool saveAs( const KUrl &url );
00785
00789 virtual void setModified( bool modified );
00790
00791 Q_SIGNALS:
00797 void sigQueryClose(bool *handled, bool* abortClosing);
00798
00799 public Q_SLOTS:
00805 void setModified();
00806
00812 virtual bool save();
00813
00818 bool waitSaveComplete();
00819
00820 protected:
00832 virtual bool saveFile() = 0;
00833
00842 virtual bool saveToUrl();
00843
00844 private:
00845 Q_PRIVATE_SLOT(d_func(), void _k_slotUploadFinished( KJob * job ))
00846
00847 Q_DISABLE_COPY(ReadWritePart)
00848 };
00849
00850 }
00851
00852
00853 #undef KPARTS_DECLARE_PRIVATE
00854
00855 #endif