Index: trunk/source/interfaces/History
===================================================================
--- trunk/source/interfaces/History	(revision 1243)
+++ trunk/source/interfaces/History	(revision 1248)
@@ -1,3 +1,3 @@
-$Id: History,v 1.125 2010/01/06 14:13:08 lgarnier Exp $
+$Id: History,v 1.127 2010/04/26 15:46:00 lgarnier Exp $
 -------------------------------------------------------------------
 
@@ -18,4 +18,12 @@
      ----------------------------------------------------------
 
+26 April, L. Garnier
+ - G4UIQt: Improvments
+ - G4Qt: Improvments
+
+15 April, 2010 G. Cosmo
+ - Fixed call to contructor QKeySequence() in G4UIQt:AddButton() to
+   allow for porting on gcc-4.5.
+
 6 January, 2010 L. Garnier
  - G4VBasicShell : improvments for command completion
Index: trunk/source/interfaces/basic/include/G4UIQt.hh
===================================================================
--- trunk/source/interfaces/basic/include/G4UIQt.hh	(revision 1243)
+++ trunk/source/interfaces/basic/include/G4UIQt.hh	(revision 1248)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4UIQt.hh,v 1.17 2010/01/06 14:13:08 lgarnier Exp $
-// GEANT4 tag $Name: laurent-QtUI_with_tabs_v1 $
+// $Id: G4UIQt.hh,v 1.18 2010/04/26 15:46:00 lgarnier Exp $
+// GEANT4 tag $Name:  $
 //
 #ifndef G4UIQt_h
@@ -129,9 +129,6 @@
   void SecondaryLoop(G4String); // a VIRER
   void CreateHelpWidget();
-#if QT_VERSION < 0x040000
-  QListView * CreateHelpTree();
-#else
-  QTreeWidget * CreateHelpTree();
-#endif
+  void InitHelpTree();
+  void FillHelpTree();
   void ExitHelp();
 
@@ -190,4 +187,5 @@
   QLabel *fEmptyViewerTabLabel;
   QSplitter * fMyVSplitter;
+  QSplitter * fHelpVSplitter;
 
 private slots :
@@ -205,5 +203,5 @@
   void CoutFilterCallback(const QString&);
   void TabCloseCallback(int);
-  void CurrentChangedCallback(int);
+  void ToolBoxActivated(int);
 };
 
Index: trunk/source/interfaces/basic/src/G4UIQt.cc
===================================================================
--- trunk/source/interfaces/basic/src/G4UIQt.cc	(revision 1243)
+++ trunk/source/interfaces/basic/src/G4UIQt.cc	(revision 1248)
@@ -25,6 +25,6 @@
 //
 //
-// $Id: G4UIQt.cc,v 1.30 2010/01/06 14:13:08 lgarnier Exp $
-// GEANT4 tag $Name: laurent-QtUI_with_tabs_v1 $
+// $Id: G4UIQt.cc,v 1.33 2010/04/27 13:49:02 lgarnier Exp $
+// GEANT4 tag $Name:  $
 //
 // L. Garnier
@@ -60,5 +60,5 @@
 #include <qtabwidget.h>
 #include <qtabbar.h>
-#include <qresizeevent>
+#include <QResizeEvent>
 #include <qstringlist.h>
 
@@ -109,4 +109,5 @@
 )
 :fG4cout("")
+,fHelpTreeWidget(NULL)
 ,fHelpTBWidget(NULL)
 ,fHistoryTBWidget(NULL)
@@ -156,5 +157,5 @@
 
 #ifdef G4DEBUG_INTERFACES_BASIC
-  printf("G4UIQt::Initialise after main window creation UImanager:%d G4UIQt(this) : %d+++++++++++\n",UI,this);
+  printf("G4UIQt::Initialise after main window creation +++++++++++\n");
 #endif
 
@@ -230,6 +231,6 @@
 
   // the splitter 
