source: trunk/source/interfaces/basic/src/G4UIQt.cc @ 1250

Last change on this file since 1250 was 1250, checked in by garnier, 14 years ago

HelpTree compil mais ne marche pas

  • Property svn:mime-type set to text/cpp
File size: 55.7 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26//
27// $Id: G4UIQt.cc,v 1.33 2010/04/27 13:49:02 lgarnier Exp $
28// GEANT4 tag $Name:  $
29//
30// L. Garnier
31
32#ifdef G4UI_BUILD_QT_SESSION
33
34#include "G4Types.hh"
35
36#include <string.h>
37
38#include "G4UIQt.hh"
39#include "G4UImanager.hh"
40#include "G4StateManager.hh"
41#include "G4UIcommandTree.hh"
42#include "G4UIcommandStatus.hh"
43
44#include "G4Qt.hh"
45
46#include <qapplication.h>
47#include <qlineedit.h>
48#include <qwidget.h>
49#include <qmenubar.h>
50#include <qlayout.h>
51#include <qpushbutton.h>
52#include <qlabel.h>
53#include <qtoolbox.h>
54#include <qsplitter.h>
55#include <qscrollbar.h>
56#include <qdialog.h>
57#include <qevent.h>
58#include <qtextedit.h>
59#include <qsignalmapper.h>
60#include <qtabwidget.h>
61#include <qtabbar.h>
62#include <QResizeEvent>
63#include <qstringlist.h>
64
65#include <qmainwindow.h>
66#if QT_VERSION >= 0x040000
67#include <qmenu.h>
68#include <qlistwidget.h>
69#include <qtreewidget.h>
70#else
71#include <qaction.h>
72#include <qheader.h>
73#include <qlistview.h>
74#include <qpopupmenu.h>
75#include <qwidgetlist.h>
76#endif
77
78
79
80#include <stdlib.h>
81
82// Pourquoi Static et non  variables de classe ?
83static G4bool exitSession = true;
84static G4bool exitPause = true;
85
86/**   Build a Qt window with a menubar, output area and promt area<br>
87<pre>
88   +-----------------------+
89   |exit menu|             |
90   |                       |
91   | +-------------------+ |
92   | |                   | |
93   | |  Output area      | |
94   | |                   | |
95   | +-------------------+ |
96   |      | clear |        |
97   | +-------------------+ |
98   | |  promt history    | |
99   | +-------------------+ |
100   | +-------------------+ |
101   | |> promt area       | |
102   | +-------------------+ |
103   +-----------------------+
104</pre>
105*/
106G4UIQt::G4UIQt (
107 int argc
108,char** argv
109)
110:fG4cout("")
111,fHelpTreeWidget(NULL)
112,fHelpTBWidget(NULL)
113,fHistoryTBWidget(NULL)
114,fCoutTBWidget(NULL)
115,fVisParametersTBWidget(NULL)
116,fViewComponentsTBWidget(NULL)
117,fTabWidget(NULL)
118,fCoutText("Output")
119{
120
121  G4Qt* interactorManager = G4Qt::getInstance (argc,argv,(char*)"Qt");
122  if (!(QApplication*)interactorManager->GetMainInteractor()) {
123    G4cout        << "G4UIQt : Unable to init Qt. Aborted" << G4endl;
124  }
125 
126  G4UImanager* UI = G4UImanager::GetUIpointer();
127  if(UI!=NULL) UI->SetSession(this);
128
129  // Check if already define in external app QMainWindow
130  bool found = false;
131#if QT_VERSION < 0x040000
132  // theses lines does nothing exept this one "GLWindow = new QDialog(0..."
133  // but if I comment them, it doesn't work...
134  QWidgetList  *list = QApplication::allWidgets();
135  QWidgetListIt it( *list );         // iterate over the widgets
136  QWidget * widget;
137  while ( (widget=it.current()) != 0 ) {  // for each widget...
138    ++it;
139    if ((found== false) && (widget->inherits("QMainWindow"))) {
140      found = true;
141    }
142  }
143  delete list;                      // delete the list, not the widgets
144#else
145  foreach (QWidget *widget, QApplication::allWidgets()) {
146    if ((found== false) && (widget->inherits("QMainWindow"))) {
147      found = true;
148    }
149  }
150#endif
151
152  if (found) {
153    G4cout        << "G4UIQt : Found an external App with a QMainWindow already defined. Aborted" << G4endl;
154    return ;
155  }
156  fMainWindow = new QMainWindow();
157
158#ifdef G4DEBUG_INTERFACES_BASIC
159  printf("G4UIQt::Initialise after main window creation +++++++++++\n");
160#endif
161
162  QWidget *mainWidget = new QWidget(fMainWindow);
163#if QT_VERSION < 0x040000
164  fMyVSplitter = new QSplitter(Qt::Horizontal,fMainWindow);
165  fToolBox = new QToolBox(Qt::Horizontal,fMyVSplitter);
166#else
167  fMyVSplitter = new QSplitter(Qt::Horizontal,fMainWindow);
168  fToolBox = new QToolBox(mainWidget);
169#endif
170
171  // Set layouts
172
173  // Add a empty tabwidget
174  fTabWidget = new G4QTabWidget(fMyVSplitter);
175#if QT_VERSION >= 0x040500
176  fTabWidget->setTabsClosable (true);
177#endif
178
179#if QT_VERSION >= 0x040200
180  fTabWidget->setUsesScrollButtons (true);
181#endif
182
183  QWidget* commandLineWidget = new QWidget(mainWidget);
184#if QT_VERSION < 0x040000
185  QVBoxLayout *layoutCommandLine = new QVBoxLayout(commandLineWidget);
186#else
187  QVBoxLayout *layoutCommandLine = new QVBoxLayout();
188#endif
189
190  // fill them
191
192  fCommandLabel = new QLabel("",commandLineWidget);
193
194  fCommandArea = new QLineEdit(commandLineWidget);
195  fCommandArea->installEventFilter(this);
196#if QT_VERSION < 0x040000
197  fCommandArea->setActiveWindow();
198#else
199  fCommandArea->activateWindow();
200#endif
201
202#if QT_VERSION < 0x040000
203  fCommandArea->setFocusPolicy ( QWidget::StrongFocus );
204  fCommandArea->setFocus();
205#else
206  fCommandArea->setFocusPolicy ( Qt::StrongFocus );
207  fCommandArea->setFocus(Qt::TabFocusReason);
208#endif
209
210
211
212  layoutCommandLine->addWidget(fCommandLabel);
213  layoutCommandLine->addWidget(fCommandArea);
214#if QT_VERSION >= 0x040000
215  QVBoxLayout *mainLayout = new QVBoxLayout();
216#else
217  QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget);
218#endif
219
220  fHelpTBWidget = new QWidget(fToolBox);
221  fHistoryTBWidget = new QWidget(fToolBox);
222  fCoutTBWidget = new QWidget(fToolBox);
223  fVisParametersTBWidget = new QWidget(fToolBox);
224  fViewComponentsTBWidget = new QWidget(fToolBox);
225 
226  CreateVisParametersTBWidget();
227  CreateViewComponentsTBWidget();
228  CreateHelpTBWidget();
229  CreateCoutTBWidget();
230  CreateHistoryTBWidget();
231
232  // the splitter
233  //  fToolBox->addItem(fVisParametersTBWidget,"Vis parameters");
234  //  fToolBox->addItem(fViewComponentsTBWidget,"Viewer components");
235  fToolBox->addItem(fHelpTBWidget,"Help");
236  fToolBox->addItem(fCoutTBWidget,"Cout");
237  fToolBox->addItem(fHistoryTBWidget,"History");
238
239
240
241  fToolBox->setSizePolicy (QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed));
242  fTabWidget->setSizePolicy (QSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum));
243
244  QSizePolicy policy = fTabWidget->sizePolicy();
245  policy.setHorizontalStretch(1);
246  policy.setVerticalStretch(1);
247  fTabWidget->setSizePolicy(policy);
248
249  fEmptyViewerTabLabel = new QLabel("         If you want to have a Viewer, please use /vis/open commands. ");
250
251  // Only at creation. Will be set visible when sessionStart();
252  fTabWidget->setVisible(false);
253  fEmptyViewerTabLabel->setVisible(false);
254
255  fMyVSplitter->addWidget(fToolBox);
256  fMyVSplitter->addWidget(fEmptyViewerTabLabel);
257  //  fMyVSplitter->addWidget(fTabWidget);
258
259  // unset parent fot TabWidget
260#if QT_VERSION < 0x040000
261  fTabWidget->reparent(0,0,QPoint(0,0)); 
262#else
263  fTabWidget->setParent(0);
264#endif
265
266
267#if QT_VERSION >= 0x040000
268  commandLineWidget->setLayout(layoutCommandLine);
269#endif
270  commandLineWidget->setSizePolicy (QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum));
271  mainLayout->addWidget(fMyVSplitter,1);
272  mainLayout->addWidget(commandLineWidget);
273
274#ifdef G4DEBUG_INTERFACES_BASIC
275  printf("G4UIQt::G4UIQt :: 5\n");
276#endif
277
278#if QT_VERSION >= 0x040000
279  mainWidget->setLayout(mainLayout);
280#endif
281
282  fMainWindow->setCentralWidget(mainWidget);
283
284#if QT_VERSION < 0x040000
285
286  // Add a quit subMenu
287  QPopupMenu *fileMenu = new QPopupMenu( fMainWindow);
288  fileMenu->insertItem( "&Quit",  this, SLOT(ExitSession()), CTRL+Key_Q );
289  fMainWindow->menuBar()->insertItem( QString("&File"), fileMenu );
290
291#else
292
293  // Add a quit subMenu
294  QMenu *fileMenu = fMainWindow->menuBar()->addMenu("File");
295  fileMenu->addAction("Quit", this, SLOT(ExitSession()));
296
297#endif
298
299  AddInteractor ("file",(G4Interactor)fileMenu);
300#ifdef G4DEBUG_INTERFACES_BASIC
301  printf("G4UIQt::G4UIQt :: 6\n");
302#endif
303
304  // Connect signal
305  connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback()));
306  connect(fTabWidget,   SIGNAL(tabCloseRequested(int)), this, SLOT(TabCloseCallback(int)));
307  connect(fTabWidget, SIGNAL(currentChanged ( int ) ), SLOT(UpdateTabWidget(int)));
308  connect(fToolBox, SIGNAL(currentChanged(int)), SLOT(ToolBoxActivated(int)));
309
310  if(UI!=NULL) UI->SetCoutDestination(this);  // TO KEEP
311
312  interactorManager->SetG4UI(this);
313
314#if QT_VERSION < 0x040000
315  fMainWindow->setCaption( tr( "G4UI Session" ));
316  fMainWindow->resize(900,600);
317  fMainWindow->move(50,100);
318#else
319  fMainWindow->setWindowTitle( tr("G4UI Session") );
320  fMainWindow->resize(900,600);
321  fMainWindow->move(QPoint(50,100));
322#endif
323
324  // Set visible
325#if QT_VERSION >= 0x040000
326#if QT_VERSION >= 0x040200
327  fMainWindow->setVisible(true);
328#else
329  fMainWindow->show();
330#endif
331#else
332  fMainWindow->show();
333#endif
334
335#ifdef G4DEBUG_INTERFACES_BASIC
336  printf("G4UIQt::G4UIQt END\n");
337#endif
338}
339
340
341
342G4UIQt::~G4UIQt(
343)
344{
345#ifdef G4DEBUG_INTERFACES_BASIC
346  printf("G4UIQt::~G4UIQt Delete\n");
347#endif
348  G4UImanager* UI = G4UImanager::GetUIpointer();  // TO KEEP
349  if(UI!=NULL) {  // TO KEEP
350    UI->SetSession(NULL);  // TO KEEP
351    UI->SetCoutDestination(NULL);  // TO KEEP
352  }
353 
354  if (fMainWindow!=NULL) {
355#ifdef G4DEBUG_INTERFACES_BASIC
356  printf("G4UIQt::~G4UIQt DELETE fMainWindow\n");
357#endif
358    delete fMainWindow;
359  }
360}
361
362/** Create the History ToolBox Widget
363 */
364void G4UIQt::CreateHistoryTBWidget(
365)
366{
367
368#if QT_VERSION < 0x040000
369  QVBoxLayout *layoutHistoryTB = new QVBoxLayout(fHistoryTBWidget);
370
371  fHistoryTBTableList = new QListView(fHistoryTBWidget);
372  fHistoryTBTableList->setSorting (-1, FALSE);
373  fHistoryTBTableList->setSelectionMode(QListView::Single);
374  fHistoryTBTableList->addColumn("");
375  fHistoryTBTableList->header()->hide();
376  connect(fHistoryTBTableList, SIGNAL(selectionChanged()), SLOT(CommandHistoryCallback()));
377#else
378  QVBoxLayout *layoutHistoryTB = new QVBoxLayout();
379  fHistoryTBTableList = new QListWidget();
380  fHistoryTBTableList->setSelectionMode(QAbstractItemView::SingleSelection);
381  connect(fHistoryTBTableList, SIGNAL(itemSelectionChanged()), SLOT(CommandHistoryCallback()));
382#endif
383  fHistoryTBTableList->installEventFilter(this);
384
385  layoutHistoryTB->addWidget(fHistoryTBTableList);
386
387#if QT_VERSION >= 0x040000
388  fHistoryTBWidget->setLayout(layoutHistoryTB);
389#endif
390}
391
392/** Create the Help ToolBox Widget
393 */
394void G4UIQt::CreateHelpTBWidget(
395)
396{
397
398 
399#if QT_VERSION < 0x040000
400  QWidget *helpWidget = new QWidget(fHelpTBWidget);
401  QHBoxLayout *helpLayout = new QHBoxLayout(helpWidget);
402  QVBoxLayout *vLayout = new QVBoxLayout(fHelpTBWidget);
403  fHelpVSplitter = new QSplitter(Qt::Horizontal,fHelpTBWidget);
404#else
405  QWidget *helpWidget = new QWidget();
406  QHBoxLayout *helpLayout = new QHBoxLayout();
407  QVBoxLayout *vLayout = new QVBoxLayout();
408  fHelpVSplitter = new QSplitter(Qt::Horizontal);
409#endif
410  fHelpLine = new QLineEdit(fHelpTBWidget);
411  helpLayout->addWidget(new QLabel("Search :",helpWidget));
412  helpLayout->addWidget(fHelpLine);
413#if QT_VERSION < 0x040000
414  connect( fHelpLine, SIGNAL( returnPressed () ), this, SLOT( LookForHelpStringCallback() ) );
415#else
416  connect( fHelpLine, SIGNAL( editingFinished () ), this, SLOT( LookForHelpStringCallback() ) );
417#endif
418 
419  // Create Help tree
420  FillHelpTree();
421 
422  fHelpArea = new QTextEdit(fHelpVSplitter);
423  fHelpArea->setReadOnly(true);
424 
425  // Set layouts
426 
427#if QT_VERSION >= 0x040000
428  if (fHelpTreeWidget) {
429    fHelpVSplitter->addWidget(fHelpTreeWidget);
430  }
431  fHelpVSplitter->addWidget(fHelpArea);
432#endif
433 
434 
435#if QT_VERSION >= 0x040000
436  vLayout->addWidget(helpWidget);
437  vLayout->addWidget(fHelpVSplitter,1);
438#endif
439 
440  fHelpTBWidget->setMinimumSize(50,50);
441  fHelpTBWidget->setSizePolicy (QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum));
442  // set the splitter size
443#if QT_VERSION >= 0x040000
444  QList<int> list;
445#else
446  QValueList<int> list;
447#endif
448  list.append( 50 );
449  list.append( 50 );
450  fHelpVSplitter->setSizes(list);
451 
452#if QT_VERSION >= 0x040000
453  helpWidget->setLayout(helpLayout);
454  fHelpTBWidget->setLayout(vLayout);
455#endif 
456}
457
458
459/** Create the Cout ToolBox Widget
460 */
461void G4UIQt::CreateCoutTBWidget(
462)
463{
464#if QT_VERSION >= 0x040000
465  QVBoxLayout *layoutCoutTB = new QVBoxLayout();
466#else
467  QVBoxLayout *layoutCoutTB = new QVBoxLayout(fCoutTBWidget);
468#endif
469
470  fCoutTBTextArea = new QTextEdit(fCoutTBWidget);
471  fCoutFilter = new QLineEdit(fCoutTBWidget);
472  QLabel* coutFilterLabel = new QLabel("Filter : ",fCoutTBWidget);
473
474  QPushButton *coutTBClearButton = new QPushButton("clear",fCoutTBWidget);
475  connect(coutTBClearButton, SIGNAL(clicked()), SLOT(ClearButtonCallback()));
476  connect(fCoutFilter, SIGNAL(textEdited ( const QString &)), SLOT(CoutFilterCallback( const QString &)));
477
478  fCoutTBTextArea->setReadOnly(true);
479
480  QWidget* coutButtonWidget = new QWidget(fCoutTBWidget);
481  QHBoxLayout* layoutCoutTBButtons = new QHBoxLayout(coutButtonWidget);
482  layoutCoutTBButtons->addWidget(coutTBClearButton);
483  layoutCoutTBButtons->addWidget(coutFilterLabel);
484  layoutCoutTBButtons->addWidget(fCoutFilter);
485
486  layoutCoutTB->addWidget(fCoutTBTextArea);
487  layoutCoutTB->addWidget(coutButtonWidget);
488
489#if QT_VERSION >= 0x040000
490  fCoutTBWidget->setLayout(layoutCoutTB);
491#endif
492}
493
494
495/** Create the VisParameters ToolBox Widget
496 */
497void G4UIQt::CreateVisParametersTBWidget(
498)
499{
500}
501
502
503/** Create the ViewComponents ToolBox Widget
504 */
505void G4UIQt::CreateViewComponentsTBWidget(
506)
507{
508}
509
510
511/**   Add a new tab widget.
512  Create the tab if it was not done
513*/
514bool G4UIQt::AddTabWidget(
515 QWidget* aWidget
516,QString name
517,int sizeX
518,int sizeY
519)
520{
521#ifdef G4DEBUG_INTERFACES_BASIC
522  printf("G4UIQt::AddTabWidget %d %d\n",sizeX, sizeY);
523#endif
524  if (!aWidget) {
525    return false;
526  }
527
528  // Remove QLabel
529  if ( fMyVSplitter->indexOf(fEmptyViewerTabLabel) != -1) {
530#if QT_VERSION < 0x040000
531    fEmptyViewerTabLabel->reparent(0,0,QPoint(0,0)); 
532#else
533    fEmptyViewerTabLabel->setParent(0);
534#endif
535    fMyVSplitter->addWidget(fTabWidget);
536#if QT_VERSION < 0x040000
537    aWidget->reparent(fTabWidget,0,QPoint(0,0)); 
538#else
539    aWidget->setParent(fTabWidget);
540#endif
541  }
542
543
544
545#ifdef G4DEBUG_INTERFACES_BASIC
546  printf("G4UIQt::AddTabWidget ADD %d %d + %d %d---------------------------------------------------\n",sizeX, sizeY,sizeX-fTabWidget->width(),sizeY-fTabWidget->height());
547#endif
548 
549#ifdef G4DEBUG_INTERFACES_BASIC
550  printf("G4UIQt::AddTabWidget resize VVVVVVVVVVVG4UIQt G4UIQt G4UIQt G4UIQt G4UIQt G4UIQt G4UIQt G4UIQt \n");
551  printf("G4UIQt::AddTabWidget resize 22222222222 W---:%d + sx:%d -fwx:%d   H---:%d + sy:%d -fwy:%d    TabW:%d TabH:%d G4UIQt G4UIQt aWX:%d aWY:%d\n",fMainWindow->width(),sizeX,fTabWidget->width(),fMainWindow->height(),sizeY,fTabWidget->height(),fTabWidget->width(),fTabWidget->height(),aWidget->size().height(),aWidget->size().width());
552#endif
553
554  fMainWindow->resize(fMainWindow->width()+sizeX-fTabWidget->width(),fMainWindow->height()+sizeY-fTabWidget->height());
555
556  // Problems with resize. The widgets are not realy drawn at this step,
557  // then we have to force them on order to check the size
558
559  fTabWidget->insertTab(fTabWidget->count(),aWidget,name);
560 
561  //   if (fTabWidget->count() == 1) {
562  //    connect(fTabWidget, SIGNAL(currentChanged ( int ) ), SLOT(UpdateTabWidget(int)));
563  //  connect(fTabWidget, SIGNAL(resizeEvent (  QResizeEvent* ) ), SLOT(ResizeTabWidget( QResizeEvent*)));
564  //   }
565
566  fTabWidget->setCurrentIndex(fTabWidget->count()-1);
567  //  UpdateTabWidget(fTabWidget->count()-1);
568  // Set visible
569#if QT_VERSION >= 0x040000
570#if QT_VERSION >= 0x040200
571  fMainWindow->setVisible(true);
572#else
573  fMainWindow->show();
574#endif
575#else
576  fMainWindow->show();
577 #endif
578 
579 
580
581// //   // Check size
582// //   int offX = (sizeX-aWidget->size().width());
583// //   int offY = (sizeY-aWidget->size().height());
584
585// // #ifdef G4DEBUG_INTERFACES_BASIC
586// //   printf("G4UIQt::AddTabWidget resize AFTER FIRST W:%d + sx:%d -fwx:%d   H:%d + sy:%d -fwy:%d    TabW:%d TabH:%d G4UIQt G4UIQt offX:%d  offY:%d aWX:%d aWY:%d\n",fMainWindow->width(),sizeX,fTabWidget->width(),fMainWindow->height(),sizeY,fTabWidget->height(),fTabWidget->width(),fTabWidget->height(),offX,offY,aWidget->size().height(),aWidget->size().width());
587// // #endif
588
589// //   // and correct if necessairy
590// //   if ((offX != 0) ||(offY != 0)) {
591// //     fMainWindow->resize(fMainWindow->width()+offX,fMainWindow->height()+offY);
592// //     // Re-Set visible
593// // #if QT_VERSION >= 0x040000
594// // #if QT_VERSION >= 0x040200
595// //     fMainWindow->setVisible(true);
596// // #else
597// //     fMainWindow->show();
598// // #endif
599// // #else
600// //     fMainWindow->show();
601// // #endif
602// //   }
603
604// // #ifdef G4DEBUG_INTERFACES_BASIC
605// //   printf("G4UIQt::AddTabWidget resize ^^^^^^^^^^^^ W:%d + sx:%d -fwx:%d   H:%d + sy:%d -fwy:%d    TabW:%d TabH:%d G4UIQt G4UIQt offX:%d  offY:%d aWX:%d aWY:%d\n",fMainWindow->width(),sizeX,fTabWidget->width(),fMainWindow->height(),sizeY,fTabWidget->height(),fTabWidget->width(),fTabWidget->height(),offX,offY,aWidget->size().height(),aWidget->size().width());
606// // #endif
607printf("G4UIQt::AddTabWidget  END\n");
608// // #endif
609 
610  fTabWidget->setVisible(true);
611
612  return true;
613}
614
615
616void G4UIQt::UpdateTabWidget(int tabNumber) {
617#ifdef G4DEBUG_INTERFACES_BASIC
618  printf("G4UIQt::UpdateTabWidget %d\n",tabNumber);
619#endif
620  if (  fTabWidget == NULL) {
621    fTabWidget = new G4QTabWidget;
622  }
623 
624
625#ifdef G4DEBUG_INTERFACES_BASIC
626  printf("G4UIQt::UpdateTabWidget CALL REPAINT tabGL\n");
627#endif
628
629  fTabWidget->setCurrentIndex(tabNumber);
630
631  // Send this signal to unblock graphic updates !
632  fTabWidget->setVisible(true);
633
634  // This will send a paintEvent to OGL Viewers
635  fTabWidget->setTabSelected();
636
637#ifdef G4DEBUG_INTERFACES_BASIC
638  printf("G4UIQt::UpdateTabWidget END\n");
639#endif
640}
641
642
643/** Send resize event to all tabs
644 */
645void G4UIQt::ResizeTabWidget( QResizeEvent* e) {
646  for (int a=0;a<fTabWidget->count() ;a++) {
647#ifdef G4DEBUG_INTERFACES_BASIC
648    printf("G4UIQt::ResizeTabWidget +++++++++++++++++++++++++++++++++++++++\n");
649#endif
650    fTabWidget->widget(a)->resize(e->size());
651  }
652}
653
654
655/**   Start the Qt main loop
656*/
657G4UIsession* G4UIQt::SessionStart (
658)
659{
660#ifdef G4DEBUG_INTERFACES_BASIC
661  printf("G4UIQt::G4UIQt SessionStart\n");
662#endif
663
664  G4Qt* interactorManager = G4Qt::getInstance ();
665
666  Prompt("Session :");
667  exitSession = false;
668
669  fTabWidget->setVisible(true);
670  fEmptyViewerTabLabel->setVisible(true);
671
672#if QT_VERSION >= 0x040000
673#if QT_VERSION >= 0x040200
674  fMainWindow->setVisible(true);
675#else
676  fMainWindow->show();
677#endif
678#else
679  fMainWindow->show();
680#endif
681
682  QCoreApplication::sendPostedEvents () ;
683
684#ifdef G4DEBUG_INTERFACES_BASIC
685  printf("G4UIQt::G4UIQt SessionStart2\n");
686#endif
687  interactorManager->DisableSecondaryLoop (); // TO KEEP
688  if ((QApplication*)interactorManager->GetMainInteractor())
689    ((QApplication*)interactorManager->GetMainInteractor())->exec();
690
691  // on ne passe pas le dessous ? FIXME ????
692  // je ne pense pas 13/06
693
694  //   void* event; // TO KEEP
695  //   while((event = interactorManager->GetEvent())!=NULL) {  // TO KEEP
696  //     interactorManager->DispatchEvent(event); // TO KEEP
697  //     if(exitSession==true) break; // TO KEEP
698  //   } // TO KEEP
699
700  interactorManager->EnableSecondaryLoop ();
701  return this;
702}
703
704
705/**   Display the prompt in the prompt area
706   @param aPrompt : string to display as the promt label
707   //FIXME : probablement inutile puisque le seul a afficher qq chose d'autre
708   que "session" est SecondaryLoop()
709*/
710void G4UIQt::Prompt (
711 G4String aPrompt
712)
713{
714  if (!aPrompt) return;
715
716  fCommandLabel->setText((char*)aPrompt.data());
717}
718
719
720
721void G4UIQt::SessionTerminate (
722)
723{
724  G4Qt* interactorManager = G4Qt::getInstance ();
725  fMainWindow->close();
726  ((QApplication*)interactorManager->GetMainInteractor())->exit();
727}
728
729
730
731/**
732   Called by intercoms/src/G4UImanager.cc<br>
733   Called by visualization/management/src/G4VisCommands.cc with "EndOfEvent" argument<br>
734   It have to pause the session command terminal.<br>
735   Call SecondaryLoop to wait for exit event<br>
736   @param aState
737   @see : G4VisCommandReviewKeptEvents::SetNewValue
738*/
739void G4UIQt::PauseSessionStart (
740 G4String aState
741)
742{
743  if (!aState) return;
744
745  if(aState=="G4_pause> ") {  // TO KEEP
746    SecondaryLoop ("Pause, type continue to exit this state"); // TO KEEP
747  } // TO KEEP
748
749  if(aState=="EndOfEvent") { // TO KEEP
750    // Picking with feed back in event data Done here !!!
751    SecondaryLoop ("End of event, type continue to exit this state"); // TO KEEP
752  } // TO KEEP
753}
754
755
756
757/**
758   Begin the secondary loop
759   @param a_prompt : label to display as the prompt label
760 */
761void G4UIQt::SecondaryLoop (
762 G4String aPrompt
763)
764{
765  if (!aPrompt) return;
766
767  G4Qt* interactorManager = G4Qt::getInstance (); // TO KEEP ?
768  Prompt(aPrompt); // TO KEEP
769  exitPause = false; // TO KEEP
770  void* event; // TO KEEP
771  while((event = interactorManager->GetEvent())!=NULL) {  // TO KEEP
772    interactorManager->DispatchEvent(event); // TO KEEP
773    if(exitPause==true) break; // TO KEEP
774  } // TO KEEP
775  Prompt("Session :"); // TO KEEP
776}
777
778
779
780/**
781   Receive a cout from Geant4. We have to display it in the cout zone
782   @param aString : label to add in the display area
783   @return 0
784*/
785G4int G4UIQt::ReceiveG4cout (
786 G4String aString
787 )
788{
789  if (!aString) return 0;
790 
791  QStringList newStr;
792 
793  // Add to stringList
794#if QT_VERSION < 0x040000
795  newStr = QStringList(QString((char*)aString.data()).simplifyWhiteSpace());
796#else
797  newStr = QStringList(QString((char*)aString.data()).trimmed());
798#endif
799  fG4cout += newStr;
800 
801  QStringList result = newStr.filter(fCoutFilter->text());
802
803  if (result.join("\n").isEmpty()) {
804    return 0;
805  }
806  fCoutTBTextArea->append(result.join("\n"));
807  fCoutTBTextArea->repaint();
808
809#if QT_VERSION < 0x040000
810  fCoutTBTextArea->verticalScrollBar()->setValue(fCoutTBTextArea->verticalScrollBar()->maxValue());
811#else
812  fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
813#endif
814
815  return 0;
816}
817
818
819/**
820   Receive a cerr from Geant4. We have to display it in the cout zone
821   @param aString : label to add in the display area
822   @return 0
823*/
824G4int G4UIQt::ReceiveG4cerr (
825 G4String aString
826)
827{
828  if (!aString) return 0;
829
830  QStringList newStr;
831
832  // Add to stringList
833#if QT_VERSION < 0x040000
834  newStr = QStringList(QString((char*)aString.data()).simplifyWhiteSpace());
835#else
836  newStr = QStringList(QString((char*)aString.data()).trimmed());
837#endif
838  fG4cout += newStr;
839 
840 QStringList result = newStr.filter(fCoutFilter->text());
841
842#if QT_VERSION < 0x040000
843  QColor previousColor = fCoutTBTextArea->color();
844  fCoutTBTextArea->setColor(Qt::red);
845  fCoutTBTextArea->append(result.join("\n"));
846  fCoutTBTextArea->setColor(previousColor);
847  fCoutTBTextArea->verticalScrollBar()->setValue(fCoutTBTextArea->verticalScrollBar()->maxValue());
848#else
849  QColor previousColor = fCoutTBTextArea->textColor();
850  fCoutTBTextArea->setTextColor(Qt::red);
851  fCoutTBTextArea->append(result.join("\n"));
852  fCoutTBTextArea->setTextColor(previousColor);
853  fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
854#endif
855  fCoutTBTextArea->repaint();
856  return 0;
857}
858
859
860
861/**
862   Add a new menu to the menu bar
863   @param aName name of menu
864   @param aLabel label to display
865 */
866void G4UIQt::AddMenu (
867 const char* aName
868,const char* aLabel
869)
870{
871  if (aName == NULL) return;
872  if (aLabel == NULL) return;
873
874#if QT_VERSION < 0x040000
875  QPopupMenu *fileMenu = new QPopupMenu( fMainWindow);
876  fMainWindow->menuBar()->insertItem( aLabel, fileMenu );
877#else
878  QMenu *fileMenu = new QMenu(aLabel);
879  fMainWindow->menuBar()->insertMenu(fMainWindow->menuBar()->actions().last(),fileMenu);
880#endif
881
882  AddInteractor (aName,(G4Interactor)fileMenu);
883}
884
885
886/**
887   Add a new button to a menu
888   @param aMenu : parent menu
889   @param aLabel : label to display
890   @param aCommand : command to execute as a callback
891 */
892void G4UIQt::AddButton (
893 const char* aMenu
894,const char* aLabel
895,const char* aCommand
896)
897{
898  if(aMenu==NULL) return; // TO KEEP
899  if(aLabel==NULL) return; // TO KEEP
900  if(aCommand==NULL) return; // TO KEEP
901
902#if QT_VERSION < 0x040000
903  QPopupMenu *parent = (QPopupMenu*)GetInteractor(aMenu);
904#else
905  QMenu *parent = (QMenu*)GetInteractor(aMenu);
906#endif
907
908  if(parent==NULL) return;
909 
910  QSignalMapper *signalMapper = new QSignalMapper(this);
911#if QT_VERSION < 0x030200
912  QAction *action = new QAction(QString(aLabel),QString(aLabel),QKeySequence(),signalMapper, SLOT(map()));
913  action->addTo(parent);
914 connect(action,SIGNAL(activated()),signalMapper,SLOT(map()));
915
916#elif QT_VERSION < 0x040000
917  QAction *action = new QAction(QString(aLabel),QKeySequence(),signalMapper, SLOT(map()));
918  action->addTo(parent);
919 connect(action,SIGNAL(activated()),signalMapper,SLOT(map()));
920
921#else
922  QAction *action = parent->addAction(aLabel, signalMapper, SLOT(map()));
923
924#endif
925  connect(signalMapper, SIGNAL(mapped(const QString &)),this, SLOT(ButtonCallback(const QString&)));
926  signalMapper->setMapping(action, QString(aCommand));
927}
928
929
930
931
932void G4UIQt::ActivateCommand(
933 G4String newCommand
934)
935{
936  if (!fHelpTreeWidget) {
937    return;
938  }
939  // Look for the choosen command "newCommand"
940  size_t i = newCommand.index(" ");
941  G4String targetCom ="";
942  if( i != std::string::npos )
943    {
944      G4String newValue = newCommand(i+1,newCommand.length()-(i+1));
945      newValue.strip(G4String::both);
946      targetCom = ModifyToFullPathCommand( newValue );
947    }
948#ifdef G4DEBUG_INTERFACES_BASIC
949  printf("G4UIQt::ActivateCommand found : %s \n",targetCom.data());
950#endif
951  if (targetCom != "") {
952    OpenHelpTreeOnCommand(targetCom.data());
953  }
954
955  fToolBox->setCurrentWidget(fHelpTBWidget);
956}
957
958
959
960/**
961   Create the help tree widget
962   @param parent : parent of tree widget
963   @return the widget containing the tree or NULL if it could not have beeen created
964 */
965
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  }
980
981  // build widget
982#if QT_VERSION < 0x040000
983  fHelpTreeWidget->setSelectionMode(QListView::Single);
984  fHelpTreeWidget->setRootIsDecorated(true);
985  fHelpTreeWidget->addColumn("Command");
986  fHelpTreeWidget->header()->setResizeEnabled(FALSE,1);
987#else
988  fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
989  QStringList labels;
990  labels << QString("Command");
991  fHelpTreeWidget->setHeaderLabels(labels);
992#endif
993
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  if (! fHelpTreeWidget ) {
1017    InitHelpTree();
1018  }
1019
1020  G4UImanager* UI = G4UImanager::GetUIpointer();
1021  if(UI==NULL) return;
1022  G4UIcommandTree * treeTop = UI->GetTree();
1023
1024
1025  // Remove all previous children
1026  //  fHelpTreeWidget->clear();
1027
1028  G4int treeSize = treeTop->GetTreeEntry();
1029#if QT_VERSION < 0x040000
1030  QListViewItem * newItem = NULL;
1031#else
1032  QTreeWidgetItem * newItem = NULL;
1033#endif
1034  QString commandText = "";
1035  for (int a=0;a<treeSize;a++) {
1036#ifdef G4DEBUG_INTERFACES_BASIC
1037  printf("G4UIQt::FillHelpTree for\n");
1038#endif
1039    // Creating new item
1040
1041#if QT_VERSION < 0x040000
1042    commandText = QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()).simplifyWhiteSpace();
1043#else
1044    commandText = QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()).trimmed();
1045#endif
1046
1047    // if already exist, don't create it !
1048#if QT_VERSION < 0x040000
1049    QListViewItem* tmpItem = fHelpTreeWidget->firstChild();
1050    while (tmpItem != 0) {
1051      if (!newItem) {
1052        newItem = FindTreeItem(tmpItem,commandText);
1053      }
1054      tmpItem = tmpItem->nextSibling();
1055    }
1056#else
1057    for (int b=0;a<fHelpTreeWidget->topLevelItemCount();b++) {
1058      if (!newItem)
1059        newItem = FindTreeItem(fHelpTreeWidget->topLevelItem(b),commandText);
1060    }
1061#endif
1062
1063    if (newItem == NULL) {
1064#ifdef G4DEBUG_INTERFACES_BASIC
1065  printf("G4UIQt::FillHelpTree check already present\n");
1066#endif
1067     
1068#if QT_VERSION < 0x040000
1069      newItem = new QListViewItem(fHelpTreeWidget);
1070#else
1071      newItem = new QTreeWidgetItem(fHelpTreeWidget);
1072#endif
1073      newItem->setText(0,GetShortCommandPath(commandText));
1074    }
1075
1076    // look for childs
1077    CreateChildTree(newItem,treeTop->GetTree(a+1));
1078    //      items.append(newItem);
1079  }
1080}
1081
1082
1083
1084/**   Fill the Help Tree Widget
1085   @param aParent : parent item to fill
1086   @param aCommandTree : commandTree node associate with this part of the Tree
1087*/
1088#if QT_VERSION < 0x040000
1089void G4UIQt::CreateChildTree(
1090 QListViewItem *aParent
1091,G4UIcommandTree *aCommandTree
1092#else
1093void G4UIQt::CreateChildTree(
1094 QTreeWidgetItem *aParent
1095,G4UIcommandTree *aCommandTree
1096#endif
1097)
1098{
1099  if (aParent == NULL) return;
1100  if (aCommandTree == NULL) return;
1101
1102
1103  // Creating new item
1104#if QT_VERSION < 0x040000
1105  QListViewItem * newItem;
1106#else
1107  QTreeWidgetItem * newItem;
1108#endif
1109
1110  QString commandText = "";
1111  // Get the Sub directories
1112  for (int a=0;a<aCommandTree->GetTreeEntry();a++) {
1113#ifdef G4DEBUG_INTERFACES_BASIC
1114  printf("G4UIQt::CreateChildTree for\n");
1115#endif
1116
1117#if QT_VERSION < 0x040000
1118    commandText = QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()).simplifyWhiteSpace();
1119#else
1120    commandText = QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()).trimmed();
1121#endif
1122   
1123    // if already exist, don't create it !
1124    newItem = FindTreeItem(aParent,commandText);
1125    if (newItem == NULL) {
1126#ifdef G4DEBUG_INTERFACES_BASIC
1127  printf("G4UIQt::CreateChildTree check already present\n");
1128#endif
1129#if QT_VERSION < 0x040000
1130      newItem = new QListViewItem(aParent);
1131#else
1132      newItem = new QTreeWidgetItem(aParent);
1133#endif
1134      newItem->setText(0,GetShortCommandPath(commandText));
1135    }
1136    CreateChildTree(newItem,aCommandTree->GetTree(a+1));
1137  }
1138
1139
1140
1141  // Get the Commands
1142
1143  for (int a=0;a<aCommandTree->GetCommandEntry();a++) {
1144   
1145    QStringList stringList;
1146#if QT_VERSION < 0x040000
1147    newItem = new QListViewItem(aParent);
1148    newItem->setText(0,GetShortCommandPath(QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()).simplifyWhiteSpace()));
1149    newItem->setOpen(false);
1150
1151#else
1152    newItem = new QTreeWidgetItem(aParent);
1153    newItem->setText(0,GetShortCommandPath(QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()).trimmed()));
1154#if QT_VERSION < 0x040202
1155        fHelpTreeWidget->setItemExpanded(newItem,false);
1156#else
1157    newItem->setExpanded(false);
1158#endif
1159#endif
1160     
1161  }
1162}
1163
1164 
1165/** Find a treeItemWidget in the help tree
1166    @param aCommand item's String to look for
1167    @return item if found, NULL if not
1168*/
1169#if QT_VERSION < 0x040000
1170QListViewItem* G4UIQt::FindTreeItem(
1171 QListViewItem *aParent
1172#else
1173QTreeWidgetItem* G4UIQt::FindTreeItem(
1174 QTreeWidgetItem *aParent
1175#endif
1176,const QString& aCommand
1177)
1178{
1179  if (aParent == NULL) return NULL;
1180
1181  if (GetLongCommandPath(aParent) == aCommand)
1182    return aParent;
1183 
1184#if QT_VERSION < 0x040000
1185  QListViewItem * tmp = NULL;
1186  QListViewItem* tmpItem = aParent->firstChild();
1187    while (tmpItem != 0) {
1188      if (!tmp)
1189        tmp = FindTreeItem(tmpItem,aCommand);
1190      tmpItem = tmpItem->nextSibling();
1191    }
1192#else
1193  QTreeWidgetItem * tmp = NULL;
1194  for (int a=0;a<aParent->childCount();a++) {
1195    if (!tmp)
1196      tmp = FindTreeItem(aParent->child(a),aCommand);
1197  }
1198#endif
1199  return tmp;
1200}
1201
1202
1203
1204/**   Build the command list parameters in a QString<br>
1205   Reimplement partialy the G4UIparameter.cc
1206   @param aCommand : command to list parameters
1207   @see G4UIparameter::List()
1208   @see G4UIcommand::List()
1209   @return the command list parameters, or "" if nothing
1210*/
1211QString G4UIQt::GetCommandList (
1212 const G4UIcommand *aCommand
1213)
1214{
1215
1216  QString txt ="";
1217  if (aCommand == NULL)
1218    return txt;
1219
1220  G4String commandPath = aCommand->GetCommandPath();
1221  G4String rangeString = aCommand->GetRange();
1222  G4int n_guidanceEntry = aCommand->GetGuidanceEntries();
1223  G4int n_parameterEntry = aCommand->GetParameterEntries();
1224 
1225  if ((commandPath == "") &&
1226      (rangeString == "") &&
1227      (n_guidanceEntry == 0) &&
1228      (n_parameterEntry == 0)) {
1229    return txt;
1230  }
1231
1232  if((commandPath.length()-1)!='/') {
1233    txt += "Command " + QString((char*)(commandPath).data()) + "\n";
1234  }
1235  txt += "Guidance :\n";
1236 
1237  for( G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
1238    txt += QString((char*)(aCommand->GetGuidanceLine(i_thGuidance)).data()) + "\n";
1239  }
1240  if( ! rangeString.isNull() ) {
1241    txt += " Range of parameters : " + QString((char*)(rangeString).data()) + "\n";
1242  }
1243  if( n_parameterEntry > 0 ) {
1244    G4UIparameter *param;
1245   
1246    // Re-implementation of G4UIparameter.cc
1247   
1248    for( G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
1249      param = aCommand->GetParameter(i_thParameter);
1250      txt += "\nParameter : " + QString((char*)(param->GetParameterName()).data()) + "\n";
1251      if( ! param->GetParameterGuidance().isNull() )
1252        txt += QString((char*)(param->GetParameterGuidance()).data())+ "\n" ;
1253      txt += " Parameter type  : " + QString(QChar(param->GetParameterType())) + "\n";
1254      if(param->IsOmittable()){
1255        txt += " Omittable       : True\n";
1256      } else {
1257        txt += " Omittable       : False\n";
1258      }
1259      if( param->GetCurrentAsDefault() ) {
1260        txt += " Default value   : taken from the current value\n";
1261      } else if( ! param->GetDefaultValue().isNull() ) {
1262        txt += " Default value   : " + QString((char*)(param->GetDefaultValue()).data())+ "\n";
1263      }
1264      if( ! param->GetParameterRange().isNull() ) {
1265        txt += " Parameter range : " + QString((char*)(param->GetParameterRange()).data())+ "\n";
1266      }
1267      if( ! param->GetParameterCandidates().isNull() ) {
1268        txt += " Candidates      : " + QString((char*)(param->GetParameterCandidates()).data())+ "\n";
1269      }
1270    }
1271  }
1272  return txt;
1273}
1274
1275
1276
1277/**  Implement G4VBasicShell vurtual function
1278 */
1279G4bool G4UIQt::GetHelpChoice(
1280 G4int&
1281)
1282{
1283#ifdef G4DEBUG_INTERFACES_BASIC
1284  printf("G4UIQt::GetHelpChoice SHOULD NEVER GO HERE");
1285#endif
1286  return true;
1287}
1288
1289
1290/**   Event filter method. Every event from QtApplication goes here.<br/>
1291   We apply a filter only for the Up and Down Arrow press when the QLineEdit<br/>
1292   is active. If this filter match, Up arrow we give the previous command<br/>
1293   and Down arrow will give the next if exist.<br/>
1294   @param obj Emitter of the event
1295   @param event Kind of event
1296*/
1297bool G4UIQt::eventFilter( // Should stay with a minuscule eventFilter because of Qt
1298 QObject *aObj
1299,QEvent *aEvent
1300)
1301{
1302  bool moveCommandCursor = false;
1303  if (aObj == NULL) return false;
1304  if (aEvent == NULL) return false;
1305
1306  if (aObj == fHistoryTBTableList) {
1307    if (aEvent->type() == QEvent::KeyPress) {
1308      fCommandArea->setFocus();
1309    }
1310  }
1311  if (aObj == fCommandArea) {
1312    if (aEvent->type() == QEvent::KeyPress) {
1313      QKeyEvent *e = static_cast<QKeyEvent*>(aEvent);
1314      if ((e->key() == (Qt::Key_Down)) ||
1315          (e->key() == (Qt::Key_PageDown)) ||
1316          (e->key() == (Qt::Key_Up)) ||
1317          (e->key() == (Qt::Key_PageUp))) {
1318#if QT_VERSION < 0x040000
1319        // count rows...
1320        QListViewItem* tmpItem = fHistoryTBTableList->firstChild();
1321        int selection = -1;
1322        int index = 0;
1323        while (tmpItem != 0) {
1324          if (tmpItem == fHistoryTBTableList->selectedItem()) {
1325            selection = index;
1326          }
1327          index ++;
1328          tmpItem = tmpItem->nextSibling();
1329        }
1330        if (fHistoryTBTableList->childCount()) {
1331          if (selection == -1) {
1332            selection = fHistoryTBTableList->childCount()-1;
1333          } else {
1334            if (e->key() == (Qt::Key_Down)) {
1335              if (selection <(fHistoryTBTableList->childCount()-1))
1336                selection++;
1337            } else if (e->key() == (Qt::Key_PageDown)) {
1338              selection = fHistoryTBTableList->childCount()-1;
1339#else
1340        int selection = fHistoryTBTableList->currentRow();
1341        if (fHistoryTBTableList->count()) {
1342          if (selection == -1) {
1343            selection = fHistoryTBTableList->count()-1;
1344          } else {
1345            if (e->key() == (Qt::Key_Down)) {
1346              if (selection <(fHistoryTBTableList->count()-1))
1347                selection++;
1348            } else if (e->key() == (Qt::Key_PageDown)) {
1349              selection = fHistoryTBTableList->count()-1;
1350#endif
1351            } else if (e->key() == (Qt::Key_Up)) {
1352              if (selection >0)
1353                selection --;
1354            } else if (e->key() == (Qt::Key_PageUp)) {
1355              selection = 0;
1356            }
1357          }
1358          fHistoryTBTableList->clearSelection();
1359#if QT_VERSION < 0x040000
1360          QListViewItem* tmpItem = fHistoryTBTableList->firstChild();
1361          int index = 0;
1362          while (tmpItem != 0) {
1363            if (index == selection) {
1364              tmpItem->setSelected(true);
1365              fHistoryTBTableList->setCurrentItem(tmpItem);
1366          }
1367          index ++;
1368          tmpItem = tmpItem->nextSibling();
1369        }
1370#else
1371#if QT_VERSION < 0x040202
1372          fHistoryTBTableList->setItemSelected(fHistoryTBTableList->item(selection),true);
1373#else
1374          fHistoryTBTableList->item(selection)->setSelected(true);
1375#endif     
1376          fHistoryTBTableList->setCurrentItem(fHistoryTBTableList->item(selection));
1377#endif
1378        }
1379        moveCommandCursor = true;
1380      } else if (e->key() == (Qt::Key_Tab)) {
1381#if QT_VERSION < 0x040000
1382        G4String ss = Complete(fCommandArea->text().ascii());
1383#else
1384        G4String ss = Complete(fCommandArea->text().toStdString().c_str());
1385#endif
1386        fCommandArea->setText((char*)(ss.data()));
1387
1388        // do not pass by parent, it will disable widget tab focus !
1389        return true;
1390#if QT_VERSION >= 0x040000
1391        // L.Garnier : MetaModifier is CTRL for MAC, but I don't want to put a MAC
1392        // specific #ifdef
1393      } else if (((e->modifiers () == Qt::ControlModifier) || (e->modifiers () == Qt::MetaModifier)) && (e->key() == Qt::Key_A)) {
1394       fCommandArea->home(false);
1395       return true;
1396      } else if (((e->modifiers () == Qt::ControlModifier) || (e->modifiers () == Qt::MetaModifier)) && (e->key() == Qt::Key_E)) {
1397       fCommandArea->end(false);
1398       return true;
1399#endif
1400      }
1401    }
1402  }
1403  bool res= false;
1404  // change cursor position if needed
1405  if (moveCommandCursor == true) {
1406#ifdef G4DEBUG_INTERFACES_BASIC
1407    printf("G4UIQt::eventFilter setCursor Position\n");
1408#endif
1409    fCommandArea->setCursorPosition ( fCommandArea->text().length() );
1410    fCommandArea->setCursorPosition (4);
1411  } else {
1412    // pass the event on to the parent class
1413    res = QObject::eventFilter(aObj, aEvent);
1414  }
1415  return res;
1416}
1417
1418
1419
1420
1421/***************************************************************************/
1422//
1423//             SLOTS DEFINITIONS
1424//
1425/***************************************************************************/
1426
1427/**   Called when user give "help" command.
1428*/
1429void G4UIQt::ShowHelpCallback (
1430)
1431{
1432  TerminalHelp("");
1433}
1434
1435
1436/**   Called when user click on clear button. Clear the text Output area
1437*/
1438void G4UIQt::ClearButtonCallback (
1439)
1440{
1441  fCoutTBTextArea->clear();
1442  fG4cout.clear();
1443}
1444
1445/**   Called when user exit session
1446*/
1447void G4UIQt::ExitSession (
1448)
1449{
1450  SessionTerminate();
1451}
1452
1453void G4UIQt::ExitHelp(
1454)
1455{
1456}
1457
1458/**   Callback call when "click on a menu entry.<br>
1459   Send the associated command to geant4
1460*/
1461void G4UIQt::CommandEnteredCallback (
1462)
1463{
1464#if QT_VERSION < 0x040000
1465  G4String command (fCommandArea->text().ascii());
1466  if (fCommandArea->text().simplifyWhiteSpace() != "") {
1467
1468    QListViewItem *newItem = new QListViewItem(fHistoryTBTableList);
1469    newItem->setText(0,fCommandArea->text());
1470    fHistoryTBTableList->insertItem(newItem);
1471    // now we have to arrange
1472    QListViewItem *temp= fHistoryTBTableList->lastItem();
1473    for (int i=0; i<fHistoryTBTableList->childCount()-1;i++) {
1474      fHistoryTBTableList->takeItem(temp);
1475      fHistoryTBTableList->insertItem(temp);
1476      temp= fHistoryTBTableList->lastItem();
1477    }
1478#else
1479  G4String command (fCommandArea->text().toStdString().c_str());
1480  if (fCommandArea->text().trimmed() != "") {
1481    fHistoryTBTableList->addItem(fCommandArea->text());
1482#endif
1483    fHistoryTBTableList->clearSelection();
1484    fHistoryTBTableList->setCurrentItem(NULL);
1485    fCommandArea->setText("");
1486
1487    G4Qt* interactorManager = G4Qt::getInstance ();
1488    if (interactorManager) {
1489      interactorManager->FlushAndWaitExecution();
1490    }
1491    if (command(0,4) != "help") {
1492      ApplyShellCommand (command,exitSession,exitPause);
1493    } else {
1494      ActivateCommand(command);
1495    }
1496    // Rebuild help tree
1497    FillHelpTree();
1498
1499    if(exitSession==true)
1500      SessionTerminate();
1501  }
1502
1503}
1504
1505
1506/**   Callback call when "enter" clicked on the command zone.<br>
1507   Send the command to geant4
1508   @param aCommand
1509*/
1510void G4UIQt::ButtonCallback (
1511 const QString& aCommand
1512)
1513{
1514#if QT_VERSION < 0x040000
1515  G4String ss = G4String(aCommand.ascii());
1516#else
1517  G4String ss = G4String(aCommand.toStdString().c_str());
1518#endif
1519  ApplyShellCommand(ss,exitSession,exitPause);
1520
1521  // Rebuild help tree
1522  FillHelpTree();
1523
1524  if(exitSession==true)
1525    SessionTerminate();
1526}
1527
1528
1529
1530/**   This callback is activated when user selected a item in the help tree
1531*/
1532void G4UIQt::HelpTreeClicCallback (
1533)
1534{
1535#if QT_VERSION < 0x040000
1536  QListViewItem* item =  NULL;
1537#else
1538  QTreeWidgetItem* item =  NULL;
1539#endif
1540
1541  if (!fHelpTreeWidget)
1542    return ;
1543
1544  if (!fHelpArea)
1545    return;
1546 
1547#if QT_VERSION < 0x040000
1548  item =fHelpTreeWidget->selectedItem();
1549#else
1550  QList<QTreeWidgetItem *> list =fHelpTreeWidget->selectedItems();
1551  if (list.isEmpty())
1552    return;
1553  item = list.first();
1554#endif
1555  if (!item)
1556    return;
1557 
1558  G4UImanager* UI = G4UImanager::GetUIpointer();
1559  if(UI==NULL) return;
1560  G4UIcommandTree * treeTop = UI->GetTree();
1561
1562  std::string itemText = GetLongCommandPath(item).toStdString();
1563 
1564  G4UIcommand* command = treeTop->FindPath(itemText.c_str());
1565
1566  if (command) {
1567#if QT_VERSION >= 0x040000
1568#if QT_VERSION < 0x040200
1569    fHelpArea->clear();
1570    fHelpArea->append(GetCommandList(command));
1571#else
1572    fHelpArea->setText(GetCommandList(command));
1573#endif
1574#else
1575    fHelpArea->setText(GetCommandList(command));
1576#endif
1577  } else {  // this is a command
1578    G4UIcommandTree* path = treeTop->FindCommandTree(itemText.c_str());
1579    if ( path) {
1580      // this is not a command, this is a sub directory
1581      // We display the Title
1582#if QT_VERSION >= 0x040000
1583#if QT_VERSION < 0x040200
1584      fHelpArea->clear();
1585      fHelpArea->append(path->GetTitle().data());
1586#else
1587      fHelpArea->setText(path->GetTitle().data());
1588#endif
1589#else
1590      fHelpArea->setText(path->GetTitle().data());
1591#endif
1592    }
1593  }
1594}
1595 
1596/**   This callback is activated when user double clic on a item in the help tree
1597*/
1598void G4UIQt::HelpTreeDoubleClicCallback (
1599)
1600{
1601  HelpTreeClicCallback();
1602
1603#if QT_VERSION < 0x040000
1604  QListViewItem* item =  NULL;
1605#else
1606  QTreeWidgetItem* item =  NULL;
1607#endif
1608  if (!fHelpTreeWidget)
1609    return ;
1610
1611  if (!fHelpArea)
1612    return;
1613 
1614#if QT_VERSION < 0x040000
1615  item =fHelpTreeWidget->selectedItem();
1616#else
1617  QList<QTreeWidgetItem *> list =fHelpTreeWidget->selectedItems();
1618  if (list.isEmpty())
1619    return;
1620  item = list.first();
1621#endif
1622  if (!item)
1623    return;
1624
1625  fCommandArea->clear();
1626  fCommandArea->setText(GetLongCommandPath(item));
1627}
1628
1629
1630/**   Callback called when user select an old command in the command history<br>
1631   Give it to the command area.
1632*/
1633void G4UIQt::CommandHistoryCallback(
1634)
1635{
1636#if QT_VERSION < 0x040000
1637  QListViewItem* item =  NULL;
1638#else
1639  QListWidgetItem* item =  NULL;
1640#endif
1641  if (!fHistoryTBTableList)
1642    return ;
1643
1644 
1645#if QT_VERSION < 0x040000
1646  item =fHistoryTBTableList->selectedItem();
1647#else
1648  QList<QListWidgetItem *> list =fHistoryTBTableList->selectedItems();
1649  if (list.isEmpty())
1650    return;
1651  item = list.first();
1652#endif
1653  if (!item)
1654    return;
1655#if QT_VERSION < 0x040000
1656  fCommandArea->setText(item->text(0));
1657#else
1658  fCommandArea->setText(item->text());
1659#endif
1660#ifdef G4DEBUG_INTERFACES_BASIC
1661    printf("G4UIQt::CommandHistoryCallback change text\n");
1662#endif
1663}
1664
1665
1666void G4UIQt::CoutFilterCallback(
1667const QString & text) {
1668
1669#ifdef G4DEBUG_INTERFACES_BASIC
1670  printf("G4UIQt::CoutFilterCallback : %s\n",text.toStdString().c_str());
1671#endif
1672 
1673  QStringList result = fG4cout.filter(text);
1674
1675  fCoutTBTextArea->setText(result.join("\n"));
1676  fCoutTBTextArea->repaint();
1677#if QT_VERSION < 0x040000
1678  fCoutTBTextArea->verticalScrollBar()->setValue(fCoutTBTextArea->verticalScrollBar()->maxValue());
1679#else
1680  fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
1681#endif
1682#ifdef G4DEBUG_INTERFACES_BASIC
1683  printf("G4UIQt::CoutFilterCallback textSize:%d resSize:%d \n",fG4cout.join("").size(),result.join("").size());
1684#endif
1685
1686 }
1687
1688/**   Callback called when user give a new string to look for<br>
1689   Display a list of matching commands descriptions. If no string is set,
1690   will display the complete help tree
1691*/
1692void G4UIQt::LookForHelpStringCallback(
1693)
1694{
1695  QString searchText = fHelpLine->text();
1696
1697#if QT_VERSION < 0x040200
1698  fHelpArea->clear();
1699#else
1700  fHelpArea->setText("");
1701#endif
1702  if (searchText =="") {
1703    // clear old help tree
1704    fHelpTreeWidget->clear();
1705#if QT_VERSION < 0x040000
1706    fHelpTreeWidget->removeColumn(1);
1707    fHelpTreeWidget->removeColumn(0);
1708#endif
1709
1710    FillHelpTree();
1711
1712    return;
1713  } else {
1714    OpenHelpTreeOnCommand(searchText);
1715  }
1716}
1717
1718
1719void G4UIQt::OpenHelpTreeOnCommand(
1720 const QString & searchText
1721)
1722{
1723
1724  // the help tree
1725  G4UImanager* UI = G4UImanager::GetUIpointer();
1726  if(UI==NULL) return;
1727  G4UIcommandTree * treeTop = UI->GetTree();
1728 
1729  G4int treeSize = treeTop->GetTreeEntry();
1730
1731  // clear old help tree
1732  fHelpTreeWidget->clear();
1733#if QT_VERSION < 0x040000
1734  fHelpTreeWidget->removeColumn(1);
1735  fHelpTreeWidget->removeColumn(0);
1736#endif
1737
1738  // look for new items
1739
1740  int tmp = 0;
1741#if QT_VERSION < 0x040000
1742  int multFactor = 1000; // factor special for having double keys in Qt3
1743  int doubleKeyAdd = 0;  // decay for doubleKeys in Qt3
1744#endif
1745
1746  QMap<int,QString> commandResultMap;
1747  QMap<int,QString> commandChildResultMap;
1748
1749  for (int a=0;a<treeSize;a++) {
1750    G4UIcommand* command = treeTop->FindPath(treeTop->GetTree(a+1)->GetPathName().data());
1751#if QT_VERSION > 0x040000
1752    tmp = GetCommandList (command).count(searchText,Qt::CaseInsensitive);
1753#else
1754    tmp = GetCommandList (command).contains(searchText,false);
1755#endif
1756    if (tmp >0) {
1757#if QT_VERSION > 0x040000
1758      commandResultMap.insertMulti(tmp,QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()));
1759#else // tricky thing for Qt3...
1760      doubleKeyAdd = 0;
1761      while (commandResultMap.find( tmp*multFactor+doubleKeyAdd) != commandResultMap.end()) {
1762        doubleKeyAdd ++;
1763      }
1764      commandResultMap.insert( tmp*multFactor+doubleKeyAdd,QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()) );
1765#endif
1766    }
1767    // look for childs
1768    commandChildResultMap = LookForHelpStringInChildTree(treeTop->GetTree(a+1),searchText);
1769    // insert new childs
1770    if (!commandChildResultMap.empty()) {
1771#if QT_VERSION > 0x040000
1772      QMap<int,QString>::const_iterator i = commandChildResultMap.constBegin();
1773      while (i != commandChildResultMap.constEnd()) {
1774        commandResultMap.insertMulti(i.key(),i.value());
1775#else // tricky thing for Qt3...
1776      QMap<int,QString>::const_iterator i = commandChildResultMap.begin();
1777      while (i != commandChildResultMap.end()) {
1778        doubleKeyAdd = 0;
1779        while (commandResultMap.find( i.key()*multFactor+doubleKeyAdd) != commandResultMap.end()) {
1780          doubleKeyAdd ++;
1781        }
1782        commandResultMap.insert(i.key()*multFactor+doubleKeyAdd,i.data());
1783#endif
1784        i++;
1785      }
1786      commandChildResultMap.clear();
1787    }
1788  }
1789
1790  // build new help tree
1791#if QT_VERSION < 0x040000
1792  fHelpTreeWidget->setSelectionMode(QListView::Single);
1793  fHelpTreeWidget->setRootIsDecorated(true);
1794  fHelpTreeWidget->addColumn("Command");
1795  fHelpTreeWidget->addColumn("Match");
1796  //  fHelpTreeWidget->header()->setResizeEnabled(FALSE,1);
1797#else
1798  fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
1799  fHelpTreeWidget->setColumnCount(2);
1800  QStringList labels;
1801  labels << QString("Command") << QString("Match");
1802  fHelpTreeWidget->setHeaderLabels(labels);
1803#endif
1804
1805  if (commandResultMap.empty()) {
1806#if QT_VERSION < 0x040200
1807    fHelpArea->clear();
1808    fHelpArea->append("No match found");
1809#else
1810    fHelpArea->setText("No match found");
1811#endif
1812    return;
1813  }
1814
1815#if QT_VERSION > 0x040000
1816  QMap<int,QString>::const_iterator i = commandResultMap.constEnd();
1817#else
1818  QMap<int,QString>::const_iterator i = commandResultMap.end();
1819#endif
1820  i--;
1821  // 10 maximum progress values
1822  float multValue = 10.0/(float)(i.key());
1823  QString progressChar = "|";
1824  QString progressStr = "|";
1825
1826#if QT_VERSION < 0x040000
1827  QListViewItem * newItem;
1828#else
1829  QTreeWidgetItem * newItem;
1830#endif
1831  bool end = false;
1832  while (!end) {
1833#if QT_VERSION > 0x040000
1834    if (i == commandResultMap.constBegin()) {
1835#else
1836    if (i == commandResultMap.begin()) {
1837#endif
1838      end = true;
1839    }
1840    for(int a=0;a<int(i.key()*multValue);a++) {
1841      progressStr += progressChar;
1842    }
1843#if QT_VERSION < 0x040000
1844    newItem = new QListViewItem(fHelpTreeWidget);
1845    newItem->setText(0,i.data().simplifyWhiteSpace());
1846#else
1847    newItem = new QTreeWidgetItem(fHelpTreeWidget);
1848    newItem->setText(0,i.value().trimmed());
1849#endif
1850    newItem->setText(1,progressStr);
1851   
1852#if QT_VERSION >= 0x040200
1853    newItem->setForeground ( 1, QBrush(Qt::blue) );
1854#endif
1855    progressStr = "|";
1856    i--;
1857  }
1858  // FIXME :  to be checked on Qt3
1859#if QT_VERSION < 0x040000
1860  fHelpTreeWidget->setColumnWidthMode (1,QListView::Maximum);
1861  fHelpTreeWidget->setSorting(1,false);
1862#else
1863  fHelpTreeWidget->resizeColumnToContents (0);
1864  fHelpTreeWidget->sortItems(1,Qt::DescendingOrder);
1865  //  fHelpTreeWidget->setColumnWidth(1,10);//resizeColumnToContents (1);
1866#endif
1867}
1868
1869
1870
1871
1872QMap<int,QString> G4UIQt::LookForHelpStringInChildTree(
1873 G4UIcommandTree *aCommandTree
1874,const QString & text
1875 )
1876{
1877  QMap<int,QString> commandResultMap;
1878  if (aCommandTree == NULL) return commandResultMap;
1879 
1880#if QT_VERSION < 0x040000
1881  int multFactor = 1000; // factor special for having double keys in Qt3
1882  int doubleKeyAdd = 0;  // decay for doubleKeys in Qt3
1883#endif
1884
1885  // Get the Sub directories
1886  int tmp = 0;
1887  QMap<int,QString> commandChildResultMap;
1888 
1889  for (int a=0;a<aCommandTree->GetTreeEntry();a++) {
1890    const G4UIcommand* command = aCommandTree->GetGuidance();
1891#if QT_VERSION > 0x040000
1892    tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
1893#else
1894    tmp = GetCommandList (command).contains(text,false);
1895#endif
1896    if (tmp >0) {
1897#if QT_VERSION > 0x040000
1898      commandResultMap.insertMulti(tmp,QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()));
1899#else // tricky thing for Qt3...
1900      doubleKeyAdd = 0;
1901      while (commandResultMap.find( tmp*multFactor+doubleKeyAdd) != commandResultMap.end()) {
1902        doubleKeyAdd ++;
1903      }
1904      commandResultMap.insert(tmp*multFactor+doubleKeyAdd,QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()));
1905#endif
1906    }
1907    // look for childs
1908    commandChildResultMap = LookForHelpStringInChildTree(aCommandTree->GetTree(a+1),text);
1909   
1910    if (!commandChildResultMap.empty()) {
1911      // insert new childs
1912#if QT_VERSION > 0x040000
1913      QMap<int,QString>::const_iterator i = commandChildResultMap.constBegin();
1914      while (i != commandChildResultMap.constEnd()) {
1915        commandResultMap.insertMulti(i.key(),i.value());
1916#else // tricky thing for Qt3...
1917      QMap<int,QString>::const_iterator i = commandChildResultMap.begin();
1918      while (i != commandChildResultMap.end()) {
1919        doubleKeyAdd = 0;
1920        while (commandResultMap.find( i.key()*multFactor+doubleKeyAdd) != commandResultMap.end()) {
1921          doubleKeyAdd ++;
1922        }
1923        commandResultMap.insert(i.key()*multFactor+doubleKeyAdd,i.data());
1924#endif
1925        i++;
1926      }
1927      commandChildResultMap.clear();
1928    }
1929  }
1930  // Get the Commands
1931 
1932  for (int a=0;a<aCommandTree->GetCommandEntry();a++) {
1933    const G4UIcommand* command = aCommandTree->GetCommand(a+1);
1934#if QT_VERSION > 0x040000
1935    tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
1936#else
1937    tmp = GetCommandList (command).contains(text,false);
1938#endif
1939    if (tmp >0) {
1940#if QT_VERSION > 0x040000
1941      commandResultMap.insertMulti(tmp,QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()));
1942#else // tricky thing for Qt3...
1943      doubleKeyAdd = 0;
1944      while (commandResultMap.find( tmp*multFactor+doubleKeyAdd) != commandResultMap.end()) {
1945        doubleKeyAdd ++;
1946      }
1947      commandResultMap.insert(tmp*multFactor+doubleKeyAdd,QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()));
1948#endif
1949    }
1950   
1951  }
1952  return commandResultMap;
1953}
1954
1955 
1956QString G4UIQt::GetShortCommandPath(
1957QString commandPath
1958)
1959{
1960  if (commandPath.indexOf("/") == 0) {
1961    commandPath = commandPath.right(commandPath.size()-1);
1962  }
1963
1964  commandPath = commandPath.right(commandPath.size()-commandPath.lastIndexOf("/",-2)-1);
1965 
1966 if (commandPath.lastIndexOf("/") == (commandPath.size()-1)) {
1967    commandPath = commandPath.left(commandPath.size()-1);
1968  }
1969
1970 return commandPath;
1971}
1972
1973
1974QString G4UIQt::GetLongCommandPath(
1975#if QT_VERSION < 0x040000
1976 QListViewItem* item
1977#else
1978 QTreeWidgetItem* item
1979#endif
1980)
1981{
1982  if (item == NULL) return "";
1983
1984  // rebuild path:
1985  QString itemText = "";
1986  itemText = item->text(0);
1987
1988  while (item->parent() != NULL) {
1989    itemText = item->parent()->text(0)+"/"+itemText;
1990    item = item->parent();
1991  }
1992  itemText = "/"+itemText;
1993 
1994  return itemText;
1995}
1996
1997G4QTabWidget::G4QTabWidget(
1998QSplitter*& split
1999):QTabWidget(split)
2000{
2001}
2002
2003G4QTabWidget::G4QTabWidget(
2004):QTabWidget()
2005{
2006}
2007
2008
2009 
2010void G4UIQt::TabCloseCallback(int a){
2011#ifdef G4DEBUG_INTERFACES_BASIC
2012  printf("G4UIQt::TabCloseCallback   %d ---------------------------------\n",a);
2013#endif
2014  QWidget* temp = fTabWidget->widget(a);
2015  fTabWidget->removeTab (a);
2016  delete temp;
2017
2018  if (fTabWidget->count() == 0) {
2019    fMyVSplitter->addWidget(fEmptyViewerTabLabel);
2020#if QT_VERSION < 0x040000
2021    fTabWidget->reparent(0,0,QPoint(0,0)); 
2022#else
2023    fTabWidget->setParent(0);
2024#endif
2025  }
2026}
2027
2028
2029void G4UIQt::ToolBoxActivated(int a){
2030
2031  if (fToolBox->widget(a) == fHelpTBWidget) {
2032    // Rebuild the help tree
2033    FillHelpTree();
2034
2035#ifdef G4DEBUG_INTERFACES_BASIC
2036    printf("G4UIQt::CurrentChangeCallback   %d ---------------------------------\n",a);
2037#endif
2038  }
2039}
2040
2041void G4QTabWidget::paintEvent(
2042QPaintEvent * event
2043)
2044{
2045
2046  if (currentWidget()) {
2047#ifdef G4DEBUG_INTERFACES_BASIC
2048    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());
2049#endif
2050    if ( isTabSelected()) {
2051
2052      QCoreApplication::sendPostedEvents () ;
2053#ifdef G4DEBUG_INTERFACES_BASIC
2054      printf("G4QTabWidget::paintEvent OK\n");
2055#endif
2056      QString text = tabText (currentIndex());
2057      QString paramSelect = QString("/vis/viewer/select ")+text;
2058      G4UImanager* UI = G4UImanager::GetUIpointer();
2059      if(UI!=NULL)  {
2060        UI->ApplyCommand(paramSelect.toStdString().c_str());
2061      }
2062      unselectTab();
2063      repaint();
2064    }
2065  }
2066}
2067
2068#endif
Note: See TracBrowser for help on using the repository browser.