libkonq Library API Documentation

konq_xmlguiclient.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 2001 Holger Freyther <freyther@yahoo.com>
00003    Copyright (c) 1998, 1999 David Faure <faure@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 as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
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., 59 Temple Place - Suite 330,
00018    Boston, MA 02111-1307, USA.
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   /*m_builder = new KonqPopupMenuGUIBuilder( this );
00049   m_factory = new KXMLGUIFactory( m_builder ); */
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 }
KDE Logo
This file is part of the documentation for libkonq Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun Aug 20 13:39:03 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003