From: ouv Date: Thu, 16 May 2019 11:51:57 +0000 (+0300) Subject: DIAGRAM issues 0004250: External 642: Add a search function to DIAGRAM X-Git-Tag: CTH_2_3_5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c977e93324d33cceb2d5f41cb5ef406ba2abd81a;p=modules%2Fgui.git DIAGRAM issues 0004250: External 642: Add a search function to DIAGRAM --- diff --git a/src/Qtx/QtxSearchTool.cxx b/src/Qtx/QtxSearchTool.cxx index 5656a695a..25040ca5e 100644 --- a/src/Qtx/QtxSearchTool.cxx +++ b/src/Qtx/QtxSearchTool.cxx @@ -451,23 +451,27 @@ QList QtxSearchTool::shortcuts() const /*! \brief Set shortcuts. \param accel shortcut binding(s) to be used + \param addDefault flag used to add default shortcuts \sa shortcuts() */ -void QtxSearchTool::setShortcuts( const QKeySequence& accel ) +void QtxSearchTool::setShortcuts( const QKeySequence& accel, + const bool addDefault ) { QList ks; ks << accel; - setShortcuts( ks ); + setShortcuts( ks, addDefault ); } /*! \brief Set shortcuts. \param accel shortcut bindings to be used + \param addDefault flag used to add default shortcuts \sa shortcuts() */ -void QtxSearchTool::setShortcuts( const QList& accels ) +void QtxSearchTool::setShortcuts( const QList& accels, + const bool addDefault ) { - initShortcuts( accels ); + initShortcuts( accels, addDefault ); } /*! @@ -1004,28 +1008,33 @@ void QtxSearchTool::clearShortcuts() \brief Install shortcuts. \internal \param accels shortcuts list + \param addDefault flag used to add default shortcuts */ -void QtxSearchTool::initShortcuts( const QList& accels ) +void QtxSearchTool::initShortcuts( const QList& accels, + const bool addDefault ) { clearShortcuts(); QWidget* p = myWatched ? myWatched : ( parentWidget() ? parentWidget() : this ); QShortcut* sc; - sc = new QShortcut( QKeySequence::Find, p ); - connect( sc, SIGNAL( activated() ), this, SLOT( find() ) ); - sc->setContext( Qt::WidgetShortcut ); - myShortcuts.append( sc ); + if( addDefault ) + { + sc = new QShortcut( QKeySequence::Find, p ); + connect( sc, SIGNAL( activated() ), this, SLOT( find() ) ); + sc->setContext( Qt::WidgetShortcut ); + myShortcuts.append( sc ); - sc = new QShortcut( QKeySequence::FindNext, p ); - sc->setContext( Qt::WidgetShortcut ); - connect( sc, SIGNAL( activated() ), this, SLOT( findNext() ) ); - myShortcuts.append( sc ); + sc = new QShortcut( QKeySequence::FindNext, p ); + sc->setContext( Qt::WidgetShortcut ); + connect( sc, SIGNAL( activated() ), this, SLOT( findNext() ) ); + myShortcuts.append( sc ); - sc = new QShortcut( QKeySequence::FindPrevious, p ); - sc->setContext( Qt::WidgetShortcut ); - connect( sc, SIGNAL( activated() ), this, SLOT( findPrevious() ) ); - myShortcuts.append( sc ); + sc = new QShortcut( QKeySequence::FindPrevious, p ); + sc->setContext( Qt::WidgetShortcut ); + connect( sc, SIGNAL( activated() ), this, SLOT( findPrevious() ) ); + myShortcuts.append( sc ); + } QList::ConstIterator it; for ( it = accels.begin(); it != accels.end(); ++it ) diff --git a/src/Qtx/QtxSearchTool.h b/src/Qtx/QtxSearchTool.h index 674eaca67..40225cc51 100644 --- a/src/Qtx/QtxSearchTool.h +++ b/src/Qtx/QtxSearchTool.h @@ -96,8 +96,8 @@ public: void setControls( const int ); QList shortcuts() const; - void setShortcuts( const QKeySequence& ); - void setShortcuts( const QList& ); + void setShortcuts( const QKeySequence&, const bool = true ); + void setShortcuts( const QList&, const bool = true ); void setShortcutContext( const Qt::ShortcutContext ); @@ -134,7 +134,7 @@ private: void init(); bool focused() const; void clearShortcuts(); - void initShortcuts( const QList& ); + void initShortcuts( const QList&, const bool = true ); void updateShortcuts(); void updateControls();