author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /microkde/kdeui/kactioncollection.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2 |
initial public commit of qt4 portp1
Diffstat (limited to 'microkde/kdeui/kactioncollection.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kdeui/kactioncollection.cpp | 50 |
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 | |||
@@ -21,28 +21,30 @@ | |||
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 | ||
46 | class KActionCollection::KActionCollectionPrivate | 48 | class KActionCollection::KActionCollectionPrivate |
47 | { | 49 | { |
48 | public: | 50 | public: |
@@ -62,23 +64,23 @@ public: | |||
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 | ||
82 | KActionCollection::KActionCollection( QWidget *parent, const char *name /*US, | 84 | KActionCollection::KActionCollection( QWidget *parent, const char *name /*US, |
83 | KInstance *instance */) | 85 | KInstance *instance */) |
84 | : QObject( (QObject*)parent, name ) | 86 | : QObject( (QObject*)parent, name ) |
@@ -128,17 +130,17 @@ KActionCollection::KActionCollection( const KActionCollection © ) | |||
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 | ||
133 | KActionCollection::~KActionCollection() | 135 | KActionCollection::~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; |
@@ -360,17 +362,17 @@ KAction* KActionCollection::_take( KAction* 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 | ||
366 | void KActionCollection::_clear() | 368 | void 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 | ||
373 | void KActionCollection::insert( KAction* action ) { _insert( action ); } | 375 | void KActionCollection::insert( KAction* action ) { _insert( action ); } |
374 | void KActionCollection::remove( KAction* action ) { _remove( action ); } | 376 | void KActionCollection::remove( KAction* action ) { _remove( action ); } |
375 | KAction* KActionCollection::take( KAction* action ) { return _take( action ); } | 377 | KAction* KActionCollection::take( KAction* action ) { return _take( action ); } |
376 | void KActionCollection::clear() { _clear(); } | 378 | void KActionCollection::clear() { _clear(); } |
@@ -381,17 +383,17 @@ KAccel* KActionCollection::builderKAccel() const { return d->m_builderKAccel; | |||
381 | KAction* KActionCollection::action( const char* name, const char* classname ) const | 383 | KAction* 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 | } |
@@ -402,17 +404,17 @@ KAction* KActionCollection::action( const char* name, const char* classname ) co | |||
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 | ||
408 | KAction* KActionCollection::action( int index ) const | 410 | KAction* 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 |
416 | bool KActionCollection::readShortcutSettings( const QString& sConfigGroup, KConfigBase* pConfig ) | 418 | bool KActionCollection::readShortcutSettings( const QString& sConfigGroup, KConfigBase* pConfig ) |
417 | { | 419 | { |
418 | return KActionShortcutList(this).readSettings( sConfigGroup, pConfig ); | 420 | return KActionShortcutList(this).readSettings( sConfigGroup, pConfig ); |
@@ -427,43 +429,43 @@ uint KActionCollection::count() const | |||
427 | { | 429 | { |
428 | return d->m_actionDict.count(); | 430 | return d->m_actionDict.count(); |
429 | } | 431 | } |
430 | 432 | ||
431 | QStringList KActionCollection::groups() const | 433 | QStringList 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 | ||
443 | KActionPtrList KActionCollection::actions( const QString& group ) const | 445 | KActionPtrList 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 | ||
457 | KActionPtrList KActionCollection::actions() const | 459 | KActionPtrList 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 |
469 | void KActionCollection::setInstance( KInstance *instance ) | 471 | void KActionCollection::setInstance( KInstance *instance ) |
@@ -503,31 +505,31 @@ bool KActionCollection::highlightingEnabled() const | |||
503 | return d->m_highlight; | 505 | return d->m_highlight; |
504 | } | 506 | } |
505 | 507 | ||
506 | void KActionCollection::connectHighlight( QWidget *container, KAction *action ) | 508 | void 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 | ||
@@ -537,17 +539,17 @@ void KActionCollection::connectHighlight( QWidget *container, KAction *action ) | |||
537 | actionList->append( action ); | 539 | actionList->append( action ); |
538 | } | 540 | } |
539 | 541 | ||
540 | void KActionCollection::disconnectHighlight( QWidget *container, KAction *action ) | 542 | void 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 ); |
@@ -620,38 +622,38 @@ void KActionCollection::slotToolBarButtonHighlighted( int id, bool highlight ) | |||
620 | 622 | ||
621 | void KActionCollection::slotDestroyed() | 623 | void 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 | ||
626 | KAction *KActionCollection::findAction( QWidget *container, int id ) | 628 | KAction *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 |
642 | KActionCollection KActionCollection::operator+(const KActionCollection &c ) const | 644 | KActionCollection 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 | ||
656 | KActionCollection &KActionCollection::operator=( const KActionCollection © ) | 658 | KActionCollection &KActionCollection::operator=( const KActionCollection © ) |
657 | { | 659 | { |
@@ -665,17 +667,17 @@ KActionCollection &KActionCollection::operator=( const KActionCollection © ) | |||
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 | ||
670 | KActionCollection &KActionCollection::operator+=( const KActionCollection &c ) | 672 | KActionCollection &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 | //--------------------------------------------------------------------- |