| # kparts Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# part.h

    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., 59 Temple Place - Suite 330,
    00018    Boston, MA 02111-1307, USA.
    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 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
    00097   enum PluginLoadingMode {
    00098     DoNotLoadPlugins = 0,
    00099     LoadPlugins = 1,         // load new plugins automatically
    00100     LoadPluginsIfEnabled = 2 // new plugins are disabled by default
    00101   };
    00102
    00106   void loadPlugins( QObject *parent, KXMLGUIClient *parentGUIClient, KInstance *instance );
    00107
    00112   void setPluginLoadingMode( PluginLoadingMode loadingMode );
    00113
    00114 private:
    00115     PartBasePrivate *d;
    00116     QObject *m_obj;
    00117 };
    00118
    00142 class Part : public QObject, public PartBase
    00143 {
    00144     Q_OBJECT
    00145
    00146 public:
    00147
    00154     Part( QObject *parent = 0, const char* name = 0 );
    00155
    00159     virtual ~Part();
    00160
    00172     virtual void embed( QWidget * parentWidget );
    00173
    00177     virtual QWidget *widget();
    00178
    00183     virtual void setManager( PartManager * manager );
    00184
    00188     PartManager * manager() const;
    00189
    00193     virtual Part *hitTest( QWidget *widget, const QPoint &globalPos );
    00194
    00198     virtual void setSelectable( bool selectable );
    00199
    00203     bool isSelectable() const;
    00204
    00205 signals:
    00210     void setWindowCaption( const QString & caption );
    00215     void setStatusBarText( const QString & text );
    00216
    00217 protected:
    00218
    00224     virtual void setWidget( QWidget * widget );
    00225
    00229     virtual void customEvent( QCustomEvent *event );
    00230
    00236     virtual void partActivateEvent( PartActivateEvent *event );
    00237
    00244     virtual void partSelectEvent( PartSelectEvent *event );
    00245
    00252     virtual void guiActivateEvent( GUIActivateEvent *event );
    00253
    00258     QWidget *hostContainer( const QString &containerName );
    00259
    00260 private slots:
    00261     void slotWidgetDestroyed();
    00262
    00263 private:
    00264     QGuardedPtr<QWidget> m_widget;
    00265
    00266     PartManager * m_manager;
    00267
    00268     PartPrivate *d;
    00269 };
    00270
    00271 class ReadOnlyPartPrivate;
    00272
    00290 class ReadOnlyPart : public Part
    00291 {
    00292   Q_OBJECT
    00293 public:
    00298   ReadOnlyPart( QObject *parent = 0, const char *name = 0 );
    00299
    00303   virtual ~ReadOnlyPart();
    00304
    00312   void setProgressInfoEnabled( bool show );
    00313
    00318   bool isProgressInfoEnabled() const;
    00319
    00320 #ifndef KDE_NO_COMPAT
    00321   void showProgressInfo( bool show );
    00322 #endif
    00323
    00324 public slots:
    00332   virtual bool openURL( const KURL &url );
    00333
    00334 public:
    00340   KURL url() const { return m_url; }
    00341
    00350   virtual bool closeURL();
    00351
    00352 public:
    00363   bool openStream( const QString& mimeType, const KURL& url );
    00364
    00371   bool writeStream( const QByteArray& data );
    00372
    00378   bool closeStream();
    00379
    00380 private: // Makes no sense for inherited classes to call those. But make it protected there.
    00381
    00387   virtual bool doOpenStream( const QString& /*mimeType*/ ) { return false; }
    00394   virtual bool doWriteStream( const QByteArray& /*data*/ ) { return false; }
    00400   virtual bool doCloseStream() { return false; }
    00401
    00402 signals:
    00408   void started( KIO::Job * );
    00409
    00415   void completed();
    00416
    00430   void completed( bool pendingAction );
    00431
    00436   void canceled( const QString &errMsg );
    00437
    00438 protected slots:
    00439   void slotJobFinished( KIO::Job * job );
    00440
    00441 protected:
    00447   virtual bool openFile() = 0;
    00448
    00452   void abortLoad();
    00453
    00464   virtual void guiActivateEvent( GUIActivateEvent *event );
    00465
    00469   KURL m_url;
    00473   QString m_file;
    00477   bool m_bTemp;
    00478
    00479 private:
    00480   ReadOnlyPartPrivate *d;
    00481 };
    00482
    00498 class ReadWritePart : public ReadOnlyPart
    00499 {
    00500   Q_OBJECT
    00501 public:
    00506   ReadWritePart( QObject *parent = 0, const char *name = 0 );
    00515   virtual ~ReadWritePart();
    00516
    00520   bool isReadWrite() const { return m_bReadWrite; }
    00521
    00526   virtual void setReadWrite ( bool readwrite = true );
    00527
    00531   bool isModified() const { return m_bModified; }
    00532
    00543   // TODO: Make virtual for KDE 4
    00544   bool queryClose();
    00545
    00557   virtual bool closeURL();
    00558
    00569   // TODO: Make virtual for KDE 4
    00570   bool closeURL( bool promptToSave );
    00571
    00577   virtual bool saveAs( const KURL &url );
    00578
    00582   virtual void setModified( bool modified );
    00583
    00584 public slots:
    00590   virtual void setModified();
    00591
    00597   virtual bool save();
    00598
    00599 protected:
    00605   virtual bool saveFile() = 0;
    00606
    00614   virtual bool saveToURL();
    00615
    00616 protected slots:
    00620   void slotUploadFinished( KIO::Job * job );
    00621
    00622 private:
    00623   bool m_bModified;
    00624   bool m_bReadWrite;
    00625   bool m_bClosing;
    00626 };
    00627
    00628 }
    00629
    00630 #endif

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:26:50 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001