Salome HOME
#18963 Minimize compiler warnings
[modules/gui.git] / src / CAM / CAM_Module.cxx
old mode 100755 (executable)
new mode 100644 (file)
index d3a0dda..f5b7b43
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -234,11 +234,10 @@ bool CAM_Module::activateModule( SUIT_Study* /*study*/ )
 {
   // IMN 05/03/2015: we copied myActionMap for reset/unset actions accelerator keys
   // after activate/deactivate modules
-  for ( QMap<QPair<int, QAction*>, QKeySequence>::Iterator it = myActionShortcutMap.begin(); it != myActionShortcutMap.end(); ++it )
+  for ( QMap<QAction*, QKeySequence>::Iterator it = myActionShortcutMap.begin(); it != myActionShortcutMap.end(); ++it )
   {
-    myActionMap.insert( it.key().first, it.key().second );
     // Reset actions accelerator keys
-    it.key().second->setShortcut( it.value() );
+    it.key()->setShortcut( it.value() );
   }
   myActionShortcutMap.clear();
   return true;
@@ -263,9 +262,9 @@ bool CAM_Module::deactivateModule( SUIT_Study* )
   myActionShortcutMap.clear();
   for ( QMap<int, QAction*>::Iterator it = myActionMap.begin(); it != myActionMap.end(); ++it )
   {
-    myActionShortcutMap.insert( qMakePair( it.key(), it.value() ), it.value()->shortcut() );
+    myActionShortcutMap.insert( it.value(), it.value()->shortcut() );
+    it.value()->setShortcut( QKeySequence() );
   }
-  myActionMap.clear();
   return true;
 }
 
@@ -328,6 +327,43 @@ void CAM_Module::putInfo( const QString& msg, const int msec )
     myInfo = msg;
 }
 
+/*!
+    \brief Shows the notifications with spectified text, title and automatic close timeout.
+    Notification will be automatically closed after specified timeout in msec. If
+    timeout is zero then automatic closing doesn't performed.
+    \param text - Notification text
+    \param title - Notification title
+    \param timeout - Notification close timeout in msec
+    \return notification identifier
+*/
+int CAM_Module::showNotification( const QString& message, const QString& title, int timeout )
+{
+  int res = -1;
+  if ( application() )
+    res = application()->showNotification( message, title, timeout );
+  return res;
+}
+
+/*!
+    \brief Closes the notifications with spectified text.
+    \param text - Notification text
+*/
+void CAM_Module::hideNotification( const QString& message )
+{
+  if ( application() )
+    application()->hideNotification( message );
+}
+
+/*!
+    \brief Closes the notifications with spectified identifier.
+    \param text - Notification text
+*/
+void CAM_Module::hideNotification( int id )
+{
+  if ( application() )
+    application()->hideNotification( id );
+}
+
 /*!
   \brief Restore message info.
 
@@ -563,6 +599,16 @@ int CAM_Module::createTool( const int id, const QString& tBar, const int idx )
   return intId != -1 ? id : -1;
 }
 
+/*!
+  Clears given toolbar.
+  \param title - title of toolbar
+*/
+void CAM_Module::clearTool( const QString& title )
+{
+  if ( toolMgr() )
+    toolMgr()->clear( title );
+}
+
 /*!
   \brief Create menu or submenu.
 
@@ -941,6 +987,33 @@ QAction* CAM_Module::createAction( const int id, const QString& text, const QIco
                                    const QString& menu, const QString& tip, const int key,
                                    QObject* parent, const bool toggle, QObject* reciever,
                                   const char* member, const QString& shortcutAction )
+{
+  return createAction( id, text, icon, menu, tip, QKeySequence(key), parent, toggle, reciever, member, shortcutAction );
+}
+
+/*!
+  \brief Create new instance of QtxAction and register action with specified \a id.
+
+  Resulting action ID may differ from the requested one. This can happen if
+  requested ID is already in use.
+
+  If \a id < 0, the action ID is generated automatically.
+
+  \param id required action ID
+  \param text tooltip text
+  \param icon action icon
+  \param menu menu text
+  \param tip status bar tip
+  \param key keyboard accelerator
+  \param parent parent object
+  \param toggle if \c true, the action will be toggled
+  \param reciever action activation signal receiver object
+  \param member action activation signal receiver slot
+*/
+QAction* CAM_Module::createAction( const int id, const QString& text, const QIcon& icon,
+                                   const QString& menu, const QString& tip, const QKeySequence& key,
+                                   QObject* parent, const bool toggle, QObject* reciever,
+                                  const char* member, const QString& shortcutAction )
 {
   QtxAction* a = new QtxAction( text, icon, menu, key, parent, toggle, shortcutAction );
   a->setStatusTip( tip );
@@ -1001,7 +1074,9 @@ int CAM_Module::registerAction( const int id, QAction* a )
   if ( toolMgr() )
     toolMgr()->registerAction( a );
 
-  if ( application() && application()->desktop() )
+  if ( application() && application()->desktop() &&
+       a->shortcutContext() != Qt::WidgetShortcut &&
+       a->shortcutContext() != Qt::WidgetWithChildrenShortcut )
     application()->desktop()->addAction( a );
 
   return ident;
@@ -1069,7 +1144,7 @@ void CAM_Module::updateModuleVisibilityState() {
   This method is called from CAM_Application::startOperation().
   \param actionId is a numerical unique operation id.
 */
-bool CAM_Module::activateOperation( int actionId )
+bool CAM_Module::activateOperation( int /*actionId*/ )
 {
   return false;
 }
@@ -1079,7 +1154,7 @@ bool CAM_Module::activateOperation( int actionId )
   This method is called from CAM_Application::startOperation().
   \param actionId is a string unique operation id.
 */
-bool CAM_Module::activateOperation( const QString& actionId )
+bool CAM_Module::activateOperation( const QString& /*actionId*/ )
 {
   return false;
 }
@@ -1090,7 +1165,7 @@ bool CAM_Module::activateOperation( const QString& actionId )
   \param actionId is a string unique operation id.
   \param pluginName is a name of a plugin where the operation is implemented.
 */
-bool CAM_Module::activateOperation( const QString& actionId, const QString& pluginName )
+bool CAM_Module::activateOperation( const QString& /*actionId*/, const QString& /*pluginName*/ )
 {
   return false;
 }