Changeset 1248 for trunk/source


Ignore:
Timestamp:
May 5, 2010, 4:26:13 PM (14 years ago)
Author:
garnier
Message:

test de helpTree update

Location:
trunk/source/interfaces
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/interfaces/History

    r1228 r1248  
    1 $Id: History,v 1.125 2010/01/06 14:13:08 lgarnier Exp $
     1$Id: History,v 1.127 2010/04/26 15:46:00 lgarnier Exp $
    22-------------------------------------------------------------------
    33
     
    1818     ----------------------------------------------------------
    1919
     2026 April, L. Garnier
     21 - G4UIQt: Improvments
     22 - G4Qt: Improvments
     23
     2415 April, 2010 G. Cosmo
     25 - Fixed call to contructor QKeySequence() in G4UIQt:AddButton() to
     26   allow for porting on gcc-4.5.
     27
    20286 January, 2010 L. Garnier
    2129 - G4VBasicShell : improvments for command completion
  • trunk/source/interfaces/basic/include/G4UIQt.hh

    r1239 r1248  
    2525//
    2626//
    27 // $Id: G4UIQt.hh,v 1.17 2010/01/06 14:13:08 lgarnier Exp $
    28 // GEANT4 tag $Name: laurent-QtUI_with_tabs_v1 $
     27// $Id: G4UIQt.hh,v 1.18 2010/04/26 15:46:00 lgarnier Exp $
     28// GEANT4 tag $Name: $
    2929//
    3030#ifndef G4UIQt_h
     
    129129  void SecondaryLoop(G4String); // a VIRER
    130130  void CreateHelpWidget();
    131 #if QT_VERSION < 0x040000
    132   QListView * CreateHelpTree();
    133 #else
    134   QTreeWidget * CreateHelpTree();
    135 #endif
     131  void InitHelpTree();
     132  void FillHelpTree();
    136133  void ExitHelp();
    137134
     
    190187  QLabel *fEmptyViewerTabLabel;
    191188  QSplitter * fMyVSplitter;
     189  QSplitter * fHelpVSplitter;
    192190
    193191private slots :
     
    205203  void CoutFilterCallback(const QString&);
    206204  void TabCloseCallback(int);
    207   void CurrentChangedCallback(int);
     205  void ToolBoxActivated(int);
    208206};
    209207
  • trunk/source/interfaces/basic/src/G4UIQt.cc

    r1243 r1248  
    2525//
    2626//
    27 // $Id: G4UIQt.cc,v 1.30 2010/01/06 14:13:08 lgarnier Exp $
    28 // GEANT4 tag $Name: laurent-QtUI_with_tabs_v1 $
     27// $Id: G4UIQt.cc,v 1.33 2010/04/27 13:49:02 lgarnier Exp $
     28// GEANT4 tag $Name: $
    2929//
    3030// L. Garnier
     
    6060#include <qtabwidget.h>
    6161#include <qtabbar.h>
    62 #include <qresizeevent>
     62#include <QResizeEvent>
    6363#include <qstringlist.h>
    6464
     
    109109)
    110110:fG4cout("")
     111,fHelpTreeWidget(NULL)
    111112,fHelpTBWidget(NULL)
    112113,fHistoryTBWidget(NULL)
     
    156157
    157158#ifdef G4DEBUG_INTERFACES_BASIC
    158   printf("G4UIQt::Initialise after main window creation UImanager:%d G4UIQt(this) : %d+++++++++++\n",UI,this);
     159  printf("G4UIQt::Initialise after main window creation +++++++++++\n");
    159160#endif
    160161
     
    230231
    231232  // the splitter
    232   fToolBox->addItem(fVisParametersTBWidget,"Vis parameters");
    233   fToolBox->addItem(fViewComponentsTBWidget,"Viewer components");
     233  //  fToolBox->addItem(fVisParametersTBWidget,"Vis parameters");
     234  //  fToolBox->addItem(fViewComponentsTBWidget,"Viewer components");
    234235  fToolBox->addItem(fHelpTBWidget,"Help");
    235236  fToolBox->addItem(fCoutTBWidget,"Cout");
     
    301302#endif
    302303
     304  // Connect signal
    303305  connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback()));
    304306  connect(fTabWidget,   SIGNAL(tabCloseRequested(int)), this, SLOT(TabCloseCallback(int)));
    305307  connect(fTabWidget, SIGNAL(currentChanged ( int ) ), SLOT(UpdateTabWidget(int)));
     308  connect(fToolBox, SIGNAL(currentChanged(int)), SLOT(ToolBoxActivated(int)));
     309
    306310  if(UI!=NULL) UI->SetCoutDestination(this);  // TO KEEP
    307311
     
    397401  QHBoxLayout *helpLayout = new QHBoxLayout(helpWidget);
    398402  QVBoxLayout *vLayout = new QVBoxLayout(fHelpTBWidget);
    399   QSplitter *splitter = new QSplitter(Qt::Horizontal,fHelpTBWidget);
     403  fHelpVSplitter = new QSplitter(Qt::Horizontal,fHelpTBWidget);
    400404#else
    401405  QWidget *helpWidget = new QWidget();
    402406  QHBoxLayout *helpLayout = new QHBoxLayout();
    403407  QVBoxLayout *vLayout = new QVBoxLayout();
    404   QSplitter *splitter = new QSplitter(Qt::Horizontal);
     408  fHelpVSplitter = new QSplitter(Qt::Horizontal);
    405409#endif
    406410  fHelpLine = new QLineEdit(fHelpTBWidget);
     
    413417#endif
    414418 
    415   // the help tree
    416 #if QT_VERSION < 0x040000
    417   fHelpTreeWidget = new QListView(splitter);
    418 #else
    419   fHelpTreeWidget = new QTreeWidget();
    420 #endif
    421   fHelpTreeWidget = CreateHelpTree();
    422  
    423   fHelpArea = new QTextEdit(splitter);
     419  // Create Help tree
     420  FillHelpTree();
     421 
     422  fHelpArea = new QTextEdit(fHelpVSplitter);
    424423  fHelpArea->setReadOnly(true);
    425424 
     
    427426 
    428427#if QT_VERSION >= 0x040000
    429   if (fHelpTreeWidget)
    430     splitter->addWidget(fHelpTreeWidget);
    431   splitter->addWidget(fHelpArea);
     428  if (fHelpTreeWidget) {
     429    fHelpVSplitter->addWidget(fHelpTreeWidget);
     430  }
     431  fHelpVSplitter->addWidget(fHelpArea);
    432432#endif
    433433 
     
    435435#if QT_VERSION >= 0x040000
    436436  vLayout->addWidget(helpWidget);
    437   vLayout->addWidget(splitter,1);
     437  vLayout->addWidget(fHelpVSplitter,1);
    438438#endif
    439439 
     
    448448  list.append( 50 );
    449449  list.append( 50 );
    450   splitter->setSizes(list);
     450  fHelpVSplitter->setSizes(list);
    451451 
    452452#if QT_VERSION >= 0x040000
     
    910910  QSignalMapper *signalMapper = new QSignalMapper(this);
    911911#if QT_VERSION < 0x030200
    912   QAction *action = new QAction(QString(aLabel),QString(aLabel),QKeySequence::QKeySequence (),signalMapper, SLOT(map()));
     912  QAction *action = new QAction(QString(aLabel),QString(aLabel),QKeySequence(),signalMapper, SLOT(map()));
    913913  action->addTo(parent);
    914914 connect(action,SIGNAL(activated()),signalMapper,SLOT(map()));
    915915
    916916#elif QT_VERSION < 0x040000
    917   QAction *action = new QAction(QString(aLabel),QKeySequence::QKeySequence (),signalMapper, SLOT(map()));
     917  QAction *action = new QAction(QString(aLabel),QKeySequence(),signalMapper, SLOT(map()));
    918918  action->addTo(parent);
    919919 connect(action,SIGNAL(activated()),signalMapper,SLOT(map()));
     
    947947    }
    948948#ifdef G4DEBUG_INTERFACES_BASIC
    949   printf("G4UIQt::ActivateCommand found : %d \n",targetCom.data());
     949  printf("G4UIQt::ActivateCommand found : %s \n",targetCom.data());
    950950#endif
    951951  if (targetCom != "") {
     
    964964 */
    965965
    966 #if QT_VERSION < 0x040000
    967 QListView * G4UIQt::CreateHelpTree()
    968 #else
    969 QTreeWidget * G4UIQt::CreateHelpTree()
    970 #endif
    971 {
    972   G4UImanager* UI = G4UImanager::GetUIpointer();
    973   if(UI==NULL) return NULL;
    974   G4UIcommandTree * treeTop = UI->GetTree();
    975 
     966void G4UIQt::InitHelpTree()
     967{
     968
     969#ifdef G4DEBUG_INTERFACES_BASIC
     970  printf("G4UIQt::InitHelpTree\n");
     971#endif
     972
     973  if (! fHelpTreeWidget ) {
     974#if QT_VERSION < 0x040000
     975    fHelpTreeWidget = new QListView(splitter);
     976#else
     977    fHelpTreeWidget = new QTreeWidget();
     978#endif
     979  }
    976980
    977981  // build widget
     
    988992#endif
    989993
     994
     995#if QT_VERSION < 0x040000
     996  connect(fHelpTreeWidget, SIGNAL(selectionChanged ()),this, SLOT(HelpTreeClicCallback())); 
     997  connect(fHelpTreeWidget, SIGNAL(doubleClicked (QListViewItem*)),this, SLOT(HelpTreeDoubleClicCallback()));
     998#else
     999  connect(fHelpTreeWidget, SIGNAL(itemSelectionChanged ()),this, SLOT(HelpTreeClicCallback())); 
     1000  connect(fHelpTreeWidget, SIGNAL(itemDoubleClicked (QTreeWidgetItem*,int)),this, SLOT(HelpTreeDoubleClicCallback())); 
     1001#endif
     1002
     1003}
     1004/**
     1005   Create the help tree widget
     1006   @param parent : parent of tree widget
     1007   @return the widget containing the tree or NULL if it could not have beeen created
     1008 */
     1009
     1010void G4UIQt::FillHelpTree()
     1011{
     1012#ifdef G4DEBUG_INTERFACES_BASIC
     1013  printf("G4UIQt::FillHelpTree\n");
     1014#endif
     1015
     1016  QString defaultSelection = "";
     1017
     1018  if (! fHelpTreeWidget ) {
     1019    InitHelpTree();
     1020  } else {
     1021    // Memorise previous selection
     1022    defaultSelection = fHelpTreeWidget->currentItem()->text(0);
     1023  }
     1024  G4UImanager* UI = G4UImanager::GetUIpointer();
     1025  if(UI==NULL) return;
     1026  G4UIcommandTree * treeTop = UI->GetTree();
     1027
     1028
     1029  // Remove all previous children
     1030  fHelpTreeWidget->clear();
     1031
    9901032  G4int treeSize = treeTop->GetTreeEntry();
    9911033#if QT_VERSION < 0x040000
    9921034  QListViewItem * newItem;
     1035  QListViewItem * defaultItem;
    9931036#else
    9941037  QTreeWidgetItem * newItem;
     1038  QTreeWidgetItem * defaultItem;
    9951039#endif
    9961040  for (int a=0;a<treeSize;a++) {
     
    10091053    CreateChildTree(newItem,treeTop->GetTree(a+1));
    10101054    //      items.append(newItem);
    1011   }
    1012 
    1013 
    1014 #if QT_VERSION < 0x040000
    1015   connect(fHelpTreeWidget, SIGNAL(selectionChanged ()),this, SLOT(HelpTreeClicCallback())); 
    1016   connect(fHelpTreeWidget, SIGNAL(doubleClicked (QListViewItem*)),this, SLOT(HelpTreeDoubleClicCallback()));
    1017 #else
    1018   connect(fHelpTreeWidget, SIGNAL(itemSelectionChanged ()),this, SLOT(HelpTreeClicCallback())); 
    1019   connect(fHelpTreeWidget, SIGNAL(itemDoubleClicked (QTreeWidgetItem*,int)),this, SLOT(HelpTreeDoubleClicCallback())); 
    1020 #endif
    1021 
    1022   return fHelpTreeWidget;
     1055    if (defaultSelection != "") {
     1056      defaultItem = FindTreeItem(newItem,defaultSelection);
     1057      if (defaultItem != NULL ) {
     1058        defaultItem->setSelected(true);
     1059        while (defaultItem->parent() != NULL) {
     1060          defaultItem = defaultItem->parent();
     1061          defaultItem->setExpanded(true);
     1062        }
     1063      }
     1064    }
     1065  }
    10231066}
    10241067
     
    10911134}
    10921135
    1093 
     1136 
    10941137/** Find a treeItemWidget in the help tree
    10951138    @param aCommand item's String to look for
     
    14241467      ActivateCommand(command);
    14251468    }
     1469    // Rebuild help tree
     1470    FillHelpTree();
     1471
    14261472    if(exitSession==true)
    14271473      SessionTerminate();
    14281474  }
     1475
    14291476}
    14301477
     
    14441491#endif
    14451492  ApplyShellCommand(ss,exitSession,exitPause);
     1493
     1494  // Rebuild help tree
     1495  FillHelpTree();
     1496
    14461497  if(exitSession==true)
    14471498    SessionTerminate();
     
    16351686    fHelpTreeWidget->removeColumn(0);
    16361687#endif
    1637     CreateHelpTree();
     1688
     1689    FillHelpTree();
     1690
    16381691    return;
    16391692  } else {
     
    19131966
    19141967
    1915 void G4UIQt::CurrentChangedCallback(int a){
    1916 #ifdef G4DEBUG_INTERFACES_BASIC
    1917   printf("G4UIQt::CurrentChangeCallback   %d ---------------------------------\n",a);
    1918 #endif
    1919 
     1968void G4UIQt::ToolBoxActivated(int a){
     1969
     1970  if (fToolBox->widget(a) == fHelpTBWidget) {
     1971    // Rebuild the help tree
     1972    FillHelpTree();
     1973
     1974#ifdef G4DEBUG_INTERFACES_BASIC
     1975    printf("G4UIQt::CurrentChangeCallback   %d ---------------------------------\n",a);
     1976#endif
     1977  }
    19201978}
    19211979
     
    19271985  if (currentWidget()) {
    19281986#ifdef G4DEBUG_INTERFACES_BASIC
    1929     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());
     1987    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());
    19301988#endif
    19311989    if ( isTabSelected()) {
  • trunk/source/interfaces/common/src/G4Qt.cc

    r1243 r1248  
    2525//
    2626//
    27 // $Id: G4Qt.cc,v 1.15 2010/01/06 14:07:34 lgarnier Exp $
     27// $Id: G4Qt.cc,v 1.16 2010/04/26 15:46:00 lgarnier Exp $
    2828// GEANT4 tag $Name:  $
    2929//
     
    6868    instance = new G4Qt(a_argn,a_args,a_class);
    6969  }
    70 #ifdef G4DEBUG_INTERFACES_COMMON
    71     printf("G4Qt::getInstance :%d\n",instance);
    72 #endif
    7370  return instance;
    7471}
     
    155152#ifdef G4DEBUG_INTERFACES_COMMON
    156153  if (qApp) {
    157     printf("G4Qt::qApp exist adress:%d\n",this);
     154    printf("G4Qt::qApp already exist\n");
    158155  }  else {
    159156    printf("G4Qt::qApp not exist\n");
Note: See TracChangeset for help on using the changeset viewer.