\section{KXMLGUIFactory Class Reference}
\label{classKXMLGUIFactory}\index{KXMLGUIFactory@{KXMLGUIFactory}}
KXMLGUIFactory, together with {\bf KXMLGUIClient}{\rm (p.\,\pageref{classKXMLGUIClient})} objects, can be used to create a GUI of container widgets (like menus, toolbars, etc.) and container items (menu items, toolbar buttons, etc.) from an XML document and action objects.  


{\tt \#include $<$kxmlguifactory.h$>$}

Inheritance diagram for KXMLGUIFactory:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=71pt]{classKXMLGUIFactory__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for KXMLGUIFactory:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=71pt]{classKXMLGUIFactory__coll__graph}
\end{center}
\end{figure}
\subsection*{Signals}
\begin{CompactItemize}
\item 
void {\bf client\-Added} ({\bf KXMLGUIClient} $\ast$client)\label{classKXMLGUIFactory_l0}

\item 
void {\bf client\-Removed} ({\bf KXMLGUIClient} $\ast$client)\label{classKXMLGUIFactory_l1}

\end{CompactItemize}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf KXMLGUIFactory} ({\bf KXMLGUIBuilder} $\ast$builder, {\bf QObject} $\ast${\bf parent}=0, const  char $\ast${\bf name}=0)
\begin{CompactList}\small\item\em Constructs a KXMLGUIFactory. \item\end{CompactList}\item 
{\bf $\sim$KXMLGUIFactory} ()
\begin{CompactList}\small\item\em Destructor. \item\end{CompactList}\item 
void {\bf add\-Client} ({\bf KXMLGUIClient} $\ast$client)
\begin{CompactList}\small\item\em Creates the GUI described by the {\bf QDom\-Document} of the client, using the client's actions, and merges it with the previously created GUI. \item\end{CompactList}\item 
void {\bf remove\-Client} ({\bf KXMLGUIClient} $\ast$client)
\begin{CompactList}\small\item\em Removes the GUI described by the client, by unplugging all provided actions and removing all owned containers (and storing container state information in the given client). \item\end{CompactList}\item 
void {\bf plug\-Action\-List} ({\bf KXMLGUIClient} $\ast$client, const  {\bf QString} \&{\bf name}, const  {\bf QPtr\-List}$<$ {\bf KAction} $>$ \&action\-List)\label{classKXMLGUIFactory_a4}

\item 
void {\bf unplug\-Action\-List} ({\bf KXMLGUIClient} $\ast$client, const  {\bf QString} \&{\bf name})\label{classKXMLGUIFactory_a5}

\item 
{\bf QPtr\-List}$<$ {\bf KXMLGUIClient} $>$ {\bf clients} () const 
\begin{CompactList}\small\item\em Returns a list of all clients currently added to this factory. \item\end{CompactList}\item 
{\bf QWidget} $\ast$ {\bf container} (const  {\bf QString} \&container\-Name, {\bf KXMLGUIClient} $\ast$client, bool use\-Tag\-Name=false)
\begin{CompactList}\small\item\em Use this method to get access to a container widget with the name specified with {\tt container\-Name} and which is owned by the {\tt client}. \item\end{CompactList}\item 
{\bf QPtr\-List}$<$ {\bf QWidget} $>$ {\bf containers} (const  {\bf QString} \&tag\-Name)\label{classKXMLGUIFactory_a8}

\item 
void {\bf reset} ()
\begin{CompactList}\small\item\em Use this method to free all memory allocated by the KXMLGUIFactory. \item\end{CompactList}\item 
void {\bf reset\-Container} (const  {\bf QString} \&container\-Name, bool use\-Tag\-Name=false)
\begin{CompactList}\small\item\em Use this method to free all memory allocated by the KXMLGUIFactory for a specific container, including all child containers and actions. \item\end{CompactList}\end{CompactItemize}
\subsection*{Static Public Member Functions}
\begin{CompactItemize}
\item 
{\bf QString} {\bf read\-Config\-File} (const  {\bf QString} \&filename, bool never\_\-null, const  {\bf KInstance} $\ast$instance=0)\label{classKXMLGUIFactory_e0}

