- Timestamp:
- May 6, 2010, 11:44:13 AM (14 years ago)
- Location:
- trunk/source/interfaces/basic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/interfaces/basic/include/G4UIQt.hh
r1248 r1249 154 154 void CreateHistoryTBWidget(); 155 155 void OpenHelpTreeOnCommand(const QString &); 156 QString GetShortCommandPath(QString); 157 #if QT_VERSION < 0x040000 158 QString GetLongCommandPath(QListViewItem*); 159 #else 160 QString GetLongCommandPath(QTreeWidgetItem*); 161 #endif 156 162 157 163 private: -
trunk/source/interfaces/basic/src/G4UIQt.cc
r1248 r1249 1020 1020 } else { 1021 1021 // Memorise previous selection 1022 defaultSelection = fHelpTreeWidget->currentItem()->text(0); 1022 if (fHelpTreeWidget->currentItem() != NULL) { 1023 defaultSelection = fHelpTreeWidget->currentItem()->text(0); 1024 } 1023 1025 } 1024 1026 G4UImanager* UI = G4UImanager::GetUIpointer(); … … 1043 1045 #if QT_VERSION < 0x040000 1044 1046 newItem = new QListViewItem(fHelpTreeWidget); 1045 newItem->setText(0, QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()).simplifyWhiteSpace());1047 newItem->setText(0,GetShortCommandPath(QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()).simplifyWhiteSpace())); 1046 1048 #else 1047 1049 newItem = new QTreeWidgetItem(fHelpTreeWidget); 1048 newItem->setText(0, QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()).trimmed());1050 newItem->setText(0,GetShortCommandPath(QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()).trimmed())); 1049 1051 #endif 1050 1052 … … 1099 1101 #if QT_VERSION < 0x040000 1100 1102 newItem = new QListViewItem(aParent); 1101 newItem->setText(0, QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()).simplifyWhiteSpace());1103 newItem->setText(0,GetShortCommandPath(QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()).simplifyWhiteSpace())); 1102 1104 1103 1105 #else 1104 1106 newItem = new QTreeWidgetItem(aParent); 1105 newItem->setText(0, QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()).trimmed());1107 newItem->setText(0,GetShortCommandPath(QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()).trimmed())); 1106 1108 #endif 1107 1109 … … 1118 1120 #if QT_VERSION < 0x040000 1119 1121 newItem = new QListViewItem(aParent); 1120 newItem->setText(0, QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()).simplifyWhiteSpace());1122 newItem->setText(0,GetShortCommandPath(QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()).simplifyWhiteSpace())); 1121 1123 newItem->setOpen(false); 1122 1124 1123 1125 #else 1124 1126 newItem = new QTreeWidgetItem(aParent); 1125 newItem->setText(0, QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()).trimmed());1127 newItem->setText(0,GetShortCommandPath(QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()).trimmed())); 1126 1128 #if QT_VERSION < 0x040202 1127 1129 fHelpTreeWidget->setItemExpanded(newItem,false); … … 1511 1513 QTreeWidgetItem* item = NULL; 1512 1514 #endif 1515 1513 1516 if (!fHelpTreeWidget) 1514 1517 return ; … … 1532 1535 G4UIcommandTree * treeTop = UI->GetTree(); 1533 1536 1534 1535 1536 std::string itemText; 1537 #if QT_VERSION < 0x040000 1538 itemText = std::string(item->text(0).ascii()); 1539 #else 1540 itemText = std::string(item->text(0).toStdString()); 1541 #endif 1542 1537 std::string itemText = GetLongCommandPath(item).toStdString(); 1538 1543 1539 G4UIcommand* command = treeTop->FindPath(itemText.c_str()); 1544 1540 … … 1603 1599 1604 1600 fCommandArea->clear(); 1605 fCommandArea->setText( item->text(0));1601 fCommandArea->setText(GetLongCommandPath(item)); 1606 1602 } 1607 1603 … … 1933 1929 1934 1930 1931 QString G4UIQt::GetShortCommandPath( 1932 QString commandPath 1933 ) 1934 { 1935 if (commandPath.indexOf("/") == 0) { 1936 commandPath = commandPath.right(commandPath.size()-1); 1937 } 1938 1939 commandPath = commandPath.right(commandPath.size()-commandPath.lastIndexOf("/",-2)-1); 1940 1941 if (commandPath.lastIndexOf("/") == (commandPath.size()-1)) { 1942 commandPath = commandPath.left(commandPath.size()-1); 1943 } 1944 1945 return commandPath; 1946 } 1947 1948 1949 QString G4UIQt::GetLongCommandPath( 1950 #if QT_VERSION < 0x040000 1951 QListViewItem* item 1952 #else 1953 QTreeWidgetItem* item 1954 #endif 1955 ) 1956 { 1957 if (item == NULL) return ""; 1958 1959 // rebuild path: 1960 QString itemText = ""; 1961 itemText = item->text(0); 1962 1963 #ifdef G4DEBUG_INTERFACES_BASIC 1964 printf("G4UIQt::HelpTreeClicCallback text:%s\n",item->text(0).toStdString().c_str()); 1965 #endif 1966 while (item->parent() != NULL) { 1967 itemText = item->parent()->text(0)+"/"+itemText; 1968 item = item->parent(); 1969 } 1970 itemText = "/"+itemText; 1971 1972 return itemText; 1973 } 1935 1974 1936 1975 G4QTabWidget::G4QTabWidget(
Note: See TracChangeset
for help on using the changeset viewer.