Ignore:
Timestamp:
Jun 20, 2007, 6:41:53 PM (17 years ago)
Author:
garnier
Message:

r642@mac-90108: laurentgarnier | 2007-06-20 18:45:19 +0200
debut avant les fleches

Location:
trunk/geant4/interfaces/basic
Files:
3 edited

Legend:

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

    r518 r519  
    4040#include <QtGui/qmainwindow.h>
    4141#include <QtGui/qlineedit.h>
     42#include <QtGui/qlistwidget.h>
    4243#include <QtGui/qtextedit.h>
    4344#include <QtGui/qlabel.h>
     
    9798  //   G4String GetCommand(Widget);
    9899
    99   // Some useful getters
    100   inline const QTextEdit * GetCommandHistoryArea() const
    101   { return fCommandHistoryArea; };
    102 
    103100private:
    104101  void SecondaryLoop(G4String); // a VIRER
     
    123120  QTextEdit *fTextArea;
    124121  QTextEdit *fHelpArea;
    125   QTextEdit *fCommandHistoryArea;
     122  QListWidget *fCommandHistoryArea;
    126123  QSignalMapper *signalMapper ;
    127124  QTreeWidget *fHelpTreeWidget;
     
    137134  void helpTreeCallback();
    138135  void showHelpCallback();
     136  void commandHistoryCallback();
    139137};
    140138
  • trunk/geant4/interfaces/basic/src/G4UIQt.cc

    r518 r519  
    109109  connect(clearButton, SIGNAL(clicked()), SLOT(clearButtonCallback()));
    110110
    111   fCommandHistoryArea = new QTextEdit();
     111  fCommandHistoryArea = new QListWidget();
     112  fCommandHistoryArea->setSelectionMode(QAbstractItemView::SingleSelection);
     113  connect(fCommandHistoryArea, SIGNAL(itemSelectionChanged()), SLOT(commandHistoryCallback()));
    112114  fCommandLabel = new QLabel();
    113115
    114   //  fCommandArea = new G4UIQtLineEdit(this); // must surcharge the keyPressEvent function
    115116  fCommandArea = new QLineEdit();
    116117  fCommandArea->installEventFilter(this);
     
    120121  fCommandArea->setFocus(Qt::TabFocusReason);
    121122  fTextArea->setReadOnly(true);
    122   fCommandHistoryArea->setReadOnly(true);
    123 
    124   //  virtual void keyPressEvent(QKeyEvent *e) {
    125   //    if (e->key == Qt::Key_F9) {
    126   // Do something
    127   //}
    128   //}
     123
    129124
    130125  // Set layouts
     
    375370    G4UIcommandTree * treeTop = UI->GetTree();
    376371
    377 
    378   // en test : creation de doc html
    379 
    380 
    381     treeTop->CreateHTML();
    382     printf("************ create file : -%s-**********\n",((char*)treeTop->GetPathName().data()));
    383 
    384 
    385 
    386 
    387 
    388 
    389 
    390   //
    391372    // build widget
    392373    fHelpTreeWidget = new QTreeWidget();
     
    592573{
    593574  printf("G4UIQt::GetHelpChoice SHOULD NEVER GO HERE");
    594 }
     575  return true;
     576}
     577
    595578/***************************************************************************/
    596579void G4UIQt::ExitHelp(
     
    622605    if (event->type() == QEvent::KeyPress) {
    623606      QKeyEvent *e = static_cast<QKeyEvent*>(event);
    624       if (e->key() == (Qt::Key_Down)) {
    625         printf("****************KEY PRESSED DOWN*****\n");
    626       } else if (e->key() == (Qt::Key_PageDown)) {
    627         printf("****************KEY PRESSED PAGE DOWN*****\n");
    628       } else if (e->key() == (Qt::Key_Up)) {
    629         printf("****************KEY PRESSED UP*****\n");
    630       } else if (e->key() == (Qt::Key_PageUp)) {
    631         printf("****************KEY PRESSED PAGE UP*****\n");
    632         //      } else {
    633         //        return QObject::eventFilter(obj, event);
     607      if ((e->key() == (Qt::Key_Down)) ||
     608          (e->key() == (Qt::Key_PageDown)) ||
     609          (e->key() == (Qt::Key_Up)) ||
     610          (e->key() == (Qt::Key_PageUp))) {
     611        int selection = fCommandHistoryArea->currentRow();
     612        printf("-selection : %d\n",selection);
     613        if (fCommandHistoryArea->count()) {
     614          if (selection == -1) {
     615            selection = fCommandHistoryArea->count()-1;
     616          }
     617          printf("selection : %d\n",selection);
     618          if (e->key() == (Qt::Key_Down)) {
     619            printf("****************KEY PRESSED DOWN*****%d <= %d\n",selection,fCommandHistoryArea->count());
     620            if (selection <(fCommandHistoryArea->count()-1))
     621              selection++;
     622          } else if (e->key() == (Qt::Key_PageDown)) {
     623            selection = fCommandHistoryArea->count()-1;
     624            printf("****************KEY PRESSED PAGE DOWN*****\n");
     625          } else if (e->key() == (Qt::Key_Up)) {
     626            if (selection >0)
     627              selection --;
     628            printf("****************KEY PRESSED UP*****\n");
     629          } else if (e->key() == (Qt::Key_PageUp)) {
     630            selection = 0;
     631            printf("****************KEY PRESSED PAGE UP*****\n");
     632          }
     633          fCommandHistoryArea->clearSelection();
     634          fCommandHistoryArea->item(selection)->setSelected(true);
     635        }
    634636      }
    635       //    } else {
    636       //      return QObject::eventFilter(obj, event);
    637637    }
    638     //  } else {
    639   }
     638  }
     639 
    640640  // pass the event on to the parent class
    641641  return QObject::eventFilter(obj, event);
    642   //  return true;
    643642}
    644643
     
    683682  G4String command (fCommandArea->text().toStdString().c_str());
    684683  if (fCommandArea->text().toStdString().c_str() != "") {
    685     fCommandHistoryArea->append(fCommandArea->text());
     684    fCommandHistoryArea->addItem(fCommandArea->text());
    686685
    687686    if (command(0,4) != "help") {
     
    750749
    751750
     751
     752void G4UIQt::commandHistoryCallback(
     753)
     754/***************************************************************************/
     755/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
     756{
     757  //  G4bool GetHelpChoice(G4int&);
     758  QListWidgetItem* item =  NULL;
     759  if (!fCommandHistoryArea)
     760    return ;
     761
     762 
     763  QList<QListWidgetItem *> list =fCommandHistoryArea->selectedItems();
     764  if (list.isEmpty())
     765    return;
     766  item = list.first();
     767  if (!item)
     768    return;
     769  fCommandArea->setText(item->text());
     770
     771}
     772
    752773#endif
  • trunk/geant4/interfaces/basic/src/G4UIQt_moc.cc

    r516 r519  
    22** Meta object code from reading C++ file 'G4UIQt.hh'
    33**
    4 ** Created: Tue Jun 19 15:07:52 2007
     4** Created: Wed Jun 20 18:07:19 2007
    55**      by: The Qt Meta Object Compiler version 59 (Qt 4.2.2)
    66**
     
    2323       0,       // classname
    2424       0,    0, // classinfo
    25        6,   10, // methods
     25       7,   10, // methods
    2626       0,    0, // properties
    2727       0,    0, // enums/sets
     
    3636     103,   31,   31,   31, 0x08,
    3737     122,   31,   31,   31, 0x08,
     38     141,   31,   31,   31, 0x08,
    3839
    3940       0        // eod
     
    4445    "clearButtonCallback()\0commandEnteredCallback()\0"
    4546    "buttonCallback(QString)\0helpTreeCallback()\0"
    46     "showHelpCallback()\0"
     47    "showHelpCallback()\0commandHistoryCallback()\0"
    4748};
    4849
     
    8283        case 4: helpTreeCallback(); break;
    8384        case 5: showHelpCallback(); break;
     85        case 6: commandHistoryCallback(); break;
    8486        }
    85         _id -= 6;
     87        _id -= 7;
    8688    }
    8789    return _id;
Note: See TracChangeset for help on using the changeset viewer.