\item 
{\bf QString} {\bf read\-Config\-File} (const  {\bf QString} \&filename, const  {\bf KInstance} $\ast$instance=0)\label{classKXMLGUIFactory_e1}

\item 
bool {\bf save\-Config\-File} (const  {\bf QDom\-Document} \&doc, const  {\bf QString} \&filename, const  {\bf KInstance} $\ast$instance=0)\label{classKXMLGUIFactory_e2}

\item 
{\bf QString} {\bf document\-To\-XML} (const  {\bf QDom\-Document} \&doc)\label{classKXMLGUIFactory_e3}

\item 
{\bf QString} {\bf element\-To\-XML} (const  {\bf QDom\-Element} \&elem)\label{classKXMLGUIFactory_e4}

\item 
void {\bf remove\-DOMComments} ({\bf QDom\-Node} \&node)
\begin{CompactList}\small\item\em Removes all {\bf QDom\-Comment} objects from the specified node and all its children. \item\end{CompactList}\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
virtual void {\bf virtual\_\-hook} (int id, void $\ast$data)\label{classKXMLGUIFactory_b0}

\end{CompactItemize}
\subsection*{Friends}
\begin{CompactItemize}
\item 
class {\bf KXMLGUI::Build\-Helper}\label{classKXMLGUIFactory_n0}

\end{CompactItemize}


\subsection{Detailed Description}
KXMLGUIFactory, together with {\bf KXMLGUIClient}{\rm (p.\,\pageref{classKXMLGUIClient})} objects, can be used to create a GUI of container widgets (like menus, toolbars, etc.) and container items (menu items, toolbar buttons, etc.) from an XML document and action objects. 

Each {\bf KXMLGUIClient}{\rm (p.\,\pageref{classKXMLGUIClient})} represents a part of the GUI, composed from containers and actions. KXMLGUIFactory takes care of building (with the help of a {\bf KXMLGUIBuilder}{\rm (p.\,\pageref{classKXMLGUIBuilder})}) and merging the GUI from an unlimited number of clients.

Each client provides XML through a {\bf QDom\-Document} and actions through a {\bf KAction\-Collection}{\rm (p.\,\pageref{classKActionCollection})} . The XML document contains the rules for how to merge the GUI.

KXMLGUIFactory processes the DOM tree provided by a client and plugs in the client's actions, according to the XML and the merging rules of previously inserted clients. Container widgets are built via a {\bf KXMLGUIBuilder}{\rm (p.\,\pageref{classKXMLGUIBuilder})} , which has to be provided with the KXMLGUIFactory constructor. 



Definition at line 59 of file kxmlguifactory.h.

\subsection{Constructor \& Destructor Documentation}
\index{KXMLGUIFactory@{KXMLGUIFactory}!KXMLGUIFactory@{KXMLGUIFactory}}
\index{KXMLGUIFactory@{KXMLGUIFactory}!KXMLGUIFactory@{KXMLGUIFactory}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KXMLGUIFactory::KXMLGUIFactory ({\bf KXMLGUIBuilder} $\ast$ {\em builder}, {\bf QObject} $\ast$ {\em parent} = 0, const char $\ast$ {\em name} = 0)}\label{classKXMLGUIFactory_a0}


Constructs a KXMLGUIFactory. 

The provided {\tt builder} {\bf KXMLGUIBuilder}{\rm (p.\,\pageref{classKXMLGUIBuilder})} will be called for creating and removing container widgets, when clients are added/removed from the GUI.

Note that the ownership of the given {\bf KXMLGUIBuilder}{\rm (p.\,\pageref{classKXMLGUIBuilder})} object won't be transferred to this KXMLGUIFactory, so you have to take care of deleting it properly. 

Definition at line 194 of file kxmlguifactory.cpp.

References KStd\-Accel::name().\index{KXMLGUIFactory@{KXMLGUIFactory}!~KXMLGUIFactory@{$\sim$KXMLGUIFactory}}
\index{~KXMLGUIFactory@{$\sim$KXMLGUIFactory}!KXMLGUIFactory@{KXMLGUIFactory}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KXMLGUIFactory::$\sim${\bf KXMLGUIFactory} ()}\label{classKXMLGUIFactory_a1}


