\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=65pt]{classKXMLGUIFactory__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for KXMLGUIFactory:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=65pt]{classKXMLGUIFactory__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Slots}
\begin{CompactItemize}
\item 
int {\bf configure\-Shortcuts} (bool b\-Allow\-Letter\-Shortcuts=true, bool b\-Save\-Settings=true)
\end{CompactItemize}
\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)
\item 
{\bf $\sim$KXMLGUIFactory} ()
\item 
void {\bf add\-Client} ({\bf KXMLGUIClient} $\ast$client)
\item 
void {\bf remove\-Client} ({\bf KXMLGUIClient} $\ast$client)
\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 
\item 
{\bf QWidget} $\ast$ {\bf container} (const {\bf QString} \&container\-Name, {\bf KXMLGUIClient} $\ast$client, bool use\-Tag\-Name=false)
\item 
{\bf QPtr\-List}$<$ {\bf QWidget} $>$ {\bf containers} (const {\bf QString} \&tag\-Name)\label{classKXMLGUIFactory_a8}

\item 
void {\bf reset} ()
\item 
void {\bf reset\-Container} (const {\bf QString} \&container\-Name, bool use\-Tag\-Name=false)
\end{CompactItemize}
\subsection*{Static Public Member Functions}
\begin{CompactItemize}
\item 
static {\bf QString} {\bf read\-Config\-File} (const {\bf QString} \&filename, bool never\_\-null, const {\bf KInstance} $\ast$instance=0)\label{classKXMLGUIFactory_e0}

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

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

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

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

\item 
static void {\bf remove\-DOMComments} ({\bf QDom\-Node} \&node)
\item 
static {\bf QDom\-Element} {\bf action\-Properties\-Element} ({\bf QDom\-Document} \&doc)\label{classKXMLGUIFactory_e6}

\item 
static {\bf QDom\-Element} {\bf find\-Action\-By\-Name} ({\bf QDom\-Element} \&elem, const {\bf QString} \&s\-Name, bool create)\label{classKXMLGUIFactory_e7}

\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 62 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} = {\tt 0}, const char $\ast$ {\em name} = {\tt 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 206 of file kxmlguifactory.cpp.\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 219 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 186 of file kxmlguifactory.cpp.

References QDom\-Node::is\-Null(), QDom\-Node::next\-Sibling(), QDom\-Node::node\-Type(), and QDom\-Node::remove\-Child().\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 224 of file kxmlguifactory.cpp.

References QString::append(), QDom\-Element::attribute(), QPtr\-List\-Iterator::current(), QDom\-Document::document\-Element(), endl(), kd\-Debug(), QString::lower(), and KGlobal::static\-QString().

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 321 of file kxmlguifactory.cpp.

References QPtr\-List\-Iterator::current(), QDom\-Document::document\-Element(), endl(), kd\-Debug(), and QPtr\-List\-Iterator::to\-Last().

Referenced by 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 379 of file kxmlguifactory.cpp.\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} = {\tt 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: 

\footnotesize\begin{verbatim} QPopupMenu *popup = static_cast<QPopupMenu*>(factory()->container("my_popup",this));
\end{verbatim}
\normalsize
 where {\tt \char`\"{}my\_\-popup\char`\"{}} is the name of the menu in the XMLUI file, and {\tt \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 container\-Name}]Name of the container widget \item[{\em client}]Owner of the container widget \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 384 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 KXMLGUIClient::set\-Factory( 0L ) for all inserted clients) 

Definition at line 406 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} = {\tt 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 KXMLGUIClient::set\-Factory( 0L ) for all clients of the container) 

Definition at line 413 of file kxmlguifactory.cpp.

References container().

Referenced by KMain\-Window::create\-GUI().\index{KXMLGUIFactory@{KXMLGUIFactory}!configureShortcuts@{configureShortcuts}}
\index{configureShortcuts@{configureShortcuts}!KXMLGUIFactory@{KXMLGUIFactory}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int KXMLGUIFactory::configure\-Shortcuts (bool {\em b\-Allow\-Letter\-Shortcuts} = {\tt true}, bool {\em b\-Save\-Settings} = {\tt true})\hspace{0.3cm}{\tt  [slot]}}\label{classKXMLGUIFactory_i0}


Show a standard configure shortcut for every action in this factory. 

This slot can be connected dirrectly to the action to configure shortcuts. This is very simple to do that by adding a single line 

\footnotesize\begin{verbatim} KStdAction::keyBindings( guiFactory(), SLOT( configureShortcuts() ), actionCollection() );
\end{verbatim}
\normalsize


\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em b\-Allow\-Letter\-Shortcuts}]Set to false if unmodified alphanumeric keys ('A', '1', etc.) are not permissible shortcuts. \item[{\em b\-Save\-Settings}]if true, the settings will also be saved back to the $\ast$uirc file which they were intially read from. \end{description}
\end{Desc}
\begin{Desc}
\item[Since:]3.3 \end{Desc}


Definition at line 553 of file kxmlguifactory.cpp.

References KXMLGUIClient::action\-Collection(), KKey\-Dialog::configure(), KKey\-Dialog::insert(), QString::is\-Empty(), QObject::parent(), and KXMLGUIClient::xml\-File().

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