Index: /trunk/geant4/interfaces/basic/include/G4UIQt.hh
===================================================================
--- /trunk/geant4/interfaces/basic/include/G4UIQt.hh	(revision 512)
+++ /trunk/geant4/interfaces/basic/include/G4UIQt.hh	(revision 513)
@@ -98,10 +98,8 @@
 private:
   void SecondaryLoop(G4String); // a VIRER
-  G4bool GetHelpChoice(G4int&);
   void TerminalHelp(G4String);
-  void CreateChildTree(QTreeWidgetItem*,G4UIcommandTree*);
+  void CreateChildTree(QTreeWidgetItem*,G4UIcommandTree*,G4UIcommand*);
   QString GetCommandList(G4UIcommand*);
 
-  void ExitHelp();
 private:
 
@@ -110,6 +108,4 @@
   //  static void commandEnteredCallback(Widget,XtPointer,XtPointer);
   //  static void keyHandler(Widget,XtPointer,XEvent*,Boolean*);
-  G4bool fHelp;
-  G4int fHelpChoice;
   QMainWindow * fMainWindow;
   QLabel *fCommandLabel;
@@ -120,4 +116,6 @@
   QSignalMapper *signalMapper ;
   QTreeWidget *fHelpTreeWidget;
+  QDialog *fHelpDialog;
+
 signals : 
   void myClicked(const QString &text);
@@ -128,4 +126,5 @@
   void buttonCallback(const QString&);
   void helpTreeCallback();
+  void showHelp();
 };
 
Index: /trunk/geant4/interfaces/basic/src/G4UIQt.cc
===================================================================
--- /trunk/geant4/interfaces/basic/src/G4UIQt.cc	(revision 512)
+++ /trunk/geant4/interfaces/basic/src/G4UIQt.cc	(revision 513)
@@ -61,9 +61,7 @@
 #include <stdlib.h>
 
-static G4bool ConvertStringToInt(const char*,int&);
-
+// Pourquoi Static et non  variables de classe ?
 static G4bool exitSession = true;
 static G4bool exitPause = true;
-static G4bool exitHelp = true;
 /***************************************************************************/
 /**
@@ -91,4 +89,6 @@
  char** argv
 )
+  :fHelpDialog(NULL)
+
 /***************************************************************************/
 /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
@@ -147,6 +147,11 @@
   fMainWindow->setCentralWidget(splitter);
 
+  // Add a quit subMenu
   QMenu *fileMenu = fMainWindow->menuBar()->addMenu("File");
   fileMenu->addAction("Quitter", fMainWindow, SLOT(close()));
+
+  // Add a Help menu
+  QMenu *helpMenu = fMainWindow->menuBar()->addMenu("Help");
+  helpMenu->addAction("Show Help", this, SLOT(showHelp()));
 
   // Set the splitter size. The fTextArea sould be 2/3 on the fMainWindow
@@ -298,38 +303,4 @@
   return 0;
 }
-/***************************************************************************/
-G4bool G4UIQt::GetHelpChoice(
- G4int& aInt
-)
-/***************************************************************************/
-/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
-{
-  printf("G4UIQt::GetHelpChoice\n");
-  
-  fHelp = true; // TO KEEP
-//   // SecondaryLoop : // TO KEEP
-  G4Qt* interactorManager = G4Qt::getInstance (); // TO KEEP ?
-  Prompt("Help"); // TO KEEP
-  exitHelp = false; // TO KEEP
-  void* event; // TO KEEP
-  while((event = interactorManager->GetEvent())!=NULL) {  // TO KEEP
-    interactorManager->DispatchEvent(event); // TO KEEP
-    if(exitHelp==true) break; // TO KEEP
-  } // TO KEEP
-  Prompt("session"); // TO KEEP
-  // // TO KEEP
-  if(fHelp==false) return false; // TO KEEP
-  aInt = fHelpChoice; // TO KEEP
-  fHelp = false; // TO KEEP
-  return true; // TO KEEP
-}
-/***************************************************************************/
-void G4UIQt::ExitHelp(
-)
-/***************************************************************************/
-/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
-{
-  printf("G4UIQt::ExitHelp\n");
-}
 
 /***************************************************************************/