-  fToolBox->addItem(fVisParametersTBWidget,"Vis parameters");
-  fToolBox->addItem(fViewComponentsTBWidget,"Viewer components");
+  //  fToolBox->addItem(fVisParametersTBWidget,"Vis parameters");
+  //  fToolBox->addItem(fViewComponentsTBWidget,"Viewer components");
   fToolBox->addItem(fHelpTBWidget,"Help");
   fToolBox->addItem(fCoutTBWidget,"Cout");
@@ -301,7 +302,10 @@
 #endif
 
+  // Connect signal
   connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback()));
   connect(fTabWidget,   SIGNAL(tabCloseRequested(int)), this, SLOT(TabCloseCallback(int)));
   connect(fTabWidget, SIGNAL(currentChanged ( int ) ), SLOT(UpdateTabWidget(int)));
+  connect(fToolBox, SIGNAL(currentChanged(int)), SLOT(ToolBoxActivated(int)));
+
   if(UI!=NULL) UI->SetCoutDestination(this);  // TO KEEP
 
@@ -397,10 +401,10 @@
   QHBoxLayout *helpLayout = new QHBoxLayout(helpWidget);
   QVBoxLayout *vLayout = new QVBoxLayout(fHelpTBWidget);
-  QSplitter *splitter = new QSplitter(Qt::Horizontal,fHelpTBWidget);
+  fHelpVSplitter = new QSplitter(Qt::Horizontal,fHelpTBWidget);
 #else
   QWidget *helpWidget = new QWidget();
   QHBoxLayout *helpLayout = new QHBoxLayout();
   QVBoxLayout *vLayout = new QVBoxLayout();
-  QSplitter *splitter = new QSplitter(Qt::Horizontal);
+  fHelpVSplitter = new QSplitter(Qt::Horizontal);
 #endif
   fHelpLine = new QLineEdit(fHelpTBWidget);
@@ -413,13 +417,8 @@
 #endif
   
-  // the help tree
-#if QT_VERSION < 0x040000
-  fHelpTreeWidget = new QListView(splitter);
-#else
-  fHelpTreeWidget = new QTreeWidget();
-#endif
-  fHelpTreeWidget = CreateHelpTree();
-  
-  fHelpArea = new QTextEdit(splitter);
+  // Create Help tree
+  FillHelpTree();
+  
+  fHelpArea = new QTextEdit(fHelpVSplitter);
   fHelpArea->setReadOnly(true);
   
@@ -427,7 +426,8 @@
   
 #if QT_VERSION >= 0x040000
-  if (fHelpTreeWidget)
-    splitter->addWidget(fHelpTreeWidget);
-  splitter->addWidget(fHelpArea);
+  if (fHelpTreeWidget) {
+    fHelpVSplitter->addWidget(fHelpTreeWidget);
+  }
+  fHelpVSplitter->addWidget(fHelpArea);
 #endif
   
@@ -435,5 +435,5 @@
 #if QT_VERSION >= 0x040000
   vLayout->addWidget(helpWidget);
-  vLayout->addWidget(splitter,1);
+  vLayout->addWidget(fHelpVSplitter,1);
 #endif
   
@@ -448,5 +448,5 @@
   list.append( 50 );
   list.append( 50 );
-  splitter->setSizes(list);
+  fHelpVSplitter->setSizes(list);
   
 #if QT_VERSION >= 0x040000
@@ -910,10 +910,10 @@
   QSignalMapper *signalMapper = new QSignalMapper(this);
 #if QT_VERSION < 0x030200
-  QAction *action = new QAction(QString(aLabel),QString(aLabel),QKeySequence::QKeySequence (),signalMapper, SLOT(map()));
+  QAction *action = new QAction(QString(aLabel),QString(aLabel),QKeySequence(),signalMapper, SLOT(map()));
   action->addTo(parent);
  connect(action,SIGNAL(activated()),signalMapper,SLOT(map()));
 
 #elif QT_VERSION < 0x040000
-  QAction *action = new QAction(QString(aLabel),QKeySequence::QKeySequence (),signalMapper, SLOT(map()));
+  QAction *action = new QAction(QString(aLabel),QKeySequence(),signalMapper, SLOT(map()));
   action->addTo(parent);
  connect(action,SIGNAL(activated()),signalMapper,SLOT(map()));
