Changeset 1248 for trunk/source/interfaces/basic/src
- Timestamp:
- May 5, 2010, 4:26:13 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/interfaces/basic/src/G4UIQt.cc
r1243 r1248 25 25 // 26 26 // 27 // $Id: G4UIQt.cc,v 1.3 0 2010/01/06 14:13:08lgarnier Exp $28 // GEANT4 tag $Name: laurent-QtUI_with_tabs_v1$27 // $Id: G4UIQt.cc,v 1.33 2010/04/27 13:49:02 lgarnier Exp $ 28 // GEANT4 tag $Name: $ 29 29 // 30 30 // L. Garnier … … 60 60 #include <qtabwidget.h> 61 61 #include <qtabbar.h> 62 #include < qresizeevent>62 #include <QResizeEvent> 63 63 #include <qstringlist.h> 64 64 … … 109 109 ) 110 110 :fG4cout("") 111 ,fHelpTreeWidget(NULL) 111 112 ,fHelpTBWidget(NULL) 112 113 ,fHistoryTBWidget(NULL) … … 156 157 157 158 #ifdef G4DEBUG_INTERFACES_BASIC 158 printf("G4UIQt::Initialise after main window creation UImanager:%d G4UIQt(this) : %d+++++++++++\n",UI,this);159 printf("G4UIQt::Initialise after main window creation +++++++++++\n"); 159 160 #endif 160 161 … … 230 231 231 232 // the splitter 232 fToolBox->addItem(fVisParametersTBWidget,"Vis parameters");233 fToolBox->addItem(fViewComponentsTBWidget,"Viewer components");233 // fToolBox->addItem(fVisParametersTBWidget,"Vis parameters"); 234 // fToolBox->addItem(fViewComponentsTBWidget,"Viewer components"); 234 235 fToolBox->addItem(fHelpTBWidget,"Help"); 235 236 fToolBox->addItem(fCoutTBWidget,"Cout"); … … 301 302 #endif 302 303 304 // Connect signal 303 305 connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback())); 304 306 connect(fTabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(TabCloseCallback(int))); 305 307 connect(fTabWidget, SIGNAL(currentChanged ( int ) ), SLOT(UpdateTabWidget(int))); 308 connect(fToolBox, SIGNAL(currentChanged(int)), SLOT(ToolBoxActivated(int))); 309 306 310 if(UI!=NULL) UI->SetCoutDestination(this); // TO KEEP 307 311 … … 397 401 QHBoxLayout *helpLayout = new QHBoxLayout(helpWidget); 398 402 QVBoxLayout *vLayout = new QVBoxLayout(fHelpTBWidget); 399 QSplitter *splitter = new QSplitter(Qt::Horizontal,fHelpTBWidget);403 fHelpVSplitter = new QSplitter(Qt::Horizontal,fHelpTBWidget); 400 404 #else 401 405 QWidget *helpWidget = new QWidget(); 402 406 QHBoxLayout *helpLayout = new QHBoxLayout(); 403 407 QVBoxLayout *vLayout = new QVBoxLayout(); 404 QSplitter *splitter = new QSplitter(Qt::Horizontal);408 fHelpVSplitter = new QSplitter(Qt::Horizontal); 405 409 #endif 406 410 fHelpLine = new QLineEdit(fHelpTBWidget); … … 413 417 #endif 414 418 415 // the help tree 416 #if QT_VERSION < 0x040000 417 fHelpTreeWidget = new QListView(splitter); 418 #else 419 fHelpTreeWidget = new QTreeWidget(); 420 #endif 421 fHelpTreeWidget = CreateHelpTree(); 422 423 fHelpArea = new QTextEdit(splitter); 419 // Create Help tree 420 FillHelpTree(); 421 422 fHelpArea = new QTextEdit(fHelpVSplitter); 424 423 fHelpArea->setReadOnly(true); 425 424 … … 427 426 428 427 #if QT_VERSION >= 0x040000 429 if (fHelpTreeWidget) 430 splitter->addWidget(fHelpTreeWidget); 431 splitter->addWidget(fHelpArea); 428 if (fHelpTreeWidget) { 429 fHelpVSplitter->addWidget(fHelpTreeWidget); 430 } 431 fHelpVSplitter->addWidget(fHelpArea); 432 432 #endif 433 433 … … 435 435 #if QT_VERSION >= 0x040000 436 436 vLayout->addWidget(helpWidget); 437 vLayout->addWidget( splitter,1);437 vLayout->addWidget(fHelpVSplitter,1); 438 438 #endif 439 439 … … 448 448 list.append( 50 ); 449 449 list.append( 50 ); 450 splitter->setSizes(list);450 fHelpVSplitter->setSizes(list); 451 451 452 452 #if QT_VERSION >= 0x040000 … … 910 910 QSignalMapper *signalMapper = new QSignalMapper(this); 911 911 #if QT_VERSION < 0x030200 912 QAction *action = new QAction(QString(aLabel),QString(aLabel),QKeySequence ::QKeySequence(),signalMapper, SLOT(map()));912 QAction *action = new QAction(QString(aLabel),QString(aLabel),QKeySequence(),signalMapper, SLOT(map())); 913 913 action->addTo(parent); 914 914 connect(action,SIGNAL(activated()),signalMapper,SLOT(map())); 915 915 916 916 #elif QT_VERSION < 0x040000 917 QAction *action = new QAction(QString(aLabel),QKeySequence ::QKeySequence(),signalMapper, SLOT(map()));917 QAction *action = new QAction(QString(aLabel),QKeySequence(),signalMapper, SLOT(map())); 918 918 action->addTo(parent); 919 919 connect(action,SIGNAL(activated()),signalMapper,SLOT(map())); … … 947 947 } 948 948 #ifdef G4DEBUG_INTERFACES_BASIC 949 printf("G4UIQt::ActivateCommand found : % d\n",targetCom.data());949 printf("G4UIQt::ActivateCommand found : %s \n",targetCom.data()); 950 950 #endif 951 951 if (targetCom != "") { … … 964 964 */ 965 965 966 #if QT_VERSION < 0x040000 967 QListView * G4UIQt::CreateHelpTree() 968 #else 969 QTreeWidget * G4UIQt::CreateHelpTree() 970 #endif 971 { 972 G4UImanager* UI = G4UImanager::GetUIpointer(); 973 if(UI==NULL) return NULL; 974 G4UIcommandTree * treeTop = UI->GetTree(); 975 966 void G4UIQt::InitHelpTree() 967 { 968 969 #ifdef G4DEBUG_INTERFACES_BASIC 970 printf("G4UIQt::InitHelpTree\n"); 971 #endif 972 973 if (! fHelpTreeWidget ) { 974 #if QT_VERSION < 0x040000 975 fHelpTreeWidget = new QListView(splitter); 976 #else 977 fHelpTreeWidget = new QTreeWidget(); 978 #endif 979 } 976 980 977 981 // build widget … … 988 992 #endif 989 993 994 995 #if QT_VERSION < 0x040000 996 connect(fHelpTreeWidget, SIGNAL(selectionChanged ()),this, SLOT(HelpTreeClicCallback())); 997 connect(fHelpTreeWidget, SIGNAL(doubleClicked (QListViewItem*)),this, SLOT(HelpTreeDoubleClicCallback())); 998 #else 999 connect(fHelpTreeWidget, SIGNAL(itemSelectionChanged ()),this, SLOT(HelpTreeClicCallback())); 1000 connect(fHelpTreeWidget, SIGNAL(itemDoubleClicked (QTreeWidgetItem*,int)),this, SLOT(HelpTreeDoubleClicCallback())); 1001 #endif 1002 1003 } 1004 /** 1005 Create the help tree widget 1006 @param parent : parent of tree widget 1007 @return the widget containing the tree or NULL if it could not have beeen created 1008 */ 1009 1010 void G4UIQt::FillHelpTree() 1011 { 1012 #ifdef G4DEBUG_INTERFACES_BASIC 1013 printf("G4UIQt::FillHelpTree\n"); 1014 #endif 1015 1016 QString defaultSelection = ""; 1017 1018 if (! fHelpTreeWidget ) { 1019 InitHelpTree(); 1020 } else { 1021 // Memorise previous selection 1022 defaultSelection = fHelpTreeWidget->currentItem()->text(0); 1023 } 1024 G4UImanager* UI = G4UImanager::GetUIpointer(); 1025 if(UI==NULL) return; 1026 G4UIcommandTree * treeTop = UI->GetTree(); 1027 1028 1029 // Remove all previous children 1030 fHelpTreeWidget->clear(); 1031 990 1032 G4int treeSize = treeTop->GetTreeEntry(); 991 1033 #if QT_VERSION < 0x040000 992 1034 QListViewItem * newItem; 1035 QListViewItem * defaultItem; 993 1036 #else 994 1037 QTreeWidgetItem * newItem; 1038 QTreeWidgetItem * defaultItem; 995 1039 #endif 996 1040 for (int a=0;a<treeSize;a++) { … … 1009 1053 CreateChildTree(newItem,treeTop->GetTree(a+1)); 1010 1054 // items.append(newItem); 1011 } 1012 1013 1014 #if QT_VERSION < 0x040000 1015 connect(fHelpTreeWidget, SIGNAL(selectionChanged ()),this, SLOT(HelpTreeClicCallback())); 1016 connect(fHelpTreeWidget, SIGNAL(doubleClicked (QListViewItem*)),this, SLOT(HelpTreeDoubleClicCallback())); 1017 #else 1018 connect(fHelpTreeWidget, SIGNAL(itemSelectionChanged ()),this, SLOT(HelpTreeClicCallback())); 1019 connect(fHelpTreeWidget, SIGNAL(itemDoubleClicked (QTreeWidgetItem*,int)),this, SLOT(HelpTreeDoubleClicCallback())); 1020 #endif 1021 1022 return fHelpTreeWidget; 1055 if (defaultSelection != "") { 1056 defaultItem = FindTreeItem(newItem,defaultSelection); 1057 if (defaultItem != NULL ) { 1058 defaultItem->setSelected(true); 1059 while (defaultItem->parent() != NULL) { 1060 defaultItem = defaultItem->parent(); 1061 defaultItem->setExpanded(true); 1062 } 1063 } 1064 } 1065 } 1023 1066 } 1024 1067 … … 1091 1134 } 1092 1135 1093 1136 1094 1137 /** Find a treeItemWidget in the help tree 1095 1138 @param aCommand item's String to look for … … 1424 1467 ActivateCommand(command); 1425 1468 } 1469 // Rebuild help tree 1470 FillHelpTree(); 1471 1426 1472 if(exitSession==true) 1427 1473 SessionTerminate(); 1428 1474 } 1475 1429 1476 } 1430 1477 … … 1444 1491 #endif 1445 1492 ApplyShellCommand(ss,exitSession,exitPause); 1493 1494 // Rebuild help tree 1495 FillHelpTree(); 1496 1446 1497 if(exitSession==true) 1447 1498 SessionTerminate(); … … 1635 1686 fHelpTreeWidget->removeColumn(0); 1636 1687 #endif 1637 CreateHelpTree(); 1688 1689 FillHelpTree(); 1690 1638 1691 return; 1639 1692 } else { … … 1913 1966 1914 1967 1915 void G4UIQt::CurrentChangedCallback(int a){ 1916 #ifdef G4DEBUG_INTERFACES_BASIC 1917 printf("G4UIQt::CurrentChangeCallback %d ---------------------------------\n",a); 1918 #endif 1919 1968 void G4UIQt::ToolBoxActivated(int a){ 1969 1970 if (fToolBox->widget(a) == fHelpTBWidget) { 1971 // Rebuild the help tree 1972 FillHelpTree(); 1973 1974 #ifdef G4DEBUG_INTERFACES_BASIC 1975 printf("G4UIQt::CurrentChangeCallback %d ---------------------------------\n",a); 1976 #endif 1977 } 1920 1978 } 1921 1979 … … 1927 1985 if (currentWidget()) { 1928 1986 #ifdef G4DEBUG_INTERFACES_BASIC 1929 printf("G4QTabWidget::paintEvent repaint type : %d -- rect %d %d region:%d %d page : %d %d ________________________ for = %d i= %d w: %d\n", event->type(),event->rect().height(),event->rect().width(),event->region().boundingRect().width(),event->region().boundingRect().height(),currentWidget()->width(),currentWidget()->height(),this,currentIndex(),currentWidget());1987 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()); 1930 1988 #endif 1931 1989 if ( isTabSelected()) {
Note: See TracChangeset
for help on using the changeset viewer.