Ignore:
Timestamp:
Feb 7, 2008, 7:19:06 PM (16 years ago)
Author:
garnier
Message:

Correction du ticket #117

File:
1 edited

Legend:

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

    r704 r719  
    2626//
    2727// $Id: G4UIQt.cc,v 1.15 2008/01/30 11:16:17 lgarnier Exp $
    28 // GEANT4 tag $Name: $
     28// GEANT4 tag $Name: HEAD $
    2929//
    3030// L. Garnier
    3131
    32 //#define GEANT4_QT_DEBUG
     32#define GEANT4_QT_DEBUG
    3333
    3434#ifdef G4UI_BUILD_QT_SESSION
     
    547547#if QT_VERSION < 0x040000
    548548    helpLayout->add(helpLine);
     549    connect( helpLine, SIGNAL( returnPressed () ), this, SLOT( lookForHelpStringCallback() ) );
    549550#else
    550551    helpLayout->addWidget(helpLine);
    551 #endif
    552552    connect( helpLine, SIGNAL( editingFinished () ), this, SLOT( lookForHelpStringCallback() ) );
     553#endif
    553554
    554555    // the help tree
     
    578579#else
    579580    vLayout->addWidget(helpWidget);
    580     vLayout->add(splitter,1);
     581    vLayout->addWidget(splitter,1);
    581582    vLayout->addWidget(exitButton);
    582583#endif
     
    13541355    // clear old help tree
    13551356    fHelpTreeWidget->clear();
     1357#if QT_VERSION < 0x040200
     1358    fHelpTreeWidget->removeColumn(1);
     1359    fHelpTreeWidget->removeColumn(0);
     1360#endif
    13561361    CreateHelpTree();
    13571362    return;
    13581363  }
     1364
     1365#ifdef GEANT4_QT_DEBUG
     1366  printf("G4UIQt::lookForHelpStringCallback\n");
     1367#endif
    13591368
    13601369  // the help tree
     
    13671376  // clear old help tree
    13681377  fHelpTreeWidget->clear();
     1378#if QT_VERSION < 0x040200
     1379  fHelpTreeWidget->removeColumn(1);
     1380  fHelpTreeWidget->removeColumn(0);
     1381#endif
    13691382
    13701383  // look for new items
    13711384
    13721385  int tmp = 0;
     1386#if QT_VERSION < 0x040000
     1387  int multFactor = 1000; // factor special for having double keys in Qt3
     1388  int doubleKeyAdd = 0;  // decay for doubleKeys in Qt3
     1389#endif
     1390
    13731391  QMap<int,QString> commandResultMap;
    13741392  QMap<int,QString> commandChildResultMap;
    13751393
    13761394  for (int a=0;a<treeSize;a++) {
    1377 #ifdef GEANT4_QT_DEBUG
    1378     printf("Command %s\n",(char*)(treeTop->GetTree(a+1)->GetPathName()).data());
    1379 #endif
    13801395    G4UIcommand* command = treeTop->FindPath(treeTop->GetTree(a+1)->GetPathName().data());
     1396#if QT_VERSION > 0x040000
    13811397    tmp = GetCommandList (command).count(helpLine->text(),Qt::CaseInsensitive);
     1398#else
     1399    tmp = GetCommandList (command).contains(helpLine->text(),false);
     1400#endif
    13821401    if (tmp >0) {
     1402#if QT_VERSION > 0x040000
    13831403      commandResultMap.insertMulti(tmp,QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()));
    1384 #ifdef GEANT4_QT_DEBUG
    1385       printf("Command %s match %d times \n",(char*)(treeTop->GetTree(a+1)->GetPathName()).data(),tmp);
     1404#else // tricky thing for Qt3...
     1405      doubleKeyAdd = 0;
     1406      while (commandResultMap.find( tmp*multFactor+doubleKeyAdd) != commandResultMap.end()) {
     1407        doubleKeyAdd ++;
     1408      }
     1409      commandResultMap.insert( tmp*multFactor+doubleKeyAdd,QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()) );
    13861410#endif
    13871411    }
     
    13901414    // insert new childs
    13911415    if (!commandChildResultMap.empty()) {
     1416#if QT_VERSION > 0x040000
    13921417      QMap<int,QString>::const_iterator i = commandChildResultMap.constBegin();
    13931418      while (i != commandChildResultMap.constEnd()) {
    13941419        commandResultMap.insertMulti(i.key(),i.value());
     1420#else // tricky thing for Qt3...
     1421      QMap<int,QString>::const_iterator i = commandChildResultMap.begin();
     1422      while (i != commandChildResultMap.end()) {
     1423        doubleKeyAdd = 0;
     1424        while (commandResultMap.find( i.key()*multFactor+doubleKeyAdd) != commandResultMap.end()) {
     1425          doubleKeyAdd ++;
     1426        }
     1427        commandResultMap.insert(i.key()*multFactor+doubleKeyAdd,i.data());
     1428#endif
    13951429        i++;
    13961430      }
     
    14241458  }
    14251459
     1460#if QT_VERSION > 0x040000
    14261461  QMap<int,QString>::const_iterator i = commandResultMap.constEnd();
     1462#else
     1463  QMap<int,QString>::const_iterator i = commandResultMap.end();
     1464#endif
    14271465  i--;
    14281466  // 10 maximum progress values
     
    14381476  bool end = false;
    14391477  while (!end) {
     1478#if QT_VERSION > 0x040000
    14401479    if (i == commandResultMap.constBegin()) {
     1480#else
     1481    if (i == commandResultMap.begin()) {
     1482#endif
    14411483      end = true;
    14421484    }
     
    14461488#if QT_VERSION < 0x040000
    14471489    newItem = new QListViewItem(fHelpTreeWidget);
    1448     newItem->setText(0,i.value().simplifyWhiteSpace());
    1449     newItem->setText(1,progressStr);
     1490    newItem->setText(0,i.data().simplifyWhiteSpace());
    14501491#else
    14511492    newItem = new QTreeWidgetItem(fHelpTreeWidget);
    14521493    newItem->setText(0,i.value().trimmed());
     1494#endif
    14531495    newItem->setText(1,progressStr);
    1454 #endif
    14551496   
    14561497#if QT_VERSION >= 0x040200
     
    14631504#if QT_VERSION < 0x040000
    14641505  fHelpTreeWidget->setColumnWidthMode (1,QListView::Maximum);
     1506  fHelpTreeWidget->setSorting(1,false);
    14651507#else
    14661508  fHelpTreeWidget->resizeColumnToContents (0);
     1509  fHelpTreeWidget->sortItems(1,Qt::DescendingOrder);
    14671510  //  fHelpTreeWidget->setColumnWidth(1,10);//resizeColumnToContents (1);
    14681511#endif
     
    14801523  if (aCommandTree == NULL) return commandResultMap;
    14811524 
     1525#if QT_VERSION < 0x040000
     1526  int multFactor = 1000; // factor special for having double keys in Qt3
     1527  int doubleKeyAdd = 0;  // decay for doubleKeys in Qt3
     1528#endif
     1529
    14821530  // Get the Sub directories
    14831531  int tmp = 0;
     
    14861534  for (int a=0;a<aCommandTree->GetTreeEntry();a++) {
    14871535    const G4UIcommand* command = aCommandTree->GetGuidance();
     1536#if QT_VERSION > 0x040000
    14881537    tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
     1538#else
     1539    tmp = GetCommandList (command).contains(text,false);
     1540#endif
    14891541    if (tmp >0) {
     1542#if QT_VERSION > 0x040000
    14901543      commandResultMap.insertMulti(tmp,QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()));
     1544#else // tricky thing for Qt3...
     1545      doubleKeyAdd = 0;
     1546      while (commandResultMap.find( tmp*multFactor+doubleKeyAdd) != commandResultMap.end()) {
     1547        doubleKeyAdd ++;
     1548      }
     1549      commandResultMap.insert(tmp*multFactor+doubleKeyAdd,QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()));
     1550#endif
    14911551    }
    14921552    // look for childs
     
    14951555    if (!commandChildResultMap.empty()) {
    14961556      // insert new childs
     1557#if QT_VERSION > 0x040000
    14971558      QMap<int,QString>::const_iterator i = commandChildResultMap.constBegin();
    14981559      while (i != commandChildResultMap.constEnd()) {
    14991560        commandResultMap.insertMulti(i.key(),i.value());
     1561#else // tricky thing for Qt3...
     1562      QMap<int,QString>::const_iterator i = commandChildResultMap.begin();
     1563      while (i != commandChildResultMap.end()) {
     1564        doubleKeyAdd = 0;
     1565        while (commandResultMap.find( i.key()*multFactor+doubleKeyAdd) != commandResultMap.end()) {
     1566          doubleKeyAdd ++;
     1567        }
     1568        commandResultMap.insert(i.key()*multFactor+doubleKeyAdd,i.data());
     1569#endif
    15001570        i++;
    15011571      }
     
    15071577  for (int a=0;a<aCommandTree->GetCommandEntry();a++) {
    15081578    const G4UIcommand* command = aCommandTree->GetCommand(a+1);
     1579#if QT_VERSION > 0x040000
     1580    tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
     1581#else
     1582    tmp = GetCommandList (command).contains(text,false);
     1583#endif
     1584    if (tmp >0) {
     1585#if QT_VERSION > 0x040000
     1586      commandResultMap.insertMulti(tmp,QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()));
     1587#else // tricky thing for Qt3...
     1588      doubleKeyAdd = 0;
     1589      while (commandResultMap.find( tmp*multFactor+doubleKeyAdd) != commandResultMap.end()) {
     1590        doubleKeyAdd ++;
     1591      }
     1592      commandResultMap.insert(tmp*multFactor+doubleKeyAdd,QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()));
     1593#endif
    15091594#ifdef GEANT4_QT_DEBUG
    1510     //    printf("%s \n",GetCommandList (command).toStdString().c_str());
    1511 #endif
    1512     tmp = GetCommandList (command).count(text,Qt::CaseInsensitive);
    1513     if (tmp >0) {
    1514       commandResultMap.insertMulti(tmp,QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()));
    1515 #ifdef GEANT4_QT_DEBUG
    15161595#endif
    15171596    }
Note: See TracChangeset for help on using the changeset viewer.