summaryrefslogtreecommitdiffabout
path: root/microkde
Unidiff
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdeui/kaction.cpp44
1 files changed, 22 insertions, 22 deletions
diff --git a/microkde/kdeui/kaction.cpp b/microkde/kdeui/kaction.cpp
index 77d36a5..d38a6d5 100644
--- a/microkde/kdeui/kaction.cpp
+++ b/microkde/kdeui/kaction.cpp
@@ -119,193 +119,192 @@ KAction::KAction( const QString& text, const KShortcut& cut,
119: QObject( parent, name ) 119: QObject( parent, name )
120{ 120{
121 initPrivate( text, cut, receiver, slot ); 121 initPrivate( text, cut, receiver, slot );
122} 122}
123 123
124KAction::KAction( const QString& text, const QString& sIconName, const KShortcut& cut, 124KAction::KAction( const QString& text, const QString& sIconName, const KShortcut& cut,
125 const QObject* receiver, const char* slot, 125 const QObject* receiver, const char* slot,
126 KActionCollection* parent, const char* name ) 126 KActionCollection* parent, const char* name )
127: QObject( parent, name ) 127: QObject( parent, name )
128{ 128{
129 initPrivate( text, cut, receiver, slot ); 129 initPrivate( text, cut, receiver, slot );
130 d->setIconName( sIconName ); 130 d->setIconName( sIconName );
131} 131}
132 132
133KAction::KAction( const QString& text, const QIconSet& pix, const KShortcut& cut, 133KAction::KAction( const QString& text, const QIconSet& pix, const KShortcut& cut,
134 const QObject* receiver, const char* slot, 134 const QObject* receiver, const char* slot,
135 KActionCollection* parent, const char* name ) 135 KActionCollection* parent, const char* name )
136: QObject( parent, name ) 136: QObject( parent, name )
137{ 137{
138 initPrivate( text, cut, receiver, slot ); 138 initPrivate( text, cut, receiver, slot );
139 d->setIconSet( pix ); 139 d->setIconSet( pix );
140} 140}
141KAction::KAction( const KGuiItem& item, const KShortcut& cut, 141KAction::KAction( const KGuiItem& item, const KShortcut& cut,
142 const QObject* receiver, const char* slot, 142 const QObject* receiver, const char* slot,
143 KActionCollection* parent, const char* name ) 143 KActionCollection* parent, const char* name )
144: QObject( parent, name ) 144: QObject( parent, name )
145{ 145{
146 initPrivate( item.text(), cut, receiver, slot ); 146 initPrivate( item.text(), cut, receiver, slot );
147 if( item.hasIconSet() ) 147 if( item.hasIconSet() )
148 setIcon( item.iconName() ); 148 setIcon( item.iconName() );
149 setToolTip( item.toolTip() ); 149 setToolTip( item.toolTip() );
150 setWhatsThis( item.whatsThis() ); 150 setWhatsThis( item.whatsThis() );
151} 151}
152 152
153// KDE 4: remove 153// KDE 4: remove
154KAction::KAction( const QString& text, const KShortcut& cut, 154KAction::KAction( const QString& text, const KShortcut& cut,
155 QObject* parent, const char* name ) 155 QObject* parent, const char* name )
156 : QObject( parent, name ) 156 : QObject( parent, name )
157{ 157{
158 initPrivate( text, cut, 0, 0 ); 158 initPrivate( text, cut, 0, 0 );
159} 159}
160KAction::KAction( const QString& text, const KShortcut& cut, 160KAction::KAction( const QString& text, const KShortcut& cut,
161 const QObject* receiver, 161 const QObject* receiver,
162 const char* slot, QObject* parent, const char* name ) 162 const char* slot, QObject* parent, const char* name )
163 : QObject( parent, name ) 163 : QObject( parent, name )
164{ 164{
165 initPrivate( text, cut, receiver, slot ); 165 initPrivate( text, cut, receiver, slot );
166} 166}
167KAction::KAction( const QString& text, const QIconSet& pix, 167KAction::KAction( const QString& text, const QIconSet& pix,
168 const KShortcut& cut, 168 const KShortcut& cut,
169 QObject* parent, const char* name ) 169 QObject* parent, const char* name )
170 : QObject( parent, name ) 170 : QObject( parent, name )
171{ 171{
172 initPrivate( text, cut, 0, 0 ); 172 initPrivate( text, cut, 0, 0 );
173 setIconSet( pix ); 173 setIconSet( pix );
174} 174}
175 175
176KAction::KAction( const QString& text, const QString& pix, 176KAction::KAction( const QString& text, const QString& pix,
177 const KShortcut& cut, 177 const KShortcut& cut,
178 QObject* parent, const char* name ) 178 QObject* parent, const char* name )
179: QObject( parent, name ) 179: QObject( parent, name )
180{ 180{
181 initPrivate( text, cut, 0, 0 ); 181 initPrivate( text, cut, 0, 0 );
182 d->setIconName( pix ); 182 d->setIconName( pix );
183} 183}
184 184
185KAction::KAction( const QString& text, const QIconSet& pix, 185KAction::KAction( const QString& text, const QIconSet& pix,
186 const KShortcut& cut, 186 const KShortcut& cut,
187 const QObject* receiver, const char* slot, QObject* parent, 187 const QObject* receiver, const char* slot, QObject* parent,
188 const char* name ) 188 const char* name )
189 : QObject( parent, name ) 189 : QObject( parent, name )
190{ 190{
191 initPrivate( text, cut, receiver, slot ); 191 initPrivate( text, cut, receiver, slot );
192 setIconSet( pix ); 192 setIconSet( pix );
193} 193}
194 194
195KAction::KAction( const QString& text, const QString& pix, 195KAction::KAction( const QString& text, const QString& pix,
196 const KShortcut& cut, 196 const KShortcut& cut,
197 const QObject* receiver, const char* slot, QObject* parent, 197 const QObject* receiver, const char* slot, QObject* parent,
198 const char* name ) 198 const char* name )
199 : QObject( parent, name ) 199 : QObject( parent, name )
200{ 200{
201 initPrivate( text, cut, receiver, slot ); 201 initPrivate( text, cut, receiver, slot );
202 d->setIconName(pix); 202 d->setIconName(pix);
203} 203}
204 204
205KAction::KAction( QObject* parent, const char* name ) 205KAction::KAction( QObject* parent, const char* name )
206 : QObject( parent, name ) 206 : QObject( parent, name )
207{ 207{
208 208
209 initPrivate( QString::null, KShortcut(), 0, 0 ); 209 initPrivate( QString::null, KShortcut(), 0, 0 );
210} 210}
211// KDE 4: remove end 211// KDE 4: remove end
212 212
213KAction::~KAction() 213KAction::~KAction()
214{ 214{
215 kdDebug(129) << "KAction::~KAction( this = \"" << name() << "\" )" << endl; // -- ellis
216#ifndef KDE_NO_COMPAT 215#ifndef KDE_NO_COMPAT
217 if (d->m_kaccel) 216 if (d->m_kaccel)
218 unplugAccel(); 217 unplugAccel();
219#endif 218#endif
220 219
221 // If actionCollection hasn't already been destructed, 220 // If actionCollection hasn't already been destructed,
222 if ( m_parentCollection ) { 221 if ( m_parentCollection ) {
223 m_parentCollection->take( this ); 222 m_parentCollection->take( this );
224 for( uint i = 0; i < d->m_kaccelList.count(); i++ ) 223 for( uint i = 0; i < d->m_kaccelList.count(); i++ )
225//US d->m_kaccelList[i]->remove( name() ); 224//US d->m_kaccelList[i]->remove( name() );
226 qDebug("KAction::KAction~ ...1 has top be fixed"); 225 qDebug("KAction::KAction~ ...1 has top be fixed");
227 } 226 }
228 227
229 // Do not call unplugAll from here, as tempting as it sounds. 228 // Do not call unplugAll from here, as tempting as it sounds.
230 // KAction is designed around the idea that you need to plug 229 // KAction is designed around the idea that you need to plug
231 // _and_ to unplug it "manually". Unplugging leads to an important 230 // _and_ to unplug it "manually". Unplugging leads to an important
232 // slowdown when e.g. closing the window, in which case we simply 231 // slowdown when e.g. closing the window, in which case we simply
233 // want to destroy everything asap, not to remove actions one by one 232 // want to destroy everything asap, not to remove actions one by one
234 // from the GUI. 233 // from the GUI.
235 234
236 delete d; d = 0; 235 delete d; d = 0;
237} 236}
238 237
239void KAction::initPrivate( const QString& text, const KShortcut& cut, 238void KAction::initPrivate( const QString& text, const KShortcut& cut,
240 const QObject* receiver, const char* slot ) 239 const QObject* receiver, const char* slot )
241{ 240{
242 d = new KActionPrivate; 241 d = new KActionPrivate;
243 242
244 d->m_cutDefault = cut; 243 d->m_cutDefault = cut;
245 244
246//US m_parentCollection = dynamic_cast<KActionCollection *>( parent() ); 245//US m_parentCollection = dynamic_cast<KActionCollection *>( parent() );
247 m_parentCollection = (KActionCollection *)( parent() ); 246 m_parentCollection = (KActionCollection *)( parent() );
248 kdDebug(129) << "KAction::initPrivate(): this = " << this << " name = \"" << name() << "\" cut = " << cut.toStringInternal() << " m_parentCollection = " << m_parentCollection << endl; 247 kdDebug(129) << "KAction::initPrivate(): this = " << this << " name = \"" << name() << "\" cut = " << cut.toStringInternal() << " m_parentCollection = " << m_parentCollection << endl;
249 if ( m_parentCollection ) 248 if ( m_parentCollection )
250 m_parentCollection->insert( this ); 249 m_parentCollection->insert( this );
251 250
252 if ( receiver && slot ) 251 if ( receiver && slot )
253 connect( this, SIGNAL( activated() ), receiver, slot ); 252 connect( this, SIGNAL( activated() ), receiver, slot );
254 253
255 if( !cut.isNull() && qstrcmp( name(), "unnamed" ) == 0 ) 254 if( !cut.isNull() && qstrcmp( name(), "unnamed" ) == 0 )
256 kdWarning(129) << "KAction::initPrivate(): trying to assign a shortcut (" << cut.toStringInternal() << ") to an unnamed action." << endl; 255 kdWarning(129) << "KAction::initPrivate(): trying to assign a shortcut (" << cut.toStringInternal() << ") to an unnamed action." << endl;
257 d->setText( text ); 256 d->setText( text );
258 initShortcut( cut ); 257 initShortcut( cut );
259 258
260} 259}
261 260
262bool KAction::isPlugged() const 261bool KAction::isPlugged() const
263{ 262{
264 return (containerCount() > 0) || d->m_kaccel; 263 return (containerCount() > 0) || d->m_kaccel;
265} 264}
266 265
267bool KAction::isPlugged( const QWidget *container ) const 266bool KAction::isPlugged( const QWidget *container ) const
268{ 267{
269 return findContainer( container ) > -1; 268 return findContainer( container ) > -1;
270} 269}
271 270
272bool KAction::isPlugged( const QWidget *container, int id ) const 271bool KAction::isPlugged( const QWidget *container, int id ) const
273{ 272{
274 int i = findContainer( container ); 273 int i = findContainer( container );
275 return ( i > -1 && itemId( i ) == id ); 274 return ( i > -1 && itemId( i ) == id );
276} 275}
277 276
278bool KAction::isPlugged( const QWidget *container, const QWidget *_representative ) const 277bool KAction::isPlugged( const QWidget *container, const QWidget *_representative ) const
279{ 278{
280 int i = findContainer( container ); 279 int i = findContainer( container );
281 return ( i > -1 && representative( i ) == _representative ); 280 return ( i > -1 && representative( i ) == _representative );
282} 281}
283 282
284 283
285/* 284/*
286Three actionCollection conditions: 285Three actionCollection conditions:
287 1) Scope is known on creation and KAccel object is created (e.g. KMainWindow) 286 1) Scope is known on creation and KAccel object is created (e.g. KMainWindow)
288 2) Scope is unknown and no KAccel object is available (e.g. KXMLGUIClient) 287 2) Scope is unknown and no KAccel object is available (e.g. KXMLGUIClient)
289 a) addClient() will be called on object 288 a) addClient() will be called on object
290 b) we just want to add the actions to another KXMLGUIClient object 289 b) we just want to add the actions to another KXMLGUIClient object
291 290
292The question is how to do we incorporate #2b into the XMLGUI framework? 291The question is how to do we incorporate #2b into the XMLGUI framework?
293 292
294 293
295We have a KCommandHistory object with undo and redo actions in a passed actionCollection 294We have a KCommandHistory object with undo and redo actions in a passed actionCollection
296We have a KoDoc object which holds a KCommandHistory object and the actionCollection 295We have a KoDoc object which holds a KCommandHistory object and the actionCollection
297We have two KoView objects which both point to the same KoDoc object 296We have two KoView objects which both point to the same KoDoc object
298Undo and Redo should be available in both KoView objects, and 297Undo and Redo should be available in both KoView objects, and
299 calling the undo->setEnabled() should affect both KoViews 298 calling the undo->setEnabled() should affect both KoViews
300 299
301When addClient is called, it needs to be able to find the undo and redo actions 300When addClient is called, it needs to be able to find the undo and redo actions
302When it calls plug() on them, they need to be inserted into the KAccel object of the appropriate KoView 301When it calls plug() on them, they need to be inserted into the KAccel object of the appropriate KoView
303 302
304In this case, the actionCollection belongs to KoDoc and we need to let it know that its shortcuts 303In this case, the actionCollection belongs to KoDoc and we need to let it know that its shortcuts
305have the same scope as the KoView actionCollection 304have the same scope as the KoView actionCollection
306 305
307KXMLGUIClient::addSubActionCollection 306KXMLGUIClient::addSubActionCollection
308 307
309Document: 308Document:
310 create document actions 309 create document actions
311 310
@@ -342,673 +341,674 @@ shortcut may be set:
342 341
343On Construction: [via initShortcut()] 342On Construction: [via initShortcut()]
344 insert into KAccel of m_parentCollection, 343 insert into KAccel of m_parentCollection,
345 if kaccel() && isAutoConnectShortcuts() exists 344 if kaccel() && isAutoConnectShortcuts() exists
346 345
347On Plug: [via plug() -> plugShortcut()] 346On Plug: [via plug() -> plugShortcut()]
348 insert into KAccel of m_parentCollection, if exists and not already inserted into 347 insert into KAccel of m_parentCollection, if exists and not already inserted into
349 348
350On Read XML: [via setShortcut()] 349On Read XML: [via setShortcut()]
351 set in all current KAccels 350 set in all current KAccels
352 insert into KAccel of m_parentCollection, if exists and not already inserted into 351 insert into KAccel of m_parentCollection, if exists and not already inserted into
353*/ 352*/
354 353
355KAccel* KAction::kaccelCurrent() 354KAccel* KAction::kaccelCurrent()
356{ 355{
357 if( m_parentCollection && m_parentCollection->builderKAccel() ) 356 if( m_parentCollection && m_parentCollection->builderKAccel() )
358 return m_parentCollection->builderKAccel(); 357 return m_parentCollection->builderKAccel();
359 else if( m_parentCollection && m_parentCollection->kaccel() ) 358 else if( m_parentCollection && m_parentCollection->kaccel() )
360 return m_parentCollection->kaccel(); 359 return m_parentCollection->kaccel();
361 else 360 else
362 return 0L; 361 return 0L;
363} 362}
364 363
365// Only to be called from initPrivate() 364// Only to be called from initPrivate()
366bool KAction::initShortcut( const KShortcut& cut ) 365bool KAction::initShortcut( const KShortcut& cut )
367{ 366{
368 d->m_cut = cut; 367 d->m_cut = cut;
369 368
370 // Only insert action into KAccel if it has a valid name, 369 // Only insert action into KAccel if it has a valid name,
371 if( qstrcmp( name(), "unnamed" ) != 0 && 370 if( qstrcmp( name(), "unnamed" ) != 0 &&
372 m_parentCollection && 371 m_parentCollection &&
373 m_parentCollection->isAutoConnectShortcuts() && 372 m_parentCollection->isAutoConnectShortcuts() &&
374 m_parentCollection->kaccel() ) 373 m_parentCollection->kaccel() )
375 { 374 {
376 insertKAccel( m_parentCollection->kaccel() ); 375 insertKAccel( m_parentCollection->kaccel() );
377 return true; 376 return true;
378 } 377 }
379 return false; 378 return false;
380 } 379 }
381 380
382// Only to be called from plug() 381// Only to be called from plug()
383void KAction::plugShortcut() 382void KAction::plugShortcut()
384{ 383{
385 KAccel* kaccel = kaccelCurrent(); 384 KAccel* kaccel = kaccelCurrent();
386 385
387 //kdDebug(129) << "KAction::plugShortcut(): this = " << this << " kaccel() = " << (m_parentCollection ? m_parentCollection->kaccel() : 0) << endl; 386 //kdDebug(129) << "KAction::plugShortcut(): this = " << this << " kaccel() = " << (m_parentCollection ? m_parentCollection->kaccel() : 0) << endl;
388 if( kaccel && qstrcmp( name(), "unnamed" ) != 0 ) { 387 if( kaccel && qstrcmp( name(), "unnamed" ) != 0 ) {
389 // Check if already plugged into current KAccel object 388 // Check if already plugged into current KAccel object
390 for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { 389 for( uint i = 0; i < d->m_kaccelList.count(); i++ ) {
391 if( d->m_kaccelList[i] == kaccel ) 390 if( d->m_kaccelList[i] == kaccel )
392 return; 391 return;
393 } 392 }
394 393
395 insertKAccel( kaccel ); 394 insertKAccel( kaccel );
396 } 395 }
397} 396}
398 397
399bool KAction::setShortcut( const KShortcut& cut ) 398bool KAction::setShortcut( const KShortcut& cut )
400{ 399{
401 qDebug("KAction::setShortcut~ ...1 has top be fixed"); 400 qDebug("KAction::setShortcut~ ...1 has top be fixed");
402/*US 401/*US
403 bool bChanged = (d->m_cut != cut); 402 bool bChanged = (d->m_cut != cut);
404 d->m_cut = cut; 403 d->m_cut = cut;
405 404
406 KAccel* kaccel = kaccelCurrent(); 405 KAccel* kaccel = kaccelCurrent();
407 bool bInsertRequired = true; 406 bool bInsertRequired = true;
408 // Apply new shortcut to all existing KAccel objects 407 // Apply new shortcut to all existing KAccel objects
409 for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { 408 for( uint i = 0; i < d->m_kaccelList.count(); i++ ) {
410 // Check whether shortcut has already been plugged into 409 // Check whether shortcut has already been plugged into
411 // the current kaccel object. 410 // the current kaccel object.
412 if( d->m_kaccelList[i] == kaccel ) 411 if( d->m_kaccelList[i] == kaccel )
413 bInsertRequired = false; 412 bInsertRequired = false;
414 if( bChanged ) 413 if( bChanged )
415 updateKAccelShortcut( d->m_kaccelList[i] ); 414 updateKAccelShortcut( d->m_kaccelList[i] );
416 } 415 }
417 416
418 // Only insert action into KAccel if it has a valid name, 417 // Only insert action into KAccel if it has a valid name,
419 if( kaccel && bInsertRequired && qstrcmp( name(), "unnamed" ) ) 418 if( kaccel && bInsertRequired && qstrcmp( name(), "unnamed" ) )
420 insertKAccel( kaccel ); 419 insertKAccel( kaccel );
421 420
422 if( bChanged ) { 421 if( bChanged ) {
423 // KDE 4: remove 422 // KDE 4: remove
424 if ( d->m_kaccel ) 423 if ( d->m_kaccel )
425 d->m_kaccel->setShortcut( name(), cut ); 424 d->m_kaccel->setShortcut( name(), cut );
426 // KDE 4: remove end 425 // KDE 4: remove end
427 int len = containerCount(); 426 int len = containerCount();
428 for( int i = 0; i < len; ++i ) 427 for( int i = 0; i < len; ++i )
429 updateShortcut( i ); 428 updateShortcut( i );
430 } 429 }
431*/ 430*/
432 431
433 return true; 432 return true;
434} 433}
435 434
436bool KAction::updateKAccelShortcut( KAccel* kaccel ) 435bool KAction::updateKAccelShortcut( KAccel* kaccel )
437{ 436{
438 qDebug("KAction::updateKAccelShortcut~ ...1 has top be fixed"); 437 //qDebug("KAction::updateKAccelShortcut~ ...1 has top be fixed");
438
439 // Check if action is permitted 439 // Check if action is permitted
440/*US 440/*US
441 if (kapp && !kapp->authorizeKAction(name())) 441 if (kapp && !kapp->authorizeKAction(name()))
442 return false; 442 return false;
443 443
444 bool b = true; 444 bool b = true;
445 445
446 if ( !kaccel->actions().actionPtr( name() ) ) { 446 if ( !kaccel->actions().actionPtr( name() ) ) {
447 if(!d->m_cut.isNull() ) { 447 if(!d->m_cut.isNull() ) {
448 kdDebug(129) << "Inserting " << name() << ", " << d->text() << ", " << d->plainText() << endl; 448 kdDebug(129) << "Inserting " << name() << ", " << d->text() << ", " << d->plainText() << endl;
449 b = kaccel->insert( name(), d->plainText(), QString::null, 449 b = kaccel->insert( name(), d->plainText(), QString::null,
450 d->m_cut, 450 d->m_cut,
451 this, SLOT(slotActivated()), 451 this, SLOT(slotActivated()),
452 isShortcutConfigurable(), isEnabled() ); 452 isShortcutConfigurable(), isEnabled() );
453 } 453 }
454 } 454 }
455 else 455 else
456 b = kaccel->setShortcut( name(), d->m_cut ); 456 b = kaccel->setShortcut( name(), d->m_cut );
457 457
458 return b; 458 return b;
459*/ 459*/
460 return true; 460 return true;
461} 461}
462 462
463void KAction::insertKAccel( KAccel* kaccel ) 463void KAction::insertKAccel( KAccel* kaccel )
464{ 464{
465 qDebug("KAction::updateKAccelShortcut~ ...1 has top be fixed"); 465 //qDebug("KAction::updateKAccelShortcut~ ...1 has top be fixed");
466
466/*US 467/*US
467 //kdDebug(129) << "KAction::insertKAccel( " << kaccel << " ): this = " << this << endl; 468 //kdDebug(129) << "KAction::insertKAccel( " << kaccel << " ): this = " << this << endl;
468 if ( !kaccel->actions().actionPtr( name() ) ) { 469 if ( !kaccel->actions().actionPtr( name() ) ) {
469 if( updateKAccelShortcut( kaccel ) ) { 470 if( updateKAccelShortcut( kaccel ) ) {
470 d->m_kaccelList.append( kaccel ); 471 d->m_kaccelList.append( kaccel );
471 connect( kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); 472 connect( kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) );
472 } 473 }
473 } 474 }
474 else 475 else
475 kdWarning(129) << "KAction::insertKAccel( kaccel = " << kaccel << " ): KAccel object already contains an action name \"" << name() << "\"" << endl; // -- ellis 476 kdWarning(129) << "KAction::insertKAccel( kaccel = " << kaccel << " ): KAccel object already contains an action name \"" << name() << "\"" << endl; // -- ellis
476*/ 477*/
477} 478}
478 479
479void KAction::removeKAccel( KAccel* kaccel ) 480void KAction::removeKAccel( KAccel* kaccel )
480{ 481{
481 qDebug("KAction::removeKAccel~ ...1 has top be fixed"); 482 // qDebug("KAction::removeKAccel~ ...1 has top be fixed");
483
482/*US 484/*US
483 //kdDebug(129) << "KAction::removeKAccel( " << i << " ): this = " << this << endl; 485 //kdDebug(129) << "KAction::removeKAccel( " << i << " ): this = " << this << endl;
484 for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { 486 for( uint i = 0; i < d->m_kaccelList.count(); i++ ) {
485 if( d->m_kaccelList[i] == kaccel ) { 487 if( d->m_kaccelList[i] == kaccel ) {
486 kaccel->remove( name() ); 488 kaccel->remove( name() );
487 d->m_kaccelList.remove( d->m_kaccelList.at( i ) ); 489 d->m_kaccelList.remove( d->m_kaccelList.at( i ) );
488 disconnect( kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); 490 disconnect( kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) );
489 break; 491 break;
490 } 492 }
491 } 493 }
492*/ 494*/
493} 495}
494 496
495// KDE 4: remove 497// KDE 4: remove
496void KAction::setAccel( int keyQt ) 498void KAction::setAccel( int keyQt )
497{ 499{
498 setShortcut( KShortcut(keyQt) ); 500 setShortcut( KShortcut(keyQt) );
499} 501}
500// KDE 4: remove end 502// KDE 4: remove end
501 503
502void KAction::updateShortcut( int i ) 504void KAction::updateShortcut( int i )
503{ 505{
504 int id = itemId( i ); 506 int id = itemId( i );
505 507
506 QWidget* w = container( i ); 508 QWidget* w = container( i );
507 if ( w->inherits( "QPopupMenu" ) ) { 509 if ( w->inherits( "QPopupMenu" ) ) {
508 QPopupMenu* menu = static_cast<QPopupMenu*>(w); 510 QPopupMenu* menu = static_cast<QPopupMenu*>(w);
509 updateShortcut( menu, id ); 511 updateShortcut( menu, id );
510 } 512 }
511 else if ( w->inherits( "QMenuBar" ) ) 513 else if ( w->inherits( "QMenuBar" ) )
512//US static_cast<QMenuBar*>(w)->setAccel( d->m_cut.keyCodeQt(), id ); 514//US static_cast<QMenuBar*>(w)->setAccel( d->m_cut.keyCodeQt(), id );
513//US (QMenuBar*)(w)->setAccel( d->m_cut.keyCodeQt(), id ); 515//US (QMenuBar*)(w)->setAccel( d->m_cut.keyCodeQt(), id );
514 qDebug("KAction::updateShortcut( int i ) ...1 has top be fixed"); 516
517 ; //qDebug("KAction::updateShortcut( int i ) ...1 has top be fixed");
515 518
516} 519}
517 520
518void KAction::updateShortcut( QPopupMenu* menu, int id ) 521void KAction::updateShortcut( QPopupMenu* menu, int id )
519{ 522{
520/*US 523/*US
521 //kdDebug(129) << "KAction::updateShortcut(): this = " << this << " d->m_kaccelList.count() = " << d->m_kaccelList.count() << endl; 524 //kdDebug(129) << "KAction::updateShortcut(): this = " << this << " d->m_kaccelList.count() = " << d->m_kaccelList.count() << endl;
522 // If the action has a KAccel object, 525 // If the action has a KAccel object,
523 // show the string representation of its shortcut. 526 // show the string representation of its shortcut.
524 if ( d->m_kaccel || d->m_kaccelList.count() ) { 527 if ( d->m_kaccel || d->m_kaccelList.count() ) {
525 QString s = menu->text( id ); 528 QString s = menu->text( id );
526 int i = s.find( '\t' ); 529 int i = s.find( '\t' );
527 if ( i >= 0 ) 530 if ( i >= 0 )
528 s.replace( i+1, s.length()-i, d->m_cut.seq(0).toString() ); 531 s.replace( i+1, s.length()-i, d->m_cut.seq(0).toString() );
529 else 532 else
530 s += "\t" + d->m_cut.seq(0).toString(); 533 s += "\t" + d->m_cut.seq(0).toString();
531 534
532 menu->changeItem( id, s ); 535 menu->changeItem( id, s );
533 } 536 }
534 // Otherwise insert the shortcut itself into the popup menu. 537 // Otherwise insert the shortcut itself into the popup menu.
535 else { 538 else {
536 // This is a fall-hack in case the KAction is missing a proper parent collection. 539 // This is a fall-hack in case the KAction is missing a proper parent collection.
537 // It should be removed eventually. --ellis 540 // It should be removed eventually. --ellis
538 menu->setAccel( d->m_cut.keyCodeQt(), id ); 541 menu->setAccel( d->m_cut.keyCodeQt(), id );
539 kdWarning(129) << "KAction::updateShortcut(): name = \"" << name() << "\", cut = " << d->m_cut.toStringInternal() << "; No KAccel, probably missing a parent collection." << endl; 542 kdWarning(129) << "KAction::updateShortcut(): name = \"" << name() << "\", cut = " << d->m_cut.toStringInternal() << "; No KAccel, probably missing a parent collection." << endl;
540 } 543 }
541*/ 544*/
542 qDebug("KAction::updateShortcut( QPopupMenu* menu, int id ) ...1 has top be fixed"); 545
546
547//qDebug("KAction::updateShortcut( QPopupMenu* menu, int id ) ...1 has top be fixed");
543 548
544} 549}
545 550
546const KShortcut& KAction::shortcut() const 551const KShortcut& KAction::shortcut() const
547{ 552{
548 return d->m_cut; 553 return d->m_cut;
549} 554}
550 555
551const KShortcut& KAction::shortcutDefault() const 556const KShortcut& KAction::shortcutDefault() const
552{ 557{
553 return d->m_cutDefault; 558 return d->m_cutDefault;
554} 559}
555 560
556QString KAction::shortcutText() const 561QString KAction::shortcutText() const
557{ 562{
558 return d->m_cut.toStringInternal(); 563 return d->m_cut.toStringInternal();
559} 564}
560 565
561void KAction::setShortcutText( const QString& s ) 566void KAction::setShortcutText( const QString& s )
562{ 567{
563 setShortcut( KShortcut(s) ); 568 setShortcut( KShortcut(s) );
564} 569}
565 570
566int KAction::accel() const 571int KAction::accel() const
567{ 572{
568 qDebug("KAction::accel() ...1 has top be fixed"); 573 // qDebug("KAction::accel() ...1 has top be fixed");
569//US return d->m_cut.keyCodeQt(); 574//US return d->m_cut.keyCodeQt();
570 return 0; 575 return 0;
571} 576}
572 577
573void KAction::setGroup( const QString& grp ) 578void KAction::setGroup( const QString& grp )
574{ 579{
575 d->m_group = grp; 580 d->m_group = grp;
576 581
577 int len = containerCount(); 582 int len = containerCount();
578 for( int i = 0; i < len; ++i ) 583 for( int i = 0; i < len; ++i )
579 updateGroup( i ); 584 updateGroup( i );
580} 585}
581 586
582void KAction::updateGroup( int ) 587void KAction::updateGroup( int )
583{ 588{
584 // DO SOMETHING 589 // DO SOMETHING
585} 590}
586 591
587QString KAction::group() const 592QString KAction::group() const
588{ 593{
589 return d->m_group; 594 return d->m_group;
590} 595}
591 596
592bool KAction::isEnabled() const 597bool KAction::isEnabled() const
593{ 598{
594 return d->isEnabled(); 599 return d->isEnabled();
595} 600}
596 601
597bool KAction::isShortcutConfigurable() const 602bool KAction::isShortcutConfigurable() const
598{ 603{
599 return d->m_configurable; 604 return d->m_configurable;
600} 605}
601 606
602void KAction::setToolTip( const QString& tt ) 607void KAction::setToolTip( const QString& tt )
603{ 608{
604 qDebug("KAction::setToolTip ...1 has top be fixed"); 609 //qDebug("KAction::setToolTip ...1 has top be fixed");
605 d->setToolTip( tt ); 610 d->setToolTip( tt );
606 611
607 int len = containerCount(); 612 int len = containerCount();
608 for( int i = 0; i < len; ++i ) 613 for( int i = 0; i < len; ++i )
609 updateToolTip( i ); 614 updateToolTip( i );
610} 615}
611 616
612void KAction::updateToolTip( int i ) 617void KAction::updateToolTip( int i )
613{ 618{
614 qDebug("KAction::updateToolTip ...1 has top be fixed"); 619 //qDebug("KAction::updateToolTip ...1 has top be fixed");
615 QWidget *w = container( i ); 620 QWidget *w = container( i );
616 621
617 if ( w->inherits( "KToolBar" ) ) 622 if ( w->inherits( "KToolBar" ) )
618 QToolTip::add( static_cast<KToolBar*>(w)->getWidget( itemId( i ) ), d->toolTip() ); 623 QToolTip::add( static_cast<KToolBar*>(w)->getWidget( itemId( i ) ), d->toolTip() );
619 else if ( w->inherits( "QToolBar" ) ) 624 else if ( w->inherits( "QToolBar" ) )
620 QToolTip::add( static_cast<KToolBar*>(w)->getWidget( itemId( i ) ), d->toolTip() ); 625 QToolTip::add( static_cast<KToolBar*>(w)->getWidget( itemId( i ) ), d->toolTip() );
621} 626}
622 627
623QString KAction::toolTip() const 628QString KAction::toolTip() const
624{ 629{
625 return d->toolTip(); 630 return d->toolTip();
626} 631}
627 632
628int KAction::plug( QWidget *w, int index ) 633int KAction::plug( QWidget *w, int index )
629{ 634{
630 //kdDebug(129) << "KAction::plug( " << w << ", " << index << " )" << endl; 635 //kdDebug(129) << "KAction::plug( " << w << ", " << index << " )" << endl;
631 if (w == 0) { 636 if (w == 0) {
632 kdWarning(129) << "KAction::plug called with 0 argument\n"; 637 kdWarning(129) << "KAction::plug called with 0 argument\n";
633 return -1; 638 return -1;
634 } 639 }
635 640
636#ifndef NDEBUG 641
637 KAccel* kaccel = kaccelCurrent();
638 // If there is a shortcut, but no KAccel available
639 if( !d->m_cut.isNull() && kaccel == 0 ) {
640 kdWarning(129) << "KAction::plug(): has no KAccel object; this = " << this << " name = " << name() << " parentCollection = " << m_parentCollection << endl; // ellis
641//US kdDebug(129) << kdBacktrace() << endl;
642 }
643#endif
644 642
645 // Check if action is permitted 643 // Check if action is permitted
646//US if (kapp && !kapp->authorizeKAction(name())) 644//US if (kapp && !kapp->authorizeKAction(name()))
647//US return -1; 645//US return -1;
648 646
649 plugShortcut(); 647 plugShortcut();
650 648
651 if ( w->inherits("QPopupMenu") ) 649 if ( w->inherits("QPopupMenu") )
652 { 650 {
653 QPopupMenu* menu = static_cast<QPopupMenu*>( w ); 651 QPopupMenu* menu = static_cast<QPopupMenu*>( w );
654 int id; 652 int id;
655 // Don't insert shortcut into menu if it's already in a KAccel object. 653 // Don't insert shortcut into menu if it's already in a KAccel object.
656 //qDebug("KAction::plug warning: real shortcuts not available yet. "); 654 //qDebug("KAction::plug warning: real shortcuts not available yet. ");
657//US int keyQt = (d->m_kaccelList.count() || d->m_kaccel) ? 0 : d->m_cut.keyCodeQt(); 655//US int keyQt = (d->m_kaccelList.count() || d->m_kaccel) ? 0 : d->m_cut.keyCodeQt();
658 int keyQt = 0; 656 int keyQt = 0;
659 657
660 if ( d->hasIcon() ) 658 if ( d->hasIcon() )
661 { 659 {
662/*US 660/*US
663 KInstance *instance; 661 KInstance *instance;
664 if ( m_parentCollection ) 662 if ( m_parentCollection )
665 instance = m_parentCollection->instance(); 663 instance = m_parentCollection->instance();
666 else 664 else
667 instance = KGlobal::instance(); 665 instance = KGlobal::instance();
668*/ 666*/
669 id = menu->insertItem( d->iconSet( KIcon::Small, 0/*US , instance */), d->text(), this,//dsweet 667 id = menu->insertItem( d->iconSet( KIcon::Small, 0/*US , instance */), d->text(), this,//dsweet
670 SLOT( slotActivated() ), keyQt, 668 SLOT( slotActivated() ), keyQt,
671 -1, index ); 669 -1, index );
672 } 670 }
673 else 671 else
674 id = menu->insertItem( d->text(), this, 672 id = menu->insertItem( d->text(), this,
675 SLOT( slotActivated() ), //dsweet 673 SLOT( slotActivated() ), //dsweet
676 keyQt, -1, index ); 674 keyQt, -1, index );
677 675
678 // If the shortcut is already in a KAccel object, then 676 // If the shortcut is already in a KAccel object, then
679 // we need to set the menu item's shortcut text. 677 // we need to set the menu item's shortcut text.
680/*US if ( d->m_kaccelList.count() || d->m_kaccel ) 678/*US if ( d->m_kaccelList.count() || d->m_kaccel )
681 updateShortcut( menu, id ); 679 updateShortcut( menu, id );
682*/ 680*/
683 // call setItemEnabled only if the item really should be disabled, 681 // call setItemEnabled only if the item really should be disabled,
684 // because that method is slow and the item is per default enabled 682 // because that method is slow and the item is per default enabled
685 if ( !d->isEnabled() ) 683 if ( !d->isEnabled() )
686 menu->setItemEnabled( id, false ); 684 menu->setItemEnabled( id, false );
687 685
688 if ( !d->whatsThis().isEmpty() ) 686 if ( !d->whatsThis().isEmpty() )
689 menu->setWhatsThis( id, whatsThisWithIcon() ); 687 menu->setWhatsThis( id, whatsThisWithIcon() );
690 688
691 addContainer( menu, id ); 689 addContainer( menu, id );
692 connect( menu, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); 690 connect( menu, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) );
693 691
694 if ( m_parentCollection ) 692 if ( m_parentCollection )
695 m_parentCollection->connectHighlight( menu, this ); 693 m_parentCollection->connectHighlight( menu, this );
696 694
697 return d->m_containers.count() - 1; 695 return d->m_containers.count() - 1;
698 } 696 }
699 else if ( w->inherits( "KToolBar" ) ) 697 else if ( w->inherits( "KToolBar" ) )
700 { 698 {
701 KToolBar *bar = static_cast<KToolBar *>( w ); 699 KToolBar *bar = static_cast<KToolBar *>( w );
702 700
703 int id_ = getToolButtonID(); 701 int id_ = getToolButtonID();
704/*US 702/*US
705 KInstance *instance; 703 KInstance *instance;
706 if ( m_parentCollection ) 704 if ( m_parentCollection )
707 instance = m_parentCollection->instance(); 705 instance = m_parentCollection->instance();
708 else 706 else
709 instance = KGlobal::instance(); 707 instance = KGlobal::instance();
710*/ 708*/
711 if ( icon().isEmpty() && !iconSet().pixmap().isNull() ) // old code using QIconSet directly 709 if ( icon().isEmpty() && !iconSet().pixmap().isNull() ) // old code using QIconSet directly
712 { 710 {
713 bar->insertButton( iconSet().pixmap(), id_, SIGNAL( clicked() ), this, 711 bar->insertButton( iconSet().pixmap(), id_, SIGNAL( clicked() ), this,
714 SLOT( slotActivated() ), 712 SLOT( slotActivated() ),
715 d->isEnabled(), d->plainText(), index ); 713 d->isEnabled(), d->plainText(), index );
716 } 714 }
717 else 715 else
718 { 716 {
719 QString icon = d->iconName(); 717 QString icon = d->iconName();
720 if ( icon.isEmpty() ) 718 if ( icon.isEmpty() )
721 icon = "unknown"; 719 icon = "unknown";
722 bar->insertButton( icon, id_, SIGNAL( clicked() ), this, 720 bar->insertButton( icon, id_, SIGNAL( clicked() ), this,
723 SLOT( slotActivated() ), 721 SLOT( slotActivated() ),
724 d->isEnabled(), d->plainText(), index/*US, instance*/ ); 722 d->isEnabled(), d->plainText(), index/*US, instance*/ );
725 } 723 }
726 bar->getButton( id_ )->setName( QCString("toolbutton_")+name() ); 724 bar->getButton( id_ )->setName( QCString("toolbutton_")+name() );
727 725
728//US if ( !d->whatsThis().isEmpty() ) 726//US if ( !d->whatsThis().isEmpty() )
729//US QWhatsThis::add( bar->getButton(id_), whatsThisWithIcon() ); 727//US QWhatsThis::add( bar->getButton(id_), whatsThisWithIcon() );
730 if ( !d->toolTip().isEmpty() ) 728 if ( !d->toolTip().isEmpty() )
731 QToolTip::add( bar->getButton(id_), d->toolTip() ); 729 QToolTip::add( bar->getButton(id_), d->toolTip() );
732 730
733 addContainer( bar, id_ ); 731 addContainer( bar, id_ );
734 732
735 connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); 733 connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) );
736 734
737 if ( m_parentCollection ) 735 if ( m_parentCollection )
738 m_parentCollection->connectHighlight( bar, this ); 736 m_parentCollection->connectHighlight( bar, this );
739 737
740 return containerCount() - 1; 738 return containerCount() - 1;
741 739
742 } 740 }
743 741
744 return -1; 742 return -1;
745} 743}
746 744
747void KAction::unplug( QWidget *w ) 745void KAction::unplug( QWidget *w )
748{ 746{
749 int i = findContainer( w ); 747 int i = findContainer( w );
750 if ( i == -1 ) 748 if ( i == -1 )
751 return; 749 return;
752 int id = itemId( i ); 750 int id = itemId( i );
753 751
754 if ( w->inherits( "QPopupMenu" ) ) 752 if ( w->inherits( "QPopupMenu" ) )
755 { 753 {
756 QPopupMenu *menu = static_cast<QPopupMenu *>( w ); 754 QPopupMenu *menu = static_cast<QPopupMenu *>( w );
757 menu->removeItem( id ); 755 menu->removeItem( id );
758 } 756 }
759 else if ( w->inherits( "KToolBar" ) ) 757 else if ( w->inherits( "KToolBar" ) )
760 { 758 {
761 KToolBar *bar = static_cast<KToolBar *>( w ); 759 KToolBar *bar = static_cast<KToolBar *>( w );
762 bar->removeItemDelayed( id ); 760 bar->removeItemDelayed( id );
763 } 761 }
764 else if ( w->inherits( "QMenuBar" ) ) 762 else if ( w->inherits( "QMenuBar" ) )
765 { 763 {
766 QMenuBar *bar = static_cast<QMenuBar *>( w ); 764 QMenuBar *bar = static_cast<QMenuBar *>( w );
767 bar->removeItem( id ); 765 bar->removeItem( id );
768 } 766 }
769 767
770 removeContainer( i ); 768 removeContainer( i );
771 769
772 if ( m_parentCollection ) 770 if ( m_parentCollection )
773 m_parentCollection->disconnectHighlight( w, this ); 771 m_parentCollection->disconnectHighlight( w, this );
774} 772}
775 773
776void KAction::plugAccel(KAccel *kacc, bool configurable) 774void KAction::plugAccel(KAccel *kacc, bool configurable)
777{ 775{
778 qDebug("KAction::plugAccel ...1 has top be fixed"); 776 // qDebug("KAction::plugAccel ...1 has top be fixed");
777
779/*US 778/*US
780 kdWarning(129) << "KAction::plugAccel(): call to deprecated action." << endl; 779 kdWarning(129) << "KAction::plugAccel(): call to deprecated action." << endl;
781 kdDebug(129) << kdBacktrace() << endl; 780 kdDebug(129) << kdBacktrace() << endl;
782 //kdDebug(129) << "KAction::plugAccel( kacc = " << kacc << " ): name \"" << name() << "\"" << endl; 781 //kdDebug(129) << "KAction::plugAccel( kacc = " << kacc << " ): name \"" << name() << "\"" << endl;
783 if ( d->m_kaccel ) 782 if ( d->m_kaccel )
784 unplugAccel(); 783 unplugAccel();
785 784
786 // If the parent collection's accel ptr isn't set yet 785 // If the parent collection's accel ptr isn't set yet
787 //if ( m_parentCollection && !m_parentCollection->accel() ) 786 //if ( m_parentCollection && !m_parentCollection->accel() )
788 // m_parentCollection->setAccel( kacc ); 787 // m_parentCollection->setAccel( kacc );
789 788
790 // We can only plug this action into the given KAccel object 789 // We can only plug this action into the given KAccel object
791 // if it does not already contain an action with the same name. 790 // if it does not already contain an action with the same name.
792 if ( !kacc->actions().actionPtr(name()) ) 791 if ( !kacc->actions().actionPtr(name()) )
793 { 792 {
794 d->m_kaccel = kacc; 793 d->m_kaccel = kacc;
795 d->m_kaccel->insert(name(), d->plainText(), QString::null, 794 d->m_kaccel->insert(name(), d->plainText(), QString::null,
796 KShortcut(d->m_cut), 795 KShortcut(d->m_cut),
797 this, SLOT(slotActivated()), 796 this, SLOT(slotActivated()),
798 configurable, isEnabled()); 797 configurable, isEnabled());
799 connect(d->m_kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed())); 798 connect(d->m_kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed()));
800 //connect(d->m_kaccel, SIGNAL(keycodeChanged()), this, SLOT(slotKeycodeChanged())); 799 //connect(d->m_kaccel, SIGNAL(keycodeChanged()), this, SLOT(slotKeycodeChanged()));
801 } 800 }
802 else 801 else
803 kdWarning(129) << "KAction::plugAccel( kacc = " << kacc << " ): KAccel object already contains an action name \"" << name() << "\"" << endl; // -- ellis 802 kdWarning(129) << "KAction::plugAccel( kacc = " << kacc << " ): KAccel object already contains an action name \"" << name() << "\"" << endl; // -- ellis
804*/ 803*/
805} 804}
806 805
807void KAction::unplugAccel() 806void KAction::unplugAccel()
808{ 807{
809 qDebug("KAction::unplugAccel ...1 has top be fixed"); 808 // qDebug("KAction::unplugAccel ...1 has top be fixed");
810/*US 809/*US
811 //kdDebug(129) << "KAction::unplugAccel() " << this << " " << name() << endl; 810 //kdDebug(129) << "KAction::unplugAccel() " << this << " " << name() << endl;
812 if ( d->m_kaccel ) 811 if ( d->m_kaccel )
813 { 812 {
814 d->m_kaccel->remove(name()); 813 d->m_kaccel->remove(name());
815 d->m_kaccel = 0; 814 d->m_kaccel = 0;
816 } 815 }
817*/ 816*/
818} 817}
819 818
820void KAction::plugMainWindowAccel( QWidget *w ) 819void KAction::plugMainWindowAccel( QWidget *w )
821{ 820{
822 qDebug("KAction::plugMainWindowAccel ...1 has top be fixed"); 821 // qDebug("KAction::plugMainWindowAccel ...1 has top be fixed");
822
823/*US 823/*US
824 // Note: topLevelWidget() stops too early, we can't use it. 824 // Note: topLevelWidget() stops too early, we can't use it.
825 QWidget * tl = w; 825 QWidget * tl = w;
826 QWidget * n; 826 QWidget * n;
827 while ( !tl->isDialog() && ( n = tl->parentWidget() ) ) // lookup parent and store 827 while ( !tl->isDialog() && ( n = tl->parentWidget() ) ) // lookup parent and store
828 tl = n; 828 tl = n;
829 829
830 KMainWindow * mw = dynamic_cast<KMainWindow *>(tl); // try to see if it's a kmainwindow 830 KMainWindow * mw = dynamic_cast<KMainWindow *>(tl); // try to see if it's a kmainwindow
831 if (mw) 831 if (mw)
832 plugAccel( mw->accel() ); 832 plugAccel( mw->accel() );
833 else 833 else
834 kdDebug(129) << "KAction::plugMainWindowAccel: Toplevel widget isn't a KMainWindow, can't plug accel. " << tl << endl; 834 kdDebug(129) << "KAction::plugMainWindowAccel: Toplevel widget isn't a KMainWindow, can't plug accel. " << tl << endl;
835*/ 835*/
836} 836}
837 837
838void KAction::setEnabled(bool enable) 838void KAction::setEnabled(bool enable)
839{ 839{
840 //kdDebug(129) << "KAction::setEnabled( " << enable << " ): this = " << this << " d->m_kaccelList.count() = " << d->m_kaccelList.count() << endl; 840 //kdDebug(129) << "KAction::setEnabled( " << enable << " ): this = " << this << " d->m_kaccelList.count() = " << d->m_kaccelList.count() << endl;
841 if ( enable == d->isEnabled() ) 841 if ( enable == d->isEnabled() )
842 return; 842 return;
843 843
844 // KDE 4: remove 844 // KDE 4: remove
845//US if (d->m_kaccel) 845//US if (d->m_kaccel)
846//US d->m_kaccel->setEnabled(name(), enable); 846//US d->m_kaccel->setEnabled(name(), enable);
847 // KDE 4: remove end 847 // KDE 4: remove end
848 848
849//US for ( uint i = 0; i < d->m_kaccelList.count(); i++ ) 849//US for ( uint i = 0; i < d->m_kaccelList.count(); i++ )
850//US d->m_kaccelList[i]->setEnabled( name(), enable ); 850//US d->m_kaccelList[i]->setEnabled( name(), enable );
851 851
852 d->setEnabled( enable ); 852 d->setEnabled( enable );
853 853
854 int len = containerCount(); 854 int len = containerCount();
855 for( int i = 0; i < len; ++i ) 855 for( int i = 0; i < len; ++i )
856 updateEnabled( i ); 856 updateEnabled( i );
857 857
858 emit enabled( d->isEnabled() ); 858 emit enabled( d->isEnabled() );
859} 859}
860 860
861void KAction::updateEnabled( int i ) 861void KAction::updateEnabled( int i )
862{ 862{
863 QWidget *w = container( i ); 863 QWidget *w = container( i );
864 864
865 if ( w->inherits("QPopupMenu") ) 865 if ( w->inherits("QPopupMenu") )
866 static_cast<QPopupMenu*>(w)->setItemEnabled( itemId( i ), d->isEnabled() ); 866 static_cast<QPopupMenu*>(w)->setItemEnabled( itemId( i ), d->isEnabled() );
867 else if ( w->inherits("QMenuBar") ) 867 else if ( w->inherits("QMenuBar") )
868 static_cast<QMenuBar*>(w)->setItemEnabled( itemId( i ), d->isEnabled() ); 868 static_cast<QMenuBar*>(w)->setItemEnabled( itemId( i ), d->isEnabled() );
869 else if ( w->inherits( "KToolBar" ) ) 869 else if ( w->inherits( "KToolBar" ) )
870 { 870 {
871 static_cast<KToolBar*>(w)->setItemEnabled( itemId( i ), d->isEnabled() ); 871 static_cast<KToolBar*>(w)->setItemEnabled( itemId( i ), d->isEnabled() );
872 } 872 }
873} 873}
874 874
875void KAction::setShortcutConfigurable( bool b ) 875void KAction::setShortcutConfigurable( bool b )
876{ 876{
877 d->m_configurable = b; 877 d->m_configurable = b;
878} 878}
879 879
880void KAction::setText( const QString& text ) 880void KAction::setText( const QString& text )
881{ 881{
882/*US 882/*US
883 // KDE 4: remove 883 // KDE 4: remove
884 if (d->m_kaccel) { 884 if (d->m_kaccel) {
885 KAccelAction* pAction = d->m_kaccel->actions().actionPtr(name()); 885 KAccelAction* pAction = d->m_kaccel->actions().actionPtr(name());
886 if (pAction) 886 if (pAction)
887 pAction->setLabel( text ); 887 pAction->setLabel( text );
888 } 888 }
889 // KDE 4: remove end 889 // KDE 4: remove end
890 890
891 for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { 891 for( uint i = 0; i < d->m_kaccelList.count(); i++ ) {
892 KAccelAction* pAction = d->m_kaccelList[i]->actions().actionPtr(name()); 892 KAccelAction* pAction = d->m_kaccelList[i]->actions().actionPtr(name());
893 if (pAction) 893 if (pAction)
894 pAction->setLabel( text ); 894 pAction->setLabel( text );
895 } 895 }
896*/ 896*/
897 d->setText( text ); 897 d->setText( text );
898 898
899 int len = containerCount(); 899 int len = containerCount();
900 for( int i = 0; i < len; ++i ) 900 for( int i = 0; i < len; ++i )
901 updateText( i ); 901 updateText( i );
902 902
903} 903}
904 904
905void KAction::updateText( int i ) 905void KAction::updateText( int i )
906{ 906{
907 QWidget *w = container( i ); 907 QWidget *w = container( i );
908 908
909 if ( w->inherits( "QPopupMenu" ) ) { 909 if ( w->inherits( "QPopupMenu" ) ) {
910 int id = itemId( i ); 910 int id = itemId( i );
911 static_cast<QPopupMenu*>(w)->changeItem( id, d->text() ); 911 static_cast<QPopupMenu*>(w)->changeItem( id, d->text() );
912 updateShortcut( static_cast<QPopupMenu*>(w), id ); 912 updateShortcut( static_cast<QPopupMenu*>(w), id );
913 } 913 }
914 else if ( w->inherits( "QMenuBar" ) ) 914 else if ( w->inherits( "QMenuBar" ) )
915 static_cast<QMenuBar*>(w)->changeItem( itemId( i ), d->text() ); 915 static_cast<QMenuBar*>(w)->changeItem( itemId( i ), d->text() );
916 else if ( w->inherits( "KToolBar" ) ) 916 else if ( w->inherits( "KToolBar" ) )
917 { 917 {
918 qDebug("KAction::updateText ...3 has top be fixed"); 918 //qDebug("KAction::updateText ...3 has top be fixed");
919 QWidget *button = static_cast<KToolBar *>(w)->getWidget( itemId( i ) ); 919 QWidget *button = static_cast<KToolBar *>(w)->getWidget( itemId( i ) );
920 if ( button->inherits( "KToolBarButton" ) ) 920 if ( button->inherits( "KToolBarButton" ) )
921 static_cast<KToolBarButton *>(button)->setText( d->plainText() ); 921 static_cast<KToolBarButton *>(button)->setText( d->plainText() );
922 922
923 } 923 }
924} 924}
925 925
926QString KAction::text() const 926QString KAction::text() const
927{ 927{
928 return d->text(); 928 return d->text();
929} 929}
930 930
931QString KAction::plainText() const 931QString KAction::plainText() const
932{ 932{
933 return d->plainText( ); 933 return d->plainText( );
934} 934}
935 935
936void KAction::setIcon( const QString &icon ) 936void KAction::setIcon( const QString &icon )
937{ 937{
938 d->setIconName( icon ); 938 d->setIconName( icon );
939 939
940 // now handle any toolbars 940 // now handle any toolbars
941 int len = containerCount(); 941 int len = containerCount();
942 for ( int i = 0; i < len; ++i ) 942 for ( int i = 0; i < len; ++i )
943 updateIcon( i ); 943 updateIcon( i );
944} 944}
945 945
946void KAction::updateIcon( int id ) 946void KAction::updateIcon( int id )
947{ 947{
948 QWidget* w = container( id ); 948 QWidget* w = container( id );
949 949
950 if ( w->inherits( "QPopupMenu" ) ) { 950 if ( w->inherits( "QPopupMenu" ) ) {
951 int itemId_ = itemId( id ); 951 int itemId_ = itemId( id );
952 static_cast<QPopupMenu*>(w)->changeItem( itemId_, d->iconSet( KIcon::Small ), d->text() ); 952 static_cast<QPopupMenu*>(w)->changeItem( itemId_, d->iconSet( KIcon::Small ), d->text() );
953 updateShortcut( static_cast<QPopupMenu*>(w), itemId_ ); 953 updateShortcut( static_cast<QPopupMenu*>(w), itemId_ );
954 } 954 }
955 else if ( w->inherits( "QMenuBar" ) ) 955 else if ( w->inherits( "QMenuBar" ) )
956 static_cast<QMenuBar*>(w)->changeItem( itemId( id ), d->iconSet( KIcon::Small ), d->text() ); 956 static_cast<QMenuBar*>(w)->changeItem( itemId( id ), d->iconSet( KIcon::Small ), d->text() );
957 else if ( w->inherits( "KToolBar" ) ) 957 else if ( w->inherits( "KToolBar" ) )
958 static_cast<KToolBar *>(w)->setButtonIcon( itemId( id ), d->iconName() ); 958 static_cast<KToolBar *>(w)->setButtonIcon( itemId( id ), d->iconName() );
959 else if ( w->inherits( "QToolBar" ) ) 959 else if ( w->inherits( "QToolBar" ) )
960 { 960 {
961 qDebug("KAction::updateIcon has top be fixed"); 961 qDebug("KAction::updateIcon has top be fixed");
962//US static_cast<QToolBar *>(w)->setButtonIcon( itemId( id ), d->iconName() ); 962//US static_cast<QToolBar *>(w)->setButtonIcon( itemId( id ), d->iconName() );
963 } 963 }
964} 964}
965 965
966QString KAction::icon() const 966QString KAction::icon() const
967{ 967{
968 return d->iconName( ); 968 return d->iconName( );
969} 969}
970 970
971void KAction::setIconSet( const QIconSet &iconset ) 971void KAction::setIconSet( const QIconSet &iconset )
972{ 972{
973 d->setIconSet( iconset ); 973 d->setIconSet( iconset );
974 974
975 int len = containerCount(); 975 int len = containerCount();
976 for( int i = 0; i < len; ++i ) 976 for( int i = 0; i < len; ++i )
977 updateIconSet( i ); 977 updateIconSet( i );
978} 978}
979 979
980 980
981void KAction::updateIconSet( int id ) 981void KAction::updateIconSet( int id )
982{ 982{
983 QWidget *w = container( id ); 983 QWidget *w = container( id );
984 984
985 if ( w->inherits( "QPopupMenu" ) ) 985 if ( w->inherits( "QPopupMenu" ) )
986 { 986 {
987 int itemId_ = itemId( id ); 987 int itemId_ = itemId( id );
988 static_cast<QPopupMenu*>(w)->changeItem( itemId_, d->iconSet(), d->text() ); 988 static_cast<QPopupMenu*>(w)->changeItem( itemId_, d->iconSet(), d->text() );
989 updateShortcut( static_cast<QPopupMenu*>(w), itemId_ ); 989 updateShortcut( static_cast<QPopupMenu*>(w), itemId_ );
990 } 990 }
991 else if ( w->inherits( "QMenuBar" ) ) 991 else if ( w->inherits( "QMenuBar" ) )
992 static_cast<QMenuBar*>(w)->changeItem( itemId( id ), d->iconSet(), d->text() ); 992 static_cast<QMenuBar*>(w)->changeItem( itemId( id ), d->iconSet(), d->text() );
993 else if ( w->inherits( "KToolBar" ) ) 993 else if ( w->inherits( "KToolBar" ) )
994 { 994 {
995 if ( icon().isEmpty() && d->hasIconSet() ) // only if there is no named icon ( scales better ) 995 if ( icon().isEmpty() && d->hasIconSet() ) // only if there is no named icon ( scales better )
996 static_cast<KToolBar *>(w)->setButtonIconSet( itemId( id ), d->iconSet() ); 996 static_cast<KToolBar *>(w)->setButtonIconSet( itemId( id ), d->iconSet() );
997 else 997 else
998 static_cast<KToolBar *>(w)->setButtonIconSet( itemId( id ), d->iconSet( KIcon::Small ) ); 998 static_cast<KToolBar *>(w)->setButtonIconSet( itemId( id ), d->iconSet( KIcon::Small ) );
999 } 999 }
1000} 1000}
1001 1001
1002QIconSet KAction::iconSet( KIcon::Group group, int size ) const 1002QIconSet KAction::iconSet( KIcon::Group group, int size ) const
1003{ 1003{
1004 return d->iconSet( group, size ); 1004 return d->iconSet( group, size );
1005} 1005}
1006 1006
1007bool KAction::hasIcon() const 1007bool KAction::hasIcon() const
1008{ 1008{
1009 return d->hasIcon(); 1009 return d->hasIcon();
1010} 1010}
1011 1011
1012 1012
1013void KAction::setWhatsThis( const QString& text ) 1013void KAction::setWhatsThis( const QString& text )
1014{ 1014{
@@ -1025,191 +1025,191 @@ void KAction::updateWhatsThis( int i )
1025 QPopupMenu* pm = popupMenu( i ); 1025 QPopupMenu* pm = popupMenu( i );
1026 if ( pm ) 1026 if ( pm )
1027 { 1027 {
1028 pm->setWhatsThis( itemId( i ), d->whatsThis() ); 1028 pm->setWhatsThis( itemId( i ), d->whatsThis() );
1029 return; 1029 return;
1030 } 1030 }
1031 1031
1032 KToolBar *tb = toolBar( i ); 1032 KToolBar *tb = toolBar( i );
1033 if ( tb ) 1033 if ( tb )
1034 { 1034 {
1035 QWidget *w = tb->getButton( itemId( i ) ); 1035 QWidget *w = tb->getButton( itemId( i ) );
1036//US QWhatsThis::remove( w ); 1036//US QWhatsThis::remove( w );
1037//US QWhatsThis::add( w, d->whatsThis() ); 1037//US QWhatsThis::add( w, d->whatsThis() );
1038 return; 1038 return;
1039 } 1039 }
1040} 1040}
1041 1041
1042QString KAction::whatsThis() const 1042QString KAction::whatsThis() const
1043{ 1043{
1044 return d->whatsThis(); 1044 return d->whatsThis();
1045} 1045}
1046 1046
1047QString KAction::whatsThisWithIcon() const 1047QString KAction::whatsThisWithIcon() const
1048{ 1048{
1049 QString text = whatsThis(); 1049 QString text = whatsThis();
1050 if (!d->iconName().isEmpty()) 1050 if (!d->iconName().isEmpty())
1051 return QString::fromLatin1("<img source=\"small|%1\"> %2").arg(d->iconName() ).arg(text); 1051 return QString::fromLatin1("<img source=\"small|%1\"> %2").arg(d->iconName() ).arg(text);
1052 return text; 1052 return text;
1053} 1053}
1054 1054
1055QWidget* KAction::container( int index ) const 1055QWidget* KAction::container( int index ) const
1056{ 1056{
1057 assert( index < containerCount() ); 1057 assert( index < containerCount() );
1058 return d->m_containers[ index ].m_container; 1058 return d->m_containers[ index ].m_container;
1059} 1059}
1060 1060
1061KToolBar* KAction::toolBar( int index ) const 1061KToolBar* KAction::toolBar( int index ) const
1062{ 1062{
1063//US return dynamic_cast<KToolBar *>( d->m_containers[ index ].m_container ); 1063//US return dynamic_cast<KToolBar *>( d->m_containers[ index ].m_container );
1064 return (KToolBar *)( d->m_containers[ index ].m_container ); 1064 return (KToolBar *)( d->m_containers[ index ].m_container );
1065} 1065}
1066 1066
1067QPopupMenu* KAction::popupMenu( int index ) const 1067QPopupMenu* KAction::popupMenu( int index ) const
1068{ 1068{
1069//US return dynamic_cast<QPopupMenu *>( d->m_containers[ index ].m_container ); 1069//US return dynamic_cast<QPopupMenu *>( d->m_containers[ index ].m_container );
1070 return (QPopupMenu *)( d->m_containers[ index ].m_container ); 1070 return (QPopupMenu *)( d->m_containers[ index ].m_container );
1071} 1071}
1072 1072
1073QWidget* KAction::representative( int index ) const 1073QWidget* KAction::representative( int index ) const
1074{ 1074{
1075 return d->m_containers[ index ].m_representative; 1075 return d->m_containers[ index ].m_representative;
1076} 1076}
1077 1077
1078int KAction::itemId( int index ) const 1078int KAction::itemId( int index ) const
1079{ 1079{
1080 return d->m_containers[ index ].m_id; 1080 return d->m_containers[ index ].m_id;
1081} 1081}
1082 1082
1083int KAction::containerCount() const 1083int KAction::containerCount() const
1084{ 1084{
1085 return d->m_containers.count(); 1085 return d->m_containers.count();
1086} 1086}
1087 1087
1088uint KAction::kaccelCount() const 1088uint KAction::kaccelCount() const
1089{ 1089{
1090 return d->m_kaccelList.count(); 1090 return d->m_kaccelList.count();
1091} 1091}
1092 1092
1093void KAction::addContainer( QWidget* c, int id ) 1093void KAction::addContainer( QWidget* c, int id )
1094{ 1094{
1095 KActionPrivate::Container p; 1095 KActionPrivate::Container p;
1096 p.m_container = c; 1096 p.m_container = c;
1097 p.m_id = id; 1097 p.m_id = id;
1098 d->m_containers.append( p ); 1098 d->m_containers.append( p );
1099} 1099}
1100 1100
1101void KAction::addContainer( QWidget* c, QWidget* w ) 1101void KAction::addContainer( QWidget* c, QWidget* w )
1102{ 1102{
1103 KActionPrivate::Container p; 1103 KActionPrivate::Container p;
1104 p.m_container = c; 1104 p.m_container = c;
1105 p.m_representative = w; 1105 p.m_representative = w;
1106 d->m_containers.append( p ); 1106 d->m_containers.append( p );
1107} 1107}
1108 1108
1109void KAction::activate() 1109void KAction::activate()
1110{ 1110{
1111 slotActivated(); 1111 slotActivated();
1112} 1112}
1113 1113
1114void KAction::slotActivated() 1114void KAction::slotActivated()
1115{ 1115{
1116 emit activated(); 1116 emit activated();
1117} 1117}
1118 1118
1119void KAction::slotDestroyed() 1119void KAction::slotDestroyed()
1120{ 1120{
1121 kdDebug(129) << "KAction::slotDestroyed(): this = " << this << ", name = \"" << name() << "\", sender = " << sender() << endl; 1121
1122 const QObject* o = sender(); 1122 const QObject* o = sender();
1123 1123
1124/* 1124/*
1125 1125
1126 1126
1127 // KDE 4: remove 1127 // KDE 4: remove
1128 if ( o == d->m_kaccel ) 1128 if ( o == d->m_kaccel )
1129 { 1129 {
1130 d->m_kaccel = 0; 1130 d->m_kaccel = 0;
1131 return; 1131 return;
1132 } 1132 }
1133 // KDE 4: remove end 1133 // KDE 4: remove end
1134 1134
1135 for( uint i = 0; i < d->m_kaccelList.count(); i++ ) 1135 for( uint i = 0; i < d->m_kaccelList.count(); i++ )
1136 { 1136 {
1137 if ( o == d->m_kaccelList[i] ) 1137 if ( o == d->m_kaccelList[i] )
1138 { 1138 {
1139 disconnect( d->m_kaccelList[i], SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); 1139 disconnect( d->m_kaccelList[i], SIGNAL(destroyed()), this, SLOT(slotDestroyed()) );
1140 d->m_kaccelList.remove( d->m_kaccelList.at( i ) ); 1140 d->m_kaccelList.remove( d->m_kaccelList.at( i ) );
1141 return; 1141 return;
1142 } 1142 }
1143 } 1143 }
1144*/ 1144*/
1145 int i; 1145 int i;
1146 do 1146 do
1147 { 1147 {
1148 i = findContainer( static_cast<const QWidget*>( o ) ); 1148 i = findContainer( static_cast<const QWidget*>( o ) );
1149 if ( i != -1 ) 1149 if ( i != -1 )
1150 removeContainer( i ); 1150 removeContainer( i );
1151 } while ( i != -1 ); 1151 } while ( i != -1 );
1152 1152
1153} 1153}
1154 1154
1155int KAction::findContainer( const QWidget* widget ) const 1155int KAction::findContainer( const QWidget* widget ) const
1156{ 1156{
1157 int pos = 0; 1157 int pos = 0;
1158 QValueList<KActionPrivate::Container>::ConstIterator it = d->m_containers.begin(); 1158 QValueList<KActionPrivate::Container>::ConstIterator it = d->m_containers.begin();
1159 while( it != d->m_containers.end() ) 1159 while( it != d->m_containers.end() )
1160 { 1160 {
1161 if ( (*it).m_representative == widget || (*it).m_container == widget ) 1161 if ( (*it).m_representative == widget || (*it).m_container == widget )
1162 return pos; 1162 return pos;
1163 ++it; 1163 ++it;
1164 ++pos; 1164 ++pos;
1165 } 1165 }
1166 1166
1167 return -1; 1167 return -1;
1168} 1168}
1169 1169
1170void KAction::removeContainer( int index ) 1170void KAction::removeContainer( int index )
1171{ 1171{
1172 int i = 0; 1172 int i = 0;
1173 QValueList<KActionPrivate::Container>::Iterator it = d->m_containers.begin(); 1173 QValueList<KActionPrivate::Container>::Iterator it = d->m_containers.begin();
1174 while( it != d->m_containers.end() ) 1174 while( it != d->m_containers.end() )
1175 { 1175 {
1176 if ( i == index ) 1176 if ( i == index )
1177 { 1177 {
1178 d->m_containers.remove( it ); 1178 d->m_containers.remove( it );
1179 return; 1179 return;
1180 } 1180 }
1181 ++it; 1181 ++it;
1182 ++i; 1182 ++i;
1183 } 1183 }
1184} 1184}
1185 1185
1186// FIXME: Remove this (ellis) 1186// FIXME: Remove this (ellis)
1187void KAction::slotKeycodeChanged() 1187void KAction::slotKeycodeChanged()
1188{ 1188{
1189 qDebug("KAction::slotKeycodeChanged() ...44 has top be fixed"); 1189 qDebug("KAction::slotKeycodeChanged() ...44 has top be fixed");
1190/*US 1190/*US
1191 kdDebug(129) << "KAction::slotKeycodeChanged()" << endl; // -- ellis 1191 kdDebug(129) << "KAction::slotKeycodeChanged()" << endl; // -- ellis
1192 KAccelAction* pAction = d->m_kaccel->actions().actionPtr(name()); 1192 KAccelAction* pAction = d->m_kaccel->actions().actionPtr(name());
1193 if( pAction ) 1193 if( pAction )
1194 setShortcut(pAction->shortcut()); 1194 setShortcut(pAction->shortcut());
1195*/ 1195*/
1196} 1196}
1197 1197
1198KActionCollection *KAction::parentCollection() const 1198KActionCollection *KAction::parentCollection() const
1199{ 1199{
1200 return m_parentCollection; 1200 return m_parentCollection;
1201} 1201}
1202 1202
1203void KAction::unplugAll() 1203void KAction::unplugAll()
1204{ 1204{
1205 while ( containerCount() != 0 ) 1205 while ( containerCount() != 0 )
1206 unplug( container( 0 ) ); 1206 unplug( container( 0 ) );
1207} 1207}
1208 1208
1209void KAction::virtual_hook( int, void* ) 1209void KAction::virtual_hook( int, void* )
1210{ /*BASE::virtual_hook( id, data );*/ } 1210{ /*BASE::virtual_hook( id, data );*/ }
1211 1211
1212/* vim: et sw=2 ts=2 1212/* vim: et sw=2 ts=2
1213 */ 1213 */
1214 1214
1215//US #include "kaction.moc" 1215//US #include "kaction.moc"