kxmlguifactory.h
00001 // -*- mode: c++; c-basic-offset: 2 -*- 00002 /* This file is part of the KDE libraries 00003 Copyright (C) 1999 Simon Hausmann <hausmann@kde.org> 00004 Copyright (C) 2000 Kurt Granroth <granroth@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License version 2 as published by the Free Software Foundation. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef __kxmlguifactory_h__ 00022 #define __kxmlguifactory_h__ 00023 00024 #include <tqobject.h> 00025 #include <tqptrlist.h> 00026 #include <tqdom.h> 00027 #include <tqvaluelist.h> 00028 00029 #include <tdelibs_export.h> 00030 00031 class TDEAction; 00032 class KXMLGUIFactoryPrivate; 00033 class KXMLGUIClient; 00034 class KXMLGUIBuilder; 00035 class TDEInstance; 00036 00037 namespace KXMLGUI 00038 { 00039 struct MergingIndex; 00040 struct ContainerNode; 00041 struct ContainerClient; 00042 class BuildHelper; 00043 } 00044 00062 class TDEUI_EXPORT KXMLGUIFactory : public TQObject 00063 { 00064 friend class KXMLGUI::BuildHelper; 00065 Q_OBJECT 00066 public: 00074 KXMLGUIFactory( KXMLGUIBuilder *builder, TQObject *parent = 0, const char *name = 0 ); 00075 00079 ~KXMLGUIFactory(); 00080 00081 // XXX move to somewhere else? (Simon) 00082 static TQString readConfigFile( const TQString &filename, bool never_null, const TDEInstance *instance = 0 ); 00083 static TQString readConfigFile( const TQString &filename, const TDEInstance *instance = 0 ); 00084 static bool saveConfigFile( const TQDomDocument& doc, const TQString& filename, 00085 const TDEInstance *instance = 0 ); 00086 00087 static TQString documentToXML( const TQDomDocument& doc ); 00088 static TQString elementToXML( const TQDomElement& elem ); 00089 00093 static void removeDOMComments( TQDomNode &node ); 00094 00099 static TQDomElement actionPropertiesElement( TQDomDocument& doc ); 00100 00106 static TQDomElement findActionByName( TQDomElement& elem, const TQString& sName, bool create ); 00107 00118 void addClient( KXMLGUIClient *client ); 00119 00125 void removeClient( KXMLGUIClient *client ); 00126 00127 void plugActionList( KXMLGUIClient *client, const TQString &name, const TQPtrList<TDEAction> &actionList ); 00128 void unplugActionList( KXMLGUIClient *client, const TQString &name ); 00129 00133 TQPtrList<KXMLGUIClient> clients() const; 00134 00155 TQWidget *container( const TQString &containerName, KXMLGUIClient *client, bool useTagName = false ); 00156 00157 TQPtrList<TQWidget> containers( const TQString &tagName ); 00158 00167 void reset(); 00168 00178 void resetContainer( const TQString &containerName, bool useTagName = false ); 00179 00180 public slots: 00196 int configureShortcuts(bool bAllowLetterShortcuts = true, bool bSaveSettings = true); 00197 00198 signals: 00199 void clientAdded( KXMLGUIClient *client ); 00200 void clientRemoved( KXMLGUIClient *client ); 00201 00202 private: 00203 00204 TQWidget *findRecursive( KXMLGUI::ContainerNode *node, bool tag ); 00205 00206 TQPtrList<TQWidget> findRecursive( KXMLGUI::ContainerNode *node, const TQString &tagName ); 00207 00208 void applyActionProperties( const TQDomElement &element ); 00209 void configureAction( TDEAction *action, const TQDomNamedNodeMap &attributes ); 00210 void configureAction( TDEAction *action, const TQDomAttr &attribute ); 00211 00212 protected: 00213 virtual void virtual_hook( int id, void* data ); 00214 private: 00215 KXMLGUIFactoryPrivate *d; 00216 }; 00217 00218 #endif 00219 /* vim: et sw=4 00220 */