Changeset 1224 for trunk/source/interfaces
- Timestamp:
- Dec 17, 2009, 6:14:30 PM (15 years ago)
- Location:
- trunk/source/interfaces
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/interfaces/basic/include/G4UIQt.hh
r1223 r1224 40 40 #include <qobject.h> 41 41 #include <qmap.h> 42 #include <qstringlist.h> 42 43 43 44 class QMainWindow; … … 57 58 class QResizeEvent; 58 59 class QToolBox; 60 class QStringList; 59 61 60 62 // Class description : … … 98 100 // Ex : AddButton("my_menu","Run","/run/beamOn 1"); 99 101 100 void AddTab VisWidget(QWidget*,QString,int,int);102 void AddTabWidget(QWidget*,QString,int,int); 101 103 // To add a tab for vis openGL Qt driver 102 104 … … 118 120 QTreeWidget * CreateHelpTree(); 119 121 #endif 122 void ExitHelp(); 120 123 121 124 #if QT_VERSION < 0x040000 … … 134 137 QMap<int,QString> LookForHelpStringInChildTree(G4UIcommandTree *,const QString&); 135 138 139 void CreateVisParametersTBWidget(); 140 void CreateViewComponentsTBWidget(); 141 void CreateHelpTBWidget(); 142 void CreateCoutTBWidget(); 143 void CreateHistoryTBWidget(); 136 144 137 145 private: … … 144 152 QLabel *fCommandLabel; 145 153 QLineEdit * fCommandArea; 146 QTextEdit *f TextArea;154 QTextEdit *fCoutTBTextArea; 147 155 QTextEdit *fHelpArea; 148 156 QToolBox* fToolBox; 157 QStringList fG4cout; 158 QLineEdit * fCoutFilter; 149 159 150 160 #if QT_VERSION < 0x040000 151 QListView *f CommandHistoryArea;161 QListView *fHistoryTBTableList; 152 162 QListView *fHelpTreeWidget; 153 163 #else 154 QListWidget *f CommandHistoryArea;164 QListWidget *fHistoryTBTableList; 155 165 QTreeWidget *fHelpTreeWidget; 156 166 #endif 157 QWidget *fHelpTBWidget; 158 QLineEdit *helpLine; 159 QWidget *visWidget; 167 QWidget* fHelpTBWidget; 168 QWidget* fHistoryTBWidget; 169 QWidget* fCoutTBWidget; 170 QWidget* fVisParametersTBWidget; 171 QWidget* fViewComponentsTBWidget; 172 QLineEdit* helpLine; 160 173 QTabWidget* fTabWidget; 161 174 QString fCoutText; … … 176 189 void UpdateTabWidget(int); 177 190 void ResizeTabWidget( QResizeEvent* ); 191 void CoutFilterCallback(const QString&); 178 192 }; 179 193 -
trunk/source/interfaces/basic/src/G4UIQt.cc
r1223 r1224 61 61 #include <qtabbar.h> 62 62 #include <qresizeevent> 63 #include <qstringlist.h> 63 64 64 65 #include <qmainwindow.h> … … 107 108 ,char** argv 108 109 ) 109 :fTabWidget(NULL) 110 :fG4cout("") 111 ,fHelpTBWidget(NULL) 112 ,fHistoryTBWidget(NULL) 113 ,fCoutTBWidget(NULL) 114 ,fVisParametersTBWidget(NULL) 115 ,fViewComponentsTBWidget(NULL) 116 ,fTabWidget(NULL) 110 117 ,fCoutText("Output") 111 118 { 119 112 120 G4Qt* interactorManager = G4Qt::getInstance (argc,argv,(char*)"Qt"); 113 121 if (!(QApplication*)interactorManager->GetMainInteractor()) { … … 150 158 printf("G4UIQt::Initialise after main window creation UImanager:%d G4UIQt(this) : %d+++++++++++\n",UI,this); 151 159 #endif 152 #if QT_VERSION < 0x040000153 fMainWindow->setCaption( tr( "G4UI Session" ));154 fMainWindow->resize(900,600);155 fMainWindow->move(50,100);156 #else157 fMainWindow->setWindowTitle( tr("G4UI Session") );158 fMainWindow->resize(900,600);159 fMainWindow->move(QPoint(50,100));160 #endif161 160 162 161 #ifdef G4DEBUG_INTERFACES_BASIC … … 177 176 // Set layouts 178 177 179 fTabWidget = new QTabWidget; 180 181 connect(fTabWidget, SIGNAL(currentChanged ( int ) ), SLOT(UpdateTabWidget(int))); 182 connect(fTabWidget, SIGNAL(resizeEvent ( QResizeEvent* ) ), SLOT(ResizeTabWidget( QResizeEvent*))); 183 184 visWidget = new QWidget(myVSplitter); 185 QWidget* coutTBWidget = new QWidget(fToolBox); 186 fHelpTBWidget = new QWidget(fToolBox); 187 QWidget* visParametersTBWidget = new QWidget(fToolBox); 188 QWidget* viewComponentsTBWidget = new QWidget(fToolBox); 189 QWidget* historyTBWidget = new QWidget(fToolBox); 178 // Add a empty tabwidget 179 fTabWidget = new QTabWidget(myVSplitter); 180 190 181 QWidget* commandLineWidget = new QWidget(mainWidget); 191 192 // QVBoxLayout *layoutVis = new QVBoxLayout(visWidget); 193 QVBoxLayout *layoutCout = new QVBoxLayout(coutTBWidget); 194 QVBoxLayout *layoutHistory = new QVBoxLayout(historyTBWidget); 182 #if QT_VERSION < 0x040000 195 183 QVBoxLayout *layoutCommandLine = new QVBoxLayout(commandLineWidget); 196 184 #else 185 QVBoxLayout *layoutCommandLine = new QVBoxLayout(); 186 #endif 187 188 #ifdef G4DEBUG_INTERFACES_BASIC 189 printf("G4UIQt::G4UIQt :: 2b\n"); 190 #endif 197 191 // fill them 198 199 fTextArea = new QTextEdit(coutTBWidget);200 QPushButton *clearButton = new QPushButton("clear",coutTBWidget);201 connect(clearButton, SIGNAL(clicked()), SLOT(ClearButtonCallback()));202 203 #if QT_VERSION < 0x040000204 205 fCommandHistoryArea = new QListView(historyTBWidget);206 fCommandHistoryArea->setSorting (-1, FALSE);207 fCommandHistoryArea->setSelectionMode(QListView::Single);208 fCommandHistoryArea->addColumn("");209 fCommandHistoryArea->header()->hide();210 connect(fCommandHistoryArea, SIGNAL(selectionChanged()), SLOT(CommandHistoryCallback()));211 #else212 fCommandHistoryArea = new QListWidget();213 fCommandHistoryArea->setSelectionMode(QAbstractItemView::SingleSelection);214 connect(fCommandHistoryArea, SIGNAL(itemSelectionChanged()), SLOT(CommandHistoryCallback()));215 #endif216 fCommandHistoryArea->installEventFilter(this);217 192 218 193 fCommandLabel = new QLabel("",commandLineWidget); … … 228 203 fCommandArea->activateWindow(); 229 204 #endif 230 connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback())); 205 231 206 #if QT_VERSION < 0x040000 232 207 fCommandArea->setFocusPolicy ( QWidget::StrongFocus ); … … 236 211 fCommandArea->setFocus(Qt::TabFocusReason); 237 212 #endif 238 fTextArea->setReadOnly(true); 239 240 // layoutVis->addWidget(visWidget); 241 242 layoutCout->addWidget(fTextArea); 243 layoutCout->addWidget(clearButton); 244 245 #ifdef G4DEBUG_INTERFACES_BASIC 246 printf("G4UIQt::G4UIQt :: 4\n"); 247 #endif 248 #if QT_VERSION >= 0x040000 249 // topWidget->setLayout(layoutTop); 250 #endif 251 252 253 layoutHistory->addWidget(fCommandHistoryArea); 213 214 #ifdef G4DEBUG_INTERFACES_BASIC 215 printf("G4UIQt::G4UIQt :: 4a\n"); 216 #endif 217 218 254 219 layoutCommandLine->addWidget(fCommandLabel); 255 220 layoutCommandLine->addWidget(fCommandArea); 256 221 #if QT_VERSION >= 0x040000 257 222 QVBoxLayout *mainLayout = new QVBoxLayout(); 223 #else 258 224 QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget); 259 260 CreateHelpWidget(); 225 #endif 226 227 fHelpTBWidget = new QWidget(fToolBox); 228 fHistoryTBWidget = new QWidget(fToolBox); 229 fCoutTBWidget = new QWidget(fToolBox); 230 fVisParametersTBWidget = new QWidget(fToolBox); 231 fViewComponentsTBWidget = new QWidget(fToolBox); 232 233 #ifdef G4DEBUG_INTERFACES_BASIC 234 printf("G4UIQt::G4UIQt :: 4b\n"); 235 #endif 236 CreateVisParametersTBWidget(); 237 #ifdef G4DEBUG_INTERFACES_BASIC 238 printf("G4UIQt::G4UIQt :: 4c\n"); 239 #endif 240 // CreateViewComponentsTBWidget(); 241 #ifdef G4DEBUG_INTERFACES_BASIC 242 printf("G4UIQt::G4UIQt :: 4d\n"); 243 #endif 244 // CreateHelpTBWidget(); 245 #ifdef G4DEBUG_INTERFACES_BASIC 246 printf("G4UIQt::G4UIQt :: 4e\n"); 247 #endif 248 CreateCoutTBWidget(); 249 #ifdef G4DEBUG_INTERFACES_BASIC 250 printf("G4UIQt::G4UIQt :: 4f\n"); 251 #endif 252 CreateHistoryTBWidget(); 253 #ifdef G4DEBUG_INTERFACES_BASIC 254 printf("G4UIQt::G4UIQt :: 4g\n"); 255 #endif 256 261 257 // the splitter 262 fToolBox->addItem(visParametersTBWidget,"Vis parameters"); 263 fToolBox->addItem(viewComponentsTBWidget,"Viewer components"); 258 fToolBox->addItem(fVisParametersTBWidget,"Vis parameters"); 259 #ifdef G4DEBUG_INTERFACES_BASIC 260 printf("G4UIQt::G4UIQt :: 4h\n"); 261 #endif 262 fToolBox->addItem(fViewComponentsTBWidget,"Viewer components"); 263 #ifdef G4DEBUG_INTERFACES_BASIC 264 printf("G4UIQt::G4UIQt :: 4i\n"); 265 #endif 264 266 fToolBox->addItem(fHelpTBWidget,"Help"); 265 fToolBox->addItem(coutTBWidget,"Cout"); 266 fToolBox->addItem(historyTBWidget,"History"); 267 #ifdef G4DEBUG_INTERFACES_BASIC 268 printf("G4UIQt::G4UIQt :: 4j\n"); 269 #endif 270 fToolBox->addItem(fCoutTBWidget,"Cout"); 271 #ifdef G4DEBUG_INTERFACES_BASIC 272 printf("G4UIQt::G4UIQt :: 4k\n"); 273 #endif 274 fToolBox->addItem(fHistoryTBWidget,"History"); 275 #ifdef G4DEBUG_INTERFACES_BASIC 276 printf("G4UIQt::G4UIQt :: 4l\n"); 277 #endif 278 267 279 268 280 269 281 fToolBox->setSizePolicy (QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed)); 270 visWidget->setSizePolicy (QSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum));271 272 QSizePolicy policy = visWidget->sizePolicy();282 fTabWidget->setSizePolicy (QSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum)); 283 284 QSizePolicy policy = fTabWidget->sizePolicy(); 273 285 policy.setHorizontalStretch(1); 274 286 policy.setVerticalStretch(1); 275 visWidget->setSizePolicy(policy);287 fTabWidget->setSizePolicy(policy); 276 288 277 289 myVSplitter->addWidget(fToolBox); 278 myVSplitter->addWidget(visWidget); 279 290 myVSplitter->addWidget(fTabWidget); 291 292 #if QT_VERSION >= 0x040000 293 commandLineWidget->setLayout(layoutCommandLine); 294 #endif 280 295 commandLineWidget->setSizePolicy (QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum)); 281 296 mainLayout->addWidget(myVSplitter,1); 282 297 mainLayout->addWidget(commandLineWidget); 283 298 284 #endif285 299 #ifdef G4DEBUG_INTERFACES_BASIC 286 300 printf("G4UIQt::G4UIQt :: 5\n"); … … 288 302 289 303 #if QT_VERSION >= 0x040000 304 mainWidget->setLayout(mainLayout); 305 #endif 306 290 307 fMainWindow->setCentralWidget(mainWidget); 291 #else292 fMainWindow->setCentralWidget(myVSplitter);293 #endif294 308 295 309 #if QT_VERSION < 0x040000 … … 313 327 #endif 314 328 315 // Set the splitter size. The fTextArea sould be 2/3 on the fMainWindow 316 #if QT_VERSION < 0x040000 317 // QValueList<int> vals = splitter->sizes(); 318 #else 319 // QList<int> vals = splitter->sizes(); 320 #endif 321 // if(vals.size()==2) { 322 // vals[0] = (splitter->orientation()==Qt::Vertical ? splitter->height() : splitter->width())*3/4; 323 // vals[1] = (splitter->orientation()==Qt::Vertical ? splitter->height() : splitter->width())*1/4; 324 // splitter->setSizes(vals); 325 // } 329 connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback())); 326 330 327 331 if(UI!=NULL) UI->SetCoutDestination(this); // TO KEEP 328 332 329 333 interactorManager->SetG4UI(this); 334 335 #if QT_VERSION < 0x040000 336 fMainWindow->setCaption( tr( "G4UI Session" )); 337 fMainWindow->resize(900,600); 338 fMainWindow->move(50,100); 339 #else 340 fMainWindow->setWindowTitle( tr("G4UI Session") ); 341 fMainWindow->resize(900,600); 342 fMainWindow->move(QPoint(50,100)); 343 #endif 330 344 331 345 #ifdef G4DEBUG_INTERFACES_BASIC … … 356 370 } 357 371 372 /** Create the History ToolBox Widget 373 */ 374 void G4UIQt::CreateHistoryTBWidget( 375 ) 376 { 377 378 #if QT_VERSION < 0x040000 379 QVBoxLayout *layoutHistoryTB = new QVBoxLayout(fHistoryTBWidget); 380 381 fHistoryTBTableList = new QListView(fHistoryTBWidget); 382 fHistoryTBTableList->setSorting (-1, FALSE); 383 fHistoryTBTableList->setSelectionMode(QListView::Single); 384 fHistoryTBTableList->addColumn(""); 385 fHistoryTBTableList->header()->hide(); 386 connect(fHistoryTBTableList, SIGNAL(selectionChanged()), SLOT(CommandHistoryCallback())); 387 #else 388 QVBoxLayout *layoutHistoryTB = new QVBoxLayout(); 389 fHistoryTBTableList = new QListWidget(); 390 fHistoryTBTableList->setSelectionMode(QAbstractItemView::SingleSelection); 391 connect(fHistoryTBTableList, SIGNAL(itemSelectionChanged()), SLOT(CommandHistoryCallback())); 392 #endif 393 fHistoryTBTableList->installEventFilter(this); 394 395 layoutHistoryTB->addWidget(fHistoryTBTableList); 396 397 #if QT_VERSION >= 0x040000 398 fHistoryTBWidget->setLayout(layoutHistoryTB); 399 #endif 400 } 401 402 /** Create the Help ToolBox Widget 403 */ 404 void G4UIQt::CreateHelpTBWidget( 405 ) 406 { 407 408 QWidget *helpWidget = new QWidget(fHelpTBWidget); 409 410 QSplitter *splitter = new QSplitter(Qt::Horizontal,fHelpTBWidget); 411 #if QT_VERSION < 0x040000 412 QHBoxLayout *helpLayout = new QHBoxLayout(helpWidget); 413 QVBoxLayout *vLayout = new QVBoxLayout(fHelpTBWidget); 414 helpLayout->add(new QLabel("Search :",helpWidget)); 415 #else 416 QHBoxLayout *helpLayout = new QHBoxLayout(); 417 QVBoxLayout *vLayout = new QVBoxLayout(); 418 helpLayout->addWidget(new QLabel("Search :",helpWidget)); 419 #endif 420 helpLine = new QLineEdit(fHelpTBWidget); 421 #if QT_VERSION < 0x040000 422 helpLayout->add(helpLine); 423 connect( helpLine, SIGNAL( returnPressed () ), this, SLOT( lookForHelpStringCallback() ) ); 424 #else 425 helpLayout->addWidget(helpLine); 426 connect( helpLine, SIGNAL( editingFinished () ), this, SLOT( lookForHelpStringCallback() ) ); 427 #endif 428 429 // the help tree 430 #if QT_VERSION < 0x040000 431 fHelpTreeWidget = new QListView(splitter); 432 #else 433 fHelpTreeWidget = new QTreeWidget(); 434 #endif 435 fHelpTreeWidget = CreateHelpTree(); 436 437 fHelpArea = new QTextEdit(splitter); 438 fHelpArea->setReadOnly(true); 439 440 // Set layouts 441 442 #if QT_VERSION >= 0x040000 443 if (fHelpTreeWidget) 444 splitter->addWidget(fHelpTreeWidget); 445 splitter->addWidget(fHelpArea); 446 #endif 447 448 449 #if QT_VERSION >= 0x040000 450 vLayout->addWidget(helpWidget); 451 vLayout->addWidget(splitter,1); 452 #else 453 vLayout->addWidget(helpWidget); 454 vLayout->addWidget(splitter,1); 455 #endif 456 457 // set the splitter size 458 #if QT_VERSION >= 0x040000 459 QList<int> list; 460 #else 461 QValueList<int> list; 462 #endif 463 list.append( 400 ); 464 list.append( 400 ); 465 splitter->setSizes(list); 466 467 #if QT_VERSION >= 0x040000 468 helpWidget->setLayout(helpLayout); 469 fHelpTBWidget->setLayout(vLayout); 470 #endif 471 } 472 473 474 /** Create the Cout ToolBox Widget 475 */ 476 void G4UIQt::CreateCoutTBWidget( 477 ) 478 { 479 #if QT_VERSION >= 0x040000 480 QVBoxLayout *layoutCoutTB = new QVBoxLayout(); 481 #else 482 QVBoxLayout *layoutCoutTB = new QVBoxLayout(fCoutTBWidget); 483 #endif 484 485 fCoutTBTextArea = new QTextEdit(fCoutTBWidget); 486 fCoutFilter = new QLineEdit(fCoutTBWidget); 487 QLabel* coutFilterLabel = new QLabel("Filter : ",fCoutTBWidget); 488 489 QPushButton *coutTBClearButton = new QPushButton("clear",fCoutTBWidget); 490 connect(coutTBClearButton, SIGNAL(clicked()), SLOT(ClearButtonCallback())); 491 connect(fCoutFilter, SIGNAL(textEdited ( const QString &)), SLOT(CoutFilterCallback( const QString &))); 492 493 fCoutTBTextArea->setReadOnly(true); 494 495 QWidget* coutButtonWidget = new QWidget(fCoutTBWidget); 496 QHBoxLayout* layoutCoutTBButtons = new QHBoxLayout(coutButtonWidget); 497 layoutCoutTBButtons->addWidget(coutTBClearButton); 498 layoutCoutTBButtons->addWidget(coutFilterLabel); 499 layoutCoutTBButtons->addWidget(fCoutFilter); 500 501 layoutCoutTB->addWidget(fCoutTBTextArea); 502 layoutCoutTB->addWidget(coutButtonWidget); 503 504 #if QT_VERSION >= 0x040000 505 fCoutTBWidget->setLayout(layoutCoutTB); 506 #endif 507 } 508 509 510 /** Create the VisParameters ToolBox Widget 511 */ 512 void G4UIQt::CreateVisParametersTBWidget( 513 ) 514 { 515 } 516 517 518 /** Create the ViewComponents ToolBox Widget 519 */ 520 void G4UIQt::CreateViewComponentsTBWidget( 521 ) 522 { 523 } 524 358 525 359 526 /** Add a new tab widget. 360 527 Create the tab if it was not done 361 528 */ 362 void G4UIQt::AddTab VisWidget(529 void G4UIQt::AddTabWidget( 363 530 QWidget* aWidget 364 531 ,QString name … … 368 535 { 369 536 #ifdef G4DEBUG_INTERFACES_BASIC 370 printf("G4UIQt::AddTabVisWidget %d %d\n",sizeX, sizeY); 371 #endif 372 if (fTabWidget != NULL) { 373 if (!aWidget) return; 537 printf("G4UIQt::AddTabWidget %d %d\n",sizeX, sizeY); 538 #endif 539 if (!aWidget) return; 540 541 #ifdef G4DEBUG_INTERFACES_BASIC 542 printf("G4UIQt::AddTabWidget ADD %d %d + %d %d---------------------------------------------------\n",sizeX, sizeY,sizeX-fTabWidget->width(),sizeY-fTabWidget->height()); 543 #endif 544 545 #if QT_VERSION < 0x040000 546 aWidget->reparent(fTabWidget,0,QPoint(0,0)); 547 #else 548 aWidget->setParent(fTabWidget); 549 #endif 374 550 375 #ifdef G4DEBUG_INTERFACES_BASIC 376 printf("G4UIQt::AddTabVisWidget ADD %d %d + %d %d---------------------------------------------------\n",sizeX, sizeY,sizeX-visWidget->width(),sizeY-visWidget->height()); 377 #endif 378 379 #if QT_VERSION < 0x040000 380 aWidget->reparent(visWidget,0,QPoint(0,0)); 381 #else 382 aWidget->setParent(visWidget); 383 #endif 384 385 fTabWidget->insertTab(fTabWidget->count()-1,aWidget,name); 386 QHBoxLayout *mainLayout = new QHBoxLayout(visWidget); 387 mainLayout->setMargin(0); 388 mainLayout->setSpacing(0); 389 mainLayout->addWidget(fTabWidget); 390 391 // Set the size 392 // fMainWindow->setSizeIncrement(); 393 394 fMainWindow->resize(fMainWindow->width()+sizeX-visWidget->width(), 395 fMainWindow->height()+sizeY-visWidget->height()); 396 } 551 fTabWidget->insertTab(fTabWidget->count()-1,aWidget,name); 552 553 fMainWindow->resize(fMainWindow->width()+sizeX-fTabWidget->width(), 554 fMainWindow->height()+sizeY-fTabWidget->height()); 397 555 } 398 556 … … 400 558 void G4UIQt::UpdateTabWidget(int tabNumber) { 401 559 #ifdef G4DEBUG_INTERFACES_BASIC 402 printf("G4UIQt::UpdateTabWidget\n"); 403 #endif 560 printf("G4UIQt::UpdateTabWidget\n"); 561 #endif 562 if ( fTabWidget == NULL) { 563 fTabWidget = new QTabWidget; 564 } 565 404 566 QString text = fTabWidget->tabText (tabNumber); 405 567 if ( text != fCoutText) { … … 417 579 } 418 580 fTabWidget->currentWidget()->repaint(); 581 } 582 if (fTabWidget->count() == 1) { 583 connect(fTabWidget, SIGNAL(currentChanged ( int ) ), SLOT(UpdateTabWidget(int))); 584 // connect(fTabWidget, SIGNAL(resizeEvent ( QResizeEvent* ) ), SLOT(ResizeTabWidget( QResizeEvent*))); 419 585 } 420 586 } … … 554 720 G4int G4UIQt::ReceiveG4cout ( 555 721 G4String aString 556 )722 ) 557 723 { 558 724 if (!aString) return 0; 559 G4Qt* interactorManager = G4Qt::getInstance (); 560 if (!interactorManager) return 0; 561 562 #if QT_VERSION < 0x040000 563 fTextArea->append(QString((char*)aString.data()).simplifyWhiteSpace()); 564 fTextArea->verticalScrollBar()->setValue(fTextArea->verticalScrollBar()->maxValue()); 565 #else 566 fTextArea->append(QString((char*)aString.data()).trimmed()); 567 fTextArea->verticalScrollBar()->setSliderPosition(fTextArea->verticalScrollBar()->maximum()); 568 #endif 569 fTextArea->repaint(); 570 // interactorManager->FlushAndWaitExecution(); 725 726 QStringList newStr; 727 728 // Add to stringList 729 #if QT_VERSION < 0x040000 730 newStr = QStringList(QString((char*)aString.data()).simplifyWhiteSpace()); 731 #else 732 newStr = QStringList(QString((char*)aString.data()).trimmed()); 733 #endif 734 fG4cout += newStr; 735 736 QStringList result = newStr.filter(fCoutFilter->text()); 737 738 if (result.join("\n").isEmpty()) { 739 return 0; 740 } 741 fCoutTBTextArea->append(result.join("\n")); 742 fCoutTBTextArea->repaint(); 743 744 #if QT_VERSION < 0x040000 745 fCoutTBTextArea->verticalScrollBar()->setValue(fCoutTBTextArea->verticalScrollBar()->maxValue()); 746 #else 747 fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum()); 748 #endif 749 571 750 return 0; 572 751 } … … 583 762 { 584 763 if (!aString) return 0; 585 G4Qt* interactorManager = G4Qt::getInstance (); 586 if (!interactorManager) return 0; 587 588 #if QT_VERSION < 0x040000 589 QColor previousColor = fTextArea->color(); 590 fTextArea->setColor(Qt::red); 591 fTextArea->append(QString((char*)aString.data()).simplifyWhiteSpace()); 592 fTextArea->setColor(previousColor); 593 fTextArea->verticalScrollBar()->setValue(fTextArea->verticalScrollBar()->maxValue()); 594 #else 595 QColor previousColor = fTextArea->textColor(); 596 fTextArea->setTextColor(Qt::red); 597 fTextArea->append(QString((char*)aString.data()).trimmed()); 598 fTextArea->setTextColor(previousColor); 599 fTextArea->verticalScrollBar()->setSliderPosition(fTextArea->verticalScrollBar()->maximum()); 600 #endif 601 fTextArea->repaint(); 602 // interactorManager->FlushAndWaitExecution(); 764 765 QStringList newStr; 766 767 // Add to stringList 768 #if QT_VERSION < 0x040000 769 newStr = QStringList(QString((char*)aString.data()).simplifyWhiteSpace()); 770 #else 771 newStr = QStringList(QString((char*)aString.data()).trimmed()); 772 #endif 773 fG4cout += newStr; 774 775 QStringList result = newStr.filter(fCoutFilter->text()); 776 777 #if QT_VERSION < 0x040000 778 QColor previousColor = fCoutTBTextArea->color(); 779 fCoutTBTextArea->setColor(Qt::red); 780 fCoutTBTextArea->append(result.join("\n")); 781 fCoutTBTextArea->setColor(previousColor); 782 fCoutTBTextArea->verticalScrollBar()->setValue(fCoutTBTextArea->verticalScrollBar()->maxValue()); 783 #else 784 QColor previousColor = fCoutTBTextArea->textColor(); 785 fCoutTBTextArea->setTextColor(Qt::red); 786 fCoutTBTextArea->append(result.join("\n")); 787 fCoutTBTextArea->setTextColor(previousColor); 788 fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum()); 789 #endif 790 fCoutTBTextArea->repaint(); 603 791 return 0; 604 792 } … … 675 863 676 864 677 678 679 /**680 Create the fHelpTBWidget681 Implementation of <b>void G4VBasicShell::TerminalHelp(G4String newCommand)</b>682 */683 void G4UIQt::CreateHelpWidget(684 )685 {686 687 QVBoxLayout *vLayout = new QVBoxLayout(fHelpTBWidget);688 QWidget *helpWidget = new QWidget(fHelpTBWidget);689 QSplitter *splitter = new QSplitter(Qt::Horizontal,fHelpTBWidget);690 691 QHBoxLayout *helpLayout = new QHBoxLayout(helpWidget);692 #if QT_VERSION < 0x040000693 helpLayout->add(new QLabel("Search :",helpWidget));694 #else695 helpLayout->addWidget(new QLabel("Search :",helpWidget));696 #endif697 helpLine = new QLineEdit(fHelpTBWidget);698 #if QT_VERSION < 0x040000699 helpLayout->add(helpLine);700 connect( helpLine, SIGNAL( returnPressed () ), this, SLOT( lookForHelpStringCallback() ) );701 #else702 helpLayout->addWidget(helpLine);703 connect( helpLine, SIGNAL( editingFinished () ), this, SLOT( lookForHelpStringCallback() ) );704 #endif705 706 // the help tree707 #if QT_VERSION < 0x040000708 fHelpTreeWidget = new QListView(splitter);709 #else710 fHelpTreeWidget = new QTreeWidget();711 #endif712 fHelpTreeWidget = CreateHelpTree();713 714 fHelpArea = new QTextEdit(splitter);715 fHelpArea->setReadOnly(true);716 717 // Set layouts718 719 #if QT_VERSION >= 0x040000720 if (fHelpTreeWidget)721 splitter->addWidget(fHelpTreeWidget);722 splitter->addWidget(fHelpArea);723 #endif724 725 726 #if QT_VERSION >= 0x040000727 vLayout->addWidget(helpWidget);728 vLayout->addWidget(splitter,1);729 #else730 vLayout->addWidget(helpWidget);731 vLayout->addWidget(splitter,1);732 #endif733 734 // set the splitter size735 #if QT_VERSION >= 0x040000736 QList<int> list;737 #else738 QValueList<int> list;739 #endif740 list.append( 400 );741 list.append( 400 );742 splitter->setSizes(list);743 744 #if QT_VERSION >= 0x040000745 fHelpTBWidget->setLayout(vLayout);746 #endif747 748 }749 865 750 866 … … 1134 1250 if (aEvent == NULL) return false; 1135 1251 1136 if (aObj == f CommandHistoryArea) {1252 if (aObj == fHistoryTBTableList) { 1137 1253 if (aEvent->type() == QEvent::KeyPress) { 1138 1254 fCommandArea->setFocus(); … … 1148 1264 #if QT_VERSION < 0x040000 1149 1265 // count rows... 1150 QListViewItem* tmpItem = f CommandHistoryArea->firstChild();1266 QListViewItem* tmpItem = fHistoryTBTableList->firstChild(); 1151 1267 int selection = -1; 1152 1268 int index = 0; 1153 1269 while (tmpItem != 0) { 1154 if (tmpItem == f CommandHistoryArea->selectedItem()) {1270 if (tmpItem == fHistoryTBTableList->selectedItem()) { 1155 1271 selection = index; 1156 1272 } … … 1158 1274 tmpItem = tmpItem->nextSibling(); 1159 1275 } 1160 if (f CommandHistoryArea->childCount()) {1276 if (fHistoryTBTableList->childCount()) { 1161 1277 if (selection == -1) { 1162 selection = f CommandHistoryArea->childCount()-1;1278 selection = fHistoryTBTableList->childCount()-1; 1163 1279 } else { 1164 1280 if (e->key() == (Qt::Key_Down)) { 1165 if (selection <(f CommandHistoryArea->childCount()-1))1281 if (selection <(fHistoryTBTableList->childCount()-1)) 1166 1282 selection++; 1167 1283 } else if (e->key() == (Qt::Key_PageDown)) { 1168 selection = f CommandHistoryArea->childCount()-1;1169 #else 1170 int selection = f CommandHistoryArea->currentRow();1171 if (f CommandHistoryArea->count()) {1284 selection = fHistoryTBTableList->childCount()-1; 1285 #else 1286 int selection = fHistoryTBTableList->currentRow(); 1287 if (fHistoryTBTableList->count()) { 1172 1288 if (selection == -1) { 1173 selection = f CommandHistoryArea->count()-1;1289 selection = fHistoryTBTableList->count()-1; 1174 1290 } else { 1175 1291 if (e->key() == (Qt::Key_Down)) { 1176 if (selection <(f CommandHistoryArea->count()-1))1292 if (selection <(fHistoryTBTableList->count()-1)) 1177 1293 selection++; 1178 1294 } else if (e->key() == (Qt::Key_PageDown)) { 1179 selection = f CommandHistoryArea->count()-1;1295 selection = fHistoryTBTableList->count()-1; 1180 1296 #endif 1181 1297 } else if (e->key() == (Qt::Key_Up)) { … … 1186 1302 } 1187 1303 } 1188 f CommandHistoryArea->clearSelection();1189 #if QT_VERSION < 0x040000 1190 QListViewItem* tmpItem = f CommandHistoryArea->firstChild();1304 fHistoryTBTableList->clearSelection(); 1305 #if QT_VERSION < 0x040000 1306 QListViewItem* tmpItem = fHistoryTBTableList->firstChild(); 1191 1307 int index = 0; 1192 1308 while (tmpItem != 0) { 1193 1309 if (index == selection) { 1194 1310 tmpItem->setSelected(true); 1195 f CommandHistoryArea->setCurrentItem(tmpItem);1311 fHistoryTBTableList->setCurrentItem(tmpItem); 1196 1312 } 1197 1313 index ++; … … 1200 1316 #else 1201 1317 #if QT_VERSION < 0x040202 1202 f CommandHistoryArea->setItemSelected(fCommandHistoryArea->item(selection),true);1203 #else 1204 f CommandHistoryArea->item(selection)->setSelected(true);1318 fHistoryTBTableList->setItemSelected(fHistoryTBTableList->item(selection),true); 1319 #else 1320 fHistoryTBTableList->item(selection)->setSelected(true); 1205 1321 #endif 1206 f CommandHistoryArea->setCurrentItem(fCommandHistoryArea->item(selection));1322 fHistoryTBTableList->setCurrentItem(fHistoryTBTableList->item(selection)); 1207 1323 #endif 1208 1324 } … … 1269 1385 ) 1270 1386 { 1271 fTextArea->clear(); 1387 fCoutTBTextArea->clear(); 1388 fG4cout.clear(); 1272 1389 } 1273 1390 … … 1280 1397 } 1281 1398 1399 void G4UIQt::ExitHelp( 1400 ) 1401 { 1402 } 1282 1403 1283 1404 /** Callback call when "click on a menu entry.<br> … … 1291 1412 if (fCommandArea->text().simplifyWhiteSpace() != "") { 1292 1413 1293 QListViewItem *newItem = new QListViewItem(f CommandHistoryArea);1414 QListViewItem *newItem = new QListViewItem(fHistoryTBTableList); 1294 1415 newItem->setText(0,fCommandArea->text()); 1295 f CommandHistoryArea->insertItem(newItem);1416 fHistoryTBTableList->insertItem(newItem); 1296 1417 // now we have to arrange 1297 QListViewItem *temp= f CommandHistoryArea->lastItem();1298 for (int i=0; i<f CommandHistoryArea->childCount()-1;i++) {1299 f CommandHistoryArea->takeItem(temp);1300 f CommandHistoryArea->insertItem(temp);1301 temp= f CommandHistoryArea->lastItem();1418 QListViewItem *temp= fHistoryTBTableList->lastItem(); 1419 for (int i=0; i<fHistoryTBTableList->childCount()-1;i++) { 1420 fHistoryTBTableList->takeItem(temp); 1421 fHistoryTBTableList->insertItem(temp); 1422 temp= fHistoryTBTableList->lastItem(); 1302 1423 } 1303 1424 #else 1304 1425 G4String command (fCommandArea->text().toStdString().c_str()); 1305 1426 if (fCommandArea->text().trimmed() != "") { 1306 f CommandHistoryArea->addItem(fCommandArea->text());1307 #endif 1308 f CommandHistoryArea->clearSelection();1309 f CommandHistoryArea->setCurrentItem(NULL);1427 fHistoryTBTableList->addItem(fCommandArea->text()); 1428 #endif 1429 fHistoryTBTableList->clearSelection(); 1430 fHistoryTBTableList->setCurrentItem(NULL); 1310 1431 fCommandArea->setText(""); 1311 1432 … … 1462 1583 QListWidgetItem* item = NULL; 1463 1584 #endif 1464 if (!f CommandHistoryArea)1585 if (!fHistoryTBTableList) 1465 1586 return ; 1466 1587 1467 1588 1468 1589 #if QT_VERSION < 0x040000 1469 item =f CommandHistoryArea->selectedItem();1470 #else 1471 QList<QListWidgetItem *> list =f CommandHistoryArea->selectedItems();1590 item =fHistoryTBTableList->selectedItem(); 1591 #else 1592 QList<QListWidgetItem *> list =fHistoryTBTableList->selectedItems(); 1472 1593 if (list.isEmpty()) 1473 1594 return; … … 1486 1607 } 1487 1608 1609 1610 void G4UIQt::CoutFilterCallback( 1611 const QString & text) { 1612 1613 #ifdef G4DEBUG_INTERFACES_BASIC 1614 printf("G4UIQt::CoutFilterCallback : %s\n",text.toStdString().c_str()); 1615 #endif 1616 1617 QStringList result = fG4cout.filter(text); 1618 1619 fCoutTBTextArea->setText(result.join("\n")); 1620 fCoutTBTextArea->repaint(); 1621 #if QT_VERSION < 0x040000 1622 fCoutTBTextArea->verticalScrollBar()->setValue(fCoutTBTextArea->verticalScrollBar()->maxValue()); 1623 #else 1624 fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum()); 1625 #endif 1626 #ifdef G4DEBUG_INTERFACES_BASIC 1627 printf("G4UIQt::CoutFilterCallback textSize:%d resSize:%d \n",fG4cout.join("").size(),result.join("").size()); 1628 #endif 1629 1630 } 1488 1631 1489 1632 /** Callback called when user give a new string to look for<br> -
trunk/source/interfaces/common/include/G4Qt.hh
r1180 r1224 60 60 void FlushAndWaitExecution(); 61 61 virtual ~G4Qt(); 62 bool AddTab VisWidget(QWidget*,QString,int,int);62 bool AddTabWidget(QWidget*,QString,int,int); 63 63 void SetG4UI(G4UIQt*); 64 64 -
trunk/source/interfaces/common/src/G4Qt.cc
r1179 r1224 130 130 qApp = new QApplication (*p_argn, args); 131 131 #else 132 #ifdef G4DEBUG_INTERFACES_COMMON 133 printf("G4Qt::G4Qt QAppl \n"); 134 #endif 132 135 new QApplication (*p_argn, args); 133 136 #endif … … 138 141 QtInited = TRUE; 139 142 if (a_argn != 0) { 143 #ifdef G4DEBUG_INTERFACES_COMMON 144 printf("G4Qt::G4Qt SetMainInteractor\n"); 145 #endif 140 146 SetMainInteractor (qApp); 141 147 } … … 218 224 219 225 /***************************************************************************/ 220 bool G4Qt::AddTab VisWidget (226 bool G4Qt::AddTabWidget ( 221 227 QWidget * vis 222 228 ,QString name … … 228 234 { 229 235 if (fG4UI != NULL) { 230 fG4UI->AddTab VisWidget(vis,name,sizeX,sizeY);236 fG4UI->AddTabWidget(vis,name,sizeX,sizeY); 231 237 return true; 232 238 }
Note: See TracChangeset
for help on using the changeset viewer.