summaryrefslogtreecommitdiffabout
path: root/microkde/kdeui/kactioncollection.cpp
Unidiff
Diffstat (limited to 'microkde/kdeui/kactioncollection.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdeui/kactioncollection.cpp50
1 files changed, 26 insertions, 24 deletions
diff --git a/microkde/kdeui/kactioncollection.cpp b/microkde/kdeui/kactioncollection.cpp
index 69e5d02..4d66c7f 100644
--- a/microkde/kdeui/kactioncollection.cpp
+++ b/microkde/kdeui/kactioncollection.cpp
@@ -17,36 +17,38 @@
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Library General Public License for more details. 18 Library General Public License for more details.
19 19
20 You should have received a copy of the GNU Library General Public License 20 You should have received a copy of the GNU Library General Public License
21 along with this library; see the file COPYING.LIB. If not, write to 21 along with this library; see the file COPYING.LIB. If not, write to
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. 23 Boston, MA 02111-1307, USA.
24*/ 24*/
25 25
26#include "kactioncollection.h" 26#include "kactioncollection.h"
27//US#include "kactionshortcutlist.h" 27//US#include "kactionshortcutlist.h"
28 28
29#include <qptrdict.h> 29#include <q3ptrdict.h>
30//Added by qt3to4:
31#include <Q3ValueList>
30//US#include <qvariant.h> 32//US#include <qvariant.h>
31 33
32//US#include <kaccel.h> 34//US#include <kaccel.h>
33//US#include <kaccelbase.h> 35//US#include <kaccelbase.h>
34//US#include <kapplication.h> 36//US#include <kapplication.h>
35#include <kdebug.h> 37#include <kdebug.h>
36//US#include <kxmlguifactory.h> 38//US#include <kxmlguifactory.h>
37 39
38//US I included the following files 40//US I included the following files
39#include <qasciidict.h> 41#include <q3asciidict.h>
40#include <qptrlist.h> 42#include <q3ptrlist.h>
41#include "kaction.h" 43#include "kaction.h"
42#include <kglobal.h> 44#include <kglobal.h>
43#include <qobject.h> 45#include <qobject.h>
44#include <qwidget.h> 46#include <qwidget.h>
45 47
46class KActionCollection::KActionCollectionPrivate 48class KActionCollection::KActionCollectionPrivate
47{ 49{
48public: 50public:
49 KActionCollectionPrivate() 51 KActionCollectionPrivate()
50 { 52 {
51//US m_instance = 0; 53//US m_instance = 0;
52 //m_bOneKAccelOnly = false; 54 //m_bOneKAccelOnly = false;
@@ -58,31 +60,31 @@ public:
58 m_highlight = false; 60 m_highlight = false;
59 m_currentHighlightAction = 0; 61 m_currentHighlightAction = 0;
60 m_statusCleared = true; 62 m_statusCleared = true;
61 } 63 }
62 64
63//US KInstance *m_instance; 65//US KInstance *m_instance;
64//US QString m_sXMLFile; 66//US QString m_sXMLFile;
65 bool m_bAutoConnectShortcuts; 67 bool m_bAutoConnectShortcuts;
66 //bool m_bOneKAccelOnly; 68 //bool m_bOneKAccelOnly;
67 //int m_iWidgetCurrent; 69 //int m_iWidgetCurrent;
68 //QValueList<QWidget*> m_widgetList; 70 //QValueList<QWidget*> m_widgetList;
69 //QValueList<KAccel*> m_kaccelList; 71 //QValueList<KAccel*> m_kaccelList;
70 QValueList<KActionCollection*> m_docList; 72 Q3ValueList<KActionCollection*> m_docList;
71 QWidget *m_widget; 73 QWidget *m_widget;
72 KAccel *m_kaccel; 74 KAccel *m_kaccel;
73 KAccel *m_builderKAccel; 75 KAccel *m_builderKAccel;
74 76
75 QAsciiDict<KAction> m_actionDict; 77 Q3AsciiDict<KAction> m_actionDict;
76 QPtrDict< QPtrList<KAction> > m_dctHighlightContainers; 78 Q3PtrDict< Q3PtrList<KAction> > m_dctHighlightContainers;
77 bool m_highlight; 79 bool m_highlight;
78 KAction *m_currentHighlightAction; 80 KAction *m_currentHighlightAction;
79 bool m_statusCleared; 81 bool m_statusCleared;
80}; 82};
81 83
82KActionCollection::KActionCollection( QWidget *parent, const char *name /*US, 84KActionCollection::KActionCollection( QWidget *parent, const char *name /*US,
83 KInstance *instance */) 85 KInstance *instance */)
84 : QObject( (QObject*)parent, name ) 86 : QObject( (QObject*)parent, name )
85{ 87{
86 kdDebug(129) << "KActionCollection::KActionCollection( " << parent << ", " << name << " ): this = " << this << endl; // ellis 88 kdDebug(129) << "KActionCollection::KActionCollection( " << parent << ", " << name << " ): this = " << this << endl; // ellis
87 d = new KActionCollectionPrivate; 89 d = new KActionCollectionPrivate;
88 if( parent ) 90 if( parent )
@@ -124,25 +126,25 @@ KActionCollection::KActionCollection( QObject *parent, const char *name /*US,
124KActionCollection::KActionCollection( const KActionCollection &copy ) 126KActionCollection::KActionCollection( const KActionCollection &copy )
125 : QObject() 127 : QObject()
126{ 128{
127 kdWarning(129) << "KActionCollection::KActionCollection( const KActionCollection & ): function is severely deprecated." << endl; 129 kdWarning(129) << "KActionCollection::KActionCollection( const KActionCollection & ): function is severely deprecated." << endl;
128 d = new KActionCollectionPrivate; 130 d = new KActionCollectionPrivate;
129 *this = copy; 131 *this = copy;
130} 132}
131// KDE 4: remove end 133// KDE 4: remove end
132 134
133KActionCollection::~KActionCollection() 135KActionCollection::~KActionCollection()
134{ 136{
135 kdDebug(129) << "KActionCollection::~KActionCollection(): this = " << this << endl; 137 kdDebug(129) << "KActionCollection::~KActionCollection(): this = " << this << endl;
136 for ( QAsciiDictIterator<KAction> it( d->m_actionDict ); it.current(); ++it ) { 138 for ( Q3AsciiDictIterator<KAction> it( d->m_actionDict ); it.current(); ++it ) {
137 KAction* pAction = it.current(); 139 KAction* pAction = it.current();
138 if ( pAction->m_parentCollection == this ) 140 if ( pAction->m_parentCollection == this )
139 pAction->m_parentCollection = 0L; 141 pAction->m_parentCollection = 0L;
140 } 142 }
141 143
142//US delete d->m_kaccel; 144//US delete d->m_kaccel;
143//US delete d->m_builderKAccel; 145//US delete d->m_builderKAccel;
144 delete d; d = 0; 146 delete d; d = 0;
145} 147}
146 148
147void KActionCollection::setWidget( QWidget* w ) 149void KActionCollection::setWidget( QWidget* w )
148{ 150{
@@ -356,118 +358,118 @@ KAction* KActionCollection::_take( KAction* action )
356 } 358 }
357 359
358 KAction *a = d->m_actionDict.take( name ); 360 KAction *a = d->m_actionDict.take( name );
359 if ( !a || a != action ) 361 if ( !a || a != action )
360 return 0; 362 return 0;
361 363
362 emit removed( action ); 364 emit removed( action );
363 return a; 365 return a;
364} 366}
365 367
366void KActionCollection::_clear() 368void KActionCollection::_clear()
367{ 369{
368 QAsciiDictIterator<KAction> it( d->m_actionDict ); 370 Q3AsciiDictIterator<KAction> it( d->m_actionDict );
369 while ( it.current() ) 371 while ( it.current() )
370 _remove( it.current() ); 372 _remove( it.current() );
371} 373}
372 374
373void KActionCollection::insert( KAction* action ) { _insert( action ); } 375void KActionCollection::insert( KAction* action ) { _insert( action ); }
374void KActionCollection::remove( KAction* action ) { _remove( action ); } 376void KActionCollection::remove( KAction* action ) { _remove( action ); }
375KAction* KActionCollection::take( KAction* action ) { return _take( action ); } 377KAction* KActionCollection::take( KAction* action ) { return _take( action ); }
376void KActionCollection::clear() { _clear(); } 378void KActionCollection::clear() { _clear(); }
377KAccel* KActionCollection::accel() { return kaccel(); } 379KAccel* KActionCollection::accel() { return kaccel(); }
378const KAccel* KActionCollection::accel() const { return kaccel(); } 380const KAccel* KActionCollection::accel() const { return kaccel(); }
379KAccel* KActionCollection::builderKAccel() const { return d->m_builderKAccel; } 381KAccel* KActionCollection::builderKAccel() const { return d->m_builderKAccel; }
380 382
381KAction* KActionCollection::action( const char* name, const char* classname ) const 383KAction* KActionCollection::action( const char* name, const char* classname ) const
382{ 384{
383 KAction* pAction = 0; 385 KAction* pAction = 0;
384 386
385 if ( !classname && name ) 387 if ( !classname && name )
386 pAction = d->m_actionDict[ name ]; 388 pAction = d->m_actionDict[ name ];
387 389
388 else { 390 else {
389 QAsciiDictIterator<KAction> it( d->m_actionDict ); 391 Q3AsciiDictIterator<KAction> it( d->m_actionDict );
390 for( ; it.current(); ++it ) 392 for( ; it.current(); ++it )
391 { 393 {
392 if ( ( !name || strcmp( it.current()->name(), name ) == 0 ) && 394 if ( ( !name || strcmp( it.current()->name(), name ) == 0 ) &&
393 ( !classname || strcmp( it.current()->className(), classname ) == 0 ) ) { 395 ( !classname || strcmp( it.current()->className(), classname ) == 0 ) ) {
394 pAction = it.current(); 396 pAction = it.current();
395 break; 397 break;
396 } 398 }
397 } 399 }
398 } 400 }
399 401
400 if( !pAction ) { 402 if( !pAction ) {
401 for( uint i = 0; i < d->m_docList.count() && !pAction; i++ ) 403 for( uint i = 0; i < d->m_docList.count() && !pAction; i++ )
402 pAction = d->m_docList[i]->action( name, classname ); 404 pAction = d->m_docList[i]->action( name, classname );
403 } 405 }
404 406
405 return pAction; 407 return pAction;
406} 408}
407 409
408KAction* KActionCollection::action( int index ) const 410KAction* KActionCollection::action( int index ) const
409{ 411{
410 QAsciiDictIterator<KAction> it( d->m_actionDict ); 412 Q3AsciiDictIterator<KAction> it( d->m_actionDict );
411 it += index; 413 it += index;
412 return it.current(); 414 return it.current();
413// return d->m_actions.at( index ); 415// return d->m_actions.at( index );
414} 416}
415/*US 417/*US
416bool KActionCollection::readShortcutSettings( const QString& sConfigGroup, KConfigBase* pConfig ) 418bool KActionCollection::readShortcutSettings( const QString& sConfigGroup, KConfigBase* pConfig )
417{ 419{
418 return KActionShortcutList(this).readSettings( sConfigGroup, pConfig ); 420 return KActionShortcutList(this).readSettings( sConfigGroup, pConfig );
419} 421}
420 422
421bool KActionCollection::writeShortcutSettings( const QString& sConfigGroup, KConfigBase* pConfig ) const 423bool KActionCollection::writeShortcutSettings( const QString& sConfigGroup, KConfigBase* pConfig ) const
422{ 424{
423 return KActionShortcutList((KActionCollection*)this).writeSettings( sConfigGroup, pConfig ); 425 return KActionShortcutList((KActionCollection*)this).writeSettings( sConfigGroup, pConfig );
424} 426}
425*/ 427*/
426uint KActionCollection::count() const 428uint KActionCollection::count() const
427{ 429{
428 return d->m_actionDict.count(); 430 return d->m_actionDict.count();
429} 431}
430 432
431QStringList KActionCollection::groups() const 433QStringList KActionCollection::groups() const
432{ 434{
433 QStringList lst; 435 QStringList lst;
434 436
435 QAsciiDictIterator<KAction> it( d->m_actionDict ); 437 Q3AsciiDictIterator<KAction> it( d->m_actionDict );
436 for( ; it.current(); ++it ) 438 for( ; it.current(); ++it )
437 if ( !it.current()->group().isEmpty() && !lst.contains( it.current()->group() ) ) 439 if ( !it.current()->group().isEmpty() && !lst.contains( it.current()->group() ) )
438 lst.append( it.current()->group() ); 440 lst.append( it.current()->group() );
439 441
440 return lst; 442 return lst;
441} 443}
442 444
443KActionPtrList KActionCollection::actions( const QString& group ) const 445KActionPtrList KActionCollection::actions( const QString& group ) const
444{ 446{
445 KActionPtrList lst; 447 KActionPtrList lst;
446 448
447 QAsciiDictIterator<KAction> it( d->m_actionDict ); 449 Q3AsciiDictIterator<KAction> it( d->m_actionDict );
448 for( ; it.current(); ++it ) 450 for( ; it.current(); ++it )
449 if ( it.current()->group() == group ) 451 if ( it.current()->group() == group )
450 lst.append( it.current() ); 452 lst.append( it.current() );
451 else if ( it.current()->group().isEmpty() && group.isEmpty() ) 453 else if ( it.current()->group().isEmpty() && group.isEmpty() )
452 lst.append( it.current() ); 454 lst.append( it.current() );
453 455
454 return lst; 456 return lst;
455} 457}
456 458
457KActionPtrList KActionCollection::actions() const 459KActionPtrList KActionCollection::actions() const
458{ 460{
459 KActionPtrList lst; 461 KActionPtrList lst;
460 462
461 QAsciiDictIterator<KAction> it( d->m_actionDict ); 463 Q3AsciiDictIterator<KAction> it( d->m_actionDict );
462 for( ; it.current(); ++it ) 464 for( ; it.current(); ++it )
463 lst.append( it.current() ); 465 lst.append( it.current() );
464 466
465 return lst; 467 return lst;
466} 468}
467 469
468/*US we have no instance object. Use KGlobal instead 470/*US we have no instance object. Use KGlobal instead
469void KActionCollection::setInstance( KInstance *instance ) 471void KActionCollection::setInstance( KInstance *instance )
470{ 472{
471 if ( instance ) 473 if ( instance )
472 d->m_instance = instance; 474 d->m_instance = instance;
473qDebug("KActionCollection::setInstance has to be fixed"); 475qDebug("KActionCollection::setInstance has to be fixed");
@@ -499,59 +501,59 @@ void KActionCollection::setHighlightingEnabled( bool enable )
499} 501}
500 502
501bool KActionCollection::highlightingEnabled() const 503bool KActionCollection::highlightingEnabled() const
502{ 504{
503 return d->m_highlight; 505 return d->m_highlight;
504} 506}
505 507
506void KActionCollection::connectHighlight( QWidget *container, KAction *action ) 508void KActionCollection::connectHighlight( QWidget *container, KAction *action )
507{ 509{
508 if ( !d->m_highlight ) 510 if ( !d->m_highlight )
509 return; 511 return;
510 512
511 QPtrList<KAction> *actionList = d->m_dctHighlightContainers[ container ]; 513 Q3PtrList<KAction> *actionList = d->m_dctHighlightContainers[ container ];
512 514
513 if ( !actionList ) 515 if ( !actionList )
514 { 516 {
515 actionList = new QPtrList<KAction>; 517 actionList = new Q3PtrList<KAction>;
516 518
517 if ( container->inherits( "QPopupMenu" ) ) 519 if ( container->inherits( "Q3PopupMenu" ) )
518 { 520 {
519 connect( container, SIGNAL( highlighted( int ) ), 521 connect( container, SIGNAL( highlighted( int ) ),
520 this, SLOT( slotMenuItemHighlighted( int ) ) ); 522 this, SLOT( slotMenuItemHighlighted( int ) ) );
521 connect( container, SIGNAL( aboutToHide() ), 523 connect( container, SIGNAL( aboutToHide() ),
522 this, SLOT( slotMenuAboutToHide() ) ); 524 this, SLOT( slotMenuAboutToHide() ) );
523 } 525 }
524//US else if ( container->inherits( "KToolBar" ) ) 526//US else if ( container->inherits( "KToolBar" ) )
525 else if ( container->inherits( "QToolBar" ) ) 527 else if ( container->inherits( "Q3ToolBar" ) )
526 { 528 {
527 connect( container, SIGNAL( highlighted( int, bool ) ), 529 connect( container, SIGNAL( highlighted( int, bool ) ),
528 this, SLOT( slotToolBarButtonHighlighted( int, bool ) ) ); 530 this, SLOT( slotToolBarButtonHighlighted( int, bool ) ) );
529 } 531 }
530 532
531 connect( container, SIGNAL( destroyed() ), 533 connect( container, SIGNAL( destroyed() ),
532 this, SLOT( slotDestroyed() ) ); 534 this, SLOT( slotDestroyed() ) );
533 535
534 d->m_dctHighlightContainers.insert( container, actionList ); 536 d->m_dctHighlightContainers.insert( container, actionList );
535 } 537 }
536 538
537 actionList->append( action ); 539 actionList->append( action );
538} 540}
539 541
540void KActionCollection::disconnectHighlight( QWidget *container, KAction *action ) 542void KActionCollection::disconnectHighlight( QWidget *container, KAction *action )
541{ 543{
542 if ( !d->m_highlight ) 544 if ( !d->m_highlight )
543 return; 545 return;
544 546
545 QPtrList<KAction> *actionList = d->m_dctHighlightContainers[ container ]; 547 Q3PtrList<KAction> *actionList = d->m_dctHighlightContainers[ container ];
546 548
547 if ( !actionList ) 549 if ( !actionList )
548 return; 550 return;
549 551
550 actionList->removeRef( action ); 552 actionList->removeRef( action );
551 553
552 if ( actionList->count() == 0 ) 554 if ( actionList->count() == 0 )
553 d->m_dctHighlightContainers.remove( container ); 555 d->m_dctHighlightContainers.remove( container );
554} 556}
555 557
556void KActionCollection::slotMenuItemHighlighted( int id ) 558void KActionCollection::slotMenuItemHighlighted( int id )
557{ 559{
@@ -616,70 +618,70 @@ void KActionCollection::slotToolBarButtonHighlighted( int id, bool highlight )
616 d->m_currentHighlightAction = 0; 618 d->m_currentHighlightAction = 0;
617// emit clearStatusText(); 619// emit clearStatusText();
618 } 620 }
619} 621}
620 622
621void KActionCollection::slotDestroyed() 623void KActionCollection::slotDestroyed()
622{ 624{
623 d->m_dctHighlightContainers.remove( reinterpret_cast<void *>( const_cast<QObject *>(sender()) ) ); 625 d->m_dctHighlightContainers.remove( reinterpret_cast<void *>( const_cast<QObject *>(sender()) ) );
624} 626}
625 627
626KAction *KActionCollection::findAction( QWidget *container, int id ) 628KAction *KActionCollection::findAction( QWidget *container, int id )
627{ 629{
628 QPtrList<KAction> *actionList = d->m_dctHighlightContainers[ reinterpret_cast<void *>( container ) ]; 630 Q3PtrList<KAction> *actionList = d->m_dctHighlightContainers[ reinterpret_cast<void *>( container ) ];
629 631
630 if ( !actionList ) 632 if ( !actionList )
631 return 0; 633 return 0;
632 634
633 QPtrListIterator<KAction> it( *actionList ); 635 Q3PtrListIterator<KAction> it( *actionList );
634 for (; it.current(); ++it ) 636 for (; it.current(); ++it )
635 if ( it.current()->isPlugged( container, id ) ) 637 if ( it.current()->isPlugged( container, id ) )
636 return it.current(); 638 return it.current();
637 639
638 return 0; 640 return 0;
639} 641}
640 642
641// KDE 4: remove 643// KDE 4: remove
642KActionCollection KActionCollection::operator+(const KActionCollection &c ) const 644KActionCollection KActionCollection::operator+(const KActionCollection &c ) const
643{ 645{
644 kdWarning(129) << "KActionCollection::operator+(): function is severely deprecated." << endl; 646 kdWarning(129) << "KActionCollection::operator+(): function is severely deprecated." << endl;
645 KActionCollection ret( *this ); 647 KActionCollection ret( *this );
646 648
647 QValueList<KAction *> actions = c.actions(); 649 Q3ValueList<KAction *> actions = c.actions();
648 QValueList<KAction *>::ConstIterator it = actions.begin(); 650 Q3ValueList<KAction *>::ConstIterator it = actions.begin();
649 QValueList<KAction *>::ConstIterator end = actions.end(); 651 Q3ValueList<KAction *>::ConstIterator end = actions.end();
650 for (; it != end; ++it ) 652 for (; it != end; ++it )
651 ret.insert( *it ); 653 ret.insert( *it );
652 654
653 return ret; 655 return ret;
654} 656}
655 657
656KActionCollection &KActionCollection::operator=( const KActionCollection &copy ) 658KActionCollection &KActionCollection::operator=( const KActionCollection &copy )
657{ 659{
658 kdWarning(129) << "KActionCollection::operator=(): function is severely deprecated." << endl; 660 kdWarning(129) << "KActionCollection::operator=(): function is severely deprecated." << endl;
659 //d->m_bOneKAccelOnly = copy.d->m_bOneKAccelOnly; 661 //d->m_bOneKAccelOnly = copy.d->m_bOneKAccelOnly;
660 //d->m_iWidgetCurrent = copy.d->m_iWidgetCurrent; 662 //d->m_iWidgetCurrent = copy.d->m_iWidgetCurrent;
661 //d->m_widgetList = copy.d->m_widgetList; 663 //d->m_widgetList = copy.d->m_widgetList;
662 //d->m_kaccelList = copy.d->m_kaccelList; 664 //d->m_kaccelList = copy.d->m_kaccelList;
663 d->m_widget = copy.d->m_widget; 665 d->m_widget = copy.d->m_widget;
664 d->m_kaccel = copy.d->m_kaccel; 666 d->m_kaccel = copy.d->m_kaccel;
665 d->m_actionDict = copy.d->m_actionDict; 667 d->m_actionDict = copy.d->m_actionDict;
666//US setInstance( copy.instance() ); 668//US setInstance( copy.instance() );
667 return *this; 669 return *this;
668} 670}
669 671
670KActionCollection &KActionCollection::operator+=( const KActionCollection &c ) 672KActionCollection &KActionCollection::operator+=( const KActionCollection &c )
671{ 673{
672 kdWarning(129) << "KActionCollection::operator+=(): function is severely deprecated." << endl; 674 kdWarning(129) << "KActionCollection::operator+=(): function is severely deprecated." << endl;
673 QAsciiDictIterator<KAction> it(c.d->m_actionDict); 675 Q3AsciiDictIterator<KAction> it(c.d->m_actionDict);
674 for ( ; it.current(); ++it ) 676 for ( ; it.current(); ++it )
675 insert( it.current() ); 677 insert( it.current() );
676 678
677 return *this; 679 return *this;
678} 680}
679// KDE 4: remove end 681// KDE 4: remove end
680 682
681//--------------------------------------------------------------------- 683//---------------------------------------------------------------------
682// KActionShortcutList 684// KActionShortcutList
683//--------------------------------------------------------------------- 685//---------------------------------------------------------------------
684/*US 686/*US
685KActionShortcutList::KActionShortcutList( KActionCollection* pColl ) 687KActionShortcutList::KActionShortcutList( KActionCollection* pColl )