From f83927935023e793b8a203693ba5b4c03da3e4bc Mon Sep 17 00:00:00 2001 From: coolo Date: Sun, 9 Dec 2007 17:56:15 +0000 Subject: [PATCH] fix signals and slots git-svn-id: http://svn.opensuse.org/svn/yast/trunk/qt4@42870 e0cc52ee-31ee-0310-8b87-e83c4596d67c --- src/YQComboBox.cc | 10 +++++----- src/YQComboBox.h | 2 +- src/YQMenuButton.cc | 20 +++++++++++++------- src/YQMenuButton.h | 6 ++++-- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/YQComboBox.cc b/src/YQComboBox.cc index d26bb89..539d82e 100644 --- a/src/YQComboBox.cc +++ b/src/YQComboBox.cc @@ -67,11 +67,11 @@ YQComboBox::YQComboBox( YWidget * parent, this, SLOT ( slotSelected(int) ) ); #endif - connect( _qt_comboBox, SIGNAL( activated ( const QString & ) ), - this, SLOT ( textChanged( const QString & ) ) ); + connect( _qt_comboBox, SIGNAL( activated ( QString ) ), + this, SLOT ( textChanged( QString ) ) ); - connect( _qt_comboBox, SIGNAL( textChanged( const QString & ) ), - this, SLOT ( textChanged( const QString & ) ) ); + connect( _qt_comboBox, SIGNAL( editTextChanged( QString ) ), + this, SLOT ( textChanged( QString ) ) ); } @@ -208,7 +208,7 @@ void YQComboBox::slotSelected( int i ) } -void YQComboBox::textChanged( const QString & new_text ) +void YQComboBox::textChanged( QString ) { if ( notify() ) YQUI::ui()->sendEvent( new YWidgetEvent( this, YEvent::ValueChanged ) ); diff --git a/src/YQComboBox.h b/src/YQComboBox.h index 93e78a7..20bc238 100644 --- a/src/YQComboBox.h +++ b/src/YQComboBox.h @@ -132,7 +132,7 @@ protected slots: * 'editable' option is set ). * This is only interesting if the `notify option is set. **/ - void textChanged( const QString &new_text ); + void textChanged( QString ); protected: diff --git a/src/YQMenuButton.cc b/src/YQMenuButton.cc index 883dfdd..395c1d4 100644 --- a/src/YQMenuButton.cc +++ b/src/YQMenuButton.cc @@ -79,8 +79,8 @@ YQMenuButton::rebuildMenuTree() YUI_CHECK_NEW( menu ); _qt_button->setMenu( menu ); - connect( menu, SIGNAL( activated ( int ) ), - this, SLOT ( menuEntryActivated( int ) ) ); + connect( menu, SIGNAL( triggered ( QAction* ) ), + this, SLOT ( menuEntryActivated( QAction* ) ) ); // // Recursively add Qt menu items from the YMenuItems @@ -118,8 +118,8 @@ YQMenuButton::rebuildMenuTree( QMenu * parentMenu, YItemIterator begin, YItemIte else subMenu = parentMenu->addMenu( QIcon( icon ), fromUTF8( item->label() )); - connect( subMenu, SIGNAL( activated ( int ) ), - this, SLOT ( menuEntryActivated( int ) ) ); + connect( subMenu, SIGNAL( triggered ( QAction* ) ), + this, SLOT ( menuEntryActivated( QAction* ) ) ); rebuildMenuTree( subMenu, item->childrenBegin(), item->childrenEnd() ); } @@ -129,18 +129,24 @@ YQMenuButton::rebuildMenuTree( QMenu * parentMenu, YItemIterator begin, YItemIte // so it can easily be used as unique ID in all Q3PopupMenus that belong // to this YQMenuButton. + QAction *act; if ( icon.isNull() ) - parentMenu->addAction( fromUTF8( item->label() ) /*, item->index() */); + act = parentMenu->addAction( fromUTF8( item->label() ) ); else - parentMenu->addAction( QIcon( icon ), fromUTF8( item->label() ) /*, item->index()*/); + act = parentMenu->addAction( QIcon( icon ), fromUTF8( item->label() ) ); + _serials[act] = item->index(); } } } void -YQMenuButton::menuEntryActivated( int serialNo ) +YQMenuButton::menuEntryActivated( QAction* action ) { + int serialNo = -1; + if ( _serials.contains( action ) ) + serialNo = _serials[action]; + // y2debug( "Selected menu entry #%d", menu_item_index ); _selectedItem = findMenuItem( serialNo ); diff --git a/src/YQMenuButton.h b/src/YQMenuButton.h index c5feb55..f9ce374 100644 --- a/src/YQMenuButton.h +++ b/src/YQMenuButton.h @@ -22,8 +22,9 @@ #include #include "YMenuButton.h" +#include - +class QAction; class QPushButton; class QMenu; @@ -96,7 +97,7 @@ protected slots: /** * Triggered when any menu item is activated. **/ - void menuEntryActivated( int menuItemIndex ); + void menuEntryActivated( QAction * menuItem ); /** * Triggered via menuEntryActivated() by zero timer to get back in sync @@ -119,6 +120,7 @@ protected: YMenuItem * _selectedItem; QPushButton * _qt_button; + QHash _serials; }; #endif // YQMenuButton_h -- 2.39.2