-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 | |||
@@ -1,249 +1,252 @@ | |||
1 | /* This file is part of the KDE libraries | 1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org> | 2 | Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org> |
3 | (C) 1999 Simon Hausmann <hausmann@kde.org> | 3 | (C) 1999 Simon Hausmann <hausmann@kde.org> |
4 | (C) 2000 Nicolas Hadacek <haadcek@kde.org> | 4 | (C) 2000 Nicolas Hadacek <haadcek@kde.org> |
5 | (C) 2000 Kurt Granroth <granroth@kde.org> | 5 | (C) 2000 Kurt Granroth <granroth@kde.org> |
6 | (C) 2000 Michael Koch <koch@kde.org> | 6 | (C) 2000 Michael Koch <koch@kde.org> |
7 | (C) 2001 Holger Freyther <freyther@kde.org> | 7 | (C) 2001 Holger Freyther <freyther@kde.org> |
8 | (C) 2002 Ellis Whitehead <ellis@kde.org> | 8 | (C) 2002 Ellis Whitehead <ellis@kde.org> |
9 | (C) 2002 Joseph Wenninger <jowenn@kde.org> | 9 | (C) 2002 Joseph Wenninger <jowenn@kde.org> |
10 | 10 | ||
11 | This library is free software; you can redistribute it and/or | 11 | This library is free software; you can redistribute it and/or |
12 | modify it under the terms of the GNU Library General Public | 12 | modify it under the terms of the GNU Library General Public |
13 | License version 2 as published by the Free Software Foundation. | 13 | License version 2 as published by the Free Software Foundation. |
14 | 14 | ||
15 | This library is distributed in the hope that it will be useful, | 15 | This library is distributed in the hope that it will be useful, |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
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 "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) |
60 | * | 63 | * |
61 | * Shortcuts: | 64 | * Shortcuts: |
62 | * An action's shortcut will not not be connected unless a focus widget has | 65 | * An action's shortcut will not not be connected unless a focus widget has |
63 | * been specified in KActionCollection. | 66 | * been specified in KActionCollection. |
64 | * | 67 | * |
65 | * XML Filename: | 68 | * XML Filename: |
66 | * This is used to save user-modified settings back to the *ui.rc file. | 69 | * This is used to save user-modified settings back to the *ui.rc file. |
67 | * It is set by KXMLGUIFactory. | 70 | * It is set by KXMLGUIFactory. |
68 | */ | 71 | */ |
69 | 72 | ||
70 | int KAction::getToolButtonID() | 73 | int KAction::getToolButtonID() |
71 | { | 74 | { |
72 | static int toolbutton_no = -2; | 75 | static int toolbutton_no = -2; |
73 | return toolbutton_no--; | 76 | return toolbutton_no--; |
74 | } | 77 | } |
75 | 78 | ||
76 | //--------------------------------------------------------------------- | 79 | //--------------------------------------------------------------------- |
77 | // KAction::KActionPrivate | 80 | // KAction::KActionPrivate |
78 | //--------------------------------------------------------------------- | 81 | //--------------------------------------------------------------------- |
79 | 82 | ||
80 | class KAction::KActionPrivate : public KGuiItem | 83 | class KAction::KActionPrivate : public KGuiItem |
81 | { | 84 | { |
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; |
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 | //--------------------------------------------------------------------- |
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 ) |
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 | ||
124 | KAction::KAction( const QString& text, const QString& sIconName, const KShortcut& cut, | 127 | KAction::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 | ||
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, |
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 | { |
146 | initPrivate( item.text(), cut, receiver, slot ); | 149 | initPrivate( item.text(), cut, receiver, slot ); |
147 | if( item.hasIconSet() ) | 150 | if( item.hasIconSet() ) |
148 | setIcon( item.iconName() ); | 151 | setIcon( item.iconName() ); |
149 | setToolTip( item.toolTip() ); | 152 | setToolTip( item.toolTip() ); |
150 | setWhatsThis( item.whatsThis() ); | 153 | setWhatsThis( item.whatsThis() ); |
151 | } | 154 | } |
152 | 155 | ||
153 | // KDE 4: remove | 156 | // KDE 4: remove |
154 | KAction::KAction( const QString& text, const KShortcut& cut, | 157 | 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 | } |
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 | ||
176 | KAction::KAction( const QString& text, const QString& pix, | 179 | 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 | } |
194 | 197 | ||
195 | KAction::KAction( const QString& text, const QString& pix, | 198 | KAction::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, |
198 | const char* name ) | 201 | const char* name ) |
199 | : QObject( parent, name ) | 202 | : QObject( parent, name ) |
200 | { | 203 | { |
201 | initPrivate( text, cut, receiver, slot ); | 204 | initPrivate( text, cut, receiver, slot ); |
202 | d->setIconName(pix); | 205 | d->setIconName(pix); |
203 | } | 206 | } |
204 | 207 | ||
205 | KAction::KAction( QObject* parent, const char* name ) | 208 | KAction::KAction( QObject* parent, const char* name ) |
206 | : QObject( parent, name ) | 209 | : QObject( parent, name ) |
207 | { | 210 | { |
208 | 211 | ||
209 | initPrivate( QString::null, KShortcut(), 0, 0 ); | 212 | initPrivate( QString::null, KShortcut(), 0, 0 ); |
210 | } | 213 | } |
211 | // KDE 4: remove end | 214 | // KDE 4: remove end |
212 | 215 | ||
213 | KAction::~KAction() | 216 | KAction::~KAction() |
214 | { | 217 | { |
215 | #ifndef KDE_NO_COMPAT | 218 | #ifndef KDE_NO_COMPAT |
216 | if (d->m_kaccel) | 219 | if (d->m_kaccel) |
217 | unplugAccel(); | 220 | unplugAccel(); |
218 | #endif | 221 | #endif |
219 | 222 | ||
220 | // If actionCollection hasn't already been destructed, | 223 | // If actionCollection hasn't already been destructed, |
221 | if ( m_parentCollection ) { | 224 | if ( m_parentCollection ) { |
222 | m_parentCollection->take( this ); | 225 | m_parentCollection->take( this ); |
223 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) | 226 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) |
224 | //US d->m_kaccelList[i]->remove( name() ); | 227 | //US d->m_kaccelList[i]->remove( name() ); |
225 | qDebug("KAction::KAction~ ...1 has top be fixed"); | 228 | qDebug("KAction::KAction~ ...1 has top be fixed"); |
226 | } | 229 | } |
227 | 230 | ||
228 | // Do not call unplugAll from here, as tempting as it sounds. | 231 | // Do not call unplugAll from here, as tempting as it sounds. |
229 | // KAction is designed around the idea that you need to plug | 232 | // KAction is designed around the idea that you need to plug |
230 | // _and_ to unplug it "manually". Unplugging leads to an important | 233 | // _and_ to unplug it "manually". Unplugging leads to an important |
231 | // slowdown when e.g. closing the window, in which case we simply | 234 | // slowdown when e.g. closing the window, in which case we simply |
232 | // want to destroy everything asap, not to remove actions one by one | 235 | // want to destroy everything asap, not to remove actions one by one |
233 | // from the GUI. | 236 | // from the GUI. |
234 | 237 | ||
235 | delete d; d = 0; | 238 | delete d; d = 0; |
236 | } | 239 | } |
237 | 240 | ||
238 | void KAction::initPrivate( const QString& text, const KShortcut& cut, | 241 | void KAction::initPrivate( const QString& text, const KShortcut& cut, |
239 | const QObject* receiver, const char* slot ) | 242 | const QObject* receiver, const char* slot ) |
240 | { | 243 | { |
241 | d = new KActionPrivate; | 244 | d = new KActionPrivate; |
242 | 245 | ||
243 | d->m_cutDefault = cut; | 246 | d->m_cutDefault = cut; |
244 | 247 | ||
245 | //US m_parentCollection = dynamic_cast<KActionCollection *>( parent() ); | 248 | //US m_parentCollection = dynamic_cast<KActionCollection *>( parent() ); |
246 | m_parentCollection = (KActionCollection *)( parent() ); | 249 | m_parentCollection = (KActionCollection *)( parent() ); |
247 | kdDebug(129) << "KAction::initPrivate(): this = " << this << " name = \"" << name() << "\" cut = " << cut.toStringInternal() << " m_parentCollection = " << m_parentCollection << endl; | 250 | kdDebug(129) << "KAction::initPrivate(): this = " << this << " name = \"" << name() << "\" cut = " << cut.toStringInternal() << " m_parentCollection = " << m_parentCollection << endl; |
248 | if ( m_parentCollection ) | 251 | if ( m_parentCollection ) |
249 | m_parentCollection->insert( this ); | 252 | m_parentCollection->insert( this ); |
@@ -445,771 +448,771 @@ bool KAction::updateKAccelShortcut( KAccel* kaccel ) | |||
445 | 448 | ||
446 | if ( !kaccel->actions().actionPtr( name() ) ) { | 449 | if ( !kaccel->actions().actionPtr( name() ) ) { |
447 | if(!d->m_cut.isNull() ) { | 450 | if(!d->m_cut.isNull() ) { |
448 | kdDebug(129) << "Inserting " << name() << ", " << d->text() << ", " << d->plainText() << endl; | 451 | kdDebug(129) << "Inserting " << name() << ", " << d->text() << ", " << d->plainText() << endl; |
449 | b = kaccel->insert( name(), d->plainText(), QString::null, | 452 | b = kaccel->insert( name(), d->plainText(), QString::null, |
450 | d->m_cut, | 453 | d->m_cut, |
451 | this, SLOT(slotActivated()), | 454 | this, SLOT(slotActivated()), |
452 | isShortcutConfigurable(), isEnabled() ); | 455 | isShortcutConfigurable(), isEnabled() ); |
453 | } | 456 | } |
454 | } | 457 | } |
455 | else | 458 | else |
456 | b = kaccel->setShortcut( name(), d->m_cut ); | 459 | b = kaccel->setShortcut( name(), d->m_cut ); |
457 | 460 | ||
458 | return b; | 461 | return b; |
459 | */ | 462 | */ |
460 | return true; | 463 | return true; |
461 | } | 464 | } |
462 | 465 | ||
463 | void KAction::insertKAccel( KAccel* kaccel ) | 466 | void KAction::insertKAccel( KAccel* kaccel ) |
464 | { | 467 | { |
465 | //qDebug("KAction::updateKAccelShortcut~ ...1 has top be fixed"); | 468 | //qDebug("KAction::updateKAccelShortcut~ ...1 has top be fixed"); |
466 | 469 | ||
467 | /*US | 470 | /*US |
468 | //kdDebug(129) << "KAction::insertKAccel( " << kaccel << " ): this = " << this << endl; | 471 | //kdDebug(129) << "KAction::insertKAccel( " << kaccel << " ): this = " << this << endl; |
469 | if ( !kaccel->actions().actionPtr( name() ) ) { | 472 | if ( !kaccel->actions().actionPtr( name() ) ) { |
470 | if( updateKAccelShortcut( kaccel ) ) { | 473 | if( updateKAccelShortcut( kaccel ) ) { |
471 | d->m_kaccelList.append( kaccel ); | 474 | d->m_kaccelList.append( kaccel ); |
472 | connect( kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); | 475 | connect( kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); |
473 | } | 476 | } |
474 | } | 477 | } |
475 | else | 478 | else |
476 | kdWarning(129) << "KAction::insertKAccel( kaccel = " << kaccel << " ): KAccel object already contains an action name \"" << name() << "\"" << endl; // -- ellis | 479 | kdWarning(129) << "KAction::insertKAccel( kaccel = " << kaccel << " ): KAccel object already contains an action name \"" << name() << "\"" << endl; // -- ellis |
477 | */ | 480 | */ |
478 | } | 481 | } |
479 | 482 | ||
480 | void KAction::removeKAccel( KAccel* kaccel ) | 483 | void KAction::removeKAccel( KAccel* kaccel ) |
481 | { | 484 | { |
482 | // qDebug("KAction::removeKAccel~ ...1 has top be fixed"); | 485 | // qDebug("KAction::removeKAccel~ ...1 has top be fixed"); |
483 | 486 | ||
484 | /*US | 487 | /*US |
485 | //kdDebug(129) << "KAction::removeKAccel( " << i << " ): this = " << this << endl; | 488 | //kdDebug(129) << "KAction::removeKAccel( " << i << " ): this = " << this << endl; |
486 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { | 489 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { |
487 | if( d->m_kaccelList[i] == kaccel ) { | 490 | if( d->m_kaccelList[i] == kaccel ) { |
488 | kaccel->remove( name() ); | 491 | kaccel->remove( name() ); |
489 | d->m_kaccelList.remove( d->m_kaccelList.at( i ) ); | 492 | d->m_kaccelList.remove( d->m_kaccelList.at( i ) ); |
490 | disconnect( kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); | 493 | disconnect( kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); |
491 | break; | 494 | break; |
492 | } | 495 | } |
493 | } | 496 | } |
494 | */ | 497 | */ |
495 | } | 498 | } |
496 | 499 | ||
497 | // KDE 4: remove | 500 | // KDE 4: remove |
498 | void KAction::setAccel( int keyQt ) | 501 | void 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 | ||
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' ); |
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(); |
534 | 537 | ||
535 | menu->changeItem( id, s ); | 538 | menu->changeItem( id, s ); |
536 | } | 539 | } |
537 | // Otherwise insert the shortcut itself into the popup menu. | 540 | // Otherwise insert the shortcut itself into the popup menu. |
538 | else { | 541 | else { |
539 | // This is a fall-hack in case the KAction is missing a proper parent collection. | 542 | // This is a fall-hack in case the KAction is missing a proper parent collection. |
540 | // It should be removed eventually. --ellis | 543 | // It should be removed eventually. --ellis |
541 | menu->setAccel( d->m_cut.keyCodeQt(), id ); | 544 | menu->setAccel( d->m_cut.keyCodeQt(), id ); |
542 | kdWarning(129) << "KAction::updateShortcut(): name = \"" << name() << "\", cut = " << d->m_cut.toStringInternal() << "; No KAccel, probably missing a parent collection." << endl; | 545 | kdWarning(129) << "KAction::updateShortcut(): name = \"" << name() << "\", cut = " << d->m_cut.toStringInternal() << "; No KAccel, probably missing a parent collection." << endl; |
543 | } | 546 | } |
544 | */ | 547 | */ |
545 | 548 | ||
546 | 549 | ||
547 | //qDebug("KAction::updateShortcut( QPopupMenu* menu, int id ) ...1 has top be fixed"); | 550 | //qDebug("KAction::updateShortcut( QPopupMenu* menu, int id ) ...1 has top be fixed"); |
548 | 551 | ||
549 | } | 552 | } |
550 | 553 | ||
551 | const KShortcut& KAction::shortcut() const | 554 | const KShortcut& KAction::shortcut() const |
552 | { | 555 | { |
553 | return d->m_cut; | 556 | return d->m_cut; |
554 | } | 557 | } |
555 | 558 | ||
556 | const KShortcut& KAction::shortcutDefault() const | 559 | const KShortcut& KAction::shortcutDefault() const |
557 | { | 560 | { |
558 | return d->m_cutDefault; | 561 | return d->m_cutDefault; |
559 | } | 562 | } |
560 | 563 | ||
561 | QString KAction::shortcutText() const | 564 | QString KAction::shortcutText() const |
562 | { | 565 | { |
563 | return d->m_cut.toStringInternal(); | 566 | return d->m_cut.toStringInternal(); |
564 | } | 567 | } |
565 | 568 | ||
566 | void KAction::setShortcutText( const QString& s ) | 569 | void KAction::setShortcutText( const QString& s ) |
567 | { | 570 | { |
568 | setShortcut( KShortcut(s) ); | 571 | setShortcut( KShortcut(s) ); |
569 | } | 572 | } |
570 | 573 | ||
571 | int KAction::accel() const | 574 | int KAction::accel() const |
572 | { | 575 | { |
573 | // qDebug("KAction::accel() ...1 has top be fixed"); | 576 | // qDebug("KAction::accel() ...1 has top be fixed"); |
574 | //US return d->m_cut.keyCodeQt(); | 577 | //US return d->m_cut.keyCodeQt(); |
575 | return 0; | 578 | return 0; |
576 | } | 579 | } |
577 | 580 | ||
578 | void KAction::setGroup( const QString& grp ) | 581 | void KAction::setGroup( const QString& grp ) |
579 | { | 582 | { |
580 | d->m_group = grp; | 583 | d->m_group = grp; |
581 | 584 | ||
582 | int len = containerCount(); | 585 | int len = containerCount(); |
583 | for( int i = 0; i < len; ++i ) | 586 | for( int i = 0; i < len; ++i ) |
584 | updateGroup( i ); | 587 | updateGroup( i ); |
585 | } | 588 | } |
586 | 589 | ||
587 | void KAction::updateGroup( int ) | 590 | void KAction::updateGroup( int ) |
588 | { | 591 | { |
589 | // DO SOMETHING | 592 | // DO SOMETHING |
590 | } | 593 | } |
591 | 594 | ||
592 | QString KAction::group() const | 595 | QString KAction::group() const |
593 | { | 596 | { |
594 | return d->m_group; | 597 | return d->m_group; |
595 | } | 598 | } |
596 | 599 | ||
597 | bool KAction::isEnabled() const | 600 | bool KAction::isEnabled() const |
598 | { | 601 | { |
599 | return d->isEnabled(); | 602 | return d->isEnabled(); |
600 | } | 603 | } |
601 | 604 | ||
602 | bool KAction::isShortcutConfigurable() const | 605 | bool KAction::isShortcutConfigurable() const |
603 | { | 606 | { |
604 | return d->m_configurable; | 607 | return d->m_configurable; |
605 | } | 608 | } |
606 | 609 | ||
607 | void KAction::setToolTip( const QString& tt ) | 610 | void KAction::setToolTip( const QString& tt ) |
608 | { | 611 | { |
609 | //qDebug("KAction::setToolTip ...1 has top be fixed"); | 612 | //qDebug("KAction::setToolTip ...1 has top be fixed"); |
610 | d->setToolTip( tt ); | 613 | d->setToolTip( tt ); |
611 | 614 | ||
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 | ||
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 | ||
633 | int KAction::plug( QWidget *w, int index ) | 636 | int 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(); |
664 | else | 667 | else |
665 | instance = KGlobal::instance(); | 668 | instance = KGlobal::instance(); |
666 | */ | 669 | */ |
667 | id = menu->insertItem( d->iconSet( KIcon::Small, 0/*US , instance */), d->text(), this,//dsweet | 670 | id = menu->insertItem( d->iconSet( KIcon::Small, 0/*US , instance */), d->text(), this,//dsweet |
668 | SLOT( slotActivated() ), keyQt, | 671 | SLOT( slotActivated() ), keyQt, |
669 | -1, index ); | 672 | -1, index ); |
670 | } | 673 | } |
671 | else | 674 | else |
672 | id = menu->insertItem( d->text(), this, | 675 | id = menu->insertItem( d->text(), this, |
673 | SLOT( slotActivated() ), //dsweet | 676 | SLOT( slotActivated() ), //dsweet |
674 | keyQt, -1, index ); | 677 | keyQt, -1, index ); |
675 | 678 | ||
676 | // If the shortcut is already in a KAccel object, then | 679 | // If the shortcut is already in a KAccel object, then |
677 | // we need to set the menu item's shortcut text. | 680 | // we need to set the menu item's shortcut text. |
678 | /*US if ( d->m_kaccelList.count() || d->m_kaccel ) | 681 | /*US if ( d->m_kaccelList.count() || d->m_kaccel ) |
679 | updateShortcut( menu, id ); | 682 | updateShortcut( menu, id ); |
680 | */ | 683 | */ |
681 | // call setItemEnabled only if the item really should be disabled, | 684 | // call setItemEnabled only if the item really should be disabled, |
682 | // because that method is slow and the item is per default enabled | 685 | // because that method is slow and the item is per default enabled |
683 | if ( !d->isEnabled() ) | 686 | if ( !d->isEnabled() ) |
684 | menu->setItemEnabled( id, false ); | 687 | menu->setItemEnabled( id, false ); |
685 | 688 | ||
686 | if ( !d->whatsThis().isEmpty() ) | 689 | if ( !d->whatsThis().isEmpty() ) |
687 | menu->setWhatsThis( id, whatsThisWithIcon() ); | 690 | menu->setWhatsThis( id, whatsThisWithIcon() ); |
688 | 691 | ||
689 | addContainer( menu, id ); | 692 | addContainer( menu, id ); |
690 | connect( menu, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); | 693 | connect( menu, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); |
691 | 694 | ||
692 | if ( m_parentCollection ) | 695 | if ( m_parentCollection ) |
693 | m_parentCollection->connectHighlight( menu, this ); | 696 | m_parentCollection->connectHighlight( menu, this ); |
694 | 697 | ||
695 | return d->m_containers.count() - 1; | 698 | return d->m_containers.count() - 1; |
696 | } | 699 | } |
697 | else if ( w->inherits( "KToolBar" ) ) | 700 | else if ( w->inherits( "KToolBar" ) ) |
698 | { | 701 | { |
699 | KToolBar *bar = static_cast<KToolBar *>( w ); | 702 | KToolBar *bar = static_cast<KToolBar *>( w ); |
700 | 703 | ||
701 | int id_ = getToolButtonID(); | 704 | int id_ = getToolButtonID(); |
702 | /*US | 705 | /*US |
703 | KInstance *instance; | 706 | KInstance *instance; |
704 | if ( m_parentCollection ) | 707 | if ( m_parentCollection ) |
705 | instance = m_parentCollection->instance(); | 708 | instance = m_parentCollection->instance(); |
706 | else | 709 | else |
707 | instance = KGlobal::instance(); | 710 | instance = KGlobal::instance(); |
708 | */ | 711 | */ |
709 | if ( icon().isEmpty() && !iconSet().pixmap().isNull() ) // old code using QIconSet directly | 712 | if ( icon().isEmpty() && !iconSet().pixmap().isNull() ) // old code using QIconSet directly |
710 | { | 713 | { |
711 | bar->insertButton( iconSet().pixmap(), id_, SIGNAL( clicked() ), this, | 714 | bar->insertButton( iconSet().pixmap(), id_, SIGNAL( clicked() ), this, |
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 ); |
737 | 740 | ||
738 | return containerCount() - 1; | 741 | return containerCount() - 1; |
739 | 742 | ||
740 | } | 743 | } |
741 | 744 | ||
742 | return -1; | 745 | return -1; |
743 | } | 746 | } |
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" ) ) |
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 | } |
767 | 770 | ||
768 | removeContainer( i ); | 771 | removeContainer( i ); |
769 | 772 | ||
770 | if ( m_parentCollection ) | 773 | if ( m_parentCollection ) |
771 | m_parentCollection->disconnectHighlight( w, this ); | 774 | m_parentCollection->disconnectHighlight( w, this ); |
772 | } | 775 | } |
773 | 776 | ||
774 | void KAction::plugAccel(KAccel *kacc, bool configurable) | 777 | void KAction::plugAccel(KAccel *kacc, bool configurable) |
775 | { | 778 | { |
776 | // qDebug("KAction::plugAccel ...1 has top be fixed"); | 779 | // qDebug("KAction::plugAccel ...1 has top be fixed"); |
777 | 780 | ||
778 | /*US | 781 | /*US |
779 | kdWarning(129) << "KAction::plugAccel(): call to deprecated action." << endl; | 782 | kdWarning(129) << "KAction::plugAccel(): call to deprecated action." << endl; |
780 | kdDebug(129) << kdBacktrace() << endl; | 783 | kdDebug(129) << kdBacktrace() << endl; |
781 | //kdDebug(129) << "KAction::plugAccel( kacc = " << kacc << " ): name \"" << name() << "\"" << endl; | 784 | //kdDebug(129) << "KAction::plugAccel( kacc = " << kacc << " ): name \"" << name() << "\"" << endl; |
782 | if ( d->m_kaccel ) | 785 | if ( d->m_kaccel ) |
783 | unplugAccel(); | 786 | unplugAccel(); |
784 | 787 | ||
785 | // If the parent collection's accel ptr isn't set yet | 788 | // If the parent collection's accel ptr isn't set yet |
786 | //if ( m_parentCollection && !m_parentCollection->accel() ) | 789 | //if ( m_parentCollection && !m_parentCollection->accel() ) |
787 | // m_parentCollection->setAccel( kacc ); | 790 | // m_parentCollection->setAccel( kacc ); |
788 | 791 | ||
789 | // We can only plug this action into the given KAccel object | 792 | // We can only plug this action into the given KAccel object |
790 | // if it does not already contain an action with the same name. | 793 | // if it does not already contain an action with the same name. |
791 | if ( !kacc->actions().actionPtr(name()) ) | 794 | if ( !kacc->actions().actionPtr(name()) ) |
792 | { | 795 | { |
793 | d->m_kaccel = kacc; | 796 | d->m_kaccel = kacc; |
794 | d->m_kaccel->insert(name(), d->plainText(), QString::null, | 797 | d->m_kaccel->insert(name(), d->plainText(), QString::null, |
795 | KShortcut(d->m_cut), | 798 | KShortcut(d->m_cut), |
796 | this, SLOT(slotActivated()), | 799 | this, SLOT(slotActivated()), |
797 | configurable, isEnabled()); | 800 | configurable, isEnabled()); |
798 | connect(d->m_kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed())); | 801 | connect(d->m_kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed())); |
799 | //connect(d->m_kaccel, SIGNAL(keycodeChanged()), this, SLOT(slotKeycodeChanged())); | 802 | //connect(d->m_kaccel, SIGNAL(keycodeChanged()), this, SLOT(slotKeycodeChanged())); |
800 | } | 803 | } |
801 | else | 804 | else |
802 | kdWarning(129) << "KAction::plugAccel( kacc = " << kacc << " ): KAccel object already contains an action name \"" << name() << "\"" << endl; // -- ellis | 805 | kdWarning(129) << "KAction::plugAccel( kacc = " << kacc << " ): KAccel object already contains an action name \"" << name() << "\"" << endl; // -- ellis |
803 | */ | 806 | */ |
804 | } | 807 | } |
805 | 808 | ||
806 | void KAction::unplugAccel() | 809 | void KAction::unplugAccel() |
807 | { | 810 | { |
808 | // qDebug("KAction::unplugAccel ...1 has top be fixed"); | 811 | // qDebug("KAction::unplugAccel ...1 has top be fixed"); |
809 | /*US | 812 | /*US |
810 | //kdDebug(129) << "KAction::unplugAccel() " << this << " " << name() << endl; | 813 | //kdDebug(129) << "KAction::unplugAccel() " << this << " " << name() << endl; |
811 | if ( d->m_kaccel ) | 814 | if ( d->m_kaccel ) |
812 | { | 815 | { |
813 | d->m_kaccel->remove(name()); | 816 | d->m_kaccel->remove(name()); |
814 | d->m_kaccel = 0; | 817 | d->m_kaccel = 0; |
815 | } | 818 | } |
816 | */ | 819 | */ |
817 | } | 820 | } |
818 | 821 | ||
819 | void KAction::plugMainWindowAccel( QWidget *w ) | 822 | void KAction::plugMainWindowAccel( QWidget *w ) |
820 | { | 823 | { |
821 | // qDebug("KAction::plugMainWindowAccel ...1 has top be fixed"); | 824 | // qDebug("KAction::plugMainWindowAccel ...1 has top be fixed"); |
822 | 825 | ||
823 | /*US | 826 | /*US |
824 | // Note: topLevelWidget() stops too early, we can't use it. | 827 | // Note: topLevelWidget() stops too early, we can't use it. |
825 | QWidget * tl = w; | 828 | QWidget * tl = w; |
826 | QWidget * n; | 829 | QWidget * n; |
827 | while ( !tl->isDialog() && ( n = tl->parentWidget() ) ) // lookup parent and store | 830 | while ( !tl->isDialog() && ( n = tl->parentWidget() ) ) // lookup parent and store |
828 | tl = n; | 831 | tl = n; |
829 | 832 | ||
830 | KMainWindow * mw = dynamic_cast<KMainWindow *>(tl); // try to see if it's a kmainwindow | 833 | KMainWindow * mw = dynamic_cast<KMainWindow *>(tl); // try to see if it's a kmainwindow |
831 | if (mw) | 834 | if (mw) |
832 | plugAccel( mw->accel() ); | 835 | plugAccel( mw->accel() ); |
833 | else | 836 | else |
834 | kdDebug(129) << "KAction::plugMainWindowAccel: Toplevel widget isn't a KMainWindow, can't plug accel. " << tl << endl; | 837 | kdDebug(129) << "KAction::plugMainWindowAccel: Toplevel widget isn't a KMainWindow, can't plug accel. " << tl << endl; |
835 | */ | 838 | */ |
836 | } | 839 | } |
837 | 840 | ||
838 | void KAction::setEnabled(bool enable) | 841 | void KAction::setEnabled(bool enable) |
839 | { | 842 | { |
840 | //kdDebug(129) << "KAction::setEnabled( " << enable << " ): this = " << this << " d->m_kaccelList.count() = " << d->m_kaccelList.count() << endl; | 843 | //kdDebug(129) << "KAction::setEnabled( " << enable << " ): this = " << this << " d->m_kaccelList.count() = " << d->m_kaccelList.count() << endl; |
841 | if ( enable == d->isEnabled() ) | 844 | if ( enable == d->isEnabled() ) |
842 | return; | 845 | return; |
843 | 846 | ||
844 | // KDE 4: remove | 847 | // KDE 4: remove |
845 | //US if (d->m_kaccel) | 848 | //US if (d->m_kaccel) |
846 | //US d->m_kaccel->setEnabled(name(), enable); | 849 | //US d->m_kaccel->setEnabled(name(), enable); |
847 | // KDE 4: remove end | 850 | // KDE 4: remove end |
848 | 851 | ||
849 | //US for ( uint i = 0; i < d->m_kaccelList.count(); i++ ) | 852 | //US for ( uint i = 0; i < d->m_kaccelList.count(); i++ ) |
850 | //US d->m_kaccelList[i]->setEnabled( name(), enable ); | 853 | //US d->m_kaccelList[i]->setEnabled( name(), enable ); |
851 | 854 | ||
852 | d->setEnabled( enable ); | 855 | d->setEnabled( 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 | ||
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 | ||
875 | void KAction::setShortcutConfigurable( bool b ) | 878 | void KAction::setShortcutConfigurable( bool b ) |
876 | { | 879 | { |
877 | d->m_configurable = b; | 880 | d->m_configurable = b; |
878 | } | 881 | } |
879 | 882 | ||
880 | void KAction::setText( const QString& text ) | 883 | void KAction::setText( const QString& text ) |
881 | { | 884 | { |
882 | /*US | 885 | /*US |
883 | // KDE 4: remove | 886 | // KDE 4: remove |
884 | if (d->m_kaccel) { | 887 | if (d->m_kaccel) { |
885 | KAccelAction* pAction = d->m_kaccel->actions().actionPtr(name()); | 888 | KAccelAction* pAction = d->m_kaccel->actions().actionPtr(name()); |
886 | if (pAction) | 889 | if (pAction) |
887 | pAction->setLabel( text ); | 890 | pAction->setLabel( text ); |
888 | } | 891 | } |
889 | // KDE 4: remove end | 892 | // KDE 4: remove end |
890 | 893 | ||
891 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { | 894 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { |
892 | KAccelAction* pAction = d->m_kaccelList[i]->actions().actionPtr(name()); | 895 | KAccelAction* pAction = d->m_kaccelList[i]->actions().actionPtr(name()); |
893 | if (pAction) | 896 | if (pAction) |
894 | pAction->setLabel( text ); | 897 | pAction->setLabel( text ); |
895 | } | 898 | } |
896 | */ | 899 | */ |
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 | ||
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" ) ) |
921 | static_cast<KToolBarButton *>(button)->setText( d->plainText() ); | 924 | static_cast<KToolBarButton *>(button)->setText( d->plainText() ); |
922 | 925 | ||
923 | } | 926 | } |
924 | } | 927 | } |
925 | 928 | ||
926 | QString KAction::text() const | 929 | QString KAction::text() const |
927 | { | 930 | { |
928 | return d->text(); | 931 | return d->text(); |
929 | } | 932 | } |
930 | 933 | ||
931 | QString KAction::plainText() const | 934 | QString KAction::plainText() const |
932 | { | 935 | { |
933 | return d->plainText( ); | 936 | return d->plainText( ); |
934 | } | 937 | } |
935 | 938 | ||
936 | void KAction::setIcon( const QString &icon ) | 939 | void KAction::setIcon( const QString &icon ) |
937 | { | 940 | { |
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 | ||
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 | } |
1011 | 1014 | ||
1012 | 1015 | ||
1013 | void KAction::setWhatsThis( const QString& text ) | 1016 | void 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 | ||
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 ) |
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() ); |
1038 | return; | 1041 | return; |
1039 | } | 1042 | } |
1040 | } | 1043 | } |
1041 | 1044 | ||
1042 | QString KAction::whatsThis() const | 1045 | QString KAction::whatsThis() const |
1043 | { | 1046 | { |
1044 | return d->whatsThis(); | 1047 | return d->whatsThis(); |
1045 | } | 1048 | } |
1046 | 1049 | ||
1047 | QString KAction::whatsThisWithIcon() const | 1050 | QString KAction::whatsThisWithIcon() const |
1048 | { | 1051 | { |
1049 | QString text = whatsThis(); | 1052 | QString text = whatsThis(); |
1050 | if (!d->iconName().isEmpty()) | 1053 | if (!d->iconName().isEmpty()) |
1051 | return QString::fromLatin1("<img source=\"small|%1\"> %2").arg(d->iconName() ).arg(text); | 1054 | return QString::fromLatin1("<img source=\"small|%1\"> %2").arg(d->iconName() ).arg(text); |
1052 | return text; | 1055 | return text; |
1053 | } | 1056 | } |
1054 | 1057 | ||
1055 | QWidget* KAction::container( int index ) const | 1058 | QWidget* 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 | ||
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 |
1079 | { | 1082 | { |
1080 | return d->m_containers[ index ].m_id; | 1083 | return d->m_containers[ index ].m_id; |
1081 | } | 1084 | } |
1082 | 1085 | ||
1083 | int KAction::containerCount() const | 1086 | int KAction::containerCount() const |
1084 | { | 1087 | { |
1085 | return d->m_containers.count(); | 1088 | return d->m_containers.count(); |
1086 | } | 1089 | } |
1087 | 1090 | ||
1088 | uint KAction::kaccelCount() const | 1091 | uint KAction::kaccelCount() const |
1089 | { | 1092 | { |
1090 | return d->m_kaccelList.count(); | 1093 | return d->m_kaccelList.count(); |
1091 | } | 1094 | } |
1092 | 1095 | ||
1093 | void KAction::addContainer( QWidget* c, int id ) | 1096 | void KAction::addContainer( QWidget* c, int id ) |
1094 | { | 1097 | { |
1095 | KActionPrivate::Container p; | 1098 | KActionPrivate::Container p; |
1096 | p.m_container = c; | 1099 | p.m_container = c; |
1097 | p.m_id = id; | 1100 | p.m_id = id; |
1098 | d->m_containers.append( p ); | 1101 | d->m_containers.append( p ); |
1099 | } | 1102 | } |
1100 | 1103 | ||
1101 | void KAction::addContainer( QWidget* c, QWidget* w ) | 1104 | void KAction::addContainer( QWidget* c, QWidget* w ) |
1102 | { | 1105 | { |
1103 | KActionPrivate::Container p; | 1106 | KActionPrivate::Container p; |
1104 | p.m_container = c; | 1107 | p.m_container = c; |
1105 | p.m_representative = w; | 1108 | p.m_representative = w; |
1106 | d->m_containers.append( p ); | 1109 | d->m_containers.append( p ); |
1107 | } | 1110 | } |
1108 | 1111 | ||
1109 | void KAction::activate() | 1112 | void KAction::activate() |
1110 | { | 1113 | { |
1111 | slotActivated(); | 1114 | slotActivated(); |
1112 | } | 1115 | } |
1113 | 1116 | ||
1114 | void KAction::slotActivated() | 1117 | void KAction::slotActivated() |
1115 | { | 1118 | { |
1116 | emit activated(); | 1119 | emit activated(); |
1117 | } | 1120 | } |
1118 | 1121 | ||
1119 | void KAction::slotDestroyed() | 1122 | void KAction::slotDestroyed() |
1120 | { | 1123 | { |
1121 | 1124 | ||
1122 | const QObject* o = sender(); | 1125 | const QObject* o = sender(); |
1123 | 1126 | ||
1124 | /* | 1127 | /* |
1125 | 1128 | ||
1126 | 1129 | ||
1127 | // KDE 4: remove | 1130 | // KDE 4: remove |
1128 | if ( o == d->m_kaccel ) | 1131 | if ( o == d->m_kaccel ) |
1129 | { | 1132 | { |
1130 | d->m_kaccel = 0; | 1133 | d->m_kaccel = 0; |
1131 | return; | 1134 | return; |
1132 | } | 1135 | } |
1133 | // KDE 4: remove end | 1136 | // KDE 4: remove end |
1134 | 1137 | ||
1135 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) | 1138 | for( uint i = 0; i < d->m_kaccelList.count(); i++ ) |
1136 | { | 1139 | { |
1137 | if ( o == d->m_kaccelList[i] ) | 1140 | if ( o == d->m_kaccelList[i] ) |
1138 | { | 1141 | { |
1139 | disconnect( d->m_kaccelList[i], SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); | 1142 | disconnect( d->m_kaccelList[i], SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); |
1140 | d->m_kaccelList.remove( d->m_kaccelList.at( i ) ); | 1143 | d->m_kaccelList.remove( d->m_kaccelList.at( i ) ); |
1141 | return; | 1144 | return; |
1142 | } | 1145 | } |
1143 | } | 1146 | } |
1144 | */ | 1147 | */ |
1145 | int i; | 1148 | int i; |
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 | ||
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; |
1182 | ++i; | 1185 | ++i; |
1183 | } | 1186 | } |
1184 | } | 1187 | } |
1185 | 1188 | ||
1186 | // FIXME: Remove this (ellis) | 1189 | // FIXME: Remove this (ellis) |
1187 | void KAction::slotKeycodeChanged() | 1190 | void KAction::slotKeycodeChanged() |
1188 | { | 1191 | { |
1189 | qDebug("KAction::slotKeycodeChanged() ...44 has top be fixed"); | 1192 | qDebug("KAction::slotKeycodeChanged() ...44 has top be fixed"); |
1190 | /*US | 1193 | /*US |
1191 | kdDebug(129) << "KAction::slotKeycodeChanged()" << endl; // -- ellis | 1194 | kdDebug(129) << "KAction::slotKeycodeChanged()" << endl; // -- ellis |
1192 | KAccelAction* pAction = d->m_kaccel->actions().actionPtr(name()); | 1195 | KAccelAction* pAction = d->m_kaccel->actions().actionPtr(name()); |
1193 | if( pAction ) | 1196 | if( pAction ) |
1194 | setShortcut(pAction->shortcut()); | 1197 | setShortcut(pAction->shortcut()); |
1195 | */ | 1198 | */ |
1196 | } | 1199 | } |
1197 | 1200 | ||
1198 | KActionCollection *KAction::parentCollection() const | 1201 | KActionCollection *KAction::parentCollection() const |
1199 | { | 1202 | { |
1200 | return m_parentCollection; | 1203 | return m_parentCollection; |
1201 | } | 1204 | } |
1202 | 1205 | ||
1203 | void KAction::unplugAll() | 1206 | void KAction::unplugAll() |
1204 | { | 1207 | { |
1205 | while ( containerCount() != 0 ) | 1208 | while ( containerCount() != 0 ) |
1206 | unplug( container( 0 ) ); | 1209 | unplug( container( 0 ) ); |
1207 | } | 1210 | } |
1208 | 1211 | ||
1209 | void KAction::virtual_hook( int, void* ) | 1212 | void KAction::virtual_hook( int, void* ) |
1210 | { /*BASE::virtual_hook( id, data );*/ } | 1213 | { /*BASE::virtual_hook( id, data );*/ } |
1211 | 1214 | ||
1212 | /* vim: et sw=2 ts=2 | 1215 | /* vim: et sw=2 ts=2 |
1213 | */ | 1216 | */ |
1214 | 1217 | ||
1215 | //US #include "kaction.moc" | 1218 | //US #include "kaction.moc" |