Salome HOME
CAM_Application: Fix log message (no translation needed).
[modules/gui.git] / src / CAM / CAM_Application.cxx
index 8dab93d7152bd622e51fb53848467e8e76e35bf4..7a9273171212677bbde07bd7cb421edb6b70176f 100644 (file)
@@ -467,7 +467,10 @@ bool CAM_Application::activateModule( CAM_Module* mod )
   {
     if ( myModule->deactivateModule( activeStudy() ) )
     {
-      logUserEvent( tr( "MODULE_DEACTIVATED" ).arg( myModule->moduleName() ) );
+      logStructuredUserEvent( myModule->moduleName(),
+                              "",
+                              "",
+                              "deactivated" );
     }
     moduleDeactivated( myModule );
   }
@@ -479,7 +482,10 @@ bool CAM_Application::activateModule( CAM_Module* mod )
     myModule->connectToStudy( dynamic_cast<CAM_Study*>( activeStudy() ) );
     if ( myModule->activateModule( activeStudy() ) )
     {
-      logUserEvent( tr( "MODULE_ACTIVATED" ).arg( myModule->moduleName() ) );
+      logStructuredUserEvent( myModule->moduleName(),
+                              "",
+                              "",
+                              "activated" );
     }
     else
     {
@@ -507,7 +513,8 @@ bool CAM_Application::activateModule( CAM_Module* mod )
   \param actionId is a numerical unique operation identifier
   \return \c true in case of success and \c false otherwise
 */
-bool CAM_Application::activateOperation( const QString& modName, int actionId )
+bool CAM_Application::activateOperation( const QString& modName,
+                                         const int actionId )
 {
   CAM_Module* mod = loadModule(modName, false);
   if (mod) {
@@ -524,7 +531,8 @@ bool CAM_Application::activateOperation( const QString& modName, int actionId )
   \param actionId is a string unique operation identifier
   \return \c true in case of success and \c false otherwise
 */
-bool CAM_Application::activateOperation( const QString& modName, const QString& actionId )
+bool CAM_Application::activateOperation( const QString& modName,
+                                         const QString& actionId )
 {
   CAM_Module* mod = loadModule(modName, false);
   if (mod) {
@@ -1032,12 +1040,29 @@ void CAM_Application::logUserEvent( const QString& eventDescription )
     {
       QDateTime current = QDateTime::currentDateTime();
       QTextStream stream( &file );
-      stream << current.toString("yyyyMMdd-hhmmss") << ": " << eventDescription << endl;
+      stream << current.toString("yyyyMMdd-hhmmss")
+             << "," << eventDescription
+             << endl;
       file.close();
     }
   }
 }
 
+void CAM_Application::logStructuredUserEvent( const QString& module,
+                                              const QString& section,
+                                              const QString& action,
+                                              const QString& event,
+                                              const QString& message )
+{
+  const QStringList mes = (QStringList() << module
+                           << section
+                           << action
+                           << event
+                           << message);
+
+  logUserEvent( mes.join( "," ) );
+}
+
 /*!
   \brief Log given action.
   \param action GUI action being logged.
@@ -1050,21 +1075,24 @@ void CAM_Application::logAction( QAction* action, const QString& moduleName )
     text = action->text();
   if ( text.isEmpty() )
     text = action->iconText();
+
   if ( !text.isEmpty() )
   {
-    QStringList message;
-    if ( !moduleName.isEmpty() )
-      message << moduleName;
     if ( action->isCheckable() )
     {
-      message << tr( "ACTION_TOGGLED" );
-      message << ( action->isChecked() ? tr( "ACTION_ON" ) : tr( "ACTION_OFF" ) );
+      logStructuredUserEvent ( moduleName,
+                               "",
+                               "toggled",
+                               action->isChecked() ? "on" : "off",
+                               text );
     }
     else
     {
-      message << tr( "ACTION_TRIGGERED" );
+      logStructuredUserEvent ( moduleName,
+                               "",
+                               "triggered",
+                               "",
+                               text );
     }
-    message << text;
-    logUserEvent( message.join( ": " ) );
   }
 }