Index: trunk/geant4/interfaces/basic/src/G4UIQt.cc
===================================================================
--- trunk/geant4/interfaces/basic/src/G4UIQt.cc	(revision 513)
+++ trunk/geant4/interfaces/basic/src/G4UIQt.cc	(revision 514)
@@ -153,5 +153,5 @@
   // Add a Help menu
   QMenu *helpMenu = fMainWindow->menuBar()->addMenu("Help");
-  helpMenu->addAction("Show Help", this, SLOT(showHelp()));
+  helpMenu->addAction("Show Help", this, SLOT(showHelpCallback()));
 
   // Set the splitter size. The fTextArea sould be 2/3 on the fMainWindow
@@ -341,56 +341,4 @@
 
 
-/**
-  Callback call when "enter" clicked on the command zone.
-  Send the command to geant4
- */
-void G4UIQt::buttonCallback (
-  const QString& a_command
-)
-/***************************************************************************/
-/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
-{
-  G4String ss = G4String(a_command.toStdString().c_str());
-  printf ("debug : execute:\n-%s- %d %d \n",ss.data(),exitSession,exitPause);
-  ApplyShellCommand(ss,exitSession,exitPause);
-  if(exitSession==true) 
-    SessionTerminate();
-}
-
-/**
-  Callback call when "click on a menu entry.
-  Send the associated command to geant4
- */
-void G4UIQt::commandEnteredCallback (
-)
-/***************************************************************************/
-/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
-{
-  printf ("debug : callback\n");
-  G4String command (fCommandArea->text().toStdString().c_str());
-  if (fCommandArea->text().toStdString().c_str() != "") {
-    fCommandHistoryArea->append(fCommandArea->text());
-
-    if (command(0,4) != "help") {
-      ApplyShellCommand (command,exitSession,exitPause);
-    } else {
-      printf ("terminal help\n");
-      TerminalHelp(command);
-    }
-    if(exitSession==true) 
-      SessionTerminate();
-  }
-  fCommandArea->setText("");
-}
-
-
-/***************************************************************************/
-void G4UIQt::clearButtonCallback (
-)
-/***************************************************************************/
-/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
-{
-  fTextArea->clear();
-}
 
 
@@ -404,77 +352,103 @@
 void G4UIQt::TerminalHelp(G4String newCommand)
 {
-  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()), fHelpDialog,SLOT(close()));
-  fHelpArea->setReadOnly(true);
-
-  // the help tree
-  G4UImanager* UI = G4UImanager::GetUIpointer();
-  if(UI==NULL) return;
-  G4UIcommandTree * treeTop = UI->GetTree();
+  if (!fHelpDialog) {
+    fHelpDialog = new QDialog;
+
+    QSplitter *splitter = new QSplitter(Qt::Horizontal);
+    fHelpArea = new QTextEdit();
+    QPushButton *exitButton = new QPushButton("Exit");
+    connect(exitButton, SIGNAL(clicked()), fHelpDialog,SLOT(close()));
+    fHelpArea->setReadOnly(true);
+
+    // the help tree
+    G4UImanager* UI = G4UImanager::GetUIpointer();
+    if(UI==NULL) return;
+    G4UIcommandTree * treeTop = UI->GetTree();
+
+
+    // build widget
+    fHelpTreeWidget = new QTreeWidget();
+    fHelpTreeWidget->setColumnCount(2);
+    fHelpTreeWidget->setColumnHidden(1,true);
+    QStringList labels;
+    labels << QString("Command") << QString("Description");
+    fHelpTreeWidget->setHeaderLabels(labels);
+
+    QList<QTreeWidgetItem *> items;
+    G4int treeSize = treeTop->GetTreeEntry();
+    QTreeWidgetItem * newItem;
+    for (int a=0;a<treeSize;a++) {
+      // Creating new item
+      QStringList stringList;
+      stringList << QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()).trimmed()  ;
+      stringList << QString((char*)(treeTop->GetTree(a+1)->GetTitle()).data()).trimmed()  ;
+
+      newItem = new QTreeWidgetItem(stringList);
+
+      // look for childs
+      CreateChildTree(newItem,treeTop->GetTree(a+1));
+      items.append(newItem);
+    }
+    fHelpTreeWidget->insertTopLevelItems(0, items);
+
+    //connecting callback
+    //  QSignalMapper signalMapper = new QSignalMapper(this);
+
+    connect(fHelpTreeWidget, SIGNAL(itemSelectionChanged ()),this, SLOT(helpTreeCallback()));  
+
+    // Set layouts
+    QHBoxLayout *splitterLayout = new QHBoxLayout;
+
+    QVBoxLayout *vLayout = new QVBoxLayout;
+
+    splitterLayout->addWidget(fHelpTreeWidget);
+    splitterLayout->addWidget(fHelpArea);
+    splitter->setLayout(splitterLayout);
+
+    vLayout->addWidget(splitter);
+    vLayout->addWidget(exitButton);
+    fHelpDialog->setLayout(vLayout);
+
+  }
 
   // Look for the choosen command "newCommand"
   size_t i = newCommand.index(" ");
-  G4UIcommand* expandCommand = NULL;
+  G4String targetCom="";
   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);
-  fHelpTreeWidget->setColumnHidden(1,true);
-  QStringList labels;
-  labels << QString("Summary") << QString("Description");
-  fHelpTreeWidget->setHeaderLabels(labels);
-
-  QList<QTreeWidgetItem *> items;
-  G4int treeSize = treeTop->GetTreeEntry();
-  QTreeWidgetItem * newItem;
-  for (int a=0;a<treeSize;a++) {
-    // Creating new item
-    QStringList stringList;
-    stringList << QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()).trimmed()  ;
-    stringList << QString((char*)(treeTop->GetTree(a+1)->GetTitle()).data()).trimmed()  ;
-
-    newItem = new QTreeWidgetItem(stringList);
-
-    // look for childs
-    CreateChildTree(newItem,treeTop->GetTree(a+1),expandCommand);
-    items.append(newItem);
-  }
-  fHelpTreeWidget->insertTopLevelItems(0, items);
-
-  //connecting callback
-  //  QSignalMapper signalMapper = new QSignalMapper(this);
-
-  connect(fHelpTreeWidget, SIGNAL(itemSelectionChanged ()),this, SLOT(helpTreeCallback()));  
-
-  // Set layouts
-  QHBoxLayout *splitterLayout = new QHBoxLayout;
-
-  QVBoxLayout *vLayout = new QVBoxLayout;
-
-  splitterLayout->addWidget(fHelpTreeWidget);
-  splitterLayout->addWidget(fHelpArea);
-  splitter->setLayout(splitterLayout);
-
-  vLayout->addWidget(splitter);
-  vLayout->addWidget(exitButton);
-  fHelpDialog->setLayout(vLayout);
-
+    targetCom = ModifyToFullPathCommand( newValue );
+    printf("test : av:%s-- ap:%s--\n",((char*)newValue.data()),((char*)targetCom.data()));
+  }
+  if (targetCom != "") {
+    QList<QTreeWidgetItem *> list = fHelpTreeWidget->findItems(QString(((char*)targetCom.data())),Qt::MatchFixedString,0);
+    for (int a=0;a<13;a++) {
+      printf("verif.... =%s= +%s+\n",fHelpTreeWidget->topLevelItem(a)->text(0).toStdString().c_str(),((char*)targetCom.data())); 
+    }
+
+    if (!list.isEmpty()) {
+      printf("found...........\n");
+      if (list.first()->childCount() >0)  
+        list.first()->setExpanded(true);
+
+      QList<QTreeWidgetItem *> selected = fHelpTreeWidget->selectedItems();
+      if (!selected.isEmpty()) {
+        for (int a=0;a<selected.count();a++) {
+          printf("unselect %d\n",selected.count());
+          //          selected.at(a)->setSelected(false);
+          selected.first()->setSelected(false);
+        }
+        printf("AAA\n");
+      }
+          printf("BB\n");
+      list.first()->setSelected(true);
+          printf("CC\n");
+
+      // Call the update of the right textArea
+      helpTreeCallback();
+          printf("DD\n");
+    }
+  }
   fHelpDialog->resize(800,600); 
   fHelpDialog->move(QPoint(400,150));
@@ -482,8 +456,9 @@
   fHelpDialog->raise();
   fHelpDialog->activateWindow();
-
-
-}
-void G4UIQt::CreateChildTree(QTreeWidgetItem *a_parent,G4UIcommandTree *a_commandTree,G4UIcommand* a_expandCommand) {
+}
+
+
+
+void G4UIQt::CreateChildTree(QTreeWidgetItem *a_parent,G4UIcommandTree *a_commandTree) {
 
   // Creating new item
@@ -499,5 +474,5 @@
     newItem = new QTreeWidgetItem(stringList);
 
-    CreateChildTree(newItem,a_commandTree->GetTree(a+1),a_expandCommand);
+    CreateChildTree(newItem,a_commandTree->GetTree(a+1));
     a_parent->addChild(newItem);
   }
@@ -510,56 +485,13 @@
     
     QStringList stringList;
-    stringList << QString((char*)(a_commandTree->GetCommand(a+1)->GetTitle()).data()).trimmed()  ;
+    stringList << QString((char*)(a_commandTree->GetCommand(a+1)->GetCommandPath()).data()).trimmed()  ;
     stringList << QString((char*)(a_commandTree->GetCommand(a+1)->GetCommandPath()).data()).trimmed()  ;
     newItem = new QTreeWidgetItem(stringList);
       
     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);
-      }
-    }
-  }
-}
-
-/**
-This callback is activated when user selected a item in the help tree
- */
-void G4UIQt::helpTreeCallback (
-)
-/***************************************************************************/
-/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
-{
-  G4bool GetHelpChoice(G4int&);
-  QTreeWidgetItem* item =  NULL;
-  if (!fHelpTreeWidget)
-    return ;
-
-  if (!fHelpArea)
-    return;
-  
-  item = fHelpTreeWidget->selectedItems().first();
-  if (!item)
-    return;
-  
-  G4UImanager* UI = G4UImanager::GetUIpointer();
-  if(UI==NULL) return;
-  G4UIcommandTree * treeTop = UI->GetTree();
-  G4UIcommand* command = treeTop->FindPath(item->text (1).toStdString().c_str());
-  if (command) {
-    fHelpArea->setText(GetCommandList(command));
-  } else {
-    // this is not a command, this is a sub directory
-    // We display the Title
-    fHelpArea->setText(item->text (1).toStdString().c_str());
-  }
-}
+    newItem->setExpanded(false);
+  }
+}
+
 
 /**
@@ -620,6 +552,26 @@
 }
 
-/***************************************************************************/
-void G4UIQt::showHelp (
+
+
+/***************************************************************************/
+void G4UIQt::expandHelpItem (
+ QTreeWidgetItem *a_parent
+,G4UIcommand* a_expandCommand
+)
+/***************************************************************************/
+/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
+{
+}
+
+
+
+/***************************************************************************/
+//
+//             SLOTS DEFINITIONS
+//
+/***************************************************************************/
+
+/***************************************************************************/
+void G4UIQt::showHelpCallback (
 )
 /***************************************************************************/
@@ -629,3 +581,89 @@
 }
 
+/***************************************************************************/
+void G4UIQt::clearButtonCallback (
+)
+/***************************************************************************/
+/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
+{
+  fTextArea->clear();
+}
+
+
+/**
+  Callback call when "click on a menu entry.
+  Send the associated command to geant4
+ */
+void G4UIQt::commandEnteredCallback (
+)
+/***************************************************************************/
+/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
+{
+  printf ("debug : callback\n");
+  G4String command (fCommandArea->text().toStdString().c_str());
+  if (fCommandArea->text().toStdString().c_str() != "") {
+    fCommandHistoryArea->append(fCommandArea->text());
+
+    if (command(0,4) != "help") {
+      ApplyShellCommand (command,exitSession,exitPause);
+    } else {
+      printf ("terminal help\n");
+      TerminalHelp(command);
+    }
+    if(exitSession==true) 
+      SessionTerminate();
+  }
+  fCommandArea->setText("");
+}
+
+/**
+  Callback call when "enter" clicked on the command zone.
+  Send the command to geant4
+ */
+void G4UIQt::buttonCallback (
+  const QString& a_command
+)
+/***************************************************************************/
+/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
+{
+  G4String ss = G4String(a_command.toStdString().c_str());
+  printf ("debug : execute:\n-%s- %d %d \n",ss.data(),exitSession,exitPause);
+  ApplyShellCommand(ss,exitSession,exitPause);
+  if(exitSession==true) 
+    SessionTerminate();
+}
+/**
+This callback is activated when user selected a item in the help tree
+ */
+void G4UIQt::helpTreeCallback (
+)
+/***************************************************************************/
+/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
+{
+  //  G4bool GetHelpChoice(G4int&);
+  QTreeWidgetItem* item =  NULL;
+  if (!fHelpTreeWidget)
+    return ;
+
+  if (!fHelpArea)
+    return;
+  
+  item = fHelpTreeWidget->selectedItems().first();
+  if (!item)
+    return;
+  
+  G4UImanager* UI = G4UImanager::GetUIpointer();
+  if(UI==NULL) return;
+  G4UIcommandTree * treeTop = UI->GetTree();
+  G4UIcommand* command = treeTop->FindPath(item->text (1).toStdString().c_str());
+  if (command) {
+    fHelpArea->setText(GetCommandList(command));
+  } else {
+    // this is not a command, this is a sub directory
+    // We display the Title
+    fHelpArea->setText(item->text (1).toStdString().c_str());
+  }
+}
+
+
 #endif
