From c977e93324d33cceb2d5f41cb5ef406ba2abd81a Mon Sep 17 00:00:00 2001 From: ouv Date: Thu, 16 May 2019 14:51:57 +0300 Subject: [PATCH] DIAGRAM issues 0004250: External 642: Add a search function to DIAGRAM --- src/Qtx/QtxSearchTool.cxx | 43 +++++++++++++++++++++++---------------- src/Qtx/QtxSearchTool.h | 6 +++--- 2 files changed, 29 insertions(+), 20 deletions(-) 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(); -- 2.39.2