• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • libkonq
 

libkonq

  • libkonq
konq_xmlguiclient.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2001 Holger Freyther <freyther@yahoo.com>
3 Copyright (c) 1998, 1999 David Faure <faure@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#include "tdeapplication.h"
22
23#include "konq_xmlguiclient.h"
24#include <kdebug.h>
25
26class KonqXMLGUIClient::Private
27{
28public:
29 Private() : attrName( "name" ), separatorPending( false ), hasAction( false ) {}
30 TQString attrName;
31 bool separatorPending;
32 bool hasAction;
33};
34
35KonqXMLGUIClient::KonqXMLGUIClient( ) : KXMLGUIClient( )
36{
37 d = new Private;
38 prepareXMLGUIStuff( );
39}
40
41KonqXMLGUIClient::KonqXMLGUIClient( KXMLGUIClient *parent ) : KXMLGUIClient(parent )
42{
43 d = new Private;
44 prepareXMLGUIStuff( );
45}
46
47void KonqXMLGUIClient::prepareXMLGUIStuff()
48{
49 m_doc = TQDomDocument( "kpartgui" );
50
51 TQDomElement root = m_doc.createElement( "kpartgui" );
52 m_doc.appendChild( root );
53 root.setAttribute( d->attrName, "popupmenu" );
54
55 m_menuElement = m_doc.createElement( "Menu" );
56 root.appendChild( m_menuElement );
57 m_menuElement.setAttribute( d->attrName, "popupmenu" );
58
59 /*m_builder = new KonqPopupMenuGUIBuilder( this );
60 m_factory = new KXMLGUIFactory( m_builder ); */
61}
62
63TQDomElement KonqXMLGUIClient::DomElement() const
64{
65 return m_menuElement;
66}
67
68TQDomDocument KonqXMLGUIClient::domDocument() const
69{
70 return m_doc;
71}
72
73void KonqXMLGUIClient::addAction( TDEAction *act, const TQDomElement &menu )
74{
75 addAction( act->name(), menu );
76}
77
78void KonqXMLGUIClient::addAction( const char *name, const TQDomElement &menu )
79{
80 static const TQString& tagAction = TDEGlobal::staticQString( "action" );
81
82 if (!tdeApp->authorizeTDEAction(name))
83 return;
84
85 handlePendingSeparator();
86 TQDomElement parent = menu;
87 if ( parent.isNull() ) {
88 parent = m_menuElement;
89 }
90
91 TQDomElement e = m_doc.createElement( tagAction );
92 parent.appendChild( e );
93 e.setAttribute( d->attrName, name );
94 d->hasAction = true;
95}
96
97void KonqXMLGUIClient::addSeparator( const TQDomElement &menu )
98{
99 static const TQString& tagSeparator = TDEGlobal::staticQString( "separator" );
100
101 TQDomElement parent = menu;
102 if ( parent.isNull() ) {
103 parent = m_menuElement;
104 }
105
106 parent.appendChild( m_doc.createElement( tagSeparator ) );
107
108 d->separatorPending = false;
109}
110
111//void KonqXMLGUIClient::addWeakSeparator()
112//{
113// static const TQString& tagWeakSeparator = TDEGlobal::staticQString( "weakSeparator" );
114// m_menuElement.appendChild( m_doc.createElement( tagWeakSeparator ) );
115//}
116
117void KonqXMLGUIClient::addMerge( const TQString &name )
118{
119 // can't call handlePendingSeparator. Merge could be empty
120 // (testcase: RMB in embedded katepart)
121 TQDomElement merge = m_doc.createElement( "merge" );
122 m_menuElement.appendChild( merge );
123 if ( !name.isEmpty() )
124 merge.setAttribute( d->attrName, name );
125}
126
127void KonqXMLGUIClient::addGroup( const TQString &grp )
128{
129 handlePendingSeparator();
130 TQDomElement group = m_doc.createElement( "definegroup" );
131 m_menuElement.appendChild( group );
132 group.setAttribute( d->attrName, grp );
133}
134
135KonqXMLGUIClient::~KonqXMLGUIClient()
136{
137 delete d;
138}
139
140void KonqXMLGUIClient::handlePendingSeparator()
141{
142 if ( d->separatorPending ) {
143 addSeparator();
144 }
145}
146
147void KonqXMLGUIClient::addPendingSeparator()
148{
149 d->separatorPending = true;
150}
151
152bool KonqXMLGUIClient::hasAction() const
153{
154 return d->hasAction;
155}
156
157bool KonqXMLGUIClient::hasGroup(const TQString &name) const
158{
159 if (name.isEmpty())
160 {
161 return false;
162 }
163 TQDomNodeList groups = m_doc.elementsByTagName("definegroup");
164 for (uint idx = 0; idx < groups.count(); ++idx)
165 {
166 TQDomElement group = groups.item(idx).toElement();
167 if (group.hasAttribute(d->attrName) && group.attribute(d->attrName) == name)
168 {
169 return true;
170 }
171 }
172 return false;
173}
174
KonqXMLGUIClient::addPendingSeparator
void addPendingSeparator()
only add a separator if an action is added afterwards
Definition: konq_xmlguiclient.cpp:147
KonqXMLGUIClient::domDocument
TQDomDocument domDocument() const
Reimplemented for internal purpose.
Definition: konq_xmlguiclient.cpp:68

libkonq

Skip menu "libkonq"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

libkonq

Skip menu "libkonq"
  • kate
  • libkonq
  • twin
  •   lib
Generated for libkonq by doxygen 1.9.4
This website is maintained by Timothy Pearson.