kdeui Library API Documentation

kxmlguiclient.h

00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2000 Simon Hausmann <hausmann@kde.org> 00003 Copyright (C) 2000 Kurt Granroth <granroth@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License version 2 as published by the Free Software Foundation. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00017 Boston, MA 02111-1307, USA. 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; // for setXMLFile(3 args) 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 //bool addSuperClient( KXMLGUIClient * ); 00264 00271 virtual void setInstance( KInstance *instance ); 00272 00286 virtual void setXMLFile( const QString& file, bool merge = false, bool setXMLDoc = true ); 00287 00288 virtual void setLocalXMLFile( const QString &file ); 00289 00296 virtual void setXML( const QString &document, bool merge = false ); 00297 00304 virtual void setDOMDocument( const QDomDocument &document, bool merge = false ); 00305 00311 virtual void conserveMemory(); 00312 00324 virtual void stateChanged(const QString &newstate, ReverseStateChange reverse = StateNoReverse); 00325 00326 // Use this one for KDE 4.0 00327 //virtual void stateChanged(const QString &newstate, bool reverse = false); 00328 00329 private: 00330 struct DocStruct 00331 { 00332 QString file; 00333 QString data; 00334 }; 00335 00336 bool mergeXML( QDomElement &base, const QDomElement &additive, 00337 KActionCollection *actionCollection ); 00338 00339 QDomElement findMatchingElement( const QDomElement &base, 00340 const QDomElement &additive ); 00341 00342 typedef QMap<QString, QMap<QString, QString> > ActionPropertiesMap; 00343 00344 static ActionPropertiesMap extractActionProperties( const QDomDocument &doc ); 00345 00346 static void storeActionProperties( QDomDocument &doc, const ActionPropertiesMap &properties ); 00347 00348 static QString findVersionNumber( const QString &_xml ); 00349 00350 // Actions to enable/disable on a state change 00351 QMap<QString,StateChange> m_actionsStateMap; 00352 00353 protected: 00354 virtual void virtual_hook( int id, void* data ); 00355 private: 00356 KXMLGUIClientPrivate *d; 00357 }; 00358 00359 #endif
KDE Logo
This file is part of the documentation for kdeui Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Sep 29 09:40:36 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003