• 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 
26 class KonqXMLGUIClient::Private
27 {
28 public:
29  Private() : attrName( "name" ), separatorPending( false ), hasAction( false ) {}
30  TQString attrName;
31  bool separatorPending;
32  bool hasAction;
33 };
34 
35 KonqXMLGUIClient::KonqXMLGUIClient( ) : KXMLGUIClient( )
36 {
37  d = new Private;
38  prepareXMLGUIStuff( );
39 }
40 
41 KonqXMLGUIClient::KonqXMLGUIClient( KXMLGUIClient *parent ) : KXMLGUIClient(parent )
42 {
43  d = new Private;
44  prepareXMLGUIStuff( );
45 }
46 
47 void 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 
63 TQDomElement KonqXMLGUIClient::DomElement() const
64 {
65  return m_menuElement;
66 }
67 
68 TQDomDocument KonqXMLGUIClient::domDocument() const
69 {
70  return m_doc;
71 }
72 
73 void KonqXMLGUIClient::addAction( TDEAction *act, const TQDomElement &menu )
74 {
75  addAction( act->name(), menu );
76 }
77 
78 void KonqXMLGUIClient::addAction( const char *name, const TQDomElement &menu )
79 {
80  static const TQString& tagAction = TDEGlobal::staticQString( "action" );
81 
82  if (!kapp->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 
97 void 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 
117 void 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 
127 void 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 
135 KonqXMLGUIClient::~KonqXMLGUIClient()
136 {
137  delete d;
138 }
139 
140 void KonqXMLGUIClient::handlePendingSeparator()
141 {
142  if ( d->separatorPending ) {
143  addSeparator();
144  }
145 }
146 
147 void KonqXMLGUIClient::addPendingSeparator()
148 {
149  d->separatorPending = true;
150 }
151 
152 bool KonqXMLGUIClient::hasAction() const
153 {
154  return d->hasAction;
155 }
156 
157 

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.8.1.2
This website is maintained by Timothy Pearson.