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

tdeui

  • tdeui
kxmlguifactory_p.cpp
1 /* This file is part of the KDE libraries
2  Copyright (C) 2001 Simon Hausmann <hausmann@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #include "kxmlguifactory_p.h"
21 #include "kxmlguiclient.h"
22 #include "kxmlguibuilder.h"
23 
24 #include <tqwidget.h>
25 
26 #include <tdeglobal.h>
27 #include <kdebug.h>
28 
29 #include <assert.h>
30 
31 using namespace KXMLGUI;
32 
33 void ActionList::plug( TQWidget *container, int index ) const
34 {
35  ActionListIt it( *this );
36  for (; it.current(); ++it )
37  it.current()->plug( container, index++ );
38 }
39 
40 void ActionList::unplug( TQWidget *container ) const
41 {
42  ActionListIt it( *this );
43  for (; it.current(); ++it )
44  it.current()->unplug( container );
45 }
46 
47 ContainerNode::ContainerNode( TQWidget *_container, const TQString &_tagName,
48  const TQString &_name, ContainerNode *_parent,
49  KXMLGUIClient *_client, KXMLGUIBuilder *_builder,
50  int id, const TQString &_mergingName,
51  const TQString &_groupName, const TQStringList &customTags,
52  const TQStringList &containerTags )
53  : parent( _parent ), client( _client ), builder( _builder ),
54  builderCustomTags( customTags ), builderContainerTags( containerTags ),
55  container( _container ), containerId( id ), tagName( _tagName ), name( _name ),
56  groupName( _groupName ), index( 0 ), mergingName( _mergingName )
57 {
58  children.setAutoDelete( true );
59  clients.setAutoDelete( true );
60 
61  if ( parent )
62  parent->children.append( this );
63 }
64 
65 void ContainerNode::removeChild( ContainerNode *child )
66 {
67  MergingIndexList::Iterator mergingIt = findIndex( child->mergingName );
68  adjustMergingIndices( -1, mergingIt );
69  children.removeRef( child );
70 }
71 
72 /*
73  * Find a merging index with the given name. Used to find an index defined by <Merge name="blah"/>
74  * or by a <DefineGroup name="foo" /> tag.
75  */
76 MergingIndexList::Iterator ContainerNode::findIndex( const TQString &name )
77 {
78  MergingIndexList::Iterator it( mergingIndices.begin() );
79  MergingIndexList::Iterator end( mergingIndices.end() );
80  for (; it != end; ++it )
81  if ( (*it).mergingName == name )
82  return it;
83  return it;
84 }
85 
86 /*
87  * Check if the given container widget is a child of this node and return the node structure
88  * if found.
89  */
90 ContainerNode *ContainerNode::findContainerNode( TQWidget *container )
91 {
92  ContainerNodeListIt it( children );
93 
94  for (; it.current(); ++it )
95  if ( it.current()->container == container )
96  return it.current();
97 
98  return 0L;
99 }
100 
101 /*
102  * Find a container recursively with the given name. Either compares _name with the
103  * container's tag name or the value of the container's name attribute. Specified by
104  * the tag bool .
105  */
106 ContainerNode *ContainerNode::findContainer( const TQString &_name, bool tag )
107 {
108  if ( ( tag && tagName == _name ) ||
109  ( !tag && name == _name ) )
110  return this;
111 
112  ContainerNodeListIt it( children );
113  for (; it.current(); ++it )
114  {
115  ContainerNode *res = it.current()->findContainer( _name, tag );
116  if ( res )
117  return res;
118  }
119 
120  return 0;
121 }
122 
123 /*
124  * Finds a child container node (not recursively) with the given name and tagname. Explicitly
125  * leaves out container widgets specified in the exludeList . Also ensures that the containers
126  * belongs to currClient.
127  */
128 ContainerNode *ContainerNode::findContainer( const TQString &name, const TQString &tagName,
129  const TQPtrList<TQWidget> *excludeList,
130  KXMLGUIClient * /*currClient*/ )
131 {
132  ContainerNode *res = 0L;
133  ContainerNodeListIt nIt( children );
134 
135  if ( !name.isEmpty() )
136  {
137  for (; nIt.current(); ++nIt )
138  if ( nIt.current()->name == name &&
139  !excludeList->containsRef( nIt.current()->container ) )
140  {
141  res = nIt.current();
142  break;
143  }
144 
145  return res;
146  }
147 
148  if ( !tagName.isEmpty() )
149  for (; nIt.current(); ++nIt )
150  {
151  if ( nIt.current()->tagName == tagName &&
152  !excludeList->containsRef( nIt.current()->container )
153  /*
154  * It is a bad idea to also compare the client, because
155  * we don't want to do so in situations like these:
156  *
157  * <MenuBar>
158  * <Menu>
159  * ...
160  *
161  * other client:
162  * <MenuBar>
163  * <Menu>
164  * ...
165  *
166  && nIt.current()->client == currClient )
167  */
168  )
169  {
170  res = nIt.current();
171  break;
172  }
173  }
174 
175  return res;
176 }
177 
178 ContainerClient *ContainerNode::findChildContainerClient( KXMLGUIClient *currentGUIClient,
179  const TQString &groupName,
180  const MergingIndexList::Iterator &mergingIdx )
181 {
182  if ( !clients.isEmpty() )
183  {
184  ContainerClientListIt clientIt( clients );
185 
186  for (; clientIt.current(); ++clientIt )
187  if ( clientIt.current()->client == currentGUIClient )
188  {
189  if ( groupName.isEmpty() )
190  return clientIt.current();
191 
192  if ( groupName == clientIt.current()->groupName )
193  return clientIt.current();
194  }
195  }
196 
197  ContainerClient *client = new ContainerClient;
198  client->client = currentGUIClient;
199  client->groupName = groupName;
200 
201  if ( mergingIdx != mergingIndices.end() )
202  client->mergingName = (*mergingIdx).mergingName;
203 
204  clients.append( client );
205 
206  return client;
207 }
208 
209 void ContainerNode::plugActionList( BuildState &state )
210 {
211  MergingIndexList::Iterator mIt( mergingIndices.begin() );
212  MergingIndexList::Iterator mEnd( mergingIndices.end() );
213  for (; mIt != mEnd; ++mIt )
214  plugActionList( state, mIt );
215 
216  TQPtrListIterator<ContainerNode> childIt( children );
217  for (; childIt.current(); ++childIt )
218  childIt.current()->plugActionList( state );
219 }
220 
221 void ContainerNode::plugActionList( BuildState &state, const MergingIndexList::Iterator &mergingIdxIt )
222 {
223  static const TQString &tagActionList = TDEGlobal::staticQString( "actionlist" );
224 
225  MergingIndex mergingIdx = *mergingIdxIt;
226 
227  TQString k( mergingIdx.mergingName );
228 
229  if ( k.find( tagActionList ) == -1 )
230  return;
231 
232  k = k.mid( tagActionList.length() );
233 
234  if ( mergingIdx.clientName != state.clientName )
235  return;
236 
237  if ( k != state.actionListName )
238  return;
239 
240  ContainerClient *client = findChildContainerClient( state.guiClient,
241  TQString(),
242  mergingIndices.end() );
243 
244  client->actionLists.insert( k, state.actionList );
245 
246  state.actionList.plug( container, mergingIdx.value );
247 
248  adjustMergingIndices( state.actionList.count(), mergingIdxIt );
249 }
250 
251 void ContainerNode::unplugActionList( BuildState &state )
252 {
253  MergingIndexList::Iterator mIt( mergingIndices.begin() );
254  MergingIndexList::Iterator mEnd( mergingIndices.end() );
255  for (; mIt != mEnd; ++mIt )
256  unplugActionList( state, mIt );
257 
258  TQPtrListIterator<ContainerNode> childIt( children );
259  for (; childIt.current(); ++childIt )
260  childIt.current()->unplugActionList( state );
261 }
262 
263 void ContainerNode::unplugActionList( BuildState &state, const MergingIndexList::Iterator &mergingIdxIt )
264 {
265  static const TQString &tagActionList = TDEGlobal::staticQString( "actionlist" );
266 
267  MergingIndex mergingIdx = *mergingIdxIt;
268 
269  TQString k = mergingIdx.mergingName;
270 
271  if ( k.find( tagActionList ) == -1 )
272  return;
273 
274  k = k.mid( tagActionList.length() );
275 
276  if ( mergingIdx.clientName != state.clientName )
277  return;
278 
279  if ( k != state.actionListName )
280  return;
281 
282  ContainerClient *client = findChildContainerClient( state.guiClient,
283  TQString(),
284  mergingIndices.end() );
285 
286  ActionListMap::Iterator lIt( client->actionLists.find( k ) );
287  if ( lIt == client->actionLists.end() )
288  return;
289 
290  lIt.data().unplug( container );
291 
292  adjustMergingIndices( -int(lIt.data().count()), mergingIdxIt );
293 
294  client->actionLists.remove( lIt );
295 }
296 
297 void ContainerNode::adjustMergingIndices( int offset,
298  const MergingIndexList::Iterator &it )
299 {
300  MergingIndexList::Iterator mergingIt = it;
301  MergingIndexList::Iterator mergingEnd = mergingIndices.end();
302 
303  for (; mergingIt != mergingEnd; ++mergingIt )
304  (*mergingIt).value += offset;
305 
306  index += offset;
307 }
308 
309 bool ContainerNode::destruct( TQDomElement element, BuildState &state )
310 {
311  destructChildren( element, state );
312 
313  unplugActions( state );
314 
315  // remove all merging indices the client defined
316  MergingIndexList::Iterator cmIt = mergingIndices.begin();
317  while ( cmIt != mergingIndices.end() )
318  if ( (*cmIt).clientName == state.clientName )
319  cmIt = mergingIndices.remove( cmIt );
320  else
321  ++cmIt;
322 
323  // ### check for merging index count, too?
324  if ( clients.count() == 0 && children.count() == 0 && container &&
325  client == state.guiClient )
326  {
327  TQWidget *parentContainer = 0L;
328 
329  if ( parent && parent->container )
330  parentContainer = parent->container;
331 
332  assert( builder );
333 
334  builder->removeContainer( container, parentContainer, element, containerId );
335 
336  client = 0L;
337 
338  return true;
339  }
340 
341  if ( client == state.guiClient )
342  client = 0L;
343 
344  return false;
345 
346 }
347 
348 void ContainerNode::destructChildren( const TQDomElement &element, BuildState &state )
349 {
350  TQPtrListIterator<ContainerNode> childIt( children );
351  while ( childIt.current() )
352  {
353  ContainerNode *childNode = childIt.current();
354 
355  TQDomElement childElement = findElementForChild( element, childNode );
356 
357  // destruct returns true in case the container really got deleted
358  if ( childNode->destruct( childElement, state ) )
359  removeChild( childNode );
360  else
361  ++childIt;
362  }
363 }
364 
365 TQDomElement ContainerNode::findElementForChild( const TQDomElement &baseElement,
366  ContainerNode *childNode )
367 {
368  static const TQString &attrName = TDEGlobal::staticQString( "name" );
369 
370  // ### slow
371  for ( TQDomNode n = baseElement.firstChild(); !n.isNull();
372  n = n.nextSibling() )
373  {
374  TQDomElement e = n.toElement();
375  if ( e.tagName().lower() == childNode->tagName &&
376  e.attribute( attrName ) == childNode->name )
377  return e;
378  }
379 
380  return TQDomElement();
381 }
382 
383 void ContainerNode::unplugActions( BuildState &state )
384 {
385  if ( !container )
386  return;
387 
388  ContainerClientListIt clientIt( clients );
389 
390  /*
391  Disabled because it means in TDEToolBar::saveState isHidden is always true then,
392  which is clearly wrong.
393 
394  if ( clients.count() == 1 && clientIt.current()->client == client &&
395  client == state.guiClient )
396  container->hide(); // this container is going to die, that's for sure.
397  // in this case let's just hide it, which makes the
398  // destruction faster
399  */
400 
401  while ( clientIt.current() )
402  //only unplug the actions of the client we want to remove, as the container might be owned
403  //by a different client
404  if ( clientIt.current()->client == state.guiClient )
405  {
406  unplugClient( clientIt.current() );
407  clients.removeRef( clientIt.current() );
408  }
409  else
410  ++clientIt;
411 }
412 
413 void ContainerNode::unplugClient( ContainerClient *client )
414 {
415  static const TQString &tagActionList = TDEGlobal::staticQString( "actionlist" );
416 
417  assert( builder );
418 
419  // now quickly remove all custom elements (i.e. separators) and unplug all actions
420 
421  TQValueList<int>::ConstIterator custIt = client->customElements.begin();
422  TQValueList<int>::ConstIterator custEnd = client->customElements.end();
423  for (; custIt != custEnd; ++custIt )
424  builder->removeCustomElement( container, *custIt );
425 
426  client->actions.unplug( container );
427 
428  // now adjust all merging indices
429 
430  MergingIndexList::Iterator mergingIt = findIndex( client->mergingName );
431 
432  adjustMergingIndices( - int( client->actions.count()
433  + client->customElements.count() ),
434  mergingIt );
435 
436  // unplug all actionslists
437 
438  ActionListMap::ConstIterator alIt = client->actionLists.begin();
439  ActionListMap::ConstIterator alEnd = client->actionLists.end();
440  for (; alIt != alEnd; ++alIt )
441  {
442  alIt.data().unplug( container );
443 
444  // construct the merging index key (i.e. like named merging) , find the
445  // corresponding merging index and adjust all indices
446  TQString mergingKey = alIt.key();
447  mergingKey.prepend( tagActionList );
448 
449  MergingIndexList::Iterator mIt = findIndex( mergingKey );
450  if ( mIt == mergingIndices.end() )
451  continue;
452 
453  adjustMergingIndices( -int(alIt.data().count()), mIt );
454 
455  // remove the actionlists' merging index
456  // ### still needed? we clean up below anyway?
457  mergingIndices.remove( mIt );
458  }
459 }
460 
461 void ContainerNode::reset()
462 {
463  TQPtrListIterator<ContainerNode> childIt( children );
464  for (; childIt.current(); ++childIt )
465  childIt.current()->reset();
466 
467  if ( client )
468  client->setFactory( 0L );
469 }
470 
471 int ContainerNode::calcMergingIndex( const TQString &mergingName,
472  MergingIndexList::Iterator &it,
473  BuildState &state,
474  bool ignoreDefaultMergingIndex )
475 {
476  MergingIndexList::Iterator mergingIt;
477 
478  if ( mergingName.isEmpty() )
479  mergingIt = findIndex( state.clientName );
480  else
481  mergingIt = findIndex( mergingName );
482 
483  MergingIndexList::Iterator mergingEnd = mergingIndices.end();
484  it = mergingEnd;
485 
486  if ( ( mergingIt == mergingEnd && state.currentDefaultMergingIt == mergingEnd ) ||
487  ignoreDefaultMergingIndex )
488  return index;
489 
490  if ( mergingIt != mergingEnd )
491  it = mergingIt;
492  else
493  it = state.currentDefaultMergingIt;
494 
495  return (*it).value;
496 }
497 
498 int BuildHelper::calcMergingIndex( const TQDomElement &element, MergingIndexList::Iterator &it, TQString &group )
499 {
500  static const TQString &attrGroup = TDEGlobal::staticQString( "group" );
501 
502  bool haveGroup = false;
503  group = element.attribute( attrGroup );
504  if ( !group.isEmpty() ) {
505  group.prepend( attrGroup );
506  haveGroup = true;
507  }
508 
509  int idx;
510  if ( haveGroup )
511  idx = parentNode->calcMergingIndex( group, it, m_state, ignoreDefaultMergingIndex );
512  else if ( m_state.currentClientMergingIt == parentNode->mergingIndices.end() )
513  idx = parentNode->index;
514  else
515  idx = (*m_state.currentClientMergingIt).value;
516 
517  return idx;
518 }
519 
520 BuildHelper::BuildHelper( BuildState &state, ContainerNode *node )
521  : containerClient( 0 ), ignoreDefaultMergingIndex( false ), m_state( state ),
522  parentNode( node )
523 {
524  static const TQString &defaultMergingName = TDEGlobal::staticQString( "<default>" );
525 
526  // create a list of supported container and custom tags
527  customTags = m_state.builderCustomTags;
528  containerTags = m_state.builderContainerTags;
529 
530  if ( parentNode->builder != m_state.builder )
531  {
532  customTags += parentNode->builderCustomTags;
533  containerTags += parentNode->builderContainerTags;
534  }
535 
536  if ( m_state.clientBuilder ) {
537  customTags = m_state.clientBuilderCustomTags + customTags;
538  containerTags = m_state.clientBuilderContainerTags + containerTags;
539  }
540 
541  m_state.currentDefaultMergingIt = parentNode->findIndex( defaultMergingName );
542  parentNode->calcMergingIndex( TQString(), m_state.currentClientMergingIt,
543  m_state, /*ignoreDefaultMergingIndex*/ false );
544 }
545 
546 void BuildHelper::build( const TQDomElement &element )
547 {
548  for (TQDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling() )
549  {
550  TQDomElement e = n.toElement();
551  if (e.isNull()) continue;
552  processElement( e );
553  }
554 }
555 
556 void BuildHelper::processElement( const TQDomElement &e )
557 {
558  // some often used QStrings
559  static const TQString &tagAction = TDEGlobal::staticQString( "action" );
560  static const TQString &tagMerge = TDEGlobal::staticQString( "merge" );
561  static const TQString &tagState = TDEGlobal::staticQString( "state" );
562  static const TQString &tagDefineGroup = TDEGlobal::staticQString( "definegroup" );
563  static const TQString &tagActionList = TDEGlobal::staticQString( "actionlist" );
564  static const TQString &attrName = TDEGlobal::staticQString( "name" );
565 
566  TQString tag( e.tagName().lower() );
567  TQString currName( e.attribute( attrName ) );
568 
569  bool isActionTag = ( tag == tagAction );
570 
571  if ( isActionTag || customTags.findIndex( tag ) != -1 )
572  processActionOrCustomElement( e, isActionTag );
573  else if ( containerTags.findIndex( tag ) != -1 )
574  processContainerElement( e, tag, currName );
575  else if ( tag == tagMerge || tag == tagDefineGroup || tag == tagActionList )
576  processMergeElement( tag, currName, e );
577  else if ( tag == tagState )
578  processStateElement( e );
579 }
580 
581 void BuildHelper::processActionOrCustomElement( const TQDomElement &e, bool isActionTag )
582 {
583  if ( !parentNode->container )
584  return;
585 
586  MergingIndexList::Iterator it( m_state.currentClientMergingIt );
587 
588  TQString group;
589  int idx = calcMergingIndex( e, it, group );
590 
591  containerClient = parentNode->findChildContainerClient( m_state.guiClient, group, it );
592 
593  bool guiElementCreated = false;
594  if ( isActionTag )
595  guiElementCreated = processActionElement( e, idx );
596  else
597  guiElementCreated = processCustomElement( e, idx );
598 
599  if ( guiElementCreated )
600  // adjust any following merging indices and the current running index for the container
601  parentNode->adjustMergingIndices( 1, it );
602 }
603 
604 bool BuildHelper::processActionElement( const TQDomElement &e, int idx )
605 {
606  assert( m_state.guiClient );
607 
608  // look up the action and plug it in
609  TDEAction *action = m_state.guiClient->action( e );
610 
611  //kdDebug() << "BuildHelper::processActionElement " << e.attribute( "name" ) << " -> " << action << " (in " << m_state.guiClient->actionCollection() << ")" << endl;
612  if ( !action )
613  return false;
614 
615  action->plug( parentNode->container, idx );
616 
617  // save a reference to the plugged action, in order to properly unplug it afterwards.
618  containerClient->actions.append( action );
619 
620  return true;
621 }
622 
623 bool BuildHelper::processCustomElement( const TQDomElement &e, int idx )
624 {
625  assert( parentNode->builder );
626 
627  int id = parentNode->builder->createCustomElement( parentNode->container, idx, e );
628  if ( id == 0 )
629  return false;
630 
631  containerClient->customElements.append( id );
632  return true;
633 }
634 
635 void BuildHelper::processStateElement( const TQDomElement &element )
636 {
637  TQString stateName = element.attribute( "name" );
638 
639  if ( !stateName || !stateName.length() ) return;
640 
641  for (TQDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling() )
642  {
643  TQDomElement e = n.toElement();
644  if (e.isNull()) continue;
645 
646  TQString tagName = e.tagName().lower();
647 
648  if ( tagName != "enable" && tagName != "disable" )
649  continue;
650 
651  bool processingActionsToEnable = (tagName == "enable");
652 
653  // process action names
654  for (TQDomNode n2 = n.firstChild(); !n2.isNull(); n2 = n2.nextSibling() )
655  {
656  TQDomElement actionEl = n2.toElement();
657  if ( actionEl.tagName().lower() != "action" ) continue;
658 
659  TQString actionName = actionEl.attribute( "name" );
660  if ( !actionName || !actionName.length() ) return;
661 
662  if ( processingActionsToEnable )
663  m_state.guiClient->addStateActionEnabled( stateName, actionName );
664  else
665  m_state.guiClient->addStateActionDisabled( stateName, actionName );
666 
667  }
668  }
669 }
670 
671 void BuildHelper::processMergeElement( const TQString &tag, const TQString &name, const TQDomElement &e )
672 {
673  static const TQString &tagDefineGroup = TDEGlobal::staticQString( "definegroup" );
674  static const TQString &tagActionList = TDEGlobal::staticQString( "actionlist" );
675  static const TQString &defaultMergingName = TDEGlobal::staticQString( "<default>" );
676  static const TQString &attrGroup = TDEGlobal::staticQString( "group" );
677 
678  TQString mergingName( name );
679  if ( mergingName.isEmpty() )
680  {
681  if ( tag == tagDefineGroup )
682  {
683  kdError(1000) << "cannot define group without name!" << endl;
684  return;
685  }
686  if ( tag == tagActionList )
687  {
688  kdError(1000) << "cannot define actionlist without name!" << endl;
689  return;
690  }
691  mergingName = defaultMergingName;
692  }
693 
694  if ( tag == tagDefineGroup )
695  mergingName.prepend( attrGroup ); //avoid possible name clashes by prepending
696  // "group" to group definitions
697  else if ( tag == tagActionList )
698  mergingName.prepend( tagActionList );
699 
700  if ( parentNode->findIndex( mergingName ) != parentNode->mergingIndices.end() )
701  return; //do not allow the redefinition of merging indices!
702 
703  MergingIndexList::Iterator mIt( parentNode->mergingIndices.end() );
704 
705  TQString group( e.attribute( attrGroup ) );
706  if ( !group.isEmpty() )
707  group.prepend( attrGroup );
708 
709  // calculate the index of the new merging index. Usually this does not need any calculation,
710  // we just want the last available index (i.e. append) . But in case the <Merge> tag appears
711  // "inside" another <Merge> tag from a previously build client, then we have to use the
712  // "parent's" index. That's why we call calcMergingIndex here.
713  MergingIndex newIdx;
714  newIdx.value = parentNode->calcMergingIndex( group, mIt, m_state, ignoreDefaultMergingIndex );
715  newIdx.mergingName = mergingName;
716  newIdx.clientName = m_state.clientName;
717 
718  // if that merging index is "inside" another one, then append it right after the "parent" .
719  if ( mIt != parentNode->mergingIndices.end() )
720  parentNode->mergingIndices.insert( ++mIt, newIdx );
721  else
722  parentNode->mergingIndices.append( newIdx );
723 
724  if ( mergingName == defaultMergingName )
725 
726  ignoreDefaultMergingIndex = true;
727 
728  // re-calculate the running default and client merging indices.
729  m_state.currentDefaultMergingIt = parentNode->findIndex( defaultMergingName );
730  parentNode->calcMergingIndex( TQString(), m_state.currentClientMergingIt,
731  m_state, ignoreDefaultMergingIndex );
732 }
733 
734 void BuildHelper::processContainerElement( const TQDomElement &e, const TQString &tag,
735  const TQString &name )
736 {
737  static const TQString &defaultMergingName = TDEGlobal::staticQString( "<default>" );
738 
739  ContainerNode *containerNode = parentNode->findContainer( name, tag,
740  &containerList,
741  m_state.guiClient );
742 
743  if ( !containerNode )
744  {
745  MergingIndexList::Iterator it( m_state.currentClientMergingIt );
746  TQString group;
747 
748  int idx = calcMergingIndex( e, it, group );
749 
750  int id;
751 
752  KXMLGUIBuilder *builder;
753 
754  TQWidget *container = createContainer( parentNode->container, idx, e, id, &builder );
755 
756  // no container? (probably some <text> tag or so ;-)
757  if ( !container )
758  return;
759 
760  parentNode->adjustMergingIndices( 1, it );
761 
762  assert( !parentNode->findContainerNode( container ) );
763 
764  containerList.append( container );
765 
766  TQString mergingName;
767  if ( it != parentNode->mergingIndices.end() )
768  mergingName = (*it).mergingName;
769 
770  TQStringList cusTags = m_state.builderCustomTags;
771  TQStringList conTags = m_state.builderContainerTags;
772  if ( builder != m_state.builder )
773  {
774  cusTags = m_state.clientBuilderCustomTags;
775  conTags = m_state.clientBuilderContainerTags;
776  }
777 
778  containerNode = new ContainerNode( container, tag, name, parentNode,
779  m_state.guiClient, builder, id,
780  mergingName, group, cusTags, conTags );
781  }
782 
783  BuildHelper( m_state, containerNode ).build( e );
784 
785  // and re-calculate running values, for better performance
786  m_state.currentDefaultMergingIt = parentNode->findIndex( defaultMergingName );
787  parentNode->calcMergingIndex( TQString(), m_state.currentClientMergingIt,
788  m_state, ignoreDefaultMergingIndex );
789 }
790 
791 TQWidget *BuildHelper::createContainer( TQWidget *parent, int index,
792  const TQDomElement &element, int &id,
793  KXMLGUIBuilder **builder )
794 {
795  TQWidget *res = 0L;
796 
797  if ( m_state.clientBuilder )
798  {
799  res = m_state.clientBuilder->createContainer( parent, index, element, id );
800 
801  if ( res )
802  {
803  *builder = m_state.clientBuilder;
804  return res;
805  }
806  }
807 
808  TDEInstance *oldInstance = m_state.builder->builderInstance();
809  KXMLGUIClient *oldClient = m_state.builder->builderClient();
810 
811  m_state.builder->setBuilderClient( m_state.guiClient );
812 
813  res = m_state.builder->createContainer( parent, index, element, id );
814 
815  m_state.builder->setBuilderInstance( oldInstance );
816  m_state.builder->setBuilderClient( oldClient );
817 
818  if ( res )
819  *builder = m_state.builder;
820 
821  return res;
822 }
823 
824 void BuildState::reset()
825 {
826  clientName = TQString();
827  actionListName = TQString();
828  actionList.clear();
829  guiClient = 0;
830  clientBuilder = 0;
831 
832  currentDefaultMergingIt = currentClientMergingIt = MergingIndexList::Iterator();
833 }
KXMLGUIBuilder
Abstract interface for a "GUI builder", used by the GUIFactory This interface is implemented by TDEMa...
Definition: kxmlguibuilder.h:40
KXMLGUIClient
A KXMLGUIClient can be used with KXMLGUIFactory to create a GUI from actions and an XML document,...
Definition: kxmlguiclient.h:44
TDEAction
Class to encapsulate user-driven action or event.
Definition: tdeaction.h:203
TDEGlobal::staticQString
static const TQString & staticQString(const char *str)
TDEInstance
endl
kndbgstream & endl(kndbgstream &s)
kdError
kdbgstream kdError(int area=0)
TDEStdAccel::name
TQString name(StdAccel id)
TDEStdAccel::end
const TDEShortcut & end()
TDEStdAccel::action
TQString action(StdAccel id)

tdeui

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

tdeui

Skip menu "tdeui"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeui by doxygen 1.9.1
This website is maintained by Timothy Pearson.