Changeset 695 for trunk/geant4
- Timestamp:
- Jan 24, 2008, 7:06:27 PM (17 years ago)
- Location:
- trunk/geant4/interfaces/basic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/geant4/interfaces/basic/include/G4UIQt.hh
r688 r695 39 39 40 40 #include <qobject.h> 41 #include <qhash.h> 41 42 42 43 class QMainWindow; … … 74 75 // 75 76 // Class description - end : 77 76 78 77 79 class G4UIQt : public QObject, public G4VBasicShell, public G4VInteractiveSession { … … 119 121 void ExitHelp();// have to be implemeted because we heritate from G4VBasicShell 120 122 bool eventFilter(QObject*,QEvent*); 123 void ActivateCommand(G4String); 124 QHash<QString, int> LookForHelpStringInChildTree(G4UIcommandTree *,const QString&); 125 121 126 122 127 private: … … 139 144 #endif 140 145 QDialog *fHelpDialog; 141 146 QLineEdit *helpLine; 147 142 148 signals : 143 149 void myClicked(const QString &text); … … 152 158 void ShowHelpCallback(); 153 159 void CommandHistoryCallback(); 160 void lookForHelpStringCallback(); 154 161 }; 155 162 -
trunk/geant4/interfaces/basic/src/G4UIQt.cc
r688 r695 30 30 // L. Garnier 31 31 32 //#define GEANT4_QT_DEBUG32 #define GEANT4_QT_DEBUG 33 33 34 34 #ifdef G4UI_BUILD_QT_SESSION … … 541 541 #endif 542 542 QVBoxLayout *vLayout = new QVBoxLayout(fHelpDialog); 543 helpLine = new QLineEdit("Look for...",fHelpDialog); 543 544 QSplitter *splitter = new QSplitter(Qt::Horizontal,fHelpDialog); 544 545 QPushButton *exitButton = new QPushButton("Exit",fHelpDialog); 545 546 connect(exitButton, SIGNAL(clicked()), fHelpDialog,SLOT(close())); 547 connect( helpLine, SIGNAL( editingFinished () ), this, SLOT( lookForHelpStringCallback() ) ); 548 546 549 547 550 // the help tree … … 646 649 } 647 650 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 669 void G4UIQt::ActivateCommand( 670 G4String newCommand 671 ) 672 { 648 673 // Look for the choosen command "newCommand" 649 674 size_t i = newCommand.index(" "); … … 743 768 } 744 769 } 745 #if QT_VERSION < 0x040000 746 fHelpDialog->setCaption( tr( "Help on commands" )); 747 #else 748 fHelpDialog->setWindowTitle(tr("Help on commands")); 749 #endif 750 fHelpDialog->resize(800,600); 751 fHelpDialog->move(QPoint(400,150)); 752 fHelpDialog->show(); 753 fHelpDialog->raise(); 754 #if QT_VERSION < 0x040000 755 fHelpDialog->setActiveWindow(); 756 #else 757 fHelpDialog->activateWindow(); 758 #endif 759 } 760 761 770 } 762 771 763 772 /** Fill the Help Tree Widget … … 1301 1310 } 1302 1311 1303 #endif 1312 /** Callback called when user give a new string to look for<br> 1313 Display a list of matching commands descriptions. 1314 */ 1315 void 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()); 1325 #endif 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 1346 QHash<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 TracChangeset
for help on using the changeset viewer.