summaryrefslogtreecommitdiffabout
path: root/microkde/kdeui/kaction.cpp
Unidiff
Diffstat (limited to 'microkde/kdeui/kaction.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdeui/kaction.cpp75
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
@@ -19,41 +19,44 @@
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 "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:
56* This is the widget which is the focus for action shortcuts. 59* This is the widget which is the focus for action shortcuts.
57* It is set either by passing a QWidget* to the KActionCollection constructor 60* It is set either by passing a QWidget* to the KActionCollection constructor
58* or by calling setWidget() if the widget wasn't known when the object was 61* or by calling setWidget() if the widget wasn't known when the object was
59* initially constructed (as in KXMLGUIClient and KParts::PartBase) 62* initially constructed (as in KXMLGUIClient and KParts::PartBase)
@@ -78,68 +81,68 @@ int KAction::getToolButtonID()
78//--------------------------------------------------------------------- 81//---------------------------------------------------------------------
79 82
80class KAction::KActionPrivate : public KGuiItem 83class KAction::KActionPrivate : public KGuiItem
81{ 84{
82public: 85public:
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;
99 102
100 struct Container 103 struct Container
101 { 104 {
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//---------------------------------------------------------------------
116KAction::KAction( const QString& text, const KShortcut& cut, 119KAction::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 )
119: QObject( parent, name ) 122: QObject( parent, name )
120{ 123{
121 initPrivate( text, cut, receiver, slot ); 124 initPrivate( text, cut, receiver, slot );
122} 125}
123 126
124KAction::KAction( const QString& text, const QString& sIconName, const KShortcut& cut, 127KAction::KAction( const QString& text, const QString& sIconName, const KShortcut& cut,
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
133KAction::KAction( const QString& text, const QIconSet& pix, const KShortcut& cut, 136KAction::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}
141KAction::KAction( const KGuiItem& item, const KShortcut& cut, 144KAction::KAction( const KGuiItem& item, const KShortcut& cut,
142 const QObject* receiver, const char* slot, 145 const QObject* receiver, const char* slot,
143 KActionCollection* parent, const char* name ) 146 KActionCollection* parent, const char* name )
144: QObject( parent, name ) 147: QObject( parent, name )
145{ 148{
@@ -155,43 +158,43 @@ KAction::KAction( const QString& text, const KShortcut& cut,
155 QObject* parent, const char* name ) 158 QObject* parent, const char* name )
156 : QObject( parent, name ) 159 : QObject( parent, name )
157{ 160{
158 initPrivate( text, cut, 0, 0 ); 161 initPrivate( text, cut, 0, 0 );
159} 162}
160KAction::KAction( const QString& text, const KShortcut& cut, 163KAction::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}
167KAction::KAction( const QString& text, const QIconSet& pix, 170KAction::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
176KAction::KAction( const QString& text, const QString& pix, 179KAction::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
185KAction::KAction( const QString& text, const QIconSet& pix, 188KAction::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}
194 197
195KAction::KAction( const QString& text, const QString& pix, 198KAction::KAction( const QString& text, const QString& pix,
196 const KShortcut& cut, 199 const KShortcut& cut,
197 const QObject* receiver, const char* slot, QObject* parent, 200 const QObject* receiver, const char* slot, QObject* parent,
@@ -497,37 +500,37 @@ void KAction::removeKAccel( KAccel* kaccel )
497// KDE 4: remove 500// KDE 4: remove
498void KAction::setAccel( int keyQt ) 501void KAction::setAccel( int keyQt )
499{ 502{
500 setShortcut( KShortcut(keyQt) ); 503 setShortcut( KShortcut(keyQt) );
501} 504}
502// KDE 4: remove end 505// KDE 4: remove end
503 506
504void KAction::updateShortcut( int i ) 507void 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
521void KAction::updateShortcut( QPopupMenu* menu, int id ) 524void 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' );
530 if ( i >= 0 ) 533 if ( i >= 0 )
531 s.replace( i+1, s.length()-i, d->m_cut.seq(0).toString() ); 534 s.replace( i+1, s.length()-i, d->m_cut.seq(0).toString() );
532 else 535 else
533 s += "\t" + d->m_cut.seq(0).toString(); 536 s += "\t" + d->m_cut.seq(0).toString();
@@ -612,52 +615,52 @@ void KAction::setToolTip( const QString& tt )
612 int len = containerCount(); 615 int len = containerCount();
613 for( int i = 0; i < len; ++i ) 616 for( int i = 0; i < len; ++i )
614 updateToolTip( i ); 617 updateToolTip( i );
615} 618}
616 619
617void KAction::updateToolTip( int i ) 620void 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
628QString KAction::toolTip() const 631QString KAction::toolTip() const
629{ 632{
630 return d->toolTip(); 633 return d->toolTip();
631} 634}
632 635
633int KAction::plug( QWidget *w, int index ) 636int KAction::plug( QWidget *w, int index )
634{ 637{
635 //kdDebug(129) << "KAction::plug( " << w << ", " << index << " )" << endl; 638 //kdDebug(129) << "KAction::plug( " << w << ", " << index << " )" << endl;
636 if (w == 0) { 639 if (w == 0) {
637 kdWarning(129) << "KAction::plug called with 0 argument\n"; 640 kdWarning(129) << "KAction::plug called with 0 argument\n";
638 return -1; 641 return -1;
639 } 642 }
640 643
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 {
660/*US 663/*US
661 KInstance *instance; 664 KInstance *instance;
662 if ( m_parentCollection ) 665 if ( m_parentCollection )
663 instance = m_parentCollection->instance(); 666 instance = m_parentCollection->instance();
@@ -712,25 +715,25 @@ int KAction::plug( QWidget *w, int index )
712 SLOT( slotActivated() ), 715 SLOT( slotActivated() ),
713 d->isEnabled(), d->plainText(), index ); 716 d->isEnabled(), d->plainText(), index );
714 } 717 }
715 else 718 else
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
733 connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); 736 connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) );
734 737
735 if ( m_parentCollection ) 738 if ( m_parentCollection )
736 m_parentCollection->connectHighlight( bar, this ); 739 m_parentCollection->connectHighlight( bar, this );
@@ -740,27 +743,27 @@ int KAction::plug( QWidget *w, int index )
740 } 743 }
741 744
742 return -1; 745 return -1;
743} 746}
744 747
745void KAction::unplug( QWidget *w ) 748void 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" ) )
763 { 766 {
764 QMenuBar *bar = static_cast<QMenuBar *>( w ); 767 QMenuBar *bar = static_cast<QMenuBar *>( w );
765 bar->removeItem( id ); 768 bar->removeItem( id );
766 } 769 }
@@ -853,26 +856,26 @@ void KAction::setEnabled(bool enable)
853 856
854 int len = containerCount(); 857 int len = containerCount();
855 for( int i = 0; i < len; ++i ) 858 for( int i = 0; i < len; ++i )
856 updateEnabled( i ); 859 updateEnabled( i );
857 860
858 emit enabled( d->isEnabled() ); 861 emit enabled( d->isEnabled() );
859} 862}
860 863
861void KAction::updateEnabled( int i ) 864void 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
875void KAction::setShortcutConfigurable( bool b ) 878void KAction::setShortcutConfigurable( bool b )
876{ 879{
877 d->m_configurable = b; 880 d->m_configurable = b;
878} 881}
@@ -897,28 +900,28 @@ void KAction::setText( const QString& text )
897 d->setText( text ); 900 d->setText( text );
898 901
899 int len = containerCount(); 902 int len = containerCount();
900 for( int i = 0; i < len; ++i ) 903 for( int i = 0; i < len; ++i )
901 updateText( i ); 904 updateText( i );
902 905
903} 906}
904 907
905void KAction::updateText( int i ) 908void 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" ) )
921 static_cast<KToolBarButton *>(button)->setText( d->plainText() ); 924 static_cast<KToolBarButton *>(button)->setText( d->plainText() );
922 925
923 } 926 }
924} 927}
@@ -938,100 +941,100 @@ void KAction::setIcon( const QString &icon )
938 d->setIconName( icon ); 941 d->setIconName( icon );
939 942
940 // now handle any toolbars 943 // now handle any toolbars
941 int len = containerCount(); 944 int len = containerCount();
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
946void KAction::updateIcon( int id ) 949void 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
966QString KAction::icon() const 969QString KAction::icon() const
967{ 970{
968 return d->iconName( ); 971 return d->iconName( );
969} 972}
970 973
971void KAction::setIconSet( const QIconSet &iconset ) 974void 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
981void KAction::updateIconSet( int id ) 984void 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
1002QIconSet KAction::iconSet( KIcon::Group group, int size ) const 1005QIcon 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
1007bool KAction::hasIcon() const 1010bool KAction::hasIcon() const
1008{ 1011{
1009 return d->hasIcon(); 1012 return d->hasIcon();
1010} 1013}
1011 1014
1012 1015
1013void KAction::setWhatsThis( const QString& text ) 1016void KAction::setWhatsThis( const QString& text )
1014{ 1017{
1015 d->setWhatsThis( text ); 1018 d->setWhatsThis( text );
1016 1019
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
1022void KAction::updateWhatsThis( int i ) 1025void 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 )
1034 { 1037 {
1035 QWidget *w = tb->getButton( itemId( i ) ); 1038 QWidget *w = tb->getButton( itemId( i ) );
1036//US QWhatsThis::remove( w ); 1039//US QWhatsThis::remove( w );
1037//US QWhatsThis::add( w, d->whatsThis() ); 1040//US QWhatsThis::add( w, d->whatsThis() );
@@ -1055,28 +1058,28 @@ QString KAction::whatsThisWithIcon() const
1055QWidget* KAction::container( int index ) const 1058QWidget* KAction::container( int index ) const
1056{ 1059{
1057 assert( index < containerCount() ); 1060 assert( index < containerCount() );
1058 return d->m_containers[ index ].m_container; 1061 return d->m_containers[ index ].m_container;
1059} 1062}
1060 1063
1061KToolBar* KAction::toolBar( int index ) const 1064KToolBar* 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
1067QPopupMenu* KAction::popupMenu( int index ) const 1070Q3PopupMenu* 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
1073QWidget* KAction::representative( int index ) const 1076QWidget* 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
1078int KAction::itemId( int index ) const 1081int KAction::itemId( int index ) const
1079{ 1082{
1080 return d->m_containers[ index ].m_id; 1083 return d->m_containers[ index ].m_id;
1081} 1084}
1082 1085
@@ -1146,40 +1149,40 @@ void KAction::slotDestroyed()
1146 do 1149 do
1147 { 1150 {
1148 i = findContainer( static_cast<const QWidget*>( o ) ); 1151 i = findContainer( static_cast<const QWidget*>( o ) );
1149 if ( i != -1 ) 1152 if ( i != -1 )
1150 removeContainer( i ); 1153 removeContainer( i );
1151 } while ( i != -1 ); 1154 } while ( i != -1 );
1152 1155
1153} 1156}
1154 1157
1155int KAction::findContainer( const QWidget* widget ) const 1158int 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
1170void KAction::removeContainer( int index ) 1173void 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;
1182 ++i; 1185 ++i;
1183 } 1186 }
1184} 1187}
1185 1188