From 473744b431f4ffd2600e981990c3b97823272e80 Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 21 Jun 2007 05:06:10 +0000 Subject: [PATCH] Porting to Qt4. --- src/Plot2d/Plot2d_ViewFrame.cxx | 8 ++++---- src/SUIT/SUIT_ToolButton.cxx | 35 ++++++++++++++------------------- src/SUIT/SUIT_ToolButton.h | 3 +-- 3 files changed, 20 insertions(+), 26 deletions(-) diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index de03ad90a..c7e9478e8 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -1448,15 +1448,15 @@ void Plot2d_ViewFrame::plotMousePressed( const QMouseEvent& me ) myPnt = me.pos(); if ( myOperation == GlPanId ) { myPlot->setAxisScale( QwtPlot::yLeft, - myPlot->invTransform( QwtPlot::yLeft, myPnt.y() ) + myYDistance/2, - myPlot->invTransform( QwtPlot::yLeft, myPnt.y() ) - myYDistance/2 ); + myPlot->invTransform( QwtPlot::yLeft, myPnt.y() ) - myYDistance/2, + myPlot->invTransform( QwtPlot::yLeft, myPnt.y() ) + myYDistance/2 ); myPlot->setAxisScale( QwtPlot::xBottom, myPlot->invTransform( QwtPlot::xBottom, myPnt.x() ) - myXDistance/2, myPlot->invTransform( QwtPlot::xBottom, myPnt.x() ) + myXDistance/2 ); if (mySecondY) myPlot->setAxisScale( QwtPlot::yRight, - myPlot->invTransform( QwtPlot::yRight, myPnt.y() ) + myYDistance2/2, - myPlot->invTransform( QwtPlot::yRight, myPnt.y() ) - myYDistance2/2 ); + myPlot->invTransform( QwtPlot::yRight, myPnt.y() ) - myYDistance2/2, + myPlot->invTransform( QwtPlot::yRight, myPnt.y() ) + myYDistance2/2 ); myPlot->replot(); } } diff --git a/src/SUIT/SUIT_ToolButton.cxx b/src/SUIT/SUIT_ToolButton.cxx index a7e60af9a..161d1952d 100755 --- a/src/SUIT/SUIT_ToolButton.cxx +++ b/src/SUIT/SUIT_ToolButton.cxx @@ -33,10 +33,9 @@ myChangeItemAfterClick( changeItemAfterClick ) /*!Initialize tool buttons.*/ void SUIT_ToolButton::initialize() { -// mySignal = NULL; myPopup = new QMenu( this ); setMenu( myPopup ); - connect( myPopup, SIGNAL( activated( int ) ), SLOT( OnSelectAction( int ) ) ); + connect( myPopup, SIGNAL( triggered( QAction* ) ), SLOT( OnSelectAction( QAction* ) ) ); } /*!drawButton is redefined to draw DownArrow*/ @@ -63,8 +62,9 @@ void SUIT_ToolButton::AddAction( QAction* theAction ) aIsFirst = true; setIcon( theAction->icon() ); setText( theAction->text() ); + myPopup->setActiveAction( theAction ); } - myPopup->addAction( theAction ); + myPopup->addAction( theAction ); } /*! Sets myPopup item with theIndex as current*/ @@ -75,36 +75,31 @@ void SUIT_ToolButton::SetItem( int theIndex ) { setIcon( a->icon() ); setText( a->text() ); + myPopup->setActiveAction( a ); } } /*!Public SLOT. - * On select action (icon and text set with id = \a theItemID) + * On select action (icon and text set from action = \a theAction) */ -void SUIT_ToolButton::OnSelectAction( int /*theItemID*/ ) +void SUIT_ToolButton::OnSelectAction( QAction* theAction ) { -/* - if ( myChangeItemAfterClick ) + if ( theAction && myChangeItemAfterClick ) { // Protection against unexpected null pointers returned - if ( myPopup->iconSet(theItemID) ) - setPixmap(myPopup->iconSet(theItemID)->pixmap()); - setTextLabel(myPopup->text(theItemID)); - QMenuItem* aItem = myPopup->findItem(theItemID); - if (aItem != NULL) - { - mySignal = aItem->signal(); - } + QIcon anIcon = theAction->icon(); + if ( !anIcon.isNull() ) + setIcon(anIcon); + setText(theAction->text()); + myPopup->setActiveAction( theAction ); } -*/ } /*!On mouse release event.*/ void SUIT_ToolButton::mouseReleaseEvent( QMouseEvent* theEvent ) { QToolButton::mouseReleaseEvent( theEvent ); -/* - if ( mySignal ) - mySignal->activate(); -*/ + QAction* anAction = myPopup->activeAction(); + if ( anAction ) + anAction->activate( QAction::Trigger ); } diff --git a/src/SUIT/SUIT_ToolButton.h b/src/SUIT/SUIT_ToolButton.h index 419ef0a4a..0acd98e74 100755 --- a/src/SUIT/SUIT_ToolButton.h +++ b/src/SUIT/SUIT_ToolButton.h @@ -47,7 +47,7 @@ public: void SetItem(int theIndex); public slots: - void OnSelectAction(int theItemID); + void OnSelectAction( QAction* theAction ); protected: void mouseReleaseEvent (QMouseEvent * theEvent); @@ -56,7 +56,6 @@ private: void initialize(); QMenu* myPopup; -// QSignal* mySignal; bool myChangeItemAfterClick; }; -- 2.39.2