Changeset 1251 for trunk


Ignore:
Timestamp:
May 7, 2010, 11:51:18 AM (14 years ago)
Author:
garnier
Message:

Help tree Add OK, del NOK

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/interfaces/basic/src/G4UIQt.cc

    r1250 r1251  
    10341034  QString commandText = "";
    10351035  for (int a=0;a<treeSize;a++) {
    1036 #ifdef G4DEBUG_INTERFACES_BASIC
    1037   printf("G4UIQt::FillHelpTree for\n");
    1038 #endif
     1036
    10391037    // Creating new item
     1038    newItem = NULL;
    10401039
    10411040#if QT_VERSION < 0x040000
     
    10451044#endif
    10461045
     1046#ifdef G4DEBUG_INTERFACES_BASIC
     1047    printf("G4UIQt::FillHelpTree for %s\n",commandText.toStdString().c_str());
     1048#endif
    10471049    // if already exist, don't create it !
    10481050#if QT_VERSION < 0x040000
     
    10551057    }
    10561058#else
    1057     for (int b=0;a<fHelpTreeWidget->topLevelItemCount();b++) {
     1059#ifdef G4DEBUG_INTERFACES_BASIC
     1060    printf("G4UIQt::FillHelpTree topCount %d\n",fHelpTreeWidget->topLevelItemCount());
     1061#endif
     1062    for (int b=0;b<fHelpTreeWidget->topLevelItemCount();b++) {
    10581063      if (!newItem)
    10591064        newItem = FindTreeItem(fHelpTreeWidget->topLevelItem(b),commandText);
     
    10631068    if (newItem == NULL) {
    10641069#ifdef G4DEBUG_INTERFACES_BASIC
    1065   printf("G4UIQt::FillHelpTree check already present\n");
     1070  printf("G4UIQt::FillHelpTree NOT present\n");
    10661071#endif
    10671072     
     
    10731078      newItem->setText(0,GetShortCommandPath(commandText));
    10741079    }
     1080#ifdef G4DEBUG_INTERFACES_BASIC
     1081    else {
     1082      printf("G4UIQt::FillHelpTree ALREADY present\n");
     1083    }
     1084#endif
    10751085
    10761086    // look for childs
     
    11111121  // Get the Sub directories
    11121122  for (int a=0;a<aCommandTree->GetTreeEntry();a++) {
    1113 #ifdef G4DEBUG_INTERFACES_BASIC
    1114   printf("G4UIQt::CreateChildTree for\n");
    1115 #endif
    11161123
    11171124#if QT_VERSION < 0x040000
     
    11211128#endif
    11221129   
     1130#ifdef G4DEBUG_INTERFACES_BASIC
     1131    printf("G4UIQt::CreateChildTree for %s \n",commandText.toStdString().c_str());
     1132#endif
    11231133    // if already exist, don't create it !
    11241134    newItem = FindTreeItem(aParent,commandText);
    11251135    if (newItem == NULL) {
    11261136#ifdef G4DEBUG_INTERFACES_BASIC
    1127   printf("G4UIQt::CreateChildTree check already present\n");
     1137      printf("G4UIQt::CreateChildTree NOT present\n");
    11281138#endif
    11291139#if QT_VERSION < 0x040000
     
    11341144      newItem->setText(0,GetShortCommandPath(commandText));
    11351145    }
     1146#ifdef G4DEBUG_INTERFACES_BASIC
     1147    else {
     1148      printf("G4UIQt::CreateChildTree ALREADY present\n");
     1149    }
     1150#endif
    11361151    CreateChildTree(newItem,aCommandTree->GetTree(a+1));
    11371152  }
     
    11451160    QStringList stringList;
    11461161#if QT_VERSION < 0x040000
    1147     newItem = new QListViewItem(aParent);
    1148     newItem->setText(0,GetShortCommandPath(QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()).simplifyWhiteSpace()));
    1149     newItem->setOpen(false);
    1150 
    1151 #else
    1152     newItem = new QTreeWidgetItem(aParent);
    1153     newItem->setText(0,GetShortCommandPath(QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()).trimmed()));
     1162    commandText = QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()).simplifyWhiteSpace();
     1163#else
     1164    commandText = QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()).trimmed();
     1165#endif
     1166
     1167    // if already exist, don't create it !
     1168    newItem = FindTreeItem(aParent,commandText);
     1169    if (newItem == NULL) {
     1170#if QT_VERSION < 0x040000
     1171      newItem = new QListViewItem(aParent);
     1172      newItem->setText(0,GetShortCommandPath(commandText));
     1173      newItem->setOpen(false);
     1174     
     1175#else
     1176      newItem = new QTreeWidgetItem(aParent);
     1177      newItem->setText(0,GetShortCommandPath(commandText));
    11541178#if QT_VERSION < 0x040202
    1155         fHelpTreeWidget->setItemExpanded(newItem,false);
    1156 #else
    1157     newItem->setExpanded(false);
    1158 #endif
    1159 #endif
    1160      
     1179      fHelpTreeWidget->setItemExpanded(newItem,false);
     1180#else
     1181      newItem->setExpanded(false);
     1182#endif
     1183#endif
     1184    }
    11611185  }
    11621186}
     
    11791203  if (aParent == NULL) return NULL;
    11801204
    1181   if (GetLongCommandPath(aParent) == aCommand)
     1205  // Suppress last "/"
     1206  QString myCommand = aCommand;
     1207 
     1208  if (myCommand.lastIndexOf("/") == (myCommand.size()-1)) {
     1209    myCommand = myCommand.left(myCommand.size()-1);
     1210  }
     1211
     1212#ifdef G4DEBUG_INTERFACES_BASIC
     1213  printf("G4UIQt::FindTreeItem check -%s=%s-\n",myCommand.toStdString().c_str(),GetLongCommandPath(aParent).toStdString().c_str());
     1214#endif
     1215  if (GetLongCommandPath(aParent) == myCommand)
    11821216    return aParent;
    11831217 
     
    11871221    while (tmpItem != 0) {
    11881222      if (!tmp)
    1189         tmp = FindTreeItem(tmpItem,aCommand);
     1223        tmp = FindTreeItem(tmpItem,myCommand);
    11901224      tmpItem = tmpItem->nextSibling();
    11911225    }
     
    11941228  for (int a=0;a<aParent->childCount();a++) {
    11951229    if (!tmp)
    1196       tmp = FindTreeItem(aParent->child(a),aCommand);
     1230      tmp = FindTreeItem(aParent->child(a),myCommand);
    11971231  }
    11981232#endif
Note: See TracChangeset for help on using the changeset viewer.