@@ -343,27 +314,8 @@
   printf("G4UIQt::AddMenu %s %s\n",a_name,a_label);
 
-  QMenu *fileMenu = fMainWindow->menuBar()->addMenu(a_label);
+  //  QMenu *fileMenu = fMainWindow->menuBar()->addMenu(a_label);
+  QMenu *fileMenu = new QMenu(a_label);
+  fMainWindow->menuBar()->insertMenu(fMainWindow->menuBar()->actions().last(),fileMenu); 
   AddInteractor (a_name,(G4Interactor)fileMenu);
-
-  //  QMenu *menu = new QMenu("test");//a_label);
-  //  fMainWindow->menuBar()->addMenu(menu); 
-
-//   if(menuBar==NULL) return;
-//   if(a_name==NULL) return;
-//   if(a_label==NULL) return;
-//   XtManageChild (menuBar);
-//   // Pulldown menu :
-//   Widget widget;
-//   widget = XmCreatePulldownMenu (menuBar,(char*)a_name,NULL,0);
-//   AddInteractor (a_name,(G4Interactor)widget);
-//   // Cascade button :
-//   Arg args[2];
-//   XmString cps = XmStringLtoRCreate((char*)a_label,XmSTRING_DEFAULT_CHARSET);
-//   XtSetArg (args[0],XmNlabelString,cps);
-//   XtSetArg (args[1],XmNsubMenuId,widget);
-//   widget = XmCreateCascadeButton (menuBar,(char*)a_name,args,2);
-//   XmStringFree (cps);
-//   XtManageChild (widget);
-//   ExecuteChangeSizeFunction(form);
 }
 /***************************************************************************/
@@ -386,27 +338,6 @@
   signalMapper->setMapping(action, QString(a_command));
   connect(signalMapper, SIGNAL(mapped(const QString &)),this, SLOT(buttonCallback(const QString&)));
-  
-  //  std::string slot = SLOT(buttonCallback(std::string));    
-  printf("G4UIQt::AddButton %s %s %s\n",a_menu,a_label,a_command);
-
-//   Widget widget = XmCreatePushButton(parent,(char*)a_label,NULL,0);
-//   XtManageChild (widget);
-//   XtAddCallback (widget,XmNactivateCallback,ButtonCallback,(XtPointer)this);
-//   commands[action] = a_command;
-}
-
-
-// /***************************************************************************/
-//G4String G4UIQt::GetCommand (
-//  QAction *a_widget
-//)
-// /***************************************************************************/
-// /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
-// {
-//   return commands[a_widget];
-// }
-/***************************************************************************/
-/***************************************************************************/
-/***************************************************************************/
+}
+
 
 /**
@@ -420,5 +351,4 @@
 /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
 {
-  if(fHelp==true) return; // Disabled when in help.
   G4String ss = G4String(a_command.toStdString().c_str());
   printf ("debug : execute:\n-%s- %d %d \n",ss.data(),exitSession,exitPause);
@@ -441,18 +371,13 @@
   if (fCommandArea->text().toStdString().c_str() != "") {
     fCommandHistoryArea->append(fCommandArea->text());
-    if(fHelp==true) {
-  printf ("ne doit plus passer ici\n");
-      exitHelp = true;
-      fHelp = ConvertStringToInt(command.data(),fHelpChoice);
+
+    if (command(0,4) != "help") {
+      ApplyShellCommand (command,exitSession,exitPause);
     } else {
-      if (command(0,4) != "help") {
-        ApplyShellCommand (command,exitSession,exitPause);
-      } else {
-        printf ("terminal help\n");
-        TerminalHelp(command);
-      }
-      if(exitSession==true) 
-        SessionTerminate();
+      printf ("terminal help\n");
+      TerminalHelp(command);
     }
+    if(exitSession==true) 
+      SessionTerminate();
   }
   fCommandArea->setText("");
@@ -469,31 +394,26 @@
 }
 
-//////////////////////////////////////////////////////////////////////////////
-G4bool ConvertStringToInt(
- const char* aString
-,int& aInt
-)
-//////////////////////////////////////////////////////////////////////////////
-//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
-{
-  aInt = 0; // TO KEEP
-  if(aString==NULL) return false; // TO KEEP
-  char* s; // TO KEEP
-  long value = strtol(aString,&s,10); // TO KEEP
-  if(s==aString) return false; // TO KEEP
-  aInt = value; // TO KEEP
-  return true; // TO KEEP
-}
-
-#endif
-
+
+/**
+  Open the help dialog in a separate window.
+  This will be display as a tree widget
+  Implementation of <b>void G4VBasicShell::TerminalHelp(G4String newCommand)</b>
+
+  @param newCommand : open the tree widget item on this command if is set
+ */
 void G4UIQt::TerminalHelp(G4String newCommand)
 {
-  QDialog *helpDialog = new QDialog;
+  if (fHelpDialog) {
+    fHelpDialog->show();
+    fHelpDialog->raise();
+    fHelpDialog->activateWindow();
+    return;
+  }
+  fHelpDialog = new QDialog;
 
   QSplitter *splitter = new QSplitter(Qt::Horizontal);
   fHelpArea = new QTextEdit();
   QPushButton *exitButton = new QPushButton("Exit");
-  connect(exitButton, SIGNAL(clicked()), helpDialog,SLOT(close()));
+  connect(exitButton, SIGNAL(clicked()), fHelpDialog,SLOT(close()));
   fHelpArea->setReadOnly(true);
 
@@ -503,4 +423,16 @@
   G4UIcommandTree * treeTop = UI->GetTree();
 
+  // Look for the choosen command "newCommand"
+  size_t i = newCommand.index(" ");
+  G4UIcommand* expandCommand = NULL;
+  if( i != std::string::npos )
+  {
+    G4String newValue = newCommand(i+1,newCommand.length()-(i+1));
+    newValue.strip(G4String::both);
+    G4String targetCom = ModifyToFullPathCommand( newValue );
+    expandCommand = treeTop->FindPath( targetCom );
+  }
+
+  // build widget
   fHelpTreeWidget = new QTreeWidget();
   fHelpTreeWidget->setColumnCount(2);
@@ -522,5 +454,5 @@
 
     // look for childs
-    CreateChildTree(newItem,treeTop->GetTree(a+1));
+    CreateChildTree(newItem,treeTop->GetTree(a+1),expandCommand);
     items.append(newItem);
   }