Destructor. 



Definition at line 207 of file kxmlguifactory.cpp.

\subsection{Member Function Documentation}
\index{KXMLGUIFactory@{KXMLGUIFactory}!removeDOMComments@{removeDOMComments}}
\index{removeDOMComments@{removeDOMComments}!KXMLGUIFactory@{KXMLGUIFactory}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KXMLGUIFactory::remove\-DOMComments ({\bf QDom\-Node} \& {\em node})\hspace{0.3cm}{\tt  [static]}}\label{classKXMLGUIFactory_e5}


Removes all {\bf QDom\-Comment} objects from the specified node and all its children. 



Definition at line 174 of file kxmlguifactory.cpp.

References QDom\-Node::first\-Child(), QDom\-Node::is\-Null(), QDom\-Node::next\-Sibling(), QDom\-Node::node\-Type(), and QDom\-Node::remove\-Child().

Referenced by KEdit\-Toolbar\-Widget::KEdit\-Toolbar\-Widget(), KTool\-Bar::save\-State(), and KXMLGUIClient::set\-DOMDocument().\index{KXMLGUIFactory@{KXMLGUIFactory}!addClient@{addClient}}
\index{addClient@{addClient}!KXMLGUIFactory@{KXMLGUIFactory}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KXMLGUIFactory::add\-Client ({\bf KXMLGUIClient} $\ast$ {\em client})}\label{classKXMLGUIFactory_a2}


Creates the GUI described by the {\bf QDom\-Document} of the client, using the client's actions, and merges it with the previously created GUI. 

This also means that the order in which clients are added to the factory is relevant; assuming that your application supports plugins, you should first add your application to the factory and then the plugin, so that the plugin's UI is merged into the UI of your application, and not the other way round. 

Definition at line 212 of file kxmlguifactory.cpp.

References QDom\-Element::attribute(), KXMLGUIClient::begin\-XMLPlug(), KXMLGUIClient::child\-Clients(), QObject::children(), KXMLGUIClient::client\-Builder(), QPtr\-List$<$ KXMLGUIClient $>$::count(), QPtr\-List\-Iterator::current(), QDom\-Document::document\-Element(), KXMLGUIClient::dom\-Document(), KXMLGUIClient::end\-XMLPlug(), KXMLGUIClient::factory(), QString::lower(), remove\-Client(), KXMLGUIClient::set\-Factory(), KGlobal::static\-QString(), and KXMLGUIClient::xmlgui\-Build\-Document().

Referenced by KMain\-Window::create\-GUI(), KEdit\-Toolbar\-Widget::save(), and KMain\-Window::set\-Standard\-Tool\-Bar\-Menu\-Enabled().\index{KXMLGUIFactory@{KXMLGUIFactory}!removeClient@{removeClient}}
\index{removeClient@{removeClient}!KXMLGUIFactory@{KXMLGUIFactory}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KXMLGUIFactory::remove\-Client ({\bf KXMLGUIClient} $\ast$ {\em client})}\label{classKXMLGUIFactory_a3}


Removes the GUI described by the client, by unplugging all provided actions and removing all owned containers (and storing container state information in the given client). 



Definition at line 305 of file kxmlguifactory.cpp.

References KXMLGUIClient::child\-Clients(), QObject::children(), KXMLGUIClient::client\-Builder(), QPtr\-List$<$ KXMLGUIClient $>$::count(), QPtr\-List\-Iterator::current(), QDom\-Document::document\-Element(), KXMLGUIClient::dom\-Document(), KXMLGUIClient::factory(), KXMLGUIClient::prepare\-XMLUnplug(), KXMLGUIClient::set\-Factory(), KXMLGUIClient::set\-XMLGUIBuild\-Document(), and KXMLGUIClient::xmlgui\-Build\-Document().

