Changeset 1249 for trunk


Ignore:
Timestamp:
May 6, 2010, 11:44:13 AM (14 years ago)
Author:
garnier
Message:

Help update

Location:
trunk/source/interfaces/basic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/interfaces/basic/include/G4UIQt.hh

    r1248 r1249  
    154154  void CreateHistoryTBWidget();
    155155  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
    156162
    157163private:
  • trunk/source/interfaces/basic/src/G4UIQt.cc

    r1248 r1249  
    10201020  } else {
    10211021    // Memorise previous selection
    1022     defaultSelection = fHelpTreeWidget->currentItem()->text(0);
     1022    if (fHelpTreeWidget->currentItem() != NULL) {
     1023      defaultSelection = fHelpTreeWidget->currentItem()->text(0);
     1024    }
    10231025  }
    10241026  G4UImanager* UI = G4UImanager::GetUIpointer();
     
    10431045#if QT_VERSION < 0x040000
    10441046    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()));
    10461048#else
    10471049    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()));
    10491051#endif
    10501052
     
    10991101#if QT_VERSION < 0x040000
    11001102      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()));
    11021104
    11031105#else
    11041106    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()));
    11061108#endif
    11071109
     
    11181120#if QT_VERSION < 0x040000
    11191121    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()));
    11211123    newItem->setOpen(false);
    11221124
    11231125#else
    11241126    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()));
    11261128#if QT_VERSION < 0x040202
    11271129        fHelpTreeWidget->setItemExpanded(newItem,false);
     
    15111513  QTreeWidgetItem* item =  NULL;
    15121514#endif
     1515
    15131516  if (!fHelpTreeWidget)
    15141517    return ;
     
    15321535  G4UIcommandTree * treeTop = UI->GetTree();
    15331536
    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 
    15431539  G4UIcommand* command = treeTop->FindPath(itemText.c_str());
    15441540
     
    16031599
    16041600  fCommandArea->clear();
    1605   fCommandArea->setText(item->text(0));
     1601  fCommandArea->setText(GetLongCommandPath(item));
    16061602}
    16071603
     
    19331929
    19341930 
     1931QString G4UIQt::GetShortCommandPath(
     1932QString 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
     1949QString 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}
    19351974
    19361975G4QTabWidget::G4QTabWidget(
Note: See TracChangeset for help on using the changeset viewer.