@@ -947,5 +947,5 @@
     }
 #ifdef G4DEBUG_INTERFACES_BASIC
-  printf("G4UIQt::ActivateCommand found : %d \n",targetCom.data());
+  printf("G4UIQt::ActivateCommand found : %s \n",targetCom.data());
 #endif
   if (targetCom != "") {
@@ -964,14 +964,18 @@
  */
 
-#if QT_VERSION < 0x040000
-QListView * G4UIQt::CreateHelpTree()
-#else
-QTreeWidget * G4UIQt::CreateHelpTree()
-#endif
-{
-  G4UImanager* UI = G4UImanager::GetUIpointer();
-  if(UI==NULL) return NULL;
-  G4UIcommandTree * treeTop = UI->GetTree();
-
+void G4UIQt::InitHelpTree()
+{
+
+#ifdef G4DEBUG_INTERFACES_BASIC
+  printf("G4UIQt::InitHelpTree\n");
+#endif
+
+  if (! fHelpTreeWidget ) {
+#if QT_VERSION < 0x040000
+    fHelpTreeWidget = new QListView(splitter);
+#else
+    fHelpTreeWidget = new QTreeWidget();
+#endif
+  }
 
   // build widget
@@ -988,9 +992,49 @@
 #endif
 
+
+#if QT_VERSION < 0x040000
+  connect(fHelpTreeWidget, SIGNAL(selectionChanged ()),this, SLOT(HelpTreeClicCallback()));  
+  connect(fHelpTreeWidget, SIGNAL(doubleClicked (QListViewItem*)),this, SLOT(HelpTreeDoubleClicCallback()));
+#else
+  connect(fHelpTreeWidget, SIGNAL(itemSelectionChanged ()),this, SLOT(HelpTreeClicCallback()));  
+  connect(fHelpTreeWidget, SIGNAL(itemDoubleClicked (QTreeWidgetItem*,int)),this, SLOT(HelpTreeDoubleClicCallback()));  
+#endif
+
+}
+/**
+   Create the help tree widget
+   @param parent : parent of tree widget
+   @return the widget containing the tree or NULL if it could not have beeen created
+ */
+
+void G4UIQt::FillHelpTree()
+{
+#ifdef G4DEBUG_INTERFACES_BASIC
+  printf("G4UIQt::FillHelpTree\n");
+#endif
+
+  QString defaultSelection = "";
+
+  if (! fHelpTreeWidget ) {
+    InitHelpTree();
+  } else {
+    // Memorise previous selection
+    defaultSelection = fHelpTreeWidget->currentItem()->text(0);
+  }
+  G4UImanager* UI = G4UImanager::GetUIpointer();
+  if(UI==NULL) return;
+  G4UIcommandTree * treeTop = UI->GetTree();
+
+
+  // Remove all previous children
+  fHelpTreeWidget->clear();
+
   G4int treeSize = treeTop->GetTreeEntry();
 #if QT_VERSION < 0x040000
   QListViewItem * newItem;
+  QListViewItem * defaultItem;
 #else
   QTreeWidgetItem * newItem;
+  QTreeWidgetItem * defaultItem;
 #endif
   for (int a=0;a<treeSize;a++) {
@@ -1009,16 +1053,15 @@
     CreateChildTree(newItem,treeTop->GetTree(a+1));
     //      items.append(newItem);
-  }
-
-
-#if QT_VERSION < 0x040000
-  connect(fHelpTreeWidget, SIGNAL(selectionChanged ()),this, SLOT(HelpTreeClicCallback()));  
-  connect(fHelpTreeWidget, SIGNAL(doubleClicked (QListViewItem*)),this, SLOT(HelpTreeDoubleClicCallback()));
-#else
-  connect(fHelpTreeWidget, SIGNAL(itemSelectionChanged ()),this, SLOT(HelpTreeClicCallback()));  
-  connect(fHelpTreeWidget, SIGNAL(itemDoubleClicked (QTreeWidgetItem*,int)),this, SLOT(HelpTreeDoubleClicCallback()));  
-#endif
-
-  return fHelpTreeWidget;
+    if (defaultSelection != "") {
+      defaultItem = FindTreeItem(newItem,defaultSelection);
+      if (defaultItem != NULL ) {
+        defaultItem->setSelected(true);
+        while (defaultItem->parent() != NULL) {
+          defaultItem = defaultItem->parent();
+          defaultItem->setExpanded(true);
+        }
+      }
+    }
+  }
 }
 
@@ -1091,5 +1134,5 @@
 }
 