Referenced by add\-Client(), KMain\-Window::create\-GUI(), KEdit\-Toolbar\-Widget::save(), and KMain\-Window::set\-Standard\-Tool\-Bar\-Menu\-Enabled().\index{KXMLGUIFactory@{KXMLGUIFactory}!clients@{clients}}
\index{clients@{clients}!KXMLGUIFactory@{KXMLGUIFactory}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QPtr\-List}$<$ {\bf KXMLGUIClient} $>$ KXMLGUIFactory::clients () const}\label{classKXMLGUIFactory_a6}


Returns a list of all clients currently added to this factory. 



Definition at line 362 of file kxmlguifactory.cpp.

Referenced by KEdit\-Toolbar\-Widget::KEdit\-Toolbar\-Widget().\index{KXMLGUIFactory@{KXMLGUIFactory}!container@{container}}
\index{container@{container}!KXMLGUIFactory@{KXMLGUIFactory}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QWidget} $\ast$ KXMLGUIFactory::container (const {\bf QString} \& {\em container\-Name}, {\bf KXMLGUIClient} $\ast$ {\em client}, bool {\em use\-Tag\-Name} = false)}\label{classKXMLGUIFactory_a7}


Use this method to get access to a container widget with the name specified with {\tt container\-Name} and which is owned by the {\tt client}. 

The container name is specified with a \char`\"{}name\char`\"{} attribute in the XML document.

This function is particularly useful for getting hold of a popupmenu defined in an XMLUI file. For instance: {\bf QPopup\-Menu} $\ast$popup = static\_\-cast$<$QPopup\-Menu$\ast$$>$(factory()-$>$container(\char`\"{}my\_\-popup\char`\"{},this)) where \char`\"{}my\_\-popup\char`\"{} is the name of the menu in the XMLUI file, and \char`\"{}this\char`\"{} is XMLGUIClient which owns the popupmenu (e.g. the mainwindow, or the part, or the plugin...)

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em use\-Tag\-Name}]Specifies whether to compare the specified name with the name attribute or the tag name.\end{description}
\end{Desc}
This method may return 0L if no container with the given name exists or is not owned by the client. 

Definition at line 367 of file kxmlguifactory.cpp.

Referenced by reset\-Container().\index{KXMLGUIFactory@{KXMLGUIFactory}!reset@{reset}}
\index{reset@{reset}!KXMLGUIFactory@{KXMLGUIFactory}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KXMLGUIFactory::reset ()}\label{classKXMLGUIFactory_a9}


Use this method to free all memory allocated by the KXMLGUIFactory. 

This deletes the internal node tree and therefore resets the internal state of the class. Please note that the actual GUI is NOT touched at all, meaning no containers are deleted nor any actions unplugged. That is something you have to do on your own. So use this method only if you know what you are doing :-)

(also note that this will call {\bf KXMLGUIClient::set\-Factory}{\rm (p.\,\pageref{classKXMLGUIClient_a12})}( 0L ) for all inserted clients) 

Definition at line 389 of file kxmlguifactory.cpp.\index{KXMLGUIFactory@{KXMLGUIFactory}!resetContainer@{resetContainer}}
\index{resetContainer@{resetContainer}!KXMLGUIFactory@{KXMLGUIFactory}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KXMLGUIFactory::reset\-Container (const {\bf QString} \& {\em container\-Name}, bool {\em use\-Tag\-Name} = false)}\label{classKXMLGUIFactory_a10}


Use this method to free all memory allocated by the KXMLGUIFactory for a specific container, including all child containers and actions. 

This deletes the internal node subtree for the specified container. The actual GUI is not touched, no containers are deleted or any actions unplugged. Use this method only if you know what you are doing :-)

(also note that this will call {\bf KXMLGUIClient::set\-Factory}{\rm (p.\,\pageref{classKXMLGUIClient_a12})}( 0L ) for all clients of the container) 

Definition at line 396 of file kxmlguifactory.cpp.

References container(), QString::is\-Empty(), and QObject::parent().

Referenced by KMain\-Window::create\-GUI().

The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
kxmlguifactory.h\item 
kxmlguifactory.cpp\end{CompactItemize}
