]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/SHAPERGUI/SHAPERGUI.cpp
Salome HOME
Merge branch 'po/29467_gui_log_file'
[modules/shaper.git] / src / SHAPERGUI / SHAPERGUI.cpp
index 9232099ac0e71d0e283f41fca7e0abc919958bd8..eebf6e6c422ece0e69c5544973008316ad1b99ba 100644 (file)
@@ -498,33 +498,47 @@ bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy)
 void SHAPERGUI::logShaperGUIEvent()
 {
   QAction* anAction = static_cast<QAction*>(sender());
-  QString anId = anAction->data().toString();
-  QString anEventDescription ("SHAPER");
+  if ( !anAction )
+    return;
+  const QString anId = anAction->data().toString();
+  const QString section = anId.contains("Sketch") ? "sketcher" : "";
+
+  CAM_Application::logStructuredUserEvent( moduleName(),
+                                           section,
+                                           anAction->text(),
+                                           "activated" );
+}
+
+//******************************************************
+static void onOperationGeneric( ModuleBase_Operation* theOperation,
+                                const QString moduleName,
+                                const QString &event )
+{
+  QString anId = theOperation->id();
+  QString section = "";
+
   if (anId.contains("Sketch"))
-    anEventDescription += " sketcher";
-  anEventDescription += ": ";
-  anEventDescription += anAction->text();
-  anEventDescription += " has been started";
-  CAM_Application::logUserEvent(anEventDescription);
+  {
+    section = "sketcher";
+    anId.remove("Sketch");
+  }
+
+  CAM_Application::logStructuredUserEvent( moduleName,
+                                           section,
+                                           anId,
+                                           event );
 }
 
 //******************************************************
 void SHAPERGUI::onOperationCommitted(ModuleBase_Operation* theOperation)
 {
-  //QString anEventDescription ("SHAPER operation has been committed");
-  QString anEventDescription ("SHAPER operation ");
-  anEventDescription += theOperation->id();
-  anEventDescription += " has been committed";
-  CAM_Application::logUserEvent(anEventDescription);
+  onOperationGeneric(theOperation, moduleName(), "committed");
 }
 
 //******************************************************
 void SHAPERGUI::onOperationAborted(ModuleBase_Operation* theOperation)
 {
-  QString anEventDescription ("SHAPER operation ");
-  anEventDescription += theOperation->id();
-  anEventDescription += " has been aborted";
-  CAM_Application::logUserEvent(anEventDescription);
+  onOperationGeneric(theOperation, moduleName(), "aborted");
 }
 
 //******************************************************
@@ -787,6 +801,8 @@ QAction* SHAPERGUI::addFeatureOfNested(const QString& theWBName,
   createTool(separator(), aWBTool); /// nested action is always separated of others
   registerCommandToolbar(theWBName, -1);
 
+  connect(anAction, SIGNAL(triggered(bool)), this, SLOT(logShaperGUIEvent()));
+
   return anAction;
 }
 
@@ -815,6 +831,9 @@ QAction* SHAPERGUI::addDesktopCommand(const QString& theId, const QString& theTi
   aAction->setStatusTip(theTip);
   aAction->setData(theId);
   createMenu(aId, aMenu, theMenuPosition);
+
+  connect(aAction, SIGNAL(triggered(bool)), this, SLOT(logShaperGUIEvent()));
+
   return aAction;
 }