• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KParts

part.h

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002    Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
00003              (C) 1999 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., 51 Franklin Street, Fifth Floor,
00018    Boston, MA 02110-1301, USA.
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     // TODO to avoid problems with the case where the loading fails, this could also be a openUrl() argument (heavy porting!).
00541     // However we need to have setArguments in any case for updated made by the part, see e.g. KHTMLPart::openUrl.
00542     // Well, maybe we should have setArguments (affects next openurl call) and updateArguments?
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: // Makes no sense for inherited classes to call those. But make it protected there.
00579 
00585     virtual bool doOpenStream( const QString& /*mimeType*/ ) { return false; }
00592     virtual bool doWriteStream( const QByteArray& /*data*/ ) { 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 } // namespace
00851 
00852 
00853 #undef KPARTS_DECLARE_PRIVATE
00854 
00855 #endif

KParts

Skip menu "KParts"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   WTF
  • KJSEmbed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  •   core
  • Phonon
  •   Backend
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal