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

KParts

  • sources
  • kde-4.14
  • kdelibs
  • kparts
part.h
Go to the documentation of this file.
1 /* This file is part of the KDE project
2  Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
3  (C) 1999 David Faure <faure@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 #ifndef _KPART_H
21 #define _KPART_H
22 
23 #include <QtCore/QPointer>
24 #include <QtCore/QEvent>
25 #include <QtCore/QSharedDataPointer>
26 #include <QtXml/QDomElement> // KDE5: remove
27 
28 #include <kurl.h>
29 #include <kxmlguiclient.h>
30 
31 #include <kparts/kparts_export.h>
32 
33 #define KPARTS_DECLARE_PRIVATE(Class) \
34  inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(PartBase::d_ptr); } \
35  inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(PartBase::d_ptr); } \
36  friend class Class##Private;
37 
38 class KIconLoader;
39 class KComponentData;
40 class QWidget;
41 class QEvent;
42 class QPoint;
43 struct QUnknownInterface;
44 
45 class KJob;
46 namespace KIO {
47  class Job;
48 }
49 
50 namespace KParts
51 {
52 
53 class PartManager;
54 class Plugin;
55 class PartPrivate;
56 class PartActivateEvent;
57 class PartSelectEvent;
58 class GUIActivateEvent;
59 class PartBasePrivate;
60 
64 class KPARTS_EXPORT PartBase : virtual public KXMLGUIClient
65 {
66  KPARTS_DECLARE_PRIVATE(PartBase)
67 
68 public:
69 
73  PartBase();
74 
78  virtual ~PartBase();
79 
85  void setPartObject( QObject *object );
86  QObject *partObject() const;
87 
88 protected:
95  virtual void setComponentData(const KComponentData &componentData);
96 
108  virtual void setComponentData(const KComponentData &componentData, bool loadPlugins);
109  // TODO KDE5: merge the above two methods, using loadPlugins=true. Or better, remove loadPlugins
110  // altogether and change plugins to call loadPlugins() manually at the end of their ctor.
111  // In the case of KParts MainWindows, plugins are automatically loaded in createGUI anyway,
112  // so setComponentData() should really not load the plugins.
113 
119  enum PluginLoadingMode {
123  DoNotLoadPlugins = 0,
130  LoadPlugins = 1,
137  LoadPluginsIfEnabled = 2
138  };
139 
156  void loadPlugins(QObject *parent, KXMLGUIClient *parentGUIClient, const KComponentData &componentData);
157 
165  void setPluginLoadingMode( PluginLoadingMode loadingMode );
166 
179  void setPluginInterfaceVersion( int version );
180 
181 protected:
182  PartBase(PartBasePrivate &dd);
183 
184  PartBasePrivate *d_ptr;
185 
186 private:
187  Q_DISABLE_COPY(PartBase)
188 };
189 
215 class KPARTS_EXPORT Part : public QObject, public PartBase
216 {
217  Q_OBJECT
218 
219  KPARTS_DECLARE_PRIVATE(Part)
220 
221 public:
222 
228  explicit Part( QObject *parent = 0 );
229 
233  virtual ~Part();
234 
246  virtual void embed( QWidget * parentWidget );
247 
251  virtual QWidget *widget();
252 
257  virtual void setManager( PartManager * manager );
258 
262  PartManager * manager() const;
263 
272  void setAutoDeleteWidget(bool autoDeleteWidget);
273 
282  void setAutoDeletePart(bool autoDeletePart);
283 
292  virtual Part *hitTest( QWidget *widget, const QPoint &globalPos );
293 
297  virtual void setSelectable( bool selectable );
298 
302  bool isSelectable() const;
303 
311  KIconLoader* iconLoader();
312 
313 Q_SIGNALS:
318  void setWindowCaption( const QString & caption );
323  void setStatusBarText( const QString & text );
324 
325 protected:
331  virtual void setWidget( QWidget * widget );
332 
336  virtual void customEvent( QEvent *event );
337 
343  virtual void partActivateEvent( PartActivateEvent *event );
344 
351  virtual void partSelectEvent( PartSelectEvent *event );
352 
359  virtual void guiActivateEvent( GUIActivateEvent *event );
360 
365  QWidget *hostContainer( const QString &containerName );
366 
373  void loadPlugins();
374  using PartBase::loadPlugins;
375 
376 protected Q_SLOTS:
380  void slotWidgetDestroyed();
381 
382 protected:
383  Part(PartPrivate &dd, QObject *parent);
384 
385 private:
386  Q_DISABLE_COPY(Part)
387 };
388 
389 class ReadWritePart;
390 class ReadOnlyPartPrivate;
391 class BrowserExtension;
392 class OpenUrlArgumentsPrivate;
393 
404 class KPARTS_EXPORT OpenUrlArguments
405 {
406 public:
407  OpenUrlArguments();
408  OpenUrlArguments(const OpenUrlArguments &other);
409  OpenUrlArguments &operator=( const OpenUrlArguments &other);
410  ~OpenUrlArguments();
411 
416  bool reload() const;
421  void setReload(bool b);
422 
428  int xOffset() const;
429  void setXOffset(int x);
430 
436  int yOffset() const;
437  void setYOffset(int y);
438 
442  QString mimeType() const;
443  void setMimeType(const QString& mime);
444 
452  bool actionRequestedByUser() const;
453  void setActionRequestedByUser(bool userRequested);
454 
460  QMap<QString, QString> &metaData();
461  const QMap<QString, QString> &metaData() const;
462 
463 private:
464  QSharedDataPointer<OpenUrlArgumentsPrivate> d;
465 };
466 
467 
488 class KPARTS_EXPORT ReadOnlyPart : public Part
489 {
490  Q_OBJECT
491 
492  Q_PROPERTY( KUrl url READ url )
493 
494  KPARTS_DECLARE_PRIVATE(ReadOnlyPart)
495 
496 public:
501  explicit ReadOnlyPart( QObject *parent = 0 );
502 
506  virtual ~ReadOnlyPart();
507 
515  void setProgressInfoEnabled( bool show );
516 
521  bool isProgressInfoEnabled() const;
522 
523 #ifndef KDE_NO_COMPAT
524  void showProgressInfo( bool show );
525 #endif
526 
527 public Q_SLOTS:
536  virtual bool openUrl( const KUrl &url );
537 
538 public:
544  KUrl url() const;
545 
554  virtual bool closeUrl();
555 
560  BrowserExtension* browserExtension() const;
561 
565  void setArguments(const OpenUrlArguments& arguments);
566  // TODO to avoid problems with the case where the loading fails, this could also be a openUrl() argument (heavy porting!).
567  // However we need to have setArguments in any case for updated made by the part, see e.g. KHTMLPart::openUrl.
568  // Well, maybe we should have setArguments (affects next openurl call) and updateArguments?
569 
570 
574  OpenUrlArguments arguments() const;
575 
576 public:
587  bool openStream( const QString& mimeType, const KUrl& url );
588 
595  bool writeStream( const QByteArray& data );
596 
602  bool closeStream();
603 
604 private: // Makes no sense for inherited classes to call those. But make it protected there.
605 
611  virtual bool doOpenStream( const QString& /*mimeType*/ ) { return false; }
618  virtual bool doWriteStream( const QByteArray& /*data*/ ) { return false; }
624  virtual bool doCloseStream() { return false; }
625 
626 Q_SIGNALS:
632  void started( KIO::Job * );
633 
639  void completed();
640 
650  void completed( bool pendingAction );
651 
656  void canceled( const QString &errMsg );
657 
662  void urlChanged( const KUrl & url );
663 
664 protected:
670  virtual bool openFile();
671 
675  void abortLoad();
676 
687  virtual void guiActivateEvent( GUIActivateEvent *event );
688 
692 #ifndef KDE_NO_DEPRECATED
693  KDE_DEPRECATED bool isLocalFileTemporary() const;
694 #endif
695 
699 #ifndef KDE_NO_DEPRECATED
700  KDE_DEPRECATED void setLocalFileTemporary( bool temp );
701 #endif
702 
706  void setUrl(const KUrl &url);
707 
711  QString localFilePath() const;
712 
716  void setLocalFilePath( const QString &localFilePath );
717 
718 protected:
719  ReadOnlyPart(ReadOnlyPartPrivate &dd, QObject *parent);
720 
721 private:
722  Q_PRIVATE_SLOT(d_func(), void _k_slotJobFinished( KJob * job ))
723  Q_PRIVATE_SLOT(d_func(), void _k_slotStatJobFinished(KJob*))
724  Q_PRIVATE_SLOT(d_func(), void _k_slotGotMimeType(KIO::Job *job, const QString &mime))
725 
726  Q_DISABLE_COPY(ReadOnlyPart)
727 };
728 class ReadWritePartPrivate;
729 
745 class KPARTS_EXPORT ReadWritePart : public ReadOnlyPart
746 {
747  Q_OBJECT
748 
749  KPARTS_DECLARE_PRIVATE(ReadWritePart)
750 
751 public:
756  explicit ReadWritePart( QObject *parent = 0 );
765  virtual ~ReadWritePart();
766 
770  bool isReadWrite() const;
771 
776  virtual void setReadWrite ( bool readwrite = true );
777 
781  bool isModified() const;
782 
791  virtual bool queryClose();
792 
804  virtual bool closeUrl();
805 
814  virtual bool closeUrl( bool promptToSave );
815 
821  virtual bool saveAs( const KUrl &url );
822 
826  virtual void setModified( bool modified );
827 
828 Q_SIGNALS:
834  void sigQueryClose(bool *handled, bool* abortClosing);
835 
836 public Q_SLOTS:
842  void setModified();
843 
849  virtual bool save();
850 
855  bool waitSaveComplete();
856 
857 protected:
869  virtual bool saveFile() = 0;
870 
879  virtual bool saveToUrl();
880 
881 private:
882  Q_PRIVATE_SLOT(d_func(), void _k_slotUploadFinished( KJob * job ))
883 
884  Q_DISABLE_COPY(ReadWritePart)
885 };
886 
887 } // namespace
888 
889 
890 #undef KPARTS_DECLARE_PRIVATE
891 
892 #endif
KParts::BrowserExtension
The Browser Extension is an extension (yes, no kidding) to KParts::ReadOnlyPart, which allows a bette...
Definition: browserextension.h:320
caption
QString caption()
QEvent
QWidget
KXMLGUIClient
kurl.h
QByteArray
KParts::PartBase::d_ptr
PartBasePrivate * d_ptr
Definition: part.h:184
saveAs
KAction * saveAs(const QObject *recvr, const char *slot, QObject *parent)
KParts::PartActivateEvent
This event is sent by the part manager when the active part changes.
Definition: event.h:82
KPARTS_DECLARE_PRIVATE
#define KPARTS_DECLARE_PRIVATE(Class)
Definition: part.h:33
QMap< QString, QString >
QPoint
KParts::Part
Base class for parts.
Definition: part.h:215
KUrl
KParts::ReadWritePart
Base class for an "editor" part.
Definition: part.h:745
KParts::PartBase
Base class for all parts.
Definition: part.h:64
QObject
QString
reload
const KShortcut & reload()
KParts::GUIActivateEvent
This event is sent to a Part when its GUI has been activated or deactivated.
Definition: event.h:59
KParts::PartBase::PluginLoadingMode
PluginLoadingMode
We have three different policies, whether to load new plugins or not.
Definition: part.h:119
kxmlguiclient.h
KIO::Job
KParts::PartBase::loadPlugins
void loadPlugins(QObject *parent, KXMLGUIClient *parentGUIClient, const KComponentData &componentData)
Load the Plugins honoring the PluginLoadingMode.
Definition: part.cpp:156
KParts::PartManager
The part manager is an object which knows about a collection of parts (even nested ones) and handles ...
Definition: partmanager.h:47
save
KAction * save(const QObject *recvr, const char *slot, QObject *parent)
KJob
KComponentData
QSharedDataPointer< OpenUrlArgumentsPrivate >
KParts::OpenUrlArguments
OpenUrlArguments is the set of arguments that specify how a URL should be opened by KParts::ReadOnlyP...
Definition: part.h:404
KIconLoader
KParts::PartSelectEvent
This event is sent when a part is selected or deselected.
Definition: event.h:103
KParts::ReadOnlyPart
Base class for any "viewer" part.
Definition: part.h:488
kparts_export.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:25:36 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KParts

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal