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

KParts

  • 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
38class KIconLoader;
39class KComponentData;
40class QWidget;
41class QEvent;
42class QPoint;
43struct QUnknownInterface;
44
45class KJob;
46namespace KIO {
47 class Job;
48}
49
50namespace KParts
51{
52
53class PartManager;
54class Plugin;
55class PartPrivate;
56class PartActivateEvent;
57class PartSelectEvent;
58class GUIActivateEvent;
59class PartBasePrivate;
60
64class KPARTS_EXPORT PartBase : virtual public KXMLGUIClient
65{
66 KPARTS_DECLARE_PRIVATE(PartBase)
67
68public:
69
73 PartBase();
74
78 virtual ~PartBase();
79
85 void setPartObject( QObject *object );
86 QObject *partObject() const;
87
88protected:
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
181protected:
182 PartBase(PartBasePrivate &dd);
183
184 PartBasePrivate *d_ptr;
185
186private:
187 Q_DISABLE_COPY(PartBase)
188};
189
215class KPARTS_EXPORT Part : public QObject, public PartBase
216{
217 Q_OBJECT
218
219 KPARTS_DECLARE_PRIVATE(Part)
220
221public:
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
313Q_SIGNALS:
318 void setWindowCaption( const QString & caption );
323 void setStatusBarText( const QString & text );
324
325protected:
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
376protected Q_SLOTS:
380 void slotWidgetDestroyed();
381
382protected:
383 Part(PartPrivate &dd, QObject *parent);
384
385private:
386 Q_DISABLE_COPY(Part)
387};
388
389class ReadWritePart;
390class ReadOnlyPartPrivate;
391class BrowserExtension;
392class OpenUrlArgumentsPrivate;
393
404class KPARTS_EXPORT OpenUrlArguments
405{
406public:
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
463private:
464 QSharedDataPointer<OpenUrlArgumentsPrivate> d;
465};
466
467
488class KPARTS_EXPORT ReadOnlyPart : public Part
489{
490 Q_OBJECT
491
492 Q_PROPERTY( KUrl url READ url )
493
494 KPARTS_DECLARE_PRIVATE(ReadOnlyPart)
495
496public:
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
527public Q_SLOTS:
536 virtual bool openUrl( const KUrl &url );
537
538public:
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
576public:
587 bool openStream( const QString& mimeType, const KUrl& url );
588
595 bool writeStream( const QByteArray& data );
596
602 bool closeStream();
603
604private: // 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
626Q_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
664protected:
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
718protected:
719 ReadOnlyPart(ReadOnlyPartPrivate &dd, QObject *parent);
720
721private:
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};
728class ReadWritePartPrivate;
729
745class KPARTS_EXPORT ReadWritePart : public ReadOnlyPart
746{
747 Q_OBJECT
748
749 KPARTS_DECLARE_PRIVATE(ReadWritePart)
750
751public:
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
828Q_SIGNALS:
834 void sigQueryClose(bool *handled, bool* abortClosing);
835
836public Q_SLOTS:
842 void setModified();
843
849 virtual bool save();
850
855 bool waitSaveComplete();
856
857protected:
869 virtual bool saveFile() = 0;
870
879 virtual bool saveToUrl();
880
881private:
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
KComponentData
KIO::Job
KIconLoader
KJob
KParts::BrowserExtension
The Browser Extension is an extension (yes, no kidding) to KParts::ReadOnlyPart, which allows a bette...
Definition: browserextension.h:321
KParts::GUIActivateEvent
This event is sent to a Part when its GUI has been activated or deactivated.
Definition: event.h:60
KParts::OpenUrlArguments
OpenUrlArguments is the set of arguments that specify how a URL should be opened by KParts::ReadOnlyP...
Definition: part.h:405
KParts::PartActivateEvent
This event is sent by the part manager when the active part changes.
Definition: event.h:83
KParts::PartBase
Base class for all parts.
Definition: part.h:65
KParts::PartBase::d_ptr
PartBasePrivate * d_ptr
Definition: part.h:184
KParts::PartBase::PluginLoadingMode
PluginLoadingMode
We have three different policies, whether to load new plugins or not.
Definition: part.h:119
KParts::PartManager
The part manager is an object which knows about a collection of parts (even nested ones) and handles ...
Definition: partmanager.h:48
KParts::PartSelectEvent
This event is sent when a part is selected or deselected.
Definition: event.h:104
KParts::Part
Base class for parts.
Definition: part.h:216
KParts::Part::setWindowCaption
void setWindowCaption(const QString &caption)
Emitted by the part, to set the caption of the window(s) hosting this part.
KParts::Part::setStatusBarText
void setStatusBarText(const QString &text)
Emitted by the part, to set a text in the statusbar of the window(s) hosting this part.
KParts::ReadOnlyPart
Base class for any "viewer" part.
Definition: part.h:489
KParts::ReadOnlyPart::started
void started(KIO::Job *)
The part emits this when starting data.
KParts::ReadOnlyPart::completed
void completed(bool pendingAction)
Same as the above signal except it indicates whether there is a pending action to be executed on a de...
KParts::ReadOnlyPart::completed
void completed()
Emit this when you have completed loading data.
KParts::ReadOnlyPart::canceled
void canceled(const QString &errMsg)
Emit this if loading is canceled by the user or by an error.
KParts::ReadOnlyPart::urlChanged
void urlChanged(const KUrl &url)
Emitted by the part when url() changes.
KParts::ReadWritePart
Base class for an "editor" part.
Definition: part.h:746
KParts::ReadWritePart::saveFile
virtual bool saveFile()=0
Save to a local file.
KParts::ReadWritePart::sigQueryClose
void sigQueryClose(bool *handled, bool *abortClosing)
set handled to true, if you don't want the default handling set abortClosing to true,...
KUrl
KXMLGUIClient
QEvent
QMap
QObject
QWidget
kparts_export.h
kurl.h
kxmlguiclient.h
KIO
KParts
save
KAction * save(const QObject *recvr, const char *slot, QObject *parent)
saveAs
KAction * saveAs(const QObject *recvr, const char *slot, QObject *parent)
reload
const KShortcut & reload()
KPARTS_DECLARE_PRIVATE
#define KPARTS_DECLARE_PRIVATE(Class)
Definition: part.h:33
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 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
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