kxmlguiclient.h
/* This file is part of the KDE libraries
Copyright (C) 2000 Simon Hausmann <hausmann@kde.org>
Copyright (C) 2000 Kurt Granroth <granroth@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 version 2 as published by the Free Software Foundation.
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 _KXMLGUICLIENT_H
#define _KXMLGUICLIENT_H
#include <qdom.h>
#include <qptrlist.h>
#include <qmap.h>
#include <qstringlist.h>
#include <kdelibs_export.h>
class QWidget;
class KAction;
class KActionCollection;
class KInstance;
class KXMLGUIClientPrivate;
class KXMLGUIFactory;
class KXMLGUIBuilder;
class KDEUI_EXPORT KXMLGUIClient
{
friend class KEditToolbarWidget; // for setXMLFile(3 args)
public:
KXMLGUIClient();
KXMLGUIClient( KXMLGUIClient *parent );
virtual ~KXMLGUIClient();
KAction* action( const char* name ) const;
virtual KAction *action( const QDomElement &element ) const;
virtual KActionCollection* actionCollection() const;
virtual KInstance *instance() const;
virtual QDomDocument domDocument() const;
virtual QString xmlFile() const;
virtual QString localXMLFile() const;
void setXMLGUIBuildDocument( const QDomDocument &doc );
QDomDocument xmlguiBuildDocument() const;
void setFactory( KXMLGUIFactory *factory );
KXMLGUIFactory *factory() const;
KXMLGUIClient *parentClient() const;
void insertChildClient( KXMLGUIClient *child );
void removeChildClient( KXMLGUIClient *child );
const QPtrList<KXMLGUIClient> *childClients();
void setClientBuilder( KXMLGUIBuilder *builder );
KXMLGUIBuilder *clientBuilder() const;
void reloadXML();
void plugActionList( const QString &name, const QPtrList<KAction> &actionList );
void unplugActionList( const QString &name );
static QString findMostRecentXMLFile( const QStringList &files, QString &doc );
void addStateActionEnabled(const QString& state, const QString& action);
void addStateActionDisabled(const QString& state, const QString& action);
enum ReverseStateChange { StateNoReverse, StateReverse };
struct StateChange
{
QStringList actionsToEnable;
QStringList actionsToDisable;
};
StateChange getActionsToChangeForState(const QString& state);
void beginXMLPlug( QWidget * );
void endXMLPlug();
void prepareXMLUnplug( QWidget * );
protected:
//bool addSuperClient( KXMLGUIClient * );
virtual void setInstance( KInstance *instance );
virtual void setXMLFile( const QString& file, bool merge = false, bool setXMLDoc = true );
virtual void setLocalXMLFile( const QString &file );
virtual void setXML( const QString &document, bool merge = false );
virtual void setDOMDocument( const QDomDocument &document, bool merge = false );
virtual void conserveMemory();
virtual void stateChanged(const QString &newstate, ReverseStateChange reverse = StateNoReverse);
// Use this one for KDE 4.0
//virtual void stateChanged(const QString &newstate, bool reverse = false);
private:
struct DocStruct
{
QString file;
QString data;
};
bool mergeXML( QDomElement &base, const QDomElement &additive,
KActionCollection *actionCollection );
QDomElement findMatchingElement( const QDomElement &base,
const QDomElement &additive );
typedef QMap<QString, QMap<QString, QString> > ActionPropertiesMap;
static ActionPropertiesMap extractActionProperties( const QDomDocument &doc );
static void storeActionProperties( QDomDocument &doc, const ActionPropertiesMap &properties );
static QString findVersionNumber( const QString &_xml );
// Actions to enable/disable on a state change
QMap<QString,StateChange> m_actionsStateMap;
protected:
virtual void virtual_hook( int id, void* data );
private:
KXMLGUIClientPrivate *d;
};
#endif
KActionCollection
A managed set of KAction objects.
Definition: kactioncollection.h:78
KEditToolbarWidget::actionCollection
virtual KActionCollection * actionCollection() const
Definition: kedittoolbar.cpp:1056
KXMLGUIClient
A KXMLGUIClient can be used with KXMLGUIFactory to create a GUI from actions and an XML document...
Definition: kxmlguiclient.h:43
KXMLGUIClient::removeChildClient
void removeChildClient(KXMLGUIClient *child)
Removes the given child from the client's children list.
Definition: kxmlguiclient.cpp:573
KXMLGUIClient::setClientBuilder
void setClientBuilder(KXMLGUIBuilder *builder)
A client can have an own KXMLGUIBuilder.
Definition: kxmlguiclient.cpp:593
KXMLGUIClient::factory
KXMLGUIFactory * factory() const
Retrieves a pointer to the KXMLGUIFactory this client is associated with (will return 0L if the clien...
Definition: kxmlguiclient.cpp:555
KXMLGUIClient::xmlFile
virtual QString xmlFile() const
This will return the name of the XML file as set by setXMLFile().
Definition: kxmlguiclient.cpp:133
KXMLGUIClient::childClients
const QPtrList< KXMLGUIClient > * childClients()
Retrieves a list of all child clients.
Definition: kxmlguiclient.cpp:588
KXMLGUIClient::reloadXML
void reloadXML()
Forces this client to re-read its XML resource file.
Definition: kxmlguiclient.cpp:150
KXMLGUIClient::setFactory
void setFactory(KXMLGUIFactory *factory)
This method is called by the KXMLGUIFactory as soon as the client is added to the KXMLGUIFactory's GU...
Definition: kxmlguiclient.cpp:550
KXMLGUIClient::plugActionList
void plugActionList(const QString &name, const QPtrList< KAction > &actionList)
ActionLists are a way for XMLGUI to support dynamic lists of actions.
Definition: kxmlguiclient.cpp:605
KXMLGUIClient::xmlguiBuildDocument
QDomDocument xmlguiBuildDocument() const
Definition: kxmlguiclient.cpp:545
KXMLGUIBuilder
Abstract interface for a "GUI builder", used by the GUIFactory This interface is implemented by KMain...
Definition: kxmlguibuilder.h:39
KInstance
KXMLGUIClient::action
KAction * action(const char *name) const
Retrieves an action of the client by name.
Definition: kxmlguiclient.cpp:93
KXMLGUIFactory
KXMLGUIFactory, together with KXMLGUIClient objects, can be used to create a GUI of container widgets...
Definition: kxmlguifactory.h:62
KXMLGUIClient::parentClient
KXMLGUIClient * parentClient() const
KXMLGUIClients can form a simple child/parent object tree.
Definition: kxmlguiclient.cpp:560
KEditToolbarWidget
A widget used to customize or configure toolbars.
Definition: kedittoolbar.h:270
KAction
Class to encapsulate user-driven action or event.
Definition: kaction.h:202
KXMLGUIClient::~KXMLGUIClient
virtual ~KXMLGUIClient()
Destructs the KXMLGUIClient.
Definition: kxmlguiclient.cpp:78
KXMLGUIClient::domDocument
virtual QDomDocument domDocument() const
Definition: kxmlguiclient.cpp:128
KXMLGUIClient::insertChildClient
void insertChildClient(KXMLGUIClient *child)
Use this method to make a client a child client of another client.
Definition: kxmlguiclient.cpp:565
KXMLGUIClient::instance
virtual KInstance * instance() const
Definition: kxmlguiclient.cpp:123
KXMLGUIClient::clientBuilder
KXMLGUIBuilder * clientBuilder() const
Retrieves the client's GUI builder or 0L if no client specific builder has been assigned via setClien...
Definition: kxmlguiclient.cpp:600
KXMLGUIClient::unplugActionList
void unplugActionList(const QString &name)
The complement of plugActionList() ...
Definition: kxmlguiclient.cpp:613
KXMLGUIClient::setXMLGUIBuildDocument
void setXMLGUIBuildDocument(const QDomDocument &doc)
Definition: kxmlguiclient.cpp:540
KXMLGUIClient::KXMLGUIClient
KXMLGUIClient()
Constructs a KXMLGUIClient which can be used with a KXMLGUIFactory to create a GUI from actions and a...
Definition: kxmlguiclient.cpp:67

KDE Home | KDE Accessibility Home | Description of Access Keys