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

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

test qt3

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