source: trunk/geant4/interfaces/basic/src/G4UIQt.cc@ 696

Last change on this file since 696 was 695, checked in by garnier, 18 years ago

debut de la zone de recherche sur le Help

  • Property svn:mime-type set to text/cpp
File size: 38.8 KB
RevLine 
[607]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//
[688]27// $Id: G4UIQt.cc,v 1.14 2008/01/15 11:04:26 lgarnier Exp $
[630]28// GEANT4 tag $Name: $
[607]29//
30// L. Garnier
31
[695]32#define GEANT4_QT_DEBUG
[607]33
34#ifdef G4UI_BUILD_QT_SESSION
35
36#include "G4Types.hh"
37
38#include <string.h>
39
40#include "G4UIQt.hh"
41#include "G4UImanager.hh"
42#include "G4StateManager.hh"
43#include "G4UIcommandTree.hh"
44#include "G4UIcommandStatus.hh"
45
46#include "G4Qt.hh"
47
48#include <qapplication.h>
49#include <qlineedit.h>
50#include <qwidget.h>
51#include <qmenubar.h>
52#include <qlayout.h>
53#include <qpushbutton.h>
54#include <qlabel.h>
55#include <qsplitter.h>
56#include <qscrollbar.h>
57#include <qdialog.h>
58#include <qevent.h>
59#include <qtextedit.h>
60#include <qsignalmapper.h>
61
[608]62#include <qmainwindow.h>
[607]63#if QT_VERSION >= 0x040000
64#include <qmenu.h>
65#include <qlistwidget.h>
66#include <qtreewidget.h>
67#else
68#include <qaction.h>
69#include <qheader.h>
70#include <qlistview.h>
71#include <qpopupmenu.h>
72#endif
73
74
75
76#include <stdlib.h>
77
78// Pourquoi Static et non variables de classe ?
79static G4bool exitSession = true;
80static G4bool exitPause = true;
81
82/** Build a Qt window with a menubar, output area and promt area<br>
83<pre>
84 +-----------------------+
85 |exit menu| |
86 | |
87 | +-------------------+ |
88 | | | |
89 | | Output area | |
90 | | | |
91 | +-------------------+ |
92 | | clear | |
93 | +-------------------+ |
94 | | promt history | |
95 | +-------------------+ |
96 | +-------------------+ |
97 | |> promt area | |
98 | +-------------------+ |
99 +-----------------------+
100</pre>
101*/
102G4UIQt::G4UIQt (
103 int argc
104,char** argv
105)
106 :fHelpDialog(NULL)
107{
[608]108#ifdef GEANT4_QT_DEBUG
[607]109 printf("G4UIQt::Initialise %d %s\n",argc,argv[0]);
[608]110#endif
[607]111 G4Qt* interactorManager = G4Qt::getInstance (argc,argv,(char*)"Qt");
112 G4UImanager* UI = G4UImanager::GetUIpointer();
113 if(UI!=NULL) UI->SetSession(this);
114
115 fMainWindow = new QMainWindow();
116
[608]117#ifdef GEANT4_QT_DEBUG
[607]118 printf("G4UIQt::Initialise after main window creation\n");
[608]119#endif
[607]120#if QT_VERSION < 0x040000
121 fMainWindow->setCaption( tr( "G4UI Session" ));
122 fMainWindow->resize(800,600);
123 fMainWindow->move(50,100);
124#else
125 fMainWindow->setWindowTitle( tr("G4UI Session") );
126 fMainWindow->resize(800,600);
127 fMainWindow->move(QPoint(50,100));
128#endif
129
[617]130 QSplitter *splitter = new QSplitter(Qt::Vertical,fMainWindow);
[611]131
[610]132 // Set layouts
133
134 QWidget* topWidget = new QWidget(splitter);
135 QWidget* bottomWidget = new QWidget(splitter);
136
137 QVBoxLayout *layoutTop = new QVBoxLayout(topWidget);
138 QVBoxLayout *layoutBottom = new QVBoxLayout(bottomWidget);
139
140 // fill them
141
142 fTextArea = new QTextEdit(topWidget);
143#ifdef GEANT4_QT_DEBUG
144 printf("G4UIQt:: end\n");
145#endif
146#ifdef GEANT4_QT_DEBUG
147 printf("G4UIQt::PushButton 1\n");
148#endif
149 QPushButton *clearButton = new QPushButton("clear",topWidget);
150#ifdef GEANT4_QT_DEBUG
151 printf("G4UIQt::end1\n");
152#endif
[607]153 connect(clearButton, SIGNAL(clicked()), SLOT(ClearButtonCallback()));
154
155#if QT_VERSION < 0x040000
[635]156
[610]157 fCommandHistoryArea = new QListView(bottomWidget);
[620]158 fCommandHistoryArea->setSorting (-1, FALSE);
[607]159 fCommandHistoryArea->setSelectionMode(QListView::Single);
[620]160 fCommandHistoryArea->addColumn("");
161 fCommandHistoryArea->header()->hide();
[608]162 connect(fCommandHistoryArea, SIGNAL(selectionChanged()), SLOT(CommandHistoryCallback()));
[607]163#else
164 fCommandHistoryArea = new QListWidget();
165 fCommandHistoryArea->setSelectionMode(QAbstractItemView::SingleSelection);
[608]166 connect(fCommandHistoryArea, SIGNAL(itemSelectionChanged()), SLOT(CommandHistoryCallback()));
[607]167#endif
168 fCommandHistoryArea->installEventFilter(this);
[610]169 fCommandLabel = new QLabel("",bottomWidget);
[607]170
[610]171 fCommandArea = new QLineEdit(bottomWidget);
[607]172 fCommandArea->installEventFilter(this);
173#if QT_VERSION < 0x040000
174 fCommandArea->setActiveWindow();
175#else
176 fCommandArea->activateWindow();
177#endif
178 connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback()));
179#if QT_VERSION < 0x040000
180 fCommandArea->setFocusPolicy ( QWidget::StrongFocus );
181 fCommandArea->setFocus();
182#else
183 fCommandArea->setFocusPolicy ( Qt::StrongFocus );
184 fCommandArea->setFocus(Qt::TabFocusReason);
185#endif
186 fTextArea->setReadOnly(true);
187
188
[610]189#ifdef GEANT4_QT_DEBUG
190 printf("G4UIQt:: 2\n");
191#endif
[607]192
193
194
195 layoutTop->addWidget(fTextArea);
196 layoutTop->addWidget(clearButton);
197
198#if QT_VERSION >= 0x040000
199 topWidget->setLayout(layoutTop);
200#endif
201
202 layoutBottom->addWidget(fCommandHistoryArea);
203 layoutBottom->addWidget(fCommandLabel);
204 layoutBottom->addWidget(fCommandArea);
205#if QT_VERSION >= 0x040000
206
207 bottomWidget->setLayout(layoutBottom);
208 splitter->addWidget(topWidget);
209 splitter->addWidget(bottomWidget);
210#endif
211
212
213 fMainWindow->setCentralWidget(splitter);
214
215#if QT_VERSION < 0x040000
216
217 // Add a quit subMenu
218 QPopupMenu *fileMenu = new QPopupMenu( fMainWindow);
[608]219 fileMenu->insertItem( "&Quitter", this, SLOT(ExitSession()), CTRL+Key_Q );
[607]220 fMainWindow->menuBar()->insertItem( QString("&File"), fileMenu );
221
222 // Add a Help menu
223 QPopupMenu *helpMenu = new QPopupMenu( fMainWindow );
224 helpMenu->insertItem( "&Show Help", this, SLOT(ShowHelpCallback()), CTRL+Key_H );
225 fMainWindow->menuBar()->insertItem( QString("&Help"), helpMenu );
226
227
228#else
229
230 // Add a quit subMenu
231 QMenu *fileMenu = fMainWindow->menuBar()->addMenu("File");
[608]232 fileMenu->addAction("Quitter", this, SLOT(ExitSession()));
[607]233
234 // Add a Help menu
235 QMenu *helpMenu = fMainWindow->menuBar()->addMenu("Help");
236 helpMenu->addAction("Show Help", this, SLOT(ShowHelpCallback()));
237#endif
238
239 // Set the splitter size. The fTextArea sould be 2/3 on the fMainWindow
240#if QT_VERSION < 0x040000
241 QValueList<int> vals = splitter->sizes();
242#else
243 QList<int> vals = splitter->sizes();
244#endif
245 if(vals.size()==2) {
246 vals[0] = (splitter->orientation()==Qt::Vertical ? splitter->height() : splitter->width())*3/4;
247 vals[1] = (splitter->orientation()==Qt::Vertical ? splitter->height() : splitter->width())*1/4;
248 splitter->setSizes(vals);
249 }
250
251 if(UI!=NULL) UI->SetCoutDestination(this); // TO KEEP
252}
253
254
255
256G4UIQt::~G4UIQt(
257)
258{
259 G4UImanager* UI = G4UImanager::GetUIpointer(); // TO KEEP
260 if(UI!=NULL) { // TO KEEP
261 UI->SetSession(NULL); // TO KEEP
262 UI->SetCoutDestination(NULL); // TO KEEP
263 }
264
265 if (fMainWindow!=NULL)
266 delete fMainWindow;
267}
268
269
270
271/** Start the Qt main loop
272*/
273G4UIsession* G4UIQt::SessionStart (
274)
275{
276
277 G4Qt* interactorManager = G4Qt::getInstance ();
278
279#if QT_VERSION >= 0x040000
[608]280#if QT_VERSION >= 0x040200
[607]281 fMainWindow->setVisible(true);
282#else
283 fMainWindow->show();
284#endif
[608]285#else
286 fMainWindow->show();
287#endif
[607]288 Prompt("session");
289 exitSession = false;
290
291
[608]292#ifdef GEANT4_QT_DEBUG
[607]293 printf("disable secondary loop\n");
[608]294#endif
[607]295 interactorManager->DisableSecondaryLoop (); // TO KEEP
[610]296 if ((QApplication*)interactorManager->GetMainInteractor())
297 ((QApplication*)interactorManager->GetMainInteractor())->exec();
298
[607]299 // on ne passe pas le dessous ? FIXME ????
300 // je ne pense pas 13/06
301
302 // void* event; // TO KEEP
303 // while((event = interactorManager->GetEvent())!=NULL) { // TO KEEP
304 // interactorManager->DispatchEvent(event); // TO KEEP
305 // if(exitSession==true) break; // TO KEEP
306 // } // TO KEEP
307
308 interactorManager->EnableSecondaryLoop ();
[608]309#ifdef GEANT4_QT_DEBUG
[607]310 printf("enable secondary loop\n");
[608]311#endif
[607]312 return this;
313}
314
315
316/** Display the prompt in the prompt area
317 @param aPrompt : string to display as the promt label
318 //FIXME : probablement inutile puisque le seul a afficher qq chose d'autre
319 que "session" est SecondaryLoop()
320*/
321void G4UIQt::Prompt (
322 G4String aPrompt
323)
324{
325 if (!aPrompt) return;
326
327 fCommandLabel->setText((char*)aPrompt.data());
328}
329
330
331void G4UIQt::SessionTerminate (
332)
333{
334 G4Qt* interactorManager = G4Qt::getInstance ();
335 fMainWindow->close();
336 ((QApplication*)interactorManager->GetMainInteractor())->exit();
337}
338
339
340
341/**
342 Called by intercoms/src/G4UImanager.cc<br>
343 Called by visualization/management/src/G4VisCommands.cc with "EndOfEvent" argument<br>
344 It have to pause the session command terminal.<br>
345 Call SecondaryLoop to wait for exit event<br>
346 @param aState
347 @see : G4VisCommandReviewKeptEvents::SetNewValue
348*/
349void G4UIQt::PauseSessionStart (
350 G4String aState
351)
352{
353 if (!aState) return;
354
[608]355#ifdef GEANT4_QT_DEBUG
[607]356 printf("G4UIQt::PauseSessionStart\n");
[608]357#endif
[607]358 if(aState=="G4_pause> ") { // TO KEEP
359 SecondaryLoop ("Pause, type continue to exit this state"); // TO KEEP
360 } // TO KEEP
361
362 if(aState=="EndOfEvent") { // TO KEEP
363 // Picking with feed back in event data Done here !!!
364 SecondaryLoop ("End of event, type continue to exit this state"); // TO KEEP
365 } // TO KEEP
366}
367
368
369
370/**
371 Begin the secondary loop
372 @param a_prompt : label to display as the prompt label
373 */
374void G4UIQt::SecondaryLoop (
375 G4String aPrompt
376)
377{
378 if (!aPrompt) return;
379
[608]380#ifdef GEANT4_QT_DEBUG
[607]381 printf("G4UIQt::SecondaryLoop\n");
[608]382#endif
[607]383 G4Qt* interactorManager = G4Qt::getInstance (); // TO KEEP ?
384 Prompt(aPrompt); // TO KEEP
385 exitPause = false; // TO KEEP
386 void* event; // TO KEEP
387 while((event = interactorManager->GetEvent())!=NULL) { // TO KEEP
388 interactorManager->DispatchEvent(event); // TO KEEP
389 if(exitPause==true) break; // TO KEEP
390 } // TO KEEP
391 Prompt("session"); // TO KEEP
392}
393
394
395
396/**
397 Receive a cout from Geant4. We have to display it in the cout zone
398 @param aString : label to add in the display area
399 @return 0
400*/
401G4int G4UIQt::ReceiveG4cout (
402 G4String aString
403)
404{
405 if (!aString) return 0;
406 G4Qt* interactorManager = G4Qt::getInstance ();
407 if (!interactorManager) return 0;
408
409#if QT_VERSION < 0x040000
410 fTextArea->append(QString((char*)aString.data()).simplifyWhiteSpace());
411 fTextArea->verticalScrollBar()->setValue(fTextArea->verticalScrollBar()->maxValue());
412#else
413 fTextArea->append(QString((char*)aString.data()).trimmed());
414 fTextArea->verticalScrollBar()->setSliderPosition(fTextArea->verticalScrollBar()->maximum());
415#endif
416 interactorManager->FlushAndWaitExecution();
417 return 0;
418}
419
420
421/**
422 Receive a cerr from Geant4. We have to display it in the cout zone
423 @param aString : label to add in the display area
424 @return 0
425*/
426G4int G4UIQt::ReceiveG4cerr (
427 G4String aString
428)
429{
430 if (!aString) return 0;
431 G4Qt* interactorManager = G4Qt::getInstance ();
432 if (!interactorManager) return 0;
433
434#if QT_VERSION < 0x040000
435 QColor previousColor = fTextArea->color();
436 fTextArea->setColor(Qt::red);
437 fTextArea->append(QString((char*)aString.data()).simplifyWhiteSpace());
438 fTextArea->setColor(previousColor);
439 fTextArea->verticalScrollBar()->setValue(fTextArea->verticalScrollBar()->maxValue());
440#else
441 QColor previousColor = fTextArea->textColor();
442 fTextArea->setTextColor(Qt::red);
443 fTextArea->append(QString((char*)aString.data()).trimmed());
444 fTextArea->setTextColor(previousColor);
445 fTextArea->verticalScrollBar()->setSliderPosition(fTextArea->verticalScrollBar()->maximum());
446#endif
447 interactorManager->FlushAndWaitExecution();
448 return 0;
449}
450
451
452
453/**
454 Add a new menu to the menu bar
455 @param aName name of menu
456 @param aLabel label to display
457 */
458void G4UIQt::AddMenu (
459 const char* aName
460,const char* aLabel
461)
462{
463 if (aName == NULL) return;
464 if (aLabel == NULL) return;
465
466#if QT_VERSION < 0x040000
467 QPopupMenu *fileMenu = new QPopupMenu( fMainWindow);
468 fMainWindow->menuBar()->insertItem( aLabel, fileMenu );
469#else
470 QMenu *fileMenu = new QMenu(aLabel);
471 fMainWindow->menuBar()->insertMenu(fMainWindow->menuBar()->actions().last(),fileMenu);
472#endif
473
474 AddInteractor (aName,(G4Interactor)fileMenu);
475}
476
477
478/**
479 Add a new button to a menu
480 @param aMenu : parent menu
481 @param aLabel : label to display
482 @param aCommand : command to execute as a callback
483 */
484void G4UIQt::AddButton (
485 const char* aMenu
486,const char* aLabel
487,const char* aCommand
488)
489{
490 if(aMenu==NULL) return; // TO KEEP
491 if(aLabel==NULL) return; // TO KEEP
492 if(aCommand==NULL) return; // TO KEEP
493
494#if QT_VERSION < 0x040000
495 QPopupMenu *parent = (QPopupMenu*)GetInteractor(aMenu);
496#else
497 QMenu *parent = (QMenu*)GetInteractor(aMenu);
498#endif
499
500 if(parent==NULL) return;
501
502 QSignalMapper *signalMapper = new QSignalMapper(this);
[617]503#if QT_VERSION < 0x030200
504 QAction *action = new QAction(QString(aLabel),QString(aLabel),QKeySequence::QKeySequence (),signalMapper, SLOT(map()));
[620]505 action->addTo(parent);
506 connect(action,SIGNAL(activated()),signalMapper,SLOT(map()));
507
508#elif QT_VERSION < 0x040000
[607]509 QAction *action = new QAction(QString(aLabel),QKeySequence::QKeySequence (),signalMapper, SLOT(map()));
510 action->addTo(parent);
[624]511 connect(action,SIGNAL(activated()),signalMapper,SLOT(map()));
[620]512
[607]513#else
514 QAction *action = parent->addAction(aLabel, signalMapper, SLOT(map()));
[620]515
[607]516#endif
[620]517 connect(signalMapper, SIGNAL(mapped(const QString &)),this, SLOT(ButtonCallback(const QString&)));
[607]518 signalMapper->setMapping(action, QString(aCommand));
519}
520
521
522
523
524/**
525 Open the help dialog in a separate window.<br>
526 This will be display as a tree widget.<br>
527 Implementation of <b>void G4VBasicShell::TerminalHelp(G4String newCommand)</b>
528
529 @param newCommand : open the tree widget item on this command if is set
530*/
531void G4UIQt::TerminalHelp(
532 G4String newCommand
533)
534{
535 // Create the help dialog
536 if (!fHelpDialog) {
537#if QT_VERSION < 0x040000
[624]538 fHelpDialog = new QDialog(0,0,FALSE,Qt::WStyle_Title | Qt::WStyle_SysMenu | Qt::WStyle_MinMax );
[607]539#else
[625]540 fHelpDialog = new QDialog(0,Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint);
[607]541#endif
[635]542 QVBoxLayout *vLayout = new QVBoxLayout(fHelpDialog);
[695]543 helpLine = new QLineEdit("Look for...",fHelpDialog);
[633]544 QSplitter *splitter = new QSplitter(Qt::Horizontal,fHelpDialog);
[619]545 QPushButton *exitButton = new QPushButton("Exit",fHelpDialog);
[607]546 connect(exitButton, SIGNAL(clicked()), fHelpDialog,SLOT(close()));
[695]547 connect( helpLine, SIGNAL( editingFinished () ), this, SLOT( lookForHelpStringCallback() ) );
[607]548
[695]549
[607]550 // the help tree
551 G4UImanager* UI = G4UImanager::GetUIpointer();
552 if(UI==NULL) return;
553 G4UIcommandTree * treeTop = UI->GetTree();
554
555 // build widget
556#if QT_VERSION < 0x040000
557 fHelpTreeWidget = new QListView(splitter);
558 fHelpTreeWidget->setSelectionMode(QListView::Single);
[619]559 fHelpTreeWidget->setRootIsDecorated(true);
[607]560 fHelpTreeWidget->addColumn("Command");
[619]561 fHelpTreeWidget->addColumn("Description",0);
562 // fHelpTreeWidget->setColumnWidth (1,0);
[607]563 fHelpTreeWidget->header()->setResizeEnabled(FALSE,1);
564 // QList<QListViewItem *> items;
565#else
566 fHelpTreeWidget = new QTreeWidget();
567 fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
568 fHelpTreeWidget->setColumnCount(2);
569 fHelpTreeWidget->setColumnHidden(1,true);
570 QStringList labels;
571 labels << QString("Command") << QString("Description");
572 fHelpTreeWidget->setHeaderLabels(labels);
573 // QList<QTreeWidgetItem *> items;
574#endif
575
576 fHelpArea = new QTextEdit(splitter);
577 fHelpArea->setReadOnly(true);
578
579 G4int treeSize = treeTop->GetTreeEntry();
580#if QT_VERSION < 0x040000
581 QListViewItem * newItem;
582#else
583 QTreeWidgetItem * newItem;
584#endif
585 for (int a=0;a<treeSize;a++) {
586 // Creating new item
587
588#if QT_VERSION < 0x040000
589 newItem = new QListViewItem(fHelpTreeWidget);
590 newItem->setText(0,QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()).simplifyWhiteSpace());
591 newItem->setText(1,QString((char*)(treeTop->GetTree(a+1)->GetTitle()).data()).simplifyWhiteSpace());
592#else
593 //FIXME : Qt 4.2
594 // QStringList stringList;
595 // stringList << QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()).trimmed() ;
596 // stringList << QString((char*)(treeTop->GetTree(a+1)->GetTitle()).data()).trimmed() ;
597 // newItem = new QTreeWidgetItem(stringList);
598 // FIXME : Qt 4.0
599 newItem = new QTreeWidgetItem(fHelpTreeWidget);
600 newItem->setText(0,QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()).trimmed());
601 newItem->setText(1,QString((char*)(treeTop->GetTree(a+1)->GetTitle()).data()).trimmed());
602#endif
603
604
605 // look for childs
606 CreateChildTree(newItem,treeTop->GetTree(a+1));
607 // items.append(newItem);
608 }
609
[648]610
[619]611#if QT_VERSION < 0x040000
612 connect(fHelpTreeWidget, SIGNAL(selectionChanged ()),this, SLOT(HelpTreeClicCallback()));
[648]613 connect(fHelpTreeWidget, SIGNAL(doubleClicked (QListViewItem*)),this, SLOT(HelpTreeDoubleClicCallback()));
[619]614#else
[607]615 connect(fHelpTreeWidget, SIGNAL(itemSelectionChanged ()),this, SLOT(HelpTreeClicCallback()));
[648]616 connect(fHelpTreeWidget, SIGNAL(itemDoubleClicked (QTreeWidgetItem*,int)),this, SLOT(HelpTreeDoubleClicCallback()));
[619]617#endif
[607]618
619 // Set layouts
620
[617]621#if QT_VERSION >= 0x040000
[607]622 splitter->addWidget(fHelpTreeWidget);
623 splitter->addWidget(fHelpArea);
624#endif
625
626
[619]627#if QT_VERSION >= 0x040000
628 vLayout->addWidget(splitter);
629 vLayout->addWidget(exitButton);
[617]630#else
[619]631 vLayout->add(splitter);
632 vLayout->addWidget(exitButton);
[617]633#endif
[619]634
635 // set the splitter size
[607]636#if QT_VERSION >= 0x040000
[619]637 QList<int> list;
638#else
639 QValueList<int> list;
640#endif
641 list.append( 400 );
642 list.append( 400 );
643 splitter->setSizes(list);
644
645#if QT_VERSION >= 0x040000
[607]646 fHelpDialog->setLayout(vLayout);
647#endif
648
649 }
650
[695]651 ActivateCommand(newCommand);
652
653#if QT_VERSION < 0x040000
654 fHelpDialog->setCaption( tr( "Help on commands" ));
655#else
656 fHelpDialog->setWindowTitle(tr("Help on commands"));
657#endif
658 fHelpDialog->resize(800,600);
659 fHelpDialog->move(QPoint(400,150));
660 fHelpDialog->show();
661 fHelpDialog->raise();
662#if QT_VERSION < 0x040000
663 fHelpDialog->setActiveWindow();
664#else
665 fHelpDialog->activateWindow();
666#endif
667}
668
669void G4UIQt::ActivateCommand(
670 G4String newCommand
671)
672{
[607]673 // Look for the choosen command "newCommand"
674 size_t i = newCommand.index(" ");
675 G4String targetCom="";
676 if( i != std::string::npos )
677 {
678 G4String newValue = newCommand(i+1,newCommand.length()-(i+1));
679 newValue.strip(G4String::both);
680 targetCom = ModifyToFullPathCommand( newValue );
681 }
682 if (targetCom != "") {
683#if QT_VERSION < 0x040000
684 QListViewItem* findItem = NULL;
685 QListViewItem* tmpItem = fHelpTreeWidget->firstChild();
686 while (tmpItem != 0) {
687 if (!findItem) {
688 findItem = FindTreeItem(tmpItem,QString((char*)targetCom.data()));
689 }
690 tmpItem = tmpItem->nextSibling();
691 }
692#else
693 QTreeWidgetItem* findItem = NULL;
694 for (int a=0;a<fHelpTreeWidget->topLevelItemCount();a++) {
695 if (!findItem) {
696 findItem = FindTreeItem(fHelpTreeWidget->topLevelItem(a),QString((char*)targetCom.data()));
697 }
698 }
699#endif
700
701 if (findItem) {
702
703 //collapsed open item
704#if QT_VERSION < 0x040000
705
706 // FIXME : Has to be checked
707 QListViewItem* tmpItem = fHelpTreeWidget->firstChild();
708 QList<QListViewItem> openItems;
709 while ((tmpItem != 0) || (!openItems.isEmpty())) {
710 if (tmpItem->isOpen() ) {
711 tmpItem->setOpen(false);
712 openItems.append(tmpItem);
713 tmpItem = tmpItem->firstChild();
714 } else {
715 tmpItem = tmpItem->nextSibling();
716 }
717 if (tmpItem == 0) {
718 tmpItem = openItems.take(openItems.count()-1);
719 }
720 }
721#else
722 QList<QTreeWidgetItem *> selected;
723
724 selected = fHelpTreeWidget->selectedItems();
725 if ( selected.count() != 0 ) {
726 QTreeWidgetItem * tmp =selected.at( 0 );
727 while ( tmp) {
728#if QT_VERSION < 0x040202
729 fHelpTreeWidget->setItemExpanded(tmp,false);
730#else
731 tmp->setExpanded(false);
732#endif
733 tmp = tmp->parent();
734 }
735 }
736#endif
737
738 // clear old selection
739 fHelpTreeWidget->clearSelection();
740
741 // set new selection
742#if QT_VERSION >= 0x040000
743#if QT_VERSION < 0x040202
744 fHelpTreeWidget->setItemSelected(findItem,true);
745#else
746 findItem->setSelected(true);
747#endif
748#else
749 findItem->setSelected(true);
750#endif
751
752 // expand parent item
753 while ( findItem) {
754#if QT_VERSION < 0x040000
755 findItem->setOpen(true);
756#else
757#if QT_VERSION < 0x040202
758 fHelpTreeWidget->setItemExpanded(findItem,true);
759#else
760 findItem->setExpanded(true);
761#endif
762#endif
763 findItem = findItem->parent();
764 }
765
766 // Call the update of the right textArea
767 HelpTreeClicCallback();
768 }
769 }
770}
771
772/** Fill the Help Tree Widget
773 @param aParent : parent item to fill
774 @param aCommandTree : commandTree node associate with this part of the Tree
775*/
776#if QT_VERSION < 0x040000
777void G4UIQt::CreateChildTree(
778 QListViewItem *aParent
779,G4UIcommandTree *aCommandTree
780#else
781void G4UIQt::CreateChildTree(
782 QTreeWidgetItem *aParent
783,G4UIcommandTree *aCommandTree
784#endif
785)
786{
787 if (aParent == NULL) return;
788 if (aCommandTree == NULL) return;
789
790
791 // Creating new item
792#if QT_VERSION < 0x040000
793 QListViewItem * newItem;
794#else
795 QTreeWidgetItem * newItem;
796#endif
797
798 // Get the Sub directories
799 for (int a=0;a<aCommandTree->GetTreeEntry();a++) {
800
801#if QT_VERSION < 0x040000
802 newItem = new QListViewItem(aParent);
803 newItem->setText(0,QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()).simplifyWhiteSpace());
804 newItem->setText(1,QString((char*)(aCommandTree->GetTree(a+1)->GetTitle()).data()).simplifyWhiteSpace());
805
806#else
807 newItem = new QTreeWidgetItem(aParent);
808 newItem->setText(0,QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()).trimmed());
809 newItem->setText(1,QString((char*)(aCommandTree->GetTree(a+1)->GetTitle()).data()).trimmed());
810#endif
811
812 CreateChildTree(newItem,aCommandTree->GetTree(a+1));
813 }
814
815
816
817 // Get the Commands
818
819 for (int a=0;a<aCommandTree->GetCommandEntry();a++) {
820
821 QStringList stringList;
822#if QT_VERSION < 0x040000
823 newItem = new QListViewItem(aParent);
824 newItem->setText(0,QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()).simplifyWhiteSpace());
825 newItem->setText(1,QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()).simplifyWhiteSpace());
826 newItem->setOpen(false);
827
828#else
829 newItem = new QTreeWidgetItem(aParent);
830 newItem->setText(0,QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()).trimmed());
831 newItem->setText(1,QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()).trimmed());
832#if QT_VERSION < 0x040202
833 fHelpTreeWidget->setItemExpanded(newItem,false);
834#else
835 newItem->setExpanded(false);
836#endif
837#endif
838
839 }
840}
841
842
843/** Find a treeItemWidget in the help tree
844 @param aCommand item's String to look for
845 @return item if found, NULL if not
846*/
847#if QT_VERSION < 0x040000
848QListViewItem* G4UIQt::FindTreeItem(
849 QListViewItem *aParent
850#else
851QTreeWidgetItem* G4UIQt::FindTreeItem(
852 QTreeWidgetItem *aParent
853#endif
854,const QString& aCommand
855)
856{
857 if (aParent == NULL) return NULL;
858
859 if (aParent->text(0) == aCommand)
860 return aParent;
861
862#if QT_VERSION < 0x040000
863 QListViewItem * tmp = NULL;
864 QListViewItem* tmpItem = aParent->firstChild();
865 while (tmpItem != 0) {
866 if (!tmp)
867 tmp = FindTreeItem(tmpItem,aCommand);
868 tmpItem = tmpItem->nextSibling();
869 }
870
871#else
872 QTreeWidgetItem * tmp = NULL;
873 for (int a=0;a<aParent->childCount();a++) {
874 if (!tmp)
875 tmp = FindTreeItem(aParent->child(a),aCommand);
876 }
877#endif
878 return tmp;
879}
880
881
882/** Build the command list parameters in a QString<br>
883 Reimplement partialy the G4UIparameter.cc
884 @param aCommand : command to list parameters
885 @see G4UIparameter::List()
886 @see G4UIcommand::List()
887 @return the command list parameters, or "" if nothing
888*/
889QString G4UIQt::GetCommandList (
890 const G4UIcommand *aCommand
891)
892{
893
894 QString txt ="";
895 if (aCommand == NULL)
896 return txt;
897
898 G4String commandPath = aCommand->GetCommandPath();
899 G4String rangeString = aCommand->GetRange();
900 G4int n_guidanceEntry = aCommand->GetGuidanceEntries();
901 G4int n_parameterEntry = aCommand->GetParameterEntries();
902
903 if ((commandPath == "") &&
904 (rangeString == "") &&
905 (n_guidanceEntry == 0) &&
906 (n_parameterEntry == 0)) {
907 return txt;
908 }
909
910 if((commandPath.length()-1)!='/') {
911 txt += "Command " + QString((char*)(commandPath).data()) + "\n";
912 }
913 txt += "Guidance :\n";
914
915 for( G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
916 txt += QString((char*)(aCommand->GetGuidanceLine(i_thGuidance)).data()) + "\n";
917 }
918 if( ! rangeString.isNull() ) {
919 txt += " Range of parameters : " + QString((char*)(rangeString).data()) + "\n";
920 }
921 if( n_parameterEntry > 0 ) {
922 G4UIparameter *param;
923
924 // Re-implementation of G4UIparameter.cc
925
926 for( G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
927 param = aCommand->GetParameter(i_thParameter);
928 txt += "\nParameter : " + QString((char*)(param->GetParameterName()).data()) + "\n";
929 if( ! param->GetParameterGuidance().isNull() )
930 txt += QString((char*)(param->GetParameterGuidance()).data())+ "\n" ;
931 txt += " Parameter type : " + QString(QChar(param->GetParameterType())) + "\n";
932 if(param->IsOmittable()){
933 txt += " Omittable : True\n";
934 } else {
935 txt += " Omittable : False\n";
936 }
937 if( param->GetCurrentAsDefault() ) {
938 txt += " Default value : taken from the current value\n";
939 } else if( ! param->GetDefaultValue().isNull() ) {
940 txt += " Default value : " + QString((char*)(param->GetDefaultValue()).data())+ "\n";
941 }
942 if( ! param->GetParameterRange().isNull() ) {
943 txt += " Parameter range : " + QString((char*)(param->GetParameterRange()).data())+ "\n";
944 }
945 if( ! param->GetParameterCandidates().isNull() ) {
946 txt += " Candidates : " + QString((char*)(param->GetParameterCandidates()).data())+ "\n";
947 }
948 }
949 }
950 return txt;
951}
952
953
954
955/** Implement G4VBasicShell vurtual function
956 */
957G4bool G4UIQt::GetHelpChoice(
958 G4int& aInt
959)
960{
[608]961#ifdef GEANT4_QT_DEBUG
[607]962 printf("G4UIQt::GetHelpChoice SHOULD NEVER GO HERE");
[608]963#endif
[607]964 return true;
965}
966
967
968/** Implement G4VBasicShell vurtual function
969*/
970void G4UIQt::ExitHelp(
971)
972{
[608]973#ifdef GEANT4_QT_DEBUG
[607]974 printf("G4UIQt::ExitHelp SHOULD NEVER GO HERE");
[608]975#endif
[607]976}
977
978
979/** Event filter method. Every event from QtApplication goes here.<br/>
980 We apply a filter only for the Up and Down Arrow press when the QLineEdit<br/>
981 is active. If this filter match, Up arrow we give the previous command<br/>
982 and Down arrow will give the next if exist.<br/>
983 @param obj Emitter of the event
984 @param event Kind of event
985*/
986bool G4UIQt::eventFilter( // Should stay with a minuscule eventFilter because of Qt
987 QObject *aObj
988,QEvent *aEvent
989)
990{
991 if (aObj == NULL) return false;
992 if (aEvent == NULL) return false;
993
994 if (aObj == fCommandHistoryArea) {
995 if (aEvent->type() == QEvent::KeyPress) {
996 fCommandArea->setFocus();
997 }
998 }
999 if (aObj == fCommandArea) {
1000 if (aEvent->type() == QEvent::KeyPress) {
1001 QKeyEvent *e = static_cast<QKeyEvent*>(aEvent);
1002 if ((e->key() == (Qt::Key_Down)) ||
1003 (e->key() == (Qt::Key_PageDown)) ||
1004 (e->key() == (Qt::Key_Up)) ||
1005 (e->key() == (Qt::Key_PageUp))) {
1006#if QT_VERSION < 0x040000
1007 // count rows...
1008 QListViewItem* tmpItem = fCommandHistoryArea->firstChild();
1009 int selection = -1;
1010 int index = 0;
1011 while (tmpItem != 0) {
1012 if (tmpItem == fCommandHistoryArea->selectedItem()) {
1013 selection = index;
1014 }
1015 index ++;
1016 tmpItem = tmpItem->nextSibling();
1017 }
1018 if (fCommandHistoryArea->childCount()) {
1019 if (selection == -1) {
1020 selection = fCommandHistoryArea->childCount()-1;
1021 } else {
1022 if (e->key() == (Qt::Key_Down)) {
1023 if (selection <(fCommandHistoryArea->childCount()-1))
1024 selection++;
1025 } else if (e->key() == (Qt::Key_PageDown)) {
1026 selection = fCommandHistoryArea->childCount()-1;
1027#else
1028 int selection = fCommandHistoryArea->currentRow();
1029 if (fCommandHistoryArea->count()) {
1030 if (selection == -1) {
1031 selection = fCommandHistoryArea->count()-1;
1032 } else {
1033 if (e->key() == (Qt::Key_Down)) {
1034 if (selection <(fCommandHistoryArea->count()-1))
1035 selection++;
1036 } else if (e->key() == (Qt::Key_PageDown)) {
1037 selection = fCommandHistoryArea->count()-1;
1038#endif
1039 } else if (e->key() == (Qt::Key_Up)) {
1040 if (selection >0)
1041 selection --;
1042 } else if (e->key() == (Qt::Key_PageUp)) {
1043 selection = 0;
1044 }
1045 }
1046 fCommandHistoryArea->clearSelection();
1047#if QT_VERSION < 0x040000
1048 QListViewItem* tmpItem = fCommandHistoryArea->firstChild();
1049 int index = 0;
1050 while (tmpItem != 0) {
1051 if (index == selection) {
1052 tmpItem->setSelected(true);
1053 fCommandHistoryArea->setCurrentItem(tmpItem);
1054 }
1055 index ++;
1056 tmpItem = tmpItem->nextSibling();
1057 }
1058#else
1059#if QT_VERSION < 0x040202
1060 fCommandHistoryArea->setItemSelected(fCommandHistoryArea->item(selection),true);
1061#else
1062 fCommandHistoryArea->item(selection)->setSelected(true);
1063#endif
1064 fCommandHistoryArea->setCurrentItem(fCommandHistoryArea->item(selection));
1065#endif
1066 }
1067 } else if (e->key() == (Qt::Key_Tab)) {
1068#if QT_VERSION < 0x040000
1069 G4String ss = Complete(fCommandArea->text().ascii());
1070#else
1071 G4String ss = Complete(fCommandArea->text().toStdString().c_str());
1072#endif
1073 fCommandArea->setText((char*)(ss.data()));
1074
1075 // do not pass by parent, it will disable widget tab focus !
1076 return true;
1077 }
1078 }
1079 }
1080 // pass the event on to the parent class
1081 return QObject::eventFilter(aObj, aEvent);
1082}
1083
1084
1085
1086
1087/***************************************************************************/
1088//
1089// SLOTS DEFINITIONS
1090//
1091/***************************************************************************/
1092
1093/** Called when user give "help" command.
1094*/
1095void G4UIQt::ShowHelpCallback (
1096)
1097{
1098 TerminalHelp("");
1099}
1100
1101
1102/** Called when user click on clear button. Clear the text Output area
1103*/
1104void G4UIQt::ClearButtonCallback (
1105)
1106{
1107 fTextArea->clear();
1108}
1109
[608]1110/** Called when user exit session
1111*/
1112void G4UIQt::ExitSession (
1113)
1114{
1115 SessionTerminate();
1116}
[607]1117
[608]1118
[607]1119/** Callback call when "click on a menu entry.<br>
1120 Send the associated command to geant4
1121*/
1122void G4UIQt::CommandEnteredCallback (
1123)
1124{
1125#if QT_VERSION < 0x040000
1126 G4String command (fCommandArea->text().ascii());
1127 if (fCommandArea->text().simplifyWhiteSpace() != "") {
1128
1129 QListViewItem *newItem = new QListViewItem(fCommandHistoryArea);
1130 newItem->setText(0,fCommandArea->text());
[619]1131 fCommandHistoryArea->insertItem(newItem);
[620]1132 // now we have to arrange
1133 QListViewItem *temp= fCommandHistoryArea->lastItem();
1134 for (int i=0; i<fCommandHistoryArea->childCount()-1;i++) {
1135 fCommandHistoryArea->takeItem(temp);
1136 fCommandHistoryArea->insertItem(temp);
1137 temp= fCommandHistoryArea->lastItem();
1138 }
[607]1139#else
1140 G4String command (fCommandArea->text().toStdString().c_str());
1141 if (fCommandArea->text().trimmed() != "") {
1142 fCommandHistoryArea->addItem(fCommandArea->text());
1143#endif
1144 fCommandHistoryArea->clearSelection();
1145 fCommandHistoryArea->setCurrentItem(NULL);
1146 fCommandArea->setText("");
1147
1148 G4Qt* interactorManager = G4Qt::getInstance ();
1149 if (interactorManager) {
1150 interactorManager->FlushAndWaitExecution();
1151 }
1152 if (command(0,4) != "help") {
1153 ApplyShellCommand (command,exitSession,exitPause);
1154 } else {
1155 TerminalHelp(command);
1156 }
1157 if(exitSession==true)
1158 SessionTerminate();
1159 }
1160}
1161
1162
1163/** Callback call when "enter" clicked on the command zone.<br>
1164 Send the command to geant4
1165 @param aCommand
1166*/
1167void G4UIQt::ButtonCallback (
1168 const QString& aCommand
1169)
1170{
1171#if QT_VERSION < 0x040000
1172 G4String ss = G4String(aCommand.ascii());
1173#else
1174 G4String ss = G4String(aCommand.toStdString().c_str());
1175#endif
1176 ApplyShellCommand(ss,exitSession,exitPause);
1177 if(exitSession==true)
1178 SessionTerminate();
1179}
1180
1181
1182
1183/** This callback is activated when user selected a item in the help tree
1184*/
1185void G4UIQt::HelpTreeClicCallback (
1186)
1187{
1188#if QT_VERSION < 0x040000
1189 QListViewItem* item = NULL;
1190#else
1191 QTreeWidgetItem* item = NULL;
1192#endif
1193 if (!fHelpTreeWidget)
1194 return ;
1195
1196 if (!fHelpArea)
1197 return;
1198
1199#if QT_VERSION < 0x040000
1200 item =fHelpTreeWidget->selectedItem();
1201#else
1202 QList<QTreeWidgetItem *> list =fHelpTreeWidget->selectedItems();
1203 if (list.isEmpty())
1204 return;
1205 item = list.first();
1206#endif
1207 if (!item)
1208 return;
1209
1210 G4UImanager* UI = G4UImanager::GetUIpointer();
1211 if(UI==NULL) return;
1212 G4UIcommandTree * treeTop = UI->GetTree();
1213#if QT_VERSION < 0x040000
1214 G4UIcommand* command = treeTop->FindPath(item->text (1).ascii());
1215#else
1216 G4UIcommand* command = treeTop->FindPath(item->text (1).toStdString().c_str());
1217#endif
1218 if (command) {
1219#if QT_VERSION >= 0x040000
1220#if QT_VERSION < 0x040200
1221 fHelpArea->clear();
1222 fHelpArea->append(GetCommandList(command));
1223#else
1224 fHelpArea->setText(GetCommandList(command));
1225#endif
1226#else
1227 fHelpArea->setText(GetCommandList(command));
1228#endif
1229 } else {
1230 // this is not a command, this is a sub directory
1231 // We display the Title
1232#if QT_VERSION >= 0x040000
1233#if QT_VERSION < 0x040200
1234 fHelpArea->clear();
1235 fHelpArea->append(item->text (1));
1236#else
1237 fHelpArea->setText(item->text (1));
1238#endif
1239#else
1240 fHelpArea->setText(item->text (1));
1241#endif
1242 }
1243}
1244
1245/** This callback is activated when user double clic on a item in the help tree
1246*/
1247void G4UIQt::HelpTreeDoubleClicCallback (
[648]1248)
1249{
1250 HelpTreeClicCallback();
1251
[607]1252#if QT_VERSION < 0x040000
[648]1253 QListViewItem* item = NULL;
[607]1254#else
[648]1255 QTreeWidgetItem* item = NULL;
[607]1256#endif
[648]1257 if (!fHelpTreeWidget)
1258 return ;
1259
1260 if (!fHelpArea)
1261 return;
1262
1263#if QT_VERSION < 0x040000
1264 item =fHelpTreeWidget->selectedItem();
1265#else
1266 QList<QTreeWidgetItem *> list =fHelpTreeWidget->selectedItems();
1267 if (list.isEmpty())
1268 return;
1269 item = list.first();
1270#endif
1271 if (!item)
1272 return;
1273
[683]1274 fCommandArea->clear();
1275 fCommandArea->setText(item->text(1));
[607]1276}
1277
1278
1279/** Callback called when user select an old command in the command history<br>
1280 Give it to the command area.
1281*/
1282void G4UIQt::CommandHistoryCallback(
1283)
1284{
1285#if QT_VERSION < 0x040000
1286 QListViewItem* item = NULL;
1287#else
1288 QListWidgetItem* item = NULL;
1289#endif
1290 if (!fCommandHistoryArea)
1291 return ;
[632]1292
[607]1293
1294#if QT_VERSION < 0x040000
[620]1295 item =fCommandHistoryArea->selectedItem();
[607]1296#else
1297 QList<QListWidgetItem *> list =fCommandHistoryArea->selectedItems();
1298 if (list.isEmpty())
1299 return;
1300 item = list.first();
1301#endif
1302 if (!item)
1303 return;
1304#if QT_VERSION < 0x040000
1305 fCommandArea->setText(item->text(0));
1306#else
1307 fCommandArea->setText(item->text());
1308#endif
1309
1310}
1311
[695]1312/** Callback called when user give a new string to look for<br>
1313 Display a list of matching commands descriptions.
1314*/
1315void G4UIQt::lookForHelpStringCallback(
1316)
1317{
1318 QString found = "";
1319 // the help tree
1320 G4UImanager* UI = G4UImanager::GetUIpointer();
1321 if(UI==NULL) return;
1322 G4UIcommandTree * treeTop = UI->GetTree();
1323#ifdef GEANT4_QT_DEBUG
1324 printf("1111 %s\n",helpLine->text().toStdString().c_str());
[607]1325#endif
[695]1326
1327 G4int treeSize = treeTop->GetTreeEntry();
1328 int tmp = 0;
1329 for (int a=0;a<treeSize;a++) {
1330#ifdef GEANT4_QT_DEBUG
1331 printf("Command %s\n",(char*)(treeTop->GetTree(a+1)->GetPathName()).data());
1332#endif
1333 G4UIcommand* command = treeTop->FindPath(treeTop->GetTree(a+1)->GetPathName().data());
1334 tmp = GetCommandList (command).count(helpLine->text(),Qt::CaseInsensitive);
1335 if (tmp >0) {
1336#ifdef GEANT4_QT_DEBUG
1337 printf("Command %s match %d times \n",(char*)(treeTop->GetTree(a+1)->GetPathName()).data(),tmp);
1338#endif
1339 }
1340 // look for childs
1341 LookForHelpStringInChildTree(treeTop->GetTree(a+1),helpLine->text());
1342 tmp = 0;
1343 }
1344}
1345
1346QHash<QString, int> G4UIQt::LookForHelpStringInChildTree(
1347 G4UIcommandTree *aCommandTree
1348 ,const QString & text
1349)
1350{
1351 QHash<QString, int> found;
1352 if (aCommandTree == NULL) return found;
1353
1354 // Get the Sub directories
1355 int tmp = 0;
1356 for (int a=0;a<aCommandTree->GetTreeEntry();a++) {
1357 const G4UIcommand* command = aCommandTree->GetGuidance();
1358#ifdef GEANT4_QT_DEBUG
1359 // printf("Command %s\n",(char*)(aCommandTree->GetTree(a+1)->GetPathName()).data());
1360 // printf("%s \n",GetCommandList (command).toStdString().c_str());
1361#endif
1362 tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
1363 if (tmp >0) {
1364 found.insert(QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()),tmp);
1365#ifdef GEANT4_QT_DEBUG
1366 printf("---Command %s match %d times \n",(char*)(aCommandTree->GetTree(a+1)->GetPathName()).data(),tmp);
1367#endif
1368 }
1369 // look for childs
1370 LookForHelpStringInChildTree(aCommandTree->GetTree(a+1),text);
1371 }
1372
1373 // Get the Commands
1374
1375 for (int a=0;a<aCommandTree->GetCommandEntry();a++) {
1376 const G4UIcommand* command = aCommandTree->GetCommand(a+1);
1377#ifdef GEANT4_QT_DEBUG
1378 // printf("Command Finale %s\n");
1379 // printf("%s \n",GetCommandList (command).toStdString().c_str());
1380#endif
1381 tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
1382 if (tmp >0) {
1383 found.insert(QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()),tmp);
1384#ifdef GEANT4_QT_DEBUG
1385 printf("---Command Finale %s match %d times \n",(char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data(),tmp);
1386#endif
1387 }
1388
1389 }
1390 return found;
1391}
1392#endif
Note: See TracBrowser for help on using the repository browser.