-rw-r--r-- | microkde/kdeui/kaction.cpp | 75 |
1 files changed, 39 insertions, 36 deletions
diff --git a/microkde/kdeui/kaction.cpp b/microkde/kdeui/kaction.cpp index d38a6d5..c2df381 100644 --- a/microkde/kdeui/kaction.cpp +++ b/microkde/kdeui/kaction.cpp | |||
@@ -23,33 +23,36 @@ | |||
23 | Boston, MA 02111-1307, USA. | 23 | Boston, MA 02111-1307, USA. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include "kaction.h" | 26 | #include "kaction.h" |
27 | 27 | ||
28 | #include <assert.h> | 28 | #include <assert.h> |
29 | 29 | ||
30 | #include <qtooltip.h> | 30 | #include <qtooltip.h> |
31 | //Added by qt3to4: | ||
32 | #include <Q3CString> | ||
33 | #include <Q3ValueList> | ||
31 | //US#include <qwhatsthis.h> | 34 | //US#include <qwhatsthis.h> |
32 | //US#include <kaccel.h> | 35 | //US#include <kaccel.h> |
33 | //US#include <kaccelbase.h> | 36 | //US#include <kaccelbase.h> |
34 | #include <kapplication.h> | 37 | #include <kapplication.h> |
35 | #include <kdebug.h> | 38 | #include <kdebug.h> |
36 | #include <kguiitem.h> | 39 | #include <kguiitem.h> |
37 | //US#include <kmainwindow.h> | 40 | //US#include <kmainwindow.h> |
38 | //US#include <kmenubar.h> | 41 | //US#include <kmenubar.h> |
39 | //US#include <kpopupmenu.h> | 42 | //US#include <kpopupmenu.h> |
40 | #include <ktoolbar.h> | 43 | #include <ktoolbar.h> |
41 | #include <ktoolbarbutton.h> | 44 | #include <ktoolbarbutton.h> |
42 | 45 | ||
43 | //US added this includefiles | 46 | //US added this includefiles |
44 | #include <qmenubar.h> | 47 | #include <qmenubar.h> |
45 | #include <qtoolbar.h> | 48 | #include <q3toolbar.h> |
46 | #include <qpopupmenu.h> | 49 | #include <q3popupmenu.h> |
47 | #include <qiconset.h> | 50 | #include <qicon.h> |
48 | 51 | ||
49 | /** | 52 | /** |
50 | * How it works. | 53 | * How it works. |
51 | * KActionCollection is an organizing container for KActions. | 54 | * KActionCollection is an organizing container for KActions. |
52 | * KActionCollection keeps track of the information necessary to handle | 55 | * KActionCollection keeps track of the information necessary to handle |
53 | * configuration and shortcuts. | 56 | * configuration and shortcuts. |
54 | * | 57 | * |
55 | * Focus Widget pointer: | 58 | * Focus Widget pointer: |
@@ -82,17 +85,17 @@ class KAction::KActionPrivate : public KGuiItem | |||
82 | public: | 85 | public: |
83 | KActionPrivate() : KGuiItem() | 86 | KActionPrivate() : KGuiItem() |
84 | { | 87 | { |
85 | m_kaccel = 0; | 88 | m_kaccel = 0; |
86 | m_configurable = true; | 89 | m_configurable = true; |
87 | } | 90 | } |
88 | 91 | ||
89 | KAccel *m_kaccel; | 92 | KAccel *m_kaccel; |
90 | QValueList<KAccel*> m_kaccelList; | 93 | Q3ValueList<KAccel*> m_kaccelList; |
91 | 94 | ||
92 | QString m_groupText; | 95 | QString m_groupText; |
93 | QString m_group; | 96 | QString m_group; |
94 | 97 | ||
95 | KShortcut m_cut; | 98 | KShortcut m_cut; |
96 | KShortcut m_cutDefault; | 99 | KShortcut m_cutDefault; |
97 | 100 | ||
98 | bool m_configurable; | 101 | bool m_configurable; |
@@ -102,17 +105,17 @@ public: | |||
102 | Container() { m_container = 0; m_representative = 0; m_id = 0; } | 105 | Container() { m_container = 0; m_representative = 0; m_id = 0; } |
103 | Container( const Container& s ) { m_container = s.m_container; | 106 | Container( const Container& s ) { m_container = s.m_container; |
104 | m_id = s.m_id; m_representative = s.m_representative; } | 107 | m_id = s.m_id; m_representative = s.m_representative; } |
105 | QWidget* m_container; | 108 | QWidget* m_container; |
106 | int m_id; | 109 | int m_id; |
107 | QWidget* m_representative; | 110 | QWidget* m_representative; |
108 | }; | 111 | }; |
109 | 112 | ||
110 | QValueList<Container> m_containers; | 113 | Q3ValueList<Container> m_containers; |
111 | }; | 114 | }; |
112 | 115 | ||
113 | //--------------------------------------------------------------------- | 116 | //--------------------------------------------------------------------- |
114 | // KAction | 117 | // KAction |
115 | //--------------------------------------------------------------------- | 118 | //--------------------------------------------------------------------- |
116 | KAction::KAction( const QString& text, const KShortcut& cut, | 119 | KAction::KAction( const QString& text, const KShortcut& cut, |
117 | const QObject* receiver, const char* slot, | 120 | const QObject* receiver, const char* slot, |
118 | KActionCollection* parent, const char* name ) | 121 | KActionCollection* parent, const char* name ) |
@@ -125,17 +128,17 @@ KAction::KAction( const QString& text, const QString& sIconName, const KShortcut | |||
125 | const QObject* receiver, const char* slot, | 128 | const QObject* receiver, const char* slot, |
126 | KActionCollection* parent, const char* name ) | 129 | KActionCollection* parent, const char* name ) |
127 | : QObject( parent, name ) | 130 | : QObject( parent, name ) |
128 | { | 131 | { |
129 | initPrivate( text, cut, receiver, slot ); | 132 | initPrivate( text, cut, receiver, slot ); |
130 | d->setIconName( sIconName ); | 133 | d->setIconName( sIconName ); |
131 | } | 134 | } |
132 | 135 | ||
133 | KAction::KAction( const QString& text, const QIconSet& pix, const KShortcut& cut, | 136 | KAction::KAction( const QString& text, const QIcon& pix, const KShortcut& cut, |
134 | const QObject* receiver, const char* slot, | 137 | const QObject* receiver, const char* slot, |
135 | KActionCollection* parent, const char* name ) | 138 | KActionCollection* parent, const char* name ) |
136 | : QObject( parent, name ) | 139 | : QObject( parent, name ) |
137 | { | 140 | { |
138 | initPrivate( text, cut, receiver, slot ); | 141 | initPrivate( text, cut, receiver, slot ); |
139 | d->setIconSet( pix ); | 142 | d->setIconSet( pix ); |
140 | } | 143 | } |
141 | KAction::KAction( const KGuiItem& item, const KShortcut& cut, | 144 | KAction::KAction( const KGuiItem& item, const KShortcut& cut, |
@@ -159,17 +162,17 @@ KAction::KAction( const QString& text, const KShortcut& cut, | |||
159 | } | 162 | } |
160 | KAction::KAction( const QString& text, const KShortcut& cut, | 163 | KAction::KAction( const QString& text, const KShortcut& cut, |
161 | const QObject* receiver, | 164 | const QObject* receiver, |
162 | const char* slot, QObject* parent, const char* name ) | 165 | const char* slot, QObject* parent, const char* name ) |
163 | : QObject( parent, name ) | 166 | : QObject( parent, name ) |
164 | { | 167 | { |
165 | initPrivate( text, cut, receiver, slot ); | 168 | initPrivate( text, cut, receiver, slot ); |
166 | } | 169 | } |
167 | KAction::KAction( const QString& text, const QIconSet& pix, | 170 | KAction::KAction( const QString& text, const QIcon& pix, |
168 | const KShortcut& cut, | 171 | const KShortcut& cut, |
169 | QObject* parent, const char* name ) | 172 | QObject* parent, const char* name ) |
170 | : QObject( parent, name ) | 173 | : QObject( parent, name ) |
171 | { | 174 | { |
172 | initPrivate( text, cut, 0, 0 ); | 175 | initPrivate( text, cut, 0, 0 ); |
173 | setIconSet( pix ); | 176 | setIconSet( pix ); |
174 | } | 177 | } |
175 | 178 | ||
@@ -177,17 +180,17 @@ KAction::KAction( const QString& text, const QString& pix, | |||
177 | const KShortcut& cut, | 180 | const KShortcut& cut, |
178 | QObject* parent, const char* name ) | 181 | QObject* parent, const char* name ) |
179 | : QObject( parent, name ) | 182 | : QObject( parent, name ) |
180 | { | 183 | { |
181 | initPrivate( text, cut, 0, 0 ); | 184 | initPrivate( text, cut, 0, 0 ); |
182 | d->setIconName( pix ); | 185 | d->setIconName( pix ); |
183 | } | 186 | } |
184 | 187 | ||
185 | KAction::KAction( const QString& text, const QIconSet& pix, | 188 | KAction::KAction( const QString& text, const QIcon& pix, |
186 | const KShortcut& cut, | 189 | const KShortcut& cut, |
187 | const QObject* receiver, const char* slot, QObject* parent, | 190 | const QObject* receiver, const char* slot, QObject* parent, |
188 | const char* name ) | 191 | const char* name ) |
189 | : QObject( parent, name ) | 192 | : QObject( parent, name ) |
190 | { | 193 | { |
191 | initPrivate( text, cut, receiver, slot ); | 194 | initPrivate( text, cut, receiver, slot ); |
192 | setIconSet( pix ); | 195 | setIconSet( pix ); |
193 | } | 196 | } |
@@ -501,29 +504,29 @@ void KAction::setAccel( int keyQt ) | |||
501 | } | 504 | } |
502 | // KDE 4: remove end | 505 | // KDE 4: remove end |
503 | 506 | ||
504 | void KAction::updateShortcut( int i ) | 507 | void KAction::updateShortcut( int i ) |
505 | { | 508 | { |
506 | int id = itemId( i ); | 509 | int id = itemId( i ); |
507 | 510 | ||
508 | QWidget* w = container( i ); | 511 | QWidget* w = container( i ); |
509 | if ( w->inherits( "QPopupMenu" ) ) { | 512 | if ( w->inherits( "Q3PopupMenu" ) ) { |
510 | QPopupMenu* menu = static_cast<QPopupMenu*>(w); | 513 | Q3PopupMenu* menu = static_cast<Q3PopupMenu*>(w); |
511 | updateShortcut( menu, id ); | 514 | updateShortcut( menu, id ); |
512 | } | 515 | } |
513 | else if ( w->inherits( "QMenuBar" ) ) | 516 | else if ( w->inherits( "QMenuBar" ) ) |
514 | //US static_cast<QMenuBar*>(w)->setAccel( d->m_cut.keyCodeQt(), id ); | 517 | //US static_cast<QMenuBar*>(w)->setAccel( d->m_cut.keyCodeQt(), id ); |
515 | //US (QMenuBar*)(w)->setAccel( d->m_cut.keyCodeQt(), id ); | 518 | //US (QMenuBar*)(w)->setAccel( d->m_cut.keyCodeQt(), id ); |
516 | 519 | ||
517 | ; //qDebug("KAction::updateShortcut( int i ) ...1 has top be fixed"); | 520 | ; //qDebug("KAction::updateShortcut( int i ) ...1 has top be fixed"); |
518 | 521 | ||
519 | } | 522 | } |
520 | 523 | ||
521 | void KAction::updateShortcut( QPopupMenu* menu, int id ) | 524 | void KAction::updateShortcut( Q3PopupMenu* menu, int id ) |
522 | { | 525 | { |
523 | /*US | 526 | /*US |
524 | //kdDebug(129) << "KAction::updateShortcut(): this = " << this << " d->m_kaccelList.count() = " << d->m_kaccelList.count() << endl; | 527 | //kdDebug(129) << "KAction::updateShortcut(): this = " << this << " d->m_kaccelList.count() = " << d->m_kaccelList.count() << endl; |
525 | // If the action has a KAccel object, | 528 | // If the action has a KAccel object, |
526 | // show the string representation of its shortcut. | 529 | // show the string representation of its shortcut. |
527 | if ( d->m_kaccel || d->m_kaccelList.count() ) { | 530 | if ( d->m_kaccel || d->m_kaccelList.count() ) { |
528 | QString s = menu->text( id ); | 531 | QString s = menu->text( id ); |
529 | int i = s.find( '\t' ); | 532 | int i = s.find( '\t' ); |
@@ -616,17 +619,17 @@ void KAction::setToolTip( const QString& tt ) | |||
616 | 619 | ||
617 | void KAction::updateToolTip( int i ) | 620 | void KAction::updateToolTip( int i ) |
618 | { | 621 | { |
619 | //qDebug("KAction::updateToolTip ...1 has top be fixed"); | 622 | //qDebug("KAction::updateToolTip ...1 has top be fixed"); |
620 | QWidget *w = container( i ); | 623 | QWidget *w = container( i ); |
621 | 624 | ||
622 | if ( w->inherits( "KToolBar" ) ) | 625 | if ( w->inherits( "KToolBar" ) ) |
623 | QToolTip::add( static_cast<KToolBar*>(w)->getWidget( itemId( i ) ), d->toolTip() ); | 626 | QToolTip::add( static_cast<KToolBar*>(w)->getWidget( itemId( i ) ), d->toolTip() ); |
624 | else if ( w->inherits( "QToolBar" ) ) | 627 | else if ( w->inherits( "Q3ToolBar" ) ) |
625 | QToolTip::add( static_cast<KToolBar*>(w)->getWidget( itemId( i ) ), d->toolTip() ); | 628 | QToolTip::add( static_cast<KToolBar*>(w)->getWidget( itemId( i ) ), d->toolTip() ); |
626 | } | 629 | } |
627 | 630 | ||
628 | QString KAction::toolTip() const | 631 | QString KAction::toolTip() const |
629 | { | 632 | { |
630 | return d->toolTip(); | 633 | return d->toolTip(); |
631 | } | 634 | } |
632 | 635 | ||
@@ -641,19 +644,19 @@ int KAction::plug( QWidget *w, int index ) | |||
641 | 644 | ||
642 | 645 | ||
643 | // Check if action is permitted | 646 | // Check if action is permitted |
644 | //US if (kapp && !kapp->authorizeKAction(name())) | 647 | //US if (kapp && !kapp->authorizeKAction(name())) |
645 | //US return -1; | 648 | //US return -1; |
646 | 649 | ||
647 | plugShortcut(); | 650 | plugShortcut(); |
648 | 651 | ||
649 | if ( w->inherits("QPopupMenu") ) | 652 | if ( w->inherits("Q3PopupMenu") ) |
650 | { | 653 | { |
651 | QPopupMenu* menu = static_cast<QPopupMenu*>( w ); | 654 | Q3PopupMenu* menu = static_cast<Q3PopupMenu*>( w ); |
652 | int id; | 655 | int id; |
653 | // Don't insert shortcut into menu if it's already in a KAccel object. | 656 | // Don't insert shortcut into menu if it's already in a KAccel object. |
654 | //qDebug("KAction::plug warning: real shortcuts not available yet. "); | 657 | //qDebug("KAction::plug warning: real shortcuts not available yet. "); |
655 | //US int keyQt = (d->m_kaccelList.count() || d->m_kaccel) ? 0 : d->m_cut.keyCodeQt(); | 658 | //US int keyQt = (d->m_kaccelList.count() || d->m_kaccel) ? 0 : d->m_cut.keyCodeQt(); |
656 | int keyQt = 0; | 659 | int keyQt = 0; |
657 | 660 | ||
658 | if ( d->hasIcon() ) | 661 | if ( d->hasIcon() ) |
659 | { | 662 | { |
@@ -716,17 +719,17 @@ int KAction::plug( QWidget *w, int index ) | |||
716 | { | 719 | { |
717 | QString icon = d->iconName(); | 720 | QString icon = d->iconName(); |
718 | if ( icon.isEmpty() ) | 721 | if ( icon.isEmpty() ) |
719 | icon = "unknown"; | 722 | icon = "unknown"; |
720 | bar->insertButton( icon, id_, SIGNAL( clicked() ), this, | 723 | bar->insertButton( icon, id_, SIGNAL( clicked() ), this, |
721 | SLOT( slotActivated() ), | 724 | SLOT( slotActivated() ), |
722 | d->isEnabled(), d->plainText(), index/*US, instance*/ ); | 725 | d->isEnabled(), d->plainText(), index/*US, instance*/ ); |
723 | } | 726 | } |
724 | bar->getButton( id_ )->setName( QCString("toolbutton_")+name() ); | 727 | bar->getButton( id_ )->setName( Q3CString("toolbutton_")+name() ); |
725 | 728 | ||
726 | //US if ( !d->whatsThis().isEmpty() ) | 729 | //US if ( !d->whatsThis().isEmpty() ) |
727 | //US QWhatsThis::add( bar->getButton(id_), whatsThisWithIcon() ); | 730 | //US QWhatsThis::add( bar->getButton(id_), whatsThisWithIcon() ); |
728 | if ( !d->toolTip().isEmpty() ) | 731 | if ( !d->toolTip().isEmpty() ) |
729 | QToolTip::add( bar->getButton(id_), d->toolTip() ); | 732 | QToolTip::add( bar->getButton(id_), d->toolTip() ); |
730 | 733 | ||
731 | addContainer( bar, id_ ); | 734 | addContainer( bar, id_ ); |
732 | 735 | ||
@@ -744,19 +747,19 @@ int KAction::plug( QWidget *w, int index ) | |||
744 | 747 | ||
745 | void KAction::unplug( QWidget *w ) | 748 | void KAction::unplug( QWidget *w ) |
746 | { | 749 | { |
747 | int i = findContainer( w ); | 750 | int i = findContainer( w ); |
748 | if ( i == -1 ) | 751 | if ( i == -1 ) |
749 | return; | 752 | return; |
750 | int id = itemId( i ); | 753 | int id = itemId( i ); |
751 | 754 | ||
752 | if ( w->inherits( "QPopupMenu" ) ) | 755 | if ( w->inherits( "Q3PopupMenu" ) ) |
753 | { | 756 | { |
754 | QPopupMenu *menu = static_cast<QPopupMenu *>( w ); | 757 | Q3PopupMenu *menu = static_cast<Q3PopupMenu *>( w ); |
755 | menu->removeItem( id ); | 758 | menu->removeItem( id ); |
756 | } | 759 | } |
757 | else if ( w->inherits( "KToolBar" ) ) | 760 | else if ( w->inherits( "KToolBar" ) ) |
758 | { | 761 | { |
759 | KToolBar *bar = static_cast<KToolBar *>( w ); | 762 | KToolBar *bar = static_cast<KToolBar *>( w ); |
760 | bar->removeItemDelayed( id ); | 763 | bar->removeItemDelayed( id ); |
761 | } | 764 | } |
762 | else if ( w->inherits( "QMenuBar" ) ) | 765 | else if ( w->inherits( "QMenuBar" ) ) |
@@ -857,18 +860,18 @@ void KAction::setEnabled(bool enable) | |||
857 | 860 | ||
858 | emit enabled( d->isEnabled() ); | 861 | emit enabled( d->isEnabled() ); |
859 | } | 862 | } |
860 | 863 | ||
861 | void KAction::updateEnabled( int i ) | 864 | void KAction::updateEnabled( int i ) |
862 | { | 865 | { |
863 | QWidget *w = container( i ); | 866 | QWidget *w = container( i ); |
864 | 867 | ||
865 | if ( w->inherits("QPopupMenu") ) | 868 | if ( w->inherits("Q3PopupMenu") ) |
866 | static_cast<QPopupMenu*>(w)->setItemEnabled( itemId( i ), d->isEnabled() ); | 869 | static_cast<Q3PopupMenu*>(w)->setItemEnabled( itemId( i ), d->isEnabled() ); |
867 | else if ( w->inherits("QMenuBar") ) | 870 | else if ( w->inherits("QMenuBar") ) |
868 | static_cast<QMenuBar*>(w)->setItemEnabled( itemId( i ), d->isEnabled() ); | 871 | static_cast<QMenuBar*>(w)->setItemEnabled( itemId( i ), d->isEnabled() ); |
869 | else if ( w->inherits( "KToolBar" ) ) | 872 | else if ( w->inherits( "KToolBar" ) ) |
870 | { | 873 | { |
871 | static_cast<KToolBar*>(w)->setItemEnabled( itemId( i ), d->isEnabled() ); | 874 | static_cast<KToolBar*>(w)->setItemEnabled( itemId( i ), d->isEnabled() ); |
872 | } | 875 | } |
873 | } | 876 | } |
874 | 877 | ||
@@ -901,20 +904,20 @@ void KAction::setText( const QString& text ) | |||
901 | updateText( i ); | 904 | updateText( i ); |
902 | 905 | ||
903 | } | 906 | } |
904 | 907 | ||
905 | void KAction::updateText( int i ) | 908 | void KAction::updateText( int i ) |
906 | { | 909 | { |
907 | QWidget *w = container( i ); | 910 | QWidget *w = container( i ); |
908 | 911 | ||
909 | if ( w->inherits( "QPopupMenu" ) ) { | 912 | if ( w->inherits( "Q3PopupMenu" ) ) { |
910 | int id = itemId( i ); | 913 | int id = itemId( i ); |
911 | static_cast<QPopupMenu*>(w)->changeItem( id, d->text() ); | 914 | static_cast<Q3PopupMenu*>(w)->changeItem( id, d->text() ); |
912 | updateShortcut( static_cast<QPopupMenu*>(w), id ); | 915 | updateShortcut( static_cast<Q3PopupMenu*>(w), id ); |
913 | } | 916 | } |
914 | else if ( w->inherits( "QMenuBar" ) ) | 917 | else if ( w->inherits( "QMenuBar" ) ) |
915 | static_cast<QMenuBar*>(w)->changeItem( itemId( i ), d->text() ); | 918 | static_cast<QMenuBar*>(w)->changeItem( itemId( i ), d->text() ); |
916 | else if ( w->inherits( "KToolBar" ) ) | 919 | else if ( w->inherits( "KToolBar" ) ) |
917 | { | 920 | { |
918 | //qDebug("KAction::updateText ...3 has top be fixed"); | 921 | //qDebug("KAction::updateText ...3 has top be fixed"); |
919 | QWidget *button = static_cast<KToolBar *>(w)->getWidget( itemId( i ) ); | 922 | QWidget *button = static_cast<KToolBar *>(w)->getWidget( itemId( i ) ); |
920 | if ( button->inherits( "KToolBarButton" ) ) | 923 | if ( button->inherits( "KToolBarButton" ) ) |
@@ -942,69 +945,69 @@ void KAction::setIcon( const QString &icon ) | |||
942 | for ( int i = 0; i < len; ++i ) | 945 | for ( int i = 0; i < len; ++i ) |
943 | updateIcon( i ); | 946 | updateIcon( i ); |
944 | } | 947 | } |
945 | 948 | ||
946 | void KAction::updateIcon( int id ) | 949 | void KAction::updateIcon( int id ) |
947 | { | 950 | { |
948 | QWidget* w = container( id ); | 951 | QWidget* w = container( id ); |
949 | 952 | ||
950 | if ( w->inherits( "QPopupMenu" ) ) { | 953 | if ( w->inherits( "Q3PopupMenu" ) ) { |
951 | int itemId_ = itemId( id ); | 954 | int itemId_ = itemId( id ); |
952 | static_cast<QPopupMenu*>(w)->changeItem( itemId_, d->iconSet( KIcon::Small ), d->text() ); | 955 | static_cast<Q3PopupMenu*>(w)->changeItem( itemId_, d->iconSet( KIcon::Small ), d->text() ); |
953 | updateShortcut( static_cast<QPopupMenu*>(w), itemId_ ); | 956 | updateShortcut( static_cast<Q3PopupMenu*>(w), itemId_ ); |
954 | } | 957 | } |
955 | else if ( w->inherits( "QMenuBar" ) ) | 958 | else if ( w->inherits( "QMenuBar" ) ) |
956 | static_cast<QMenuBar*>(w)->changeItem( itemId( id ), d->iconSet( KIcon::Small ), d->text() ); | 959 | static_cast<QMenuBar*>(w)->changeItem( itemId( id ), d->iconSet( KIcon::Small ), d->text() ); |
957 | else if ( w->inherits( "KToolBar" ) ) | 960 | else if ( w->inherits( "KToolBar" ) ) |
958 | static_cast<KToolBar *>(w)->setButtonIcon( itemId( id ), d->iconName() ); | 961 | static_cast<KToolBar *>(w)->setButtonIcon( itemId( id ), d->iconName() ); |
959 | else if ( w->inherits( "QToolBar" ) ) | 962 | else if ( w->inherits( "Q3ToolBar" ) ) |
960 | { | 963 | { |
961 | qDebug("KAction::updateIcon has top be fixed"); | 964 | qDebug("KAction::updateIcon has top be fixed"); |
962 | //US static_cast<QToolBar *>(w)->setButtonIcon( itemId( id ), d->iconName() ); | 965 | //US static_cast<QToolBar *>(w)->setButtonIcon( itemId( id ), d->iconName() ); |
963 | } | 966 | } |
964 | } | 967 | } |
965 | 968 | ||
966 | QString KAction::icon() const | 969 | QString KAction::icon() const |
967 | { | 970 | { |
968 | return d->iconName( ); | 971 | return d->iconName( ); |
969 | } | 972 | } |
970 | 973 | ||
971 | void KAction::setIconSet( const QIconSet &iconset ) | 974 | void KAction::setIconSet( const QIcon &iconset ) |
972 | { | 975 | { |
973 | d->setIconSet( iconset ); | 976 | d->setIconSet( iconset ); |
974 | 977 | ||
975 | int len = containerCount(); | 978 | int len = containerCount(); |
976 | for( int i = 0; i < len; ++i ) | 979 | for( int i = 0; i < len; ++i ) |
977 | updateIconSet( i ); | 980 | updateIconSet( i ); |
978 | } | 981 | } |
979 | 982 | ||
980 | 983 | ||
981 | void KAction::updateIconSet( int id ) | 984 | void KAction::updateIconSet( int id ) |
982 | { | 985 | { |
983 | QWidget *w = container( id ); | 986 | QWidget *w = container( id ); |
984 | 987 | ||
985 | if ( w->inherits( "QPopupMenu" ) ) | 988 | if ( w->inherits( "Q3PopupMenu" ) ) |
986 | { | 989 | { |
987 | int itemId_ = itemId( id ); | 990 | int itemId_ = itemId( id ); |
988 | static_cast<QPopupMenu*>(w)->changeItem( itemId_, d->iconSet(), d->text() ); | 991 | static_cast<Q3PopupMenu*>(w)->changeItem( itemId_, d->iconSet(), d->text() ); |
989 | updateShortcut( static_cast<QPopupMenu*>(w), itemId_ ); | 992 | updateShortcut( static_cast<Q3PopupMenu*>(w), itemId_ ); |
990 | } | 993 | } |
991 | else if ( w->inherits( "QMenuBar" ) ) | 994 | else if ( w->inherits( "QMenuBar" ) ) |
992 | static_cast<QMenuBar*>(w)->changeItem( itemId( id ), d->iconSet(), d->text() ); | 995 | static_cast<QMenuBar*>(w)->changeItem( itemId( id ), d->iconSet(), d->text() ); |
993 | else if ( w->inherits( "KToolBar" ) ) | 996 | else if ( w->inherits( "KToolBar" ) ) |
994 | { | 997 | { |
995 | if ( icon().isEmpty() && d->hasIconSet() ) // only if there is no named icon ( scales better ) | 998 | if ( icon().isEmpty() && d->hasIconSet() ) // only if there is no named icon ( scales better ) |
996 | static_cast<KToolBar *>(w)->setButtonIconSet( itemId( id ), d->iconSet() ); | 999 | static_cast<KToolBar *>(w)->setButtonIconSet( itemId( id ), d->iconSet() ); |
997 | else | 1000 | else |
998 | static_cast<KToolBar *>(w)->setButtonIconSet( itemId( id ), d->iconSet( KIcon::Small ) ); | 1001 | static_cast<KToolBar *>(w)->setButtonIconSet( itemId( id ), d->iconSet( KIcon::Small ) ); |
999 | } | 1002 | } |
1000 | } | 1003 | } |
1001 | 1004 | ||
1002 | QIconSet KAction::iconSet( KIcon::Group group, int size ) const | 1005 | QIcon KAction::iconSet( KIcon::Group group, int size ) const |
1003 | { | 1006 | { |
1004 | return d->iconSet( group, size ); | 1007 | return d->iconSet( group, size ); |
1005 | } | 1008 | } |
1006 | 1009 | ||
1007 | bool KAction::hasIcon() const | 1010 | bool KAction::hasIcon() const |
1008 | { | 1011 | { |
1009 | return d->hasIcon(); | 1012 | return d->hasIcon(); |
1010 | } | 1013 | } |
@@ -1017,17 +1020,17 @@ void KAction::setWhatsThis( const QString& text ) | |||
1017 | int len = containerCount(); | 1020 | int len = containerCount(); |
1018 | for( int i = 0; i < len; ++i ) | 1021 | for( int i = 0; i < len; ++i ) |
1019 | updateWhatsThis( i ); | 1022 | updateWhatsThis( i ); |
1020 | } | 1023 | } |
1021 | 1024 | ||
1022 | void KAction::updateWhatsThis( int i ) | 1025 | void KAction::updateWhatsThis( int i ) |
1023 | { | 1026 | { |
1024 | qDebug("KAction::updateWhatsThis ...1 has top be fixed"); | 1027 | qDebug("KAction::updateWhatsThis ...1 has top be fixed"); |
1025 | QPopupMenu* pm = popupMenu( i ); | 1028 | Q3PopupMenu* pm = popupMenu( i ); |
1026 | if ( pm ) | 1029 | if ( pm ) |
1027 | { | 1030 | { |
1028 | pm->setWhatsThis( itemId( i ), d->whatsThis() ); | 1031 | pm->setWhatsThis( itemId( i ), d->whatsThis() ); |
1029 | return; | 1032 | return; |
1030 | } | 1033 | } |
1031 | 1034 | ||
1032 | KToolBar *tb = toolBar( i ); | 1035 | KToolBar *tb = toolBar( i ); |
1033 | if ( tb ) | 1036 | if ( tb ) |
@@ -1059,20 +1062,20 @@ QWidget* KAction::container( int index ) const | |||
1059 | } | 1062 | } |
1060 | 1063 | ||
1061 | KToolBar* KAction::toolBar( int index ) const | 1064 | KToolBar* KAction::toolBar( int index ) const |
1062 | { | 1065 | { |
1063 | //US return dynamic_cast<KToolBar *>( d->m_containers[ index ].m_container ); | 1066 | //US return dynamic_cast<KToolBar *>( d->m_containers[ index ].m_container ); |
1064 | return (KToolBar *)( d->m_containers[ index ].m_container ); | 1067 | return (KToolBar *)( d->m_containers[ index ].m_container ); |
1065 | } | 1068 | } |
1066 | 1069 | ||
1067 | QPopupMenu* KAction::popupMenu( int index ) const | 1070 | Q3PopupMenu* KAction::popupMenu( int index ) const |
1068 | { | 1071 | { |
1069 | //US return dynamic_cast<QPopupMenu *>( d->m_containers[ index ].m_container ); | 1072 | //US return dynamic_cast<QPopupMenu *>( d->m_containers[ index ].m_container ); |
1070 | return (QPopupMenu *)( d->m_containers[ index ].m_container ); | 1073 | return (Q3PopupMenu *)( d->m_containers[ index ].m_container ); |
1071 | } | 1074 | } |
1072 | 1075 | ||
1073 | QWidget* KAction::representative( int index ) const | 1076 | QWidget* KAction::representative( int index ) const |
1074 | { | 1077 | { |
1075 | return d->m_containers[ index ].m_representative; | 1078 | return d->m_containers[ index ].m_representative; |
1076 | } | 1079 | } |
1077 | 1080 | ||
1078 | int KAction::itemId( int index ) const | 1081 | int KAction::itemId( int index ) const |
@@ -1150,32 +1153,32 @@ void KAction::slotDestroyed() | |||
1150 | removeContainer( i ); | 1153 | removeContainer( i ); |
1151 | } while ( i != -1 ); | 1154 | } while ( i != -1 ); |
1152 | 1155 | ||
1153 | } | 1156 | } |
1154 | 1157 | ||
1155 | int KAction::findContainer( const QWidget* widget ) const | 1158 | int KAction::findContainer( const QWidget* widget ) const |
1156 | { | 1159 | { |
1157 | int pos = 0; | 1160 | int pos = 0; |
1158 | QValueList<KActionPrivate::Container>::ConstIterator it = d->m_containers.begin(); | 1161 | Q3ValueList<KActionPrivate::Container>::ConstIterator it = d->m_containers.begin(); |
1159 | while( it != d->m_containers.end() ) | 1162 | while( it != d->m_containers.end() ) |
1160 | { | 1163 | { |
1161 | if ( (*it).m_representative == widget || (*it).m_container == widget ) | 1164 | if ( (*it).m_representative == widget || (*it).m_container == widget ) |
1162 | return pos; | 1165 | return pos; |
1163 | ++it; | 1166 | ++it; |
1164 | ++pos; | 1167 | ++pos; |
1165 | } | 1168 | } |
1166 | 1169 | ||
1167 | return -1; | 1170 | return -1; |
1168 | } | 1171 | } |
1169 | 1172 | ||
1170 | void KAction::removeContainer( int index ) | 1173 | void KAction::removeContainer( int index ) |
1171 | { | 1174 | { |
1172 | int i = 0; | 1175 | int i = 0; |
1173 | QValueList<KActionPrivate::Container>::Iterator it = d->m_containers.begin(); | 1176 | Q3ValueList<KActionPrivate::Container>::Iterator it = d->m_containers.begin(); |
1174 | while( it != d->m_containers.end() ) | 1177 | while( it != d->m_containers.end() ) |
1175 | { | 1178 | { |
1176 | if ( i == index ) | 1179 | if ( i == index ) |
1177 | { | 1180 | { |
1178 | d->m_containers.remove( it ); | 1181 | d->m_containers.remove( it ); |
1179 | return; | 1182 | return; |
1180 | } | 1183 | } |
1181 | ++it; | 1184 | ++it; |