part.h
/* This file is part of the KDE project
Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
(C) 1999 David Faure <faure@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef _KPART_H
#define _KPART_H
#include <qstring.h>
#include <qdom.h>
#include <qguardedptr.h>
#include <kurl.h>
#include <kxmlguiclient.h>
class KInstance;
class QWidget;
class KAction;
class KActionCollection;
class QEvent;
struct QUnknownInterface;
namespace KIO {
class Job;
}
namespace KParts
{
class PartManager;
class Plugin;
class PartPrivate;
class PartActivateEvent;
class PartSelectEvent;
class GUIActivateEvent;
class PartBasePrivate;
class KPARTS_EXPORT PartBase : virtual public KXMLGUIClient
{
friend class PartBasePrivate;
public:
PartBase();
virtual ~PartBase();
void setPartObject( QObject *object );
QObject *partObject() const;
protected:
virtual void setInstance( KInstance *instance );
virtual void setInstance( KInstance *instance, bool loadPlugins );
enum PluginLoadingMode {
DoNotLoadPlugins = 0,
LoadPlugins = 1,
LoadPluginsIfEnabled = 2
};
void loadPlugins( QObject *parent, KXMLGUIClient *parentGUIClient, KInstance *instance );
void setPluginLoadingMode( PluginLoadingMode loadingMode );
private:
PartBasePrivate *d;
QObject *m_obj;
};
class KPARTS_EXPORT Part : public QObject, public PartBase
{
Q_OBJECT
public:
Part( QObject *parent = 0, const char* name = 0 );
virtual ~Part();
virtual void embed( QWidget * parentWidget );
virtual QWidget *widget();
virtual void setManager( PartManager * manager );
PartManager * manager() const;
virtual Part *hitTest( QWidget *widget, const QPoint &globalPos );
virtual void setSelectable( bool selectable );
bool isSelectable() const;
signals:
void setWindowCaption( const QString & caption );
void setStatusBarText( const QString & text );
protected:
virtual void setWidget( QWidget * widget );
virtual void customEvent( QCustomEvent *event );
virtual void partActivateEvent( PartActivateEvent *event );
virtual void partSelectEvent( PartSelectEvent *event );
virtual void guiActivateEvent( GUIActivateEvent *event );
QWidget *hostContainer( const QString &containerName );
private slots:
void slotWidgetDestroyed();
private:
QGuardedPtr<QWidget> m_widget;
PartManager * m_manager;
PartPrivate *d;
};
class ReadWritePart;
class ReadOnlyPartPrivate;
class KPARTS_EXPORT ReadOnlyPart : public Part
{
Q_OBJECT
friend class ReadWritePart;
public:
ReadOnlyPart( QObject *parent = 0, const char *name = 0 );
virtual ~ReadOnlyPart();
void setProgressInfoEnabled( bool show );
bool isProgressInfoEnabled() const;
#ifndef KDE_NO_COMPAT
void showProgressInfo( bool show );
#endif
public slots:
virtual bool openURL( const KURL &url );
public:
KURL url() const { return m_url; }
virtual bool closeURL();
public:
bool openStream( const QString& mimeType, const KURL& url );
bool writeStream( const QByteArray& data );
bool closeStream();
private: // Makes no sense for inherited classes to call those. But make it protected there.
virtual bool doOpenStream( const QString& /*mimeType*/ ) { return false; }
virtual bool doWriteStream( const QByteArray& /*data*/ ) { return false; }
virtual bool doCloseStream() { return false; }
signals:
void started( KIO::Job * );
void completed();
void completed( bool pendingAction );
void canceled( const QString &errMsg );
protected slots:
void slotJobFinished( KIO::Job * job );
protected:
virtual bool openFile() = 0;
void abortLoad();
virtual void guiActivateEvent( GUIActivateEvent *event );
KURL m_url;
QString m_file;
bool m_bTemp;
private:
ReadOnlyPartPrivate *d;
};
class KPARTS_EXPORT ReadWritePart : public ReadOnlyPart
{
Q_OBJECT
public:
ReadWritePart( QObject *parent = 0, const char *name = 0 );
virtual ~ReadWritePart();
bool isReadWrite() const { return m_bReadWrite; }
virtual void setReadWrite ( bool readwrite = true );
bool isModified() const { return m_bModified; }
// TODO: Make virtual for KDE 4
bool queryClose();
virtual bool closeURL();
// TODO: Make virtual for KDE 4
bool closeURL( bool promptToSave );
virtual bool saveAs( const KURL &url );
virtual void setModified( bool modified );
signals:
void sigQueryClose(bool *handled, bool* abortClosing);
public slots:
virtual void setModified();
virtual bool save();
bool waitSaveComplete();
protected:
virtual bool saveFile() = 0;
virtual bool saveToURL();
protected slots:
void slotUploadFinished( KIO::Job * job );
private:
void prepareSaving();
private:
bool m_bModified;
bool m_bReadWrite;
bool m_bClosing;
};
} // namespace
#endif
KURL
KActionCollection
KParts::ReadOnlyPart::m_url
KURL m_url
Remote (or local) url - the one displayed to the user.
Definition: part.h:515
KXMLGUIClient
KParts::ReadWritePart::isModified
bool isModified() const
Definition: part.h:577
KParts::PartActivateEvent
This event is sent by the part manager when the active part changes.
Definition: event.h:76
KParts::Part
Base class for parts.
Definition: part.h:181
KParts::ReadWritePart
Base class for an "editor" part.
Definition: part.h:544
KParts::PartBase
Base class for all parts.
Definition: part.h:57
KParts::ReadOnlyPart::url
KURL url() const
Returns the currently in part used URL.
Definition: part.h:390
KInstance
KParts::GUIActivateEvent
This event is sent to a Part when its GUI has been activated or deactivated.
Definition: event.h:54
KParts::PartBase::PluginLoadingMode
PluginLoadingMode
We have three different policies, whether to load new plugins or not.
Definition: part.h:102
KParts::ReadOnlyPart::m_bTemp
bool m_bTemp
If true, m_file is a temporary file that needs to be deleted later.
Definition: part.h:523
KParts::ReadWritePart::isReadWrite
bool isReadWrite() const
Definition: part.h:566
KAction
KParts::ReadOnlyPart::m_file
QString m_file
Local file - the only one the part implementation should deal with.
Definition: part.h:519
KParts::PartManager
The part manager is an object which knows about a collection of parts (even nested ones) and handles ...
Definition: partmanager.h:50
KParts::PartSelectEvent
This event is sent when a part is selected or deselected.
Definition: event.h:99
KParts::ReadOnlyPart
Base class for any "viewer" part.
Definition: part.h:338

KDE Home | KDE Accessibility Home | Description of Access Keys