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 #include <kdelibs_export.h>
00028 
00029 class QWidget;
00030 class KAction;
00031 class KActionCollection;
00032 class KInstance;
00033 class KXMLGUIClientPrivate;
00034 class KXMLGUIFactory;
00035 class KXMLGUIBuilder;
00036 
00043 class KDEUI_EXPORT KXMLGUIClient
00044 {
00045     friend class KEditToolbarWidget; // for setXMLFile(3 args)
00046 public:
00052   KXMLGUIClient();
00053 
00065   KXMLGUIClient( KXMLGUIClient *parent );
00066 
00070   virtual ~KXMLGUIClient();
00071 
00077   KAction* action( const char* name ) const;
00078 
00084   virtual KAction *action( const QDomElement &element ) const;
00085 
00089   virtual KActionCollection* actionCollection() const;
00090 
00094   virtual KInstance *instance() const;
00095 
00101   virtual QDomDocument domDocument() const;
00102 
00116   virtual QString xmlFile() const;
00117 
00118   virtual QString localXMLFile() const;
00119 
00123   void setXMLGUIBuildDocument( const QDomDocument &doc );
00127   QDomDocument xmlguiBuildDocument() const;
00128 
00133   void setFactory( KXMLGUIFactory *factory );
00139   KXMLGUIFactory *factory() const;
00140 
00146   KXMLGUIClient *parentClient() const;
00147 
00154   void insertChildClient( KXMLGUIClient *child );
00155 
00159   void removeChildClient( KXMLGUIClient *child );
00160 
00164   const QPtrList<KXMLGUIClient> *childClients();
00165 
00174   void setClientBuilder( KXMLGUIBuilder *builder );
00175 
00180   KXMLGUIBuilder *clientBuilder() const;
00181 
00189   void reloadXML();
00190 
00231   void plugActionList( const QString &name, const QPtrList<KAction> &actionList );
00232 
00236   void unplugActionList( const QString &name );
00237 
00238   static QString findMostRecentXMLFile( const QStringList &files, QString &doc );
00239 
00240   void addStateActionEnabled(const QString& state, const QString& action);
00241 
00242   void addStateActionDisabled(const QString& state, const QString& action);
00243 
00244   enum ReverseStateChange { StateNoReverse, StateReverse };
00245   struct StateChange
00246   {
00247     QStringList actionsToEnable;
00248     QStringList actionsToDisable;
00249   };
00250 
00251   StateChange getActionsToChangeForState(const QString& state);
00252 
00254   void beginXMLPlug( QWidget * );
00256   void endXMLPlug();
00258   void prepareXMLUnplug( QWidget * );
00259 
00260 protected:
00265   //bool addSuperClient( KXMLGUIClient * );
00266 
00273   virtual void setInstance( KInstance *instance );
00274 
00288   virtual void setXMLFile( const QString& file, bool merge = false, bool setXMLDoc = true );
00289 
00290   virtual void setLocalXMLFile( const QString &file );
00291 
00298   virtual void setXML( const QString &document, bool merge = false );
00299 
00306   virtual void setDOMDocument( const QDomDocument &document, bool merge = false );
00307 
00313   virtual void conserveMemory();
00314 
00326    virtual void stateChanged(const QString &newstate, ReverseStateChange reverse = StateNoReverse);
00327 
00328    // Use this one for KDE 4.0
00329    //virtual void stateChanged(const QString &newstate, bool reverse = false);
00330 
00331 private:
00332   struct DocStruct
00333   {
00334     QString file;
00335     QString data;
00336   };
00337 
00338   bool mergeXML( QDomElement &base, const QDomElement &additive,
00339                  KActionCollection *actionCollection );
00340 
00341   QDomElement findMatchingElement( const QDomElement &base,
00342                                    const QDomElement &additive );
00343 
00344   typedef QMap<QString, QMap<QString, QString> > ActionPropertiesMap;
00345 
00346   static ActionPropertiesMap extractActionProperties( const QDomDocument &doc );
00347 
00348   static void storeActionProperties( QDomDocument &doc, const ActionPropertiesMap &properties );
00349 
00350   static QString findVersionNumber( const QString &_xml );
00351 
00352   // Actions to enable/disable on a state change
00353   QMap<QString,StateChange> m_actionsStateMap;
00354 
00355 protected:
00356   virtual void virtual_hook( int id, void* data );
00357 private:
00358   KXMLGUIClientPrivate *d;
00359 };
00360 
00361 #endif
KDE Logo
This file is part of the documentation for kdeui Library Version 3.3.90.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 30 10:12:03 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003