- Timestamp:
- May 6, 2010, 5:49:48 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/interfaces/basic/src/G4UIQt.cc
r1249 r1250 1014 1014 #endif 1015 1015 1016 QString defaultSelection = "";1017 1018 1016 if (! fHelpTreeWidget ) { 1019 1017 InitHelpTree(); 1020 } else { 1021 // Memorise previous selection 1022 if (fHelpTreeWidget->currentItem() != NULL) { 1023 defaultSelection = fHelpTreeWidget->currentItem()->text(0); 1024 } 1025 } 1018 } 1019 1026 1020 G4UImanager* UI = G4UImanager::GetUIpointer(); 1027 1021 if(UI==NULL) return; … … 1030 1024 1031 1025 // Remove all previous children 1032 fHelpTreeWidget->clear();1026 // fHelpTreeWidget->clear(); 1033 1027 1034 1028 G4int treeSize = treeTop->GetTreeEntry(); 1035 1029 #if QT_VERSION < 0x040000 1036 QListViewItem * newItem; 1037 QListViewItem * defaultItem; 1038 #else 1039 QTreeWidgetItem * newItem; 1040 QTreeWidgetItem * defaultItem; 1041 #endif 1030 QListViewItem * newItem = NULL; 1031 #else 1032 QTreeWidgetItem * newItem = NULL; 1033 #endif 1034 QString commandText = ""; 1042 1035 for (int a=0;a<treeSize;a++) { 1036 #ifdef G4DEBUG_INTERFACES_BASIC 1037 printf("G4UIQt::FillHelpTree for\n"); 1038 #endif 1043 1039 // Creating new item 1044 1040 1045 1041 #if QT_VERSION < 0x040000 1046 newItem = new QListViewItem(fHelpTreeWidget); 1047 newItem->setText(0,GetShortCommandPath(QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()).simplifyWhiteSpace())); 1048 #else 1049 newItem = new QTreeWidgetItem(fHelpTreeWidget); 1050 newItem->setText(0,GetShortCommandPath(QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()).trimmed())); 1051 #endif 1052 1042 commandText = QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()).simplifyWhiteSpace(); 1043 #else 1044 commandText = QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()).trimmed(); 1045 #endif 1046 1047 // if already exist, don't create it ! 1048 #if QT_VERSION < 0x040000 1049 QListViewItem* tmpItem = fHelpTreeWidget->firstChild(); 1050 while (tmpItem != 0) { 1051 if (!newItem) { 1052 newItem = FindTreeItem(tmpItem,commandText); 1053 } 1054 tmpItem = tmpItem->nextSibling(); 1055 } 1056 #else 1057 for (int b=0;a<fHelpTreeWidget->topLevelItemCount();b++) { 1058 if (!newItem) 1059 newItem = FindTreeItem(fHelpTreeWidget->topLevelItem(b),commandText); 1060 } 1061 #endif 1062 1063 if (newItem == NULL) { 1064 #ifdef G4DEBUG_INTERFACES_BASIC 1065 printf("G4UIQt::FillHelpTree check already present\n"); 1066 #endif 1067 1068 #if QT_VERSION < 0x040000 1069 newItem = new QListViewItem(fHelpTreeWidget); 1070 #else 1071 newItem = new QTreeWidgetItem(fHelpTreeWidget); 1072 #endif 1073 newItem->setText(0,GetShortCommandPath(commandText)); 1074 } 1053 1075 1054 1076 // look for childs 1055 1077 CreateChildTree(newItem,treeTop->GetTree(a+1)); 1056 1078 // items.append(newItem); 1057 if (defaultSelection != "") {1058 defaultItem = FindTreeItem(newItem,defaultSelection);1059 if (defaultItem != NULL ) {1060 defaultItem->setSelected(true);1061 while (defaultItem->parent() != NULL) {1062 defaultItem = defaultItem->parent();1063 defaultItem->setExpanded(true);1064 }1065 }1066 }1067 1079 } 1068 1080 } … … 1096 1108 #endif 1097 1109 1110 QString commandText = ""; 1098 1111 // Get the Sub directories 1099 1112 for (int a=0;a<aCommandTree->GetTreeEntry();a++) { 1100 1113 #ifdef G4DEBUG_INTERFACES_BASIC 1114 printf("G4UIQt::CreateChildTree for\n"); 1115 #endif 1116 1117 #if QT_VERSION < 0x040000 1118 commandText = QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()).simplifyWhiteSpace(); 1119 #else 1120 commandText = QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()).trimmed(); 1121 #endif 1122 1123 // if already exist, don't create it ! 1124 newItem = FindTreeItem(aParent,commandText); 1125 if (newItem == NULL) { 1126 #ifdef G4DEBUG_INTERFACES_BASIC 1127 printf("G4UIQt::CreateChildTree check already present\n"); 1128 #endif 1101 1129 #if QT_VERSION < 0x040000 1102 1130 newItem = new QListViewItem(aParent); 1103 newItem->setText(0,GetShortCommandPath(QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()).simplifyWhiteSpace())); 1104 1105 #else 1106 newItem = new QTreeWidgetItem(aParent); 1107 newItem->setText(0,GetShortCommandPath(QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()).trimmed())); 1108 #endif 1109 1131 #else 1132 newItem = new QTreeWidgetItem(aParent); 1133 #endif 1134 newItem->setText(0,GetShortCommandPath(commandText)); 1135 } 1110 1136 CreateChildTree(newItem,aCommandTree->GetTree(a+1)); 1111 1137 } … … 1153 1179 if (aParent == NULL) return NULL; 1154 1180 1155 if ( aParent->text(0) == aCommand)1181 if (GetLongCommandPath(aParent) == aCommand) 1156 1182 return aParent; 1157 1183 … … 1164 1190 tmpItem = tmpItem->nextSibling(); 1165 1191 } 1166 1167 1192 #else 1168 1193 QTreeWidgetItem * tmp = NULL; … … 1961 1986 itemText = item->text(0); 1962 1987 1963 #ifdef G4DEBUG_INTERFACES_BASIC1964 printf("G4UIQt::HelpTreeClicCallback text:%s\n",item->text(0).toStdString().c_str());1965 #endif1966 1988 while (item->parent() != NULL) { 1967 1989 itemText = item->parent()->text(0)+"/"+itemText;
Note: See TracChangeset
for help on using the changeset viewer.