@@ -530,5 +462,4 @@
   //  QSignalMapper signalMapper = new QSignalMapper(this);
 
-  connect(fHelpTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem*, int)),this, SLOT(helpTreeCallback(QTreeWidgetItem*, int)));  
   connect(fHelpTreeWidget, SIGNAL(itemSelectionChanged ()),this, SLOT(helpTreeCallback()));  
 
@@ -544,86 +475,15 @@
   vLayout->addWidget(splitter);
   vLayout->addWidget(exitButton);
-  helpDialog->setLayout(vLayout);
-
-  helpDialog->resize(800,600); 
-  helpDialog->move(QPoint(400,150));
-  helpDialog->show();
-  helpDialog->raise();
-  helpDialog->activateWindow();
-  ////////////////
-
-  printf ("G4UIQt::TerminalHelp \n");
-
-
-//   size_t i = newCommand.index(" ");
-//   if( i != std::string::npos )
-//   {
-//     G4String newValue = newCommand(i+1,newCommand.length()-(i+1));
-//     newValue.strip(G4String::both);
-//     G4String targetCom = ModifyToFullPathCommand( newValue );
-//     G4UIcommand* theCommand = treeTop->FindPath( targetCom );
-//     if( theCommand != NULL ) 
-//     { 
-//       theCommand->List();
-//       return;
-//     }
-//     else
-//     {
-//       G4cout << "Command <" << newValue << " is not found." << G4endl;
-//       return;
-//     }
-//   }
-
-//   G4UIcommandTree * floor[10];
-//   floor[0] = treeTop;
-//   G4int iFloor = 0;
-//   size_t prefixIndex = 1;
-//   G4String prefix = GetCurrentWorkingDirectory();
-//   while( prefixIndex < prefix.length()-1 )
-//   {
-//     size_t ii = prefix.index("/",prefixIndex);
-//     floor[iFloor+1] = 
-//       floor[iFloor]->GetTree(G4String(prefix(0,ii+1)));
-//     prefixIndex = ii+1;
-//     iFloor++;
-//   }
-//   floor[iFloor]->ListCurrentWithNum();
-//   // 1998 Oct 2 non-number input
-//   while(1){
-//    //G4cout << G4endl << "Type the number ( 0:end, -n:n level back ) : "<<std::flush;
-//     G4cout << G4endl << "Type the number ( 0:end, -n:n level back ) : "<<G4endl;
-//     G4int i;
-//     if(!GetHelpChoice(i)){
-//       G4cout << G4endl << "Not a number, once more" << G4endl; 
-//       continue;
-//     } else if( i < 0 ){
-//       iFloor += i;
-//       if( iFloor < 0 ) iFloor = 0;
-//       floor[iFloor]->ListCurrentWithNum(); 
-//       continue;
-//     } else if(i == 0) { 
-//       break;
-//     } else if( i > 0 ) {
-//       G4int n_tree = floor[iFloor]->GetTreeEntry();
-//       if( i > n_tree )
-//       { 
-//         if( i <= n_tree + floor[iFloor]->GetCommandEntry() )
-//         { 
-//           floor[iFloor]->GetCommand(i-n_tree)->List(); 
-//         }
-//       }
-//       else
-//       {
-//         floor[iFloor+1] = floor[iFloor]->GetTree(i);
-//         iFloor++;
-//         floor[iFloor]->ListCurrentWithNum();
-//       }
-//     }
-//   }
-  G4cout << "Exit from HELP." << G4endl << G4endl;
-  //G4cout << G4endl;
-  ExitHelp();
-}
-void G4UIQt::CreateChildTree(QTreeWidgetItem *a_parent,G4UIcommandTree *a_commandTree) {
+  fHelpDialog->setLayout(vLayout);
+
+  fHelpDialog->resize(800,600); 
+  fHelpDialog->move(QPoint(400,150));
+  fHelpDialog->show();
+  fHelpDialog->raise();
+  fHelpDialog->activateWindow();
+
+
+}
+void G4UIQt::CreateChildTree(QTreeWidgetItem *a_parent,G4UIcommandTree *a_commandTree,G4UIcommand* a_expandCommand) {
 
   // Creating new item
@@ -639,13 +499,5 @@
     newItem = new QTreeWidgetItem(stringList);
 
-    //connecting callback
-    //    signalMapper = new QSignalMapper(this);
-    //    QAction *action = parent->addAction(a_label, signalMapper, SLOT(map()));
-    
-    //  signalMapper->setMapping(action, QString(a_command));
-    //  connect(signalMapper, SIGNAL(mapped(const QString &)),this, SLOT(helpTreeCallback(const QString&)));
-    //QTreeWidget::itemActivated ( QTreeWidgetItem * item, int column )   [signal]
-
-    CreateChildTree(newItem,a_commandTree->GetTree(a+1));
+    CreateChildTree(newItem,a_commandTree->GetTree(a+1),a_expandCommand);
     a_parent->addChild(newItem);
   }
@@ -664,4 +516,15 @@
     a_parent->addChild(newItem);
 
+    // expand if possible
+    if (a_expandCommand) {
+      printf("compare : -%s- -%s- \n",((char*)(a_expandCommand->GetCommandPath()).data()),((char*)(a_commandTree->GetCommand(a+1)->GetCommandPath()).data()));
+      if (a_expandCommand->GetCommandPath() == a_commandTree->GetCommand(a+1)->GetCommandPath()) {
+        printf("mmmmmmmmmmmmmmmmmmm\n");
+        newItem->setExpanded(true);
+        fHelpArea->setText(GetCommandList(a_expandCommand));
+      } else {
+        newItem->setExpanded(false);
+      }
+    }
   }
 }
@@ -675,5 +538,5 @@
 /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
 {
-  printf ("G4UIQt::TerminalHelp ===========================\n");
+  G4bool GetHelpChoice(G4int&);
   QTreeWidgetItem* item =  NULL;
   if (!fHelpTreeWidget)
@@ -756,2 +619,13 @@
   return txt;
 }
+
+/***************************************************************************/
+void G4UIQt::showHelp (
+)
+/***************************************************************************/
+/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
+{
+  TerminalHelp("");
+}
+
+#endif
