00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#include "kapplication.h"
00022
00023
#include "konq_xmlguiclient.h"
00024
00025 KonqXMLGUIClient::KonqXMLGUIClient( ) : KXMLGUIClient( )
00026 {
00027 attrName = QString::fromLatin1(
"name" );
00028 prepareXMLGUIStuff( );
00029 }
00030 KonqXMLGUIClient::KonqXMLGUIClient( KXMLGUIClient *parent ) : KXMLGUIClient(parent )
00031 {
00032 attrName = QString::fromLatin1(
"name" );
00033 prepareXMLGUIStuff( );
00034 }
00035
00036
void KonqXMLGUIClient::prepareXMLGUIStuff()
00037 {
00038 m_doc = QDomDocument(
"kpartgui" );
00039
00040 QDomElement root = m_doc.createElement(
"kpartgui" );
00041 m_doc.appendChild( root );
00042 root.setAttribute( attrName,
"popupmenu" );
00043
00044 m_menuElement = m_doc.createElement(
"Menu" );
00045 root.appendChild( m_menuElement );
00046 m_menuElement.setAttribute( attrName,
"popupmenu" );
00047
00048
00049
00050 }
00051
00052 QDomElement KonqXMLGUIClient::DomElement( )
const {
00053
return m_menuElement;
00054 }
00055 QDomDocument
KonqXMLGUIClient::domDocument( )
const {
00056
return m_doc;
00057 }
00058
void KonqXMLGUIClient::addAction( KAction *act,
const QDomElement &menu )
00059 {
00060 addAction( act->name(), menu );
00061 }
00062
00063
void KonqXMLGUIClient::addAction(
const char *name,
const QDomElement &menu )
00064 {
00065
static QString tagAction = QString::fromLatin1(
"action" );
00066
00067
if (!kapp->authorizeKAction(name))
00068
return;
00069
00070 QDomElement parent = menu;
00071
if ( parent.isNull() )
00072 parent = m_menuElement;
00073
00074 QDomElement e = m_doc.createElement( tagAction );
00075 parent.appendChild( e );
00076 e.setAttribute( attrName, name );
00077 }
00078
00079
void KonqXMLGUIClient::addSeparator(
const QDomElement &menu )
00080 {
00081
static QString tagSeparator = QString::fromLatin1(
"separator" );
00082
00083 QDomElement parent = menu;
00084
if ( parent.isNull() )
00085 parent = m_menuElement;
00086
00087 parent.appendChild( m_doc.createElement( tagSeparator ) );
00088 }
00089
00090
void KonqXMLGUIClient::addMerge(
const QString &name )
00091 {
00092 QDomElement merge = m_doc.createElement(
"merge" );
00093 m_menuElement.appendChild( merge );
00094
if ( !name.isEmpty() )
00095 merge.setAttribute( attrName, name );
00096 }
00097
00098
void KonqXMLGUIClient::addGroup(
const QString &grp )
00099 {
00100 QDomElement group = m_doc.createElement(
"definegroup" );
00101 m_menuElement.appendChild( group );
00102 group.setAttribute(
"name", grp );
00103 }
00104
00105 KonqXMLGUIClient::~KonqXMLGUIClient( ){
00106 }