kxmlguiclient.h Source File (kdeui Library)

| # kdeui Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# 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
    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    // Use this one for KDE 4.0
    00326    //virtual void stateChanged(const QString &newstate, bool reverse = false);
    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   // Actions to enable/disable on a state change
    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.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 12:58:02 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001