-
+ 
 /** Find a treeItemWidget in the help tree
     @param aCommand item's String to look for
@@ -1424,7 +1467,11 @@
       ActivateCommand(command);
     }
+    // Rebuild help tree
+    FillHelpTree();
+
     if(exitSession==true) 
       SessionTerminate();
   }
+
 }
 
@@ -1444,4 +1491,8 @@
 #endif
   ApplyShellCommand(ss,exitSession,exitPause);
+
+  // Rebuild help tree
+  FillHelpTree();
+
   if(exitSession==true) 
     SessionTerminate();
@@ -1635,5 +1686,7 @@
     fHelpTreeWidget->removeColumn(0);
 #endif
-    CreateHelpTree();
+
+    FillHelpTree();
+
     return;
   } else {
@@ -1913,9 +1966,14 @@
 
 
-void G4UIQt::CurrentChangedCallback(int a){
-#ifdef G4DEBUG_INTERFACES_BASIC
-  printf("G4UIQt::CurrentChangeCallback   %d ---------------------------------\n",a);
-#endif
-
+void G4UIQt::ToolBoxActivated(int a){
+
+  if (fToolBox->widget(a) == fHelpTBWidget) {
+    // Rebuild the help tree
+    FillHelpTree();
+
+#ifdef G4DEBUG_INTERFACES_BASIC
+    printf("G4UIQt::CurrentChangeCallback   %d ---------------------------------\n",a);
+#endif
+  }
 }
 
@@ -1927,5 +1985,5 @@
   if (currentWidget()) {
 #ifdef G4DEBUG_INTERFACES_BASIC
-    printf("G4QTabWidget::paintEvent repaint type : %d -- rect %d %d  region:%d %d page : %d %d  ________________________ for = %d i= %d w: %d\n", event->type(),event->rect().height(),event->rect().width(),event->region().boundingRect().width(),event->region().boundingRect().height(),currentWidget()->width(),currentWidget()->height(),this,currentIndex(),currentWidget());
+    printf("G4QTabWidget::paintEvent repaint type : %d -- rect %d %d  region:%d %d page : %d %d  ________________________  i= %d\n", event->type(),event->rect().height(),event->rect().width(),event->region().boundingRect().width(),event->region().boundingRect().height(),currentWidget()->width(),currentWidget()->height(),currentIndex());
 #endif
     if ( isTabSelected()) {
Index: trunk/source/interfaces/common/src/G4Qt.cc
===================================================================
--- trunk/source/interfaces/common/src/G4Qt.cc	(revision 1243)
+++ trunk/source/interfaces/common/src/G4Qt.cc	(revision 1248)
@@ -25,5 +25,5 @@
 //
 //
-// $Id: G4Qt.cc,v 1.15 2010/01/06 14:07:34 lgarnier Exp $
+// $Id: G4Qt.cc,v 1.16 2010/04/26 15:46:00 lgarnier Exp $
 // GEANT4 tag $Name:  $
 //
@@ -68,7 +68,4 @@
     instance = new G4Qt(a_argn,a_args,a_class);
   }
-#ifdef G4DEBUG_INTERFACES_COMMON
-    printf("G4Qt::getInstance :%d\n",instance);
-#endif
   return instance;
 }
@@ -155,5 +152,5 @@
 #ifdef G4DEBUG_INTERFACES_COMMON
   if (qApp) {
-    printf("G4Qt::qApp exist adress:%d\n",this);
+    printf("G4Qt::qApp already exist\n");
   }  else {
     printf("G4Qt::qApp not exist\n");
