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 <QtCore/QPointer>
00024 #include <QtCore/QEvent>
00025 #include <QtCore/QSharedDataPointer>
00026 #include <QtXml/QDomElement>
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
00064 class KPARTS_EXPORT PartBase : virtual public KXMLGUIClient
00065 {
00066 KPARTS_DECLARE_PRIVATE(PartBase)
00067
00068 public:
00069
00073 PartBase();
00074
00078 virtual ~PartBase();
00079
00085 void setPartObject( QObject *object );
00086 QObject *partObject() const;
00087
00088 protected:
00095 virtual void setComponentData(const KComponentData &componentData);
00096
00108 virtual void setComponentData(const KComponentData &componentData, bool loadPlugins);
00109
00110
00111
00112
00113
00119 enum PluginLoadingMode {
00123 DoNotLoadPlugins = 0,
00130 LoadPlugins = 1,
00137 LoadPluginsIfEnabled = 2
00138 };
00139
00156 void loadPlugins(QObject *parent, KXMLGUIClient *parentGUIClient, const KComponentData &componentData);
00157
00165 void setPluginLoadingMode( PluginLoadingMode loadingMode );
00166
00179 void setPluginInterfaceVersion( int version );
00180
00181 protected:
00182 PartBase(PartBasePrivate &dd);
00183
00184 PartBasePrivate *d_ptr;
00185
00186 private:
00187 Q_DISABLE_COPY(PartBase)
00188 };
00189
00215 class KPARTS_EXPORT Part : public QObject, public PartBase
00216 {
00217 Q_OBJECT
00218
00219 KPARTS_DECLARE_PRIVATE(Part)
00220
00221 public:
00222
00228 explicit Part( QObject *parent = 0 );
00229
00233 virtual ~Part();
00234
00246 virtual void embed( QWidget * parentWidget );
00247
00251 virtual QWidget *widget();
00252
00257 virtual void setManager( PartManager * manager );
00258
00262 PartManager * manager() const;
00263
00272 void setAutoDeleteWidget(bool autoDeleteWidget);
00273
00282 void setAutoDeletePart(bool autoDeletePart);
00283
00292 virtual Part *hitTest( QWidget *widget, const QPoint &globalPos );
00293
00297 virtual void setSelectable( bool selectable );
00298
00302 bool isSelectable() const;
00303
00311 KIconLoader* iconLoader();
00312
00313 Q_SIGNALS:
00318 void setWindowCaption( const QString & caption );
00323 void setStatusBarText( const QString & text );
00324
00325 protected:
00331 virtual void setWidget( QWidget * widget );
00332
00336 virtual void customEvent( QEvent *event );
00337
00343 virtual void partActivateEvent( PartActivateEvent *event );
00344
00351 virtual void partSelectEvent( PartSelectEvent *event );
00352
00359 virtual void guiActivateEvent( GUIActivateEvent *event );
00360
00365 QWidget *hostContainer( const QString &containerName );
00366
00373 void loadPlugins();
00374 using PartBase::loadPlugins;
00375
00376 protected Q_SLOTS:
00380 void slotWidgetDestroyed();
00381
00382 protected:
00383 Part(PartPrivate &dd, QObject *parent);
00384
00385 private:
00386 Q_DISABLE_COPY(Part)
00387 };
00388
00389 class ReadWritePart;
00390 class ReadOnlyPartPrivate;
00391 class BrowserExtension;
00392 class OpenUrlArgumentsPrivate;
00393
00404 class KPARTS_EXPORT OpenUrlArguments
00405 {
00406 public:
00407 OpenUrlArguments();
00408 OpenUrlArguments(const OpenUrlArguments &other);
00409 OpenUrlArguments &operator=( const OpenUrlArguments &other);
00410 ~OpenUrlArguments();
00411
00416 bool reload() const;
00421 void setReload(bool b);
00422
00428 int xOffset() const;
00429 void setXOffset(int x);
00430
00436 int yOffset() const;
00437 void setYOffset(int y);
00438
00442 QString mimeType() const;
00443 void setMimeType(const QString& mime);
00444
00452 bool actionRequestedByUser() const;
00453 void setActionRequestedByUser(bool userRequested);
00454
00460 QMap<QString, QString> &metaData();
00461 const QMap<QString, QString> &metaData() const;
00462
00463 private:
00464 QSharedDataPointer<OpenUrlArgumentsPrivate> d;
00465 };
00466
00467
00488 class KPARTS_EXPORT ReadOnlyPart : public Part
00489 {
00490 Q_OBJECT
00491
00492 Q_PROPERTY( KUrl url READ url )
00493
00494 KPARTS_DECLARE_PRIVATE(ReadOnlyPart)
00495
00496 public:
00501 explicit ReadOnlyPart( QObject *parent = 0 );
00502
00506 virtual ~ReadOnlyPart();
00507
00515 void setProgressInfoEnabled( bool show );
00516
00521 bool isProgressInfoEnabled() const;
00522
00523 #ifndef KDE_NO_COMPAT
00524 void showProgressInfo( bool show );
00525 #endif
00526
00527 public Q_SLOTS:
00536 virtual bool openUrl( const KUrl &url );
00537
00538 public:
00544 KUrl url() const;
00545
00554 virtual bool closeUrl();
00555
00560 BrowserExtension* browserExtension() const;
00561
00565 void setArguments(const OpenUrlArguments& arguments);
00566
00567
00568
00569
00570
00574 OpenUrlArguments arguments() const;
00575
00576 public:
00587 bool openStream( const QString& mimeType, const KUrl& url );
00588
00595 bool writeStream( const QByteArray& data );
00596
00602 bool closeStream();
00603
00604 private:
00605
00611 virtual bool doOpenStream( const QString& ) { return false; }
00618 virtual bool doWriteStream( const QByteArray& ) { return false; }
00624 virtual bool doCloseStream() { return false; }
00625
00626 Q_SIGNALS:
00632 void started( KIO::Job * );
00633
00639 void completed();
00640
00650 void completed( bool pendingAction );
00651
00656 void canceled( const QString &errMsg );
00657
00658 protected:
00664 virtual bool openFile() = 0;
00665
00669 void abortLoad();
00670
00681 virtual void guiActivateEvent( GUIActivateEvent *event );
00682
00686 KDE_DEPRECATED bool isLocalFileTemporary() const;
00687
00691 KDE_DEPRECATED void setLocalFileTemporary( bool temp );
00692
00696 void setUrl(const KUrl &url);
00697
00701 QString localFilePath() const;
00702
00706 void setLocalFilePath( const QString &localFilePath );
00707
00708 protected:
00709 ReadOnlyPart(ReadOnlyPartPrivate &dd, QObject *parent);
00710
00711 private:
00712 Q_PRIVATE_SLOT(d_func(), void _k_slotJobFinished( KJob * job ))
00713 Q_PRIVATE_SLOT(d_func(), void _k_slotGotMimeType(KIO::Job *job, const QString &mime))
00714
00715 Q_DISABLE_COPY(ReadOnlyPart)
00716 };
00717 class ReadWritePartPrivate;
00718
00734 class KPARTS_EXPORT ReadWritePart : public ReadOnlyPart
00735 {
00736 Q_OBJECT
00737
00738 KPARTS_DECLARE_PRIVATE(ReadWritePart)
00739
00740 public:
00745 explicit ReadWritePart( QObject *parent = 0 );
00754 virtual ~ReadWritePart();
00755
00759 bool isReadWrite() const;
00760
00765 virtual void setReadWrite ( bool readwrite = true );
00766
00770 bool isModified() const;
00771
00780 virtual bool queryClose();
00781
00793 virtual bool closeUrl();
00794
00803 virtual bool closeUrl( bool promptToSave );
00804
00810 virtual bool saveAs( const KUrl &url );
00811
00815 virtual void setModified( bool modified );
00816
00817 Q_SIGNALS:
00823 void sigQueryClose(bool *handled, bool* abortClosing);
00824
00825 public Q_SLOTS:
00831 void setModified();
00832
00838 virtual bool save();
00839
00844 bool waitSaveComplete();
00845
00846 protected:
00858 virtual bool saveFile() = 0;
00859
00868 virtual bool saveToUrl();
00869
00870 private:
00871 Q_PRIVATE_SLOT(d_func(), void _k_slotUploadFinished( KJob * job ))
00872
00873 Q_DISABLE_COPY(ReadWritePart)
00874 };
00875
00876 }
00877
00878
00879 #undef KPARTS_DECLARE_PRIVATE
00880
00881 #endif