summaryrefslogtreecommitdiffstats
path: root/karm/tdeaccelmenuwatch.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-02-01 17:25:43 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-02-01 17:25:43 -0600
commit6cc5f72b33f1d281de3e1bf809b1b5e77d5c96cf (patch)
treeb90f9ba234d5a04288c37fe3ef65fd9e936c363f /karm/tdeaccelmenuwatch.cpp
parentfd5d099065a748cac49e20a13481f85666c53c71 (diff)
downloadtdepim-6cc5f72b33f1d281de3e1bf809b1b5e77d5c96cf.tar.gz
tdepim-6cc5f72b33f1d281de3e1bf809b1b5e77d5c96cf.zip
Fix FTBFS
Diffstat (limited to 'karm/tdeaccelmenuwatch.cpp')
-rw-r--r--karm/tdeaccelmenuwatch.cpp113
1 files changed, 113 insertions, 0 deletions
diff --git a/karm/tdeaccelmenuwatch.cpp b/karm/tdeaccelmenuwatch.cpp
new file mode 100644
index 000000000..4b5952848
--- /dev/null
+++ b/karm/tdeaccelmenuwatch.cpp
@@ -0,0 +1,113 @@
+/*
+* kaccelmenuwatch.cpp -- Implementation of class TDEAccelMenuWatch.
+* Author: Sirtaj Singh Kang
+* Generated: Thu Jan 7 15:05:26 EST 1999
+*/
+
+#include <assert.h>
+#include <tqpopupmenu.h>
+
+#include "kaccelmenuwatch.h"
+
+TDEAccelMenuWatch::TDEAccelMenuWatch( TDEAccel *accel, TQObject *parent )
+ : TQObject( parent ),
+ _accel( accel ),
+ _menu ( 0 )
+{
+ _accList.setAutoDelete( true );
+ _menuList.setAutoDelete( false );
+}
+
+void TDEAccelMenuWatch::setMenu( TQPopupMenu *menu )
+{
+ assert( menu );
+
+ // we use _menuList to ensure that the signal is
+ // connected only once per menu.
+
+ if ( !_menuList.findRef( menu ) ) {
+ _menuList.append( menu );
+ connect( menu, TQT_SIGNAL(destroyed()), this, TQT_SLOT(removeDeadMenu()) );
+ }
+
+ _menu = menu;
+}
+
+void TDEAccelMenuWatch::connectAccel( int itemId, const char *action )
+{
+ AccelItem *item = newAccelItem( _menu, itemId, StringAccel ) ;
+ item->action = TQString::fromLocal8Bit( action );
+}
+
+void TDEAccelMenuWatch::connectAccel( int itemId, TDEStdAccel::StdAccel accel )
+{
+ AccelItem *item = newAccelItem( _menu, itemId, StdAccel ) ;
+ item->stdAction = accel;
+}
+
+void TDEAccelMenuWatch::updateMenus()
+{
+ assert( _accel != 0 );
+
+ TQPtrListIterator<AccelItem> iter( _accList );
+ AccelItem *item;
+
+ for( ; (item = iter.current()) ; ++iter ) {
+ // These setAccel calls were converted from all changeMenuAccel calls
+ // as descibed in KDE3PORTING.html
+ switch( item->type ) {
+ case StringAccel:
+ item->menu->setAccel( _accel->shortcut( item->action ).keyCodeQt(), item->itemId );
+ break;
+ case StdAccel:
+ item->menu->setAccel( TDEStdAccel::shortcut( item->stdAction ).keyCodeQt(), item->itemId );
+ break;
+ default:
+ break;
+ }
+ }
+
+}
+
+void TDEAccelMenuWatch::removeDeadMenu()
+{
+ TQPopupMenu *sdr = (TQPopupMenu *) sender();
+ assert( sdr );
+
+ if ( !_menuList.findRef( sdr ) )
+ return;
+
+ // remove all accels
+
+ AccelItem *accel;
+ for ( accel = _accList.first(); accel; accel = _accList.next() )
+ {
+loop:
+ if( accel && accel->menu == sdr ) {
+ _accList.remove();
+ accel = _accList.current();
+ goto loop;
+ }
+ }
+
+ // remove from menu list
+ _menuList.remove( sdr );
+
+ return;
+}
+
+TDEAccelMenuWatch::AccelItem *TDEAccelMenuWatch::newAccelItem( TQPopupMenu *,
+ int itemId, AccelType type )
+{
+ AccelItem *item = new AccelItem;
+
+ item->menu = _menu;
+ item->itemId = itemId;
+ item->type = type;
+
+ _accList.append( item );
+
+ return item;
+}
+
+#include "kaccelmenuwatch.moc"