kxmlguiclient.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _KXMLGUICLIENT_H
00020 #define _KXMLGUICLIENT_H
00021
00022 #include <qdom.h>
00023 #include <qptrlist.h>
00024 #include <qmap.h>
00025 #include <qstringlist.h>
00026
00027 class QWidget;
00028 class KAction;
00029 class KActionCollection;
00030 class KInstance;
00031 class KXMLGUIClientPrivate;
00032 class KXMLGUIFactory;
00033 class KXMLGUIBuilder;
00034
00041 class KXMLGUIClient
00042 {
00043 friend class KEditToolbarWidget;
00044 public:
00050 KXMLGUIClient();
00051
00063 KXMLGUIClient( KXMLGUIClient *parent );
00064
00068 virtual ~KXMLGUIClient();
00069
00075 KAction* action( const char* name ) const;
00076
00082 virtual KAction *action( const QDomElement &element ) const;
00083
00087 virtual KActionCollection* actionCollection() const;
00088
00092 virtual KInstance *instance() const;
00093
00099 virtual QDomDocument domDocument() const;
00100
00114 virtual QString xmlFile() const;
00115
00116 virtual QString localXMLFile() const;
00117
00121 void setXMLGUIBuildDocument( const QDomDocument &doc );
00125 QDomDocument xmlguiBuildDocument() const;
00126
00131 void setFactory( KXMLGUIFactory *factory );
00137 KXMLGUIFactory *factory() const;
00138
00144 KXMLGUIClient *parentClient() const;
00145
00152 void insertChildClient( KXMLGUIClient *child );
00153
00157 void removeChildClient( KXMLGUIClient *child );
00158
00162 const QPtrList<KXMLGUIClient> *childClients();
00163
00172 void setClientBuilder( KXMLGUIBuilder *builder );
00173
00178 KXMLGUIBuilder *clientBuilder() const;
00179
00187 void reloadXML();
00188
00229 void plugActionList( const QString &name, const QPtrList<KAction> &actionList );
00230
00234 void unplugActionList( const QString &name );
00235
00236 static QString findMostRecentXMLFile( const QStringList &files, QString &doc );
00237
00238 void addStateActionEnabled(const QString& state, const QString& action);
00239
00240 void addStateActionDisabled(const QString& state, const QString& action);
00241
00242 enum ReverseStateChange { StateNoReverse, StateReverse };
00243 struct StateChange
00244 {
00245 QStringList actionsToEnable;
00246 QStringList actionsToDisable;
00247 };
00248
00249 StateChange getActionsToChangeForState(const QString& state);
00250
00252 void beginXMLPlug( QWidget * );
00254 void endXMLPlug();
00256 void prepareXMLUnplug( QWidget * );
00257
00258 protected:
00263
00264
00271 virtual void setInstance( KInstance *instance );
00272
00285 virtual void setXMLFile( const QString& file, bool merge = false, bool setXMLDoc = true );
00286
00287 virtual void setLocalXMLFile( const QString &file );
00288
00295 virtual void setXML( const QString &document, bool merge = false );
00296
00303 virtual void setDOMDocument( const QDomDocument &document, bool merge = false );
00304
00310 virtual void conserveMemory();
00311
00323 virtual void stateChanged(const QString &newstate, ReverseStateChange reverse = StateNoReverse);
00324
00325
00326
00327
00328 private:
00329 struct DocStruct
00330 {
00331 QString file;
00332 QString data;
00333 };
00334
00335 bool mergeXML( QDomElement &base, const QDomElement &additive,
00336 KActionCollection *actionCollection );
00337
00338 QDomElement findMatchingElement( const QDomElement &base,
00339 const QDomElement &additive );
00340
00341 typedef QMap<QString, QMap<QString, QString> > ActionPropertiesMap;
00342
00343 static ActionPropertiesMap extractActionProperties( const QDomDocument &doc );
00344
00345 static void storeActionProperties( QDomDocument &doc, const ActionPropertiesMap &properties );
00346
00347 static QString findVersionNumber( const QString &_xml );
00348
00349
00350 QMap<QString,StateChange> m_actionsStateMap;
00351
00352 protected:
00353 virtual void virtual_hook( int id, void* data );
00354 private:
00355 KXMLGUIClientPrivate *d;
00356 };
00357
00358 #endif
This file is part of the documentation for kdelibs Version 3.1.4.