| 1 | //
|
|---|
| 2 | // ********************************************************************
|
|---|
| 3 | // * License and Disclaimer *
|
|---|
| 4 | // * *
|
|---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of *
|
|---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and *
|
|---|
| 7 | // * conditions of the Geant4 Software License, included in the file *
|
|---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These *
|
|---|
| 9 | // * include a list of copyright holders. *
|
|---|
| 10 | // * *
|
|---|
| 11 | // * Neither the authors of this software system, nor their employing *
|
|---|
| 12 | // * institutes,nor the agencies providing financial support for this *
|
|---|
| 13 | // * work make any representation or warranty, express or implied, *
|
|---|
| 14 | // * regarding this software system or assume any liability for its *
|
|---|
| 15 | // * use. Please see the license in the file LICENSE and URL above *
|
|---|
| 16 | // * for the full disclaimer and the limitation of liability. *
|
|---|
| 17 | // * *
|
|---|
| 18 | // * This code implementation is the result of the scientific and *
|
|---|
| 19 | // * technical work of the GEANT4 collaboration. *
|
|---|
| 20 | // * By using, copying, modifying or distributing the software (or *
|
|---|
| 21 | // * any work based on the software) you agree to acknowledge its *
|
|---|
| 22 | // * use in resulting scientific publications, and indicate your *
|
|---|
| 23 | // * acceptance of all terms of the Geant4 Software license. *
|
|---|
| 24 | // ********************************************************************
|
|---|
| 25 | //
|
|---|
| 26 | //
|
|---|
| 27 | // $Id: G4UIQt.cc,v 1.13 2007/11/30 14:28:50 lgarnier Exp $
|
|---|
| 28 | // GEANT4 tag $Name: $
|
|---|
| 29 | //
|
|---|
| 30 | // L. Garnier
|
|---|
| 31 |
|
|---|
| 32 | //#define DEBUG
|
|---|
| 33 |
|
|---|
| 34 | #ifdef G4UI_BUILD_QT_SESSION
|
|---|
| 35 |
|
|---|
| 36 | #include "G4Types.hh"
|
|---|
| 37 |
|
|---|
| 38 | #include <string.h>
|
|---|
| 39 |
|
|---|
| 40 | #include "G4UIQt.hh"
|
|---|
| 41 | #include "G4UImanager.hh"
|
|---|
| 42 | #include "G4StateManager.hh"
|
|---|
| 43 | #include "G4UIcommandTree.hh"
|
|---|
| 44 | #include "G4UIcommandStatus.hh"
|
|---|
| 45 |
|
|---|
| 46 | #include "G4Qt.hh"
|
|---|
| 47 |
|
|---|
| 48 | #include <qapplication.h>
|
|---|
| 49 | #include <qlineedit.h>
|
|---|
| 50 | #include <qwidget.h>
|
|---|
| 51 | #include <qmenubar.h>
|
|---|
| 52 | #include <qlayout.h>
|
|---|
| 53 | #include <qpushbutton.h>
|
|---|
| 54 | #include <qlabel.h>
|
|---|
| 55 | #include <qsplitter.h>
|
|---|
| 56 | #include <qscrollbar.h>
|
|---|
| 57 | #include <qdialog.h>
|
|---|
| 58 | #include <qevent.h>
|
|---|
| 59 | #include <qtextedit.h>
|
|---|
| 60 | #include <qsignalmapper.h>
|
|---|
| 61 |
|
|---|
| 62 | #include <qmainwindow.h>
|
|---|
| 63 | #if QT_VERSION >= 0x040000
|
|---|
| 64 | #include <qmenu.h>
|
|---|
| 65 | #include <qlistwidget.h>
|
|---|
| 66 | #include <qtreewidget.h>
|
|---|
| 67 | #else
|
|---|
| 68 | #include <qaction.h>
|
|---|
| 69 | #include <qheader.h>
|
|---|
| 70 | #include <qlistview.h>
|
|---|
| 71 | #include <qpopupmenu.h>
|
|---|
| 72 | #endif
|
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 | #include <stdlib.h>
|
|---|
| 77 |
|
|---|
| 78 | // Pourquoi Static et non variables de classe ?
|
|---|
| 79 | static G4bool exitSession = true;
|
|---|
| 80 | static G4bool exitPause = true;
|
|---|
| 81 |
|
|---|
| 82 | /** Build a Qt window with a menubar, output area and promt area<br>
|
|---|
| 83 | <pre>
|
|---|
| 84 | +-----------------------+
|
|---|
| 85 | |exit menu| |
|
|---|
| 86 | | |
|
|---|
| 87 | | +-------------------+ |
|
|---|
| 88 | | | | |
|
|---|
| 89 | | | Output area | |
|
|---|
| 90 | | | | |
|
|---|
| 91 | | +-------------------+ |
|
|---|
| 92 | | | clear | |
|
|---|
| 93 | | +-------------------+ |
|
|---|
| 94 | | | promt history | |
|
|---|
| 95 | | +-------------------+ |
|
|---|
| 96 | | +-------------------+ |
|
|---|
| 97 | | |> promt area | |
|
|---|
| 98 | | +-------------------+ |
|
|---|
| 99 | +-----------------------+
|
|---|
| 100 | </pre>
|
|---|
| 101 | */
|
|---|
| 102 | G4UIQt::G4UIQt (
|
|---|
| 103 | int argc
|
|---|
| 104 | ,char** argv
|
|---|
| 105 | )
|
|---|
| 106 | :fHelpDialog(NULL)
|
|---|
| 107 | {
|
|---|
| 108 | #ifdef GEANT4_QT_DEBUG
|
|---|
| 109 | printf("G4UIQt::Initialise %d %s\n",argc,argv[0]);
|
|---|
| 110 | #endif
|
|---|
| 111 | G4Qt* interactorManager = G4Qt::getInstance (argc,argv,(char*)"Qt");
|
|---|
| 112 | G4UImanager* UI = G4UImanager::GetUIpointer();
|
|---|
| 113 | if(UI!=NULL) UI->SetSession(this);
|
|---|
| 114 |
|
|---|
| 115 | fMainWindow = new QMainWindow();
|
|---|
| 116 |
|
|---|
| 117 | #ifdef GEANT4_QT_DEBUG
|
|---|
| 118 | printf("G4UIQt::Initialise after main window creation\n");
|
|---|
| 119 | #endif
|
|---|
| 120 | #if QT_VERSION < 0x040000
|
|---|
| 121 | fMainWindow->setCaption( tr( "G4UI Session" ));
|
|---|
| 122 | fMainWindow->resize(800,600);
|
|---|
| 123 | fMainWindow->move(50,100);
|
|---|
| 124 | #else
|
|---|
| 125 | fMainWindow->setWindowTitle( tr("G4UI Session") );
|
|---|
| 126 | fMainWindow->resize(800,600);
|
|---|
| 127 | fMainWindow->move(QPoint(50,100));
|
|---|
| 128 | #endif
|
|---|
| 129 |
|
|---|
| 130 | QSplitter *splitter = new QSplitter(Qt::Vertical,fMainWindow);
|
|---|
| 131 |
|
|---|
| 132 | // Set layouts
|
|---|
| 133 |
|
|---|
| 134 | #if QT_VERSION < 0x040000
|
|---|
| 135 |
|
|---|
| 136 | QWidget* topWidget = new QWidget(splitter);
|
|---|
| 137 | QWidget* bottomWidget = new QWidget(splitter);
|
|---|
| 138 |
|
|---|
| 139 | QVBoxLayout *layoutTop = new QVBoxLayout(topWidget);
|
|---|
| 140 | QVBoxLayout *layoutBottom = new QVBoxLayout(bottomWidget);
|
|---|
| 141 | #else
|
|---|
| 142 | QWidget* topWidget = new QWidget();
|
|---|
| 143 | QWidget* bottomWidget = new QWidget();
|
|---|
| 144 |
|
|---|
| 145 | QVBoxLayout *layoutTop = new QVBoxLayout;
|
|---|
| 146 | QVBoxLayout *layoutBottom = new QVBoxLayout;
|
|---|
| 147 | #endif
|
|---|
| 148 |
|
|---|
| 149 | // fill them
|
|---|
| 150 |
|
|---|
| 151 | fTextArea = new QTextEdit(topWidget);
|
|---|
| 152 | #ifdef GEANT4_QT_DEBUG
|
|---|
| 153 | printf("G4UIQt:: end\n");
|
|---|
| 154 | #endif
|
|---|
| 155 | #ifdef GEANT4_QT_DEBUG
|
|---|
| 156 | printf("G4UIQt::PushButton 1\n");
|
|---|
| 157 | #endif
|
|---|
| 158 | QPushButton *clearButton = new QPushButton("clear",topWidget);
|
|---|
| 159 | #ifdef GEANT4_QT_DEBUG
|
|---|
| 160 | printf("G4UIQt::end1\n");
|
|---|
| 161 | #endif
|
|---|
| 162 | connect(clearButton, SIGNAL(clicked()), SLOT(ClearButtonCallback()));
|
|---|
| 163 |
|
|---|
| 164 | #if QT_VERSION < 0x040000
|
|---|
| 165 | fCommandHistoryArea = new QListView(bottomWidget);
|
|---|
| 166 |
|
|---|
| 167 | fCommandHistoryArea->setSorting (-1, FALSE);
|
|---|
| 168 | fCommandHistoryArea->setSelectionMode(QListView::Single);
|
|---|
| 169 | fCommandHistoryArea->addColumn("");
|
|---|
| 170 | fCommandHistoryArea->header()->hide();
|
|---|
| 171 | connect(fCommandHistoryArea, SIGNAL(selectionChanged()), SLOT(CommandHistoryCallback()));
|
|---|
| 172 | #else
|
|---|
| 173 | fCommandHistoryArea = new QListWidget();
|
|---|
| 174 | fCommandHistoryArea->setSelectionMode(QAbstractItemView::SingleSelection);
|
|---|
| 175 | connect(fCommandHistoryArea, SIGNAL(itemSelectionChanged()), SLOT(CommandHistoryCallback()));
|
|---|
| 176 | #endif
|
|---|
| 177 | fCommandHistoryArea->installEventFilter(this);
|
|---|
| 178 | fCommandLabel = new QLabel("",bottomWidget);
|
|---|
| 179 |
|
|---|
| 180 | fCommandArea = new QLineEdit(bottomWidget);
|
|---|
| 181 | fCommandArea->installEventFilter(this);
|
|---|
| 182 | #if QT_VERSION < 0x040000
|
|---|
| 183 | fCommandArea->setActiveWindow();
|
|---|
| 184 | #else
|
|---|
| 185 | fCommandArea->activateWindow();
|
|---|
| 186 | #endif
|
|---|
| 187 | connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback()));
|
|---|
| 188 | #if QT_VERSION < 0x040000
|
|---|
| 189 | fCommandArea->setFocusPolicy ( QWidget::StrongFocus );
|
|---|
| 190 | fCommandArea->setFocus();
|
|---|
| 191 | #else
|
|---|
| 192 | fCommandArea->setFocusPolicy ( Qt::StrongFocus );
|
|---|
| 193 | fCommandArea->setFocus(Qt::TabFocusReason);
|
|---|
| 194 | #endif
|
|---|
| 195 | fTextArea->setReadOnly(true);
|
|---|
| 196 |
|
|---|
| 197 |
|
|---|
| 198 | #ifdef GEANT4_QT_DEBUG
|
|---|
| 199 | printf("G4UIQt:: 2\n");
|
|---|
| 200 | #endif
|
|---|
| 201 |
|
|---|
| 202 |
|
|---|
| 203 |
|
|---|
| 204 | layoutTop->addWidget(fTextArea);
|
|---|
| 205 | layoutTop->addWidget(clearButton);
|
|---|
| 206 |
|
|---|
| 207 | #if QT_VERSION >= 0x040000
|
|---|
| 208 | topWidget->setLayout(layoutTop);
|
|---|
| 209 | #endif
|
|---|
| 210 |
|
|---|
| 211 | layoutBottom->addWidget(fCommandHistoryArea);
|
|---|
| 212 | layoutBottom->addWidget(fCommandLabel);
|
|---|
| 213 | layoutBottom->addWidget(fCommandArea);
|
|---|
| 214 | #if QT_VERSION >= 0x040000
|
|---|
| 215 |
|
|---|
| 216 | bottomWidget->setLayout(layoutBottom);
|
|---|
| 217 | splitter->addWidget(topWidget);
|
|---|
| 218 | splitter->addWidget(bottomWidget);
|
|---|
| 219 | #endif
|
|---|
| 220 |
|
|---|
| 221 |
|
|---|
| 222 | fMainWindow->setCentralWidget(splitter);
|
|---|
| 223 |
|
|---|
| 224 | #if QT_VERSION < 0x040000
|
|---|
| 225 |
|
|---|
| 226 | // Add a quit subMenu
|
|---|
| 227 | QPopupMenu *fileMenu = new QPopupMenu( fMainWindow);
|
|---|
| 228 | fileMenu->insertItem( "&Quitter", this, SLOT(ExitSession()), CTRL+Key_Q );
|
|---|
| 229 | fMainWindow->menuBar()->insertItem( QString("&File"), fileMenu );
|
|---|
| 230 |
|
|---|
| 231 | // Add a Help menu
|
|---|
| 232 | QPopupMenu *helpMenu = new QPopupMenu( fMainWindow );
|
|---|
| 233 | helpMenu->insertItem( "&Show Help", this, SLOT(ShowHelpCallback()), CTRL+Key_H );
|
|---|
| 234 | fMainWindow->menuBar()->insertItem( QString("&Help"), helpMenu );
|
|---|
| 235 |
|
|---|
| 236 |
|
|---|
| 237 | #else
|
|---|
| 238 |
|
|---|
| 239 | // Add a quit subMenu
|
|---|
| 240 | QMenu *fileMenu = fMainWindow->menuBar()->addMenu("File");
|
|---|
| 241 | fileMenu->addAction("Quitter", this, SLOT(ExitSession()));
|
|---|
| 242 |
|
|---|
| 243 | // Add a Help menu
|
|---|
| 244 | QMenu *helpMenu = fMainWindow->menuBar()->addMenu("Help");
|
|---|
| 245 | helpMenu->addAction("Show Help", this, SLOT(ShowHelpCallback()));
|
|---|
| 246 | #endif
|
|---|
| 247 |
|
|---|
| 248 | // Set the splitter size. The fTextArea sould be 2/3 on the fMainWindow
|
|---|
| 249 | #if QT_VERSION < 0x040000
|
|---|
| 250 | QValueList<int> vals = splitter->sizes();
|
|---|
| 251 | #else
|
|---|
| 252 | QList<int> vals = splitter->sizes();
|
|---|
| 253 | #endif
|
|---|
| 254 | if(vals.size()==2) {
|
|---|
| 255 | vals[0] = (splitter->orientation()==Qt::Vertical ? splitter->height() : splitter->width())*3/4;
|
|---|
| 256 | vals[1] = (splitter->orientation()==Qt::Vertical ? splitter->height() : splitter->width())*1/4;
|
|---|
| 257 | splitter->setSizes(vals);
|
|---|
| 258 | }
|
|---|
| 259 |
|
|---|
| 260 | if(UI!=NULL) UI->SetCoutDestination(this); // TO KEEP
|
|---|
| 261 | }
|
|---|
| 262 |
|
|---|
| 263 |
|
|---|
| 264 |
|
|---|
| 265 | G4UIQt::~G4UIQt(
|
|---|
| 266 | )
|
|---|
| 267 | {
|
|---|
| 268 | G4UImanager* UI = G4UImanager::GetUIpointer(); // TO KEEP
|
|---|
| 269 | if(UI!=NULL) { // TO KEEP
|
|---|
| 270 | UI->SetSession(NULL); // TO KEEP
|
|---|
| 271 | UI->SetCoutDestination(NULL); // TO KEEP
|
|---|
| 272 | }
|
|---|
| 273 |
|
|---|
| 274 | if (fMainWindow!=NULL)
|
|---|
| 275 | delete fMainWindow;
|
|---|
| 276 | }
|
|---|
| 277 |
|
|---|
| 278 |
|
|---|
| 279 |
|
|---|
| 280 | /** Start the Qt main loop
|
|---|
| 281 | */
|
|---|
| 282 | G4UIsession* G4UIQt::SessionStart (
|
|---|
| 283 | )
|
|---|
| 284 | {
|
|---|
| 285 |
|
|---|
| 286 | G4Qt* interactorManager = G4Qt::getInstance ();
|
|---|
| 287 |
|
|---|
| 288 | #if QT_VERSION >= 0x040000
|
|---|
| 289 | #if QT_VERSION >= 0x040200
|
|---|
| 290 | fMainWindow->setVisible(true);
|
|---|
| 291 | #else
|
|---|
| 292 | fMainWindow->show();
|
|---|
| 293 | #endif
|
|---|
| 294 | #else
|
|---|
| 295 | fMainWindow->show();
|
|---|
| 296 | #endif
|
|---|
| 297 | Prompt("session");
|
|---|
| 298 | exitSession = false;
|
|---|
| 299 |
|
|---|
| 300 |
|
|---|
| 301 | #ifdef GEANT4_QT_DEBUG
|
|---|
| 302 | printf("disable secondary loop\n");
|
|---|
| 303 | #endif
|
|---|
| 304 | interactorManager->DisableSecondaryLoop (); // TO KEEP
|
|---|
| 305 | if ((QApplication*)interactorManager->GetMainInteractor())
|
|---|
| 306 | ((QApplication*)interactorManager->GetMainInteractor())->exec();
|
|---|
| 307 |
|
|---|
| 308 | // on ne passe pas le dessous ? FIXME ????
|
|---|
| 309 | // je ne pense pas 13/06
|
|---|
| 310 |
|
|---|
| 311 | // void* event; // TO KEEP
|
|---|
| 312 | // while((event = interactorManager->GetEvent())!=NULL) { // TO KEEP
|
|---|
| 313 | // interactorManager->DispatchEvent(event); // TO KEEP
|
|---|
| 314 | // if(exitSession==true) break; // TO KEEP
|
|---|
| 315 | // } // TO KEEP
|
|---|
| 316 |
|
|---|
| 317 | interactorManager->EnableSecondaryLoop ();
|
|---|
| 318 | #ifdef GEANT4_QT_DEBUG
|
|---|
| 319 | printf("enable secondary loop\n");
|
|---|
| 320 | #endif
|
|---|
| 321 | return this;
|
|---|
| 322 | }
|
|---|
| 323 |
|
|---|
| 324 |
|
|---|
| 325 | /** Display the prompt in the prompt area
|
|---|
| 326 | @param aPrompt : string to display as the promt label
|
|---|
| 327 | //FIXME : probablement inutile puisque le seul a afficher qq chose d'autre
|
|---|
| 328 | que "session" est SecondaryLoop()
|
|---|
| 329 | */
|
|---|
| 330 | void G4UIQt::Prompt (
|
|---|
| 331 | G4String aPrompt
|
|---|
| 332 | )
|
|---|
| 333 | {
|
|---|
| 334 | if (!aPrompt) return;
|
|---|
| 335 |
|
|---|
| 336 | fCommandLabel->setText((char*)aPrompt.data());
|
|---|
| 337 | }
|
|---|
| 338 |
|
|---|
| 339 |
|
|---|
| 340 | void G4UIQt::SessionTerminate (
|
|---|
| 341 | )
|
|---|
| 342 | {
|
|---|
| 343 | G4Qt* interactorManager = G4Qt::getInstance ();
|
|---|
| 344 | fMainWindow->close();
|
|---|
| 345 | ((QApplication*)interactorManager->GetMainInteractor())->exit();
|
|---|
| 346 | }
|
|---|
| 347 |
|
|---|
| 348 |
|
|---|
| 349 |
|
|---|
| 350 | /**
|
|---|
| 351 | Called by intercoms/src/G4UImanager.cc<br>
|
|---|
| 352 | Called by visualization/management/src/G4VisCommands.cc with "EndOfEvent" argument<br>
|
|---|
| 353 | It have to pause the session command terminal.<br>
|
|---|
| 354 | Call SecondaryLoop to wait for exit event<br>
|
|---|
| 355 | @param aState
|
|---|
| 356 | @see : G4VisCommandReviewKeptEvents::SetNewValue
|
|---|
| 357 | */
|
|---|
| 358 | void G4UIQt::PauseSessionStart (
|
|---|
| 359 | G4String aState
|
|---|
| 360 | )
|
|---|
| 361 | {
|
|---|
| 362 | if (!aState) return;
|
|---|
| 363 |
|
|---|
| 364 | #ifdef GEANT4_QT_DEBUG
|
|---|
| 365 | printf("G4UIQt::PauseSessionStart\n");
|
|---|
| 366 | #endif
|
|---|
| 367 | if(aState=="G4_pause> ") { // TO KEEP
|
|---|
| 368 | SecondaryLoop ("Pause, type continue to exit this state"); // TO KEEP
|
|---|
| 369 | } // TO KEEP
|
|---|
| 370 |
|
|---|
| 371 | if(aState=="EndOfEvent") { // TO KEEP
|
|---|
| 372 | // Picking with feed back in event data Done here !!!
|
|---|
| 373 | SecondaryLoop ("End of event, type continue to exit this state"); // TO KEEP
|
|---|
| 374 | } // TO KEEP
|
|---|
| 375 | }
|
|---|
| 376 |
|
|---|
| 377 |
|
|---|
| 378 |
|
|---|
| 379 | /**
|
|---|
| 380 | Begin the secondary loop
|
|---|
| 381 | @param a_prompt : label to display as the prompt label
|
|---|
| 382 | */
|
|---|
| 383 | void G4UIQt::SecondaryLoop (
|
|---|
| 384 | G4String aPrompt
|
|---|
| 385 | )
|
|---|
| 386 | {
|
|---|
| 387 | if (!aPrompt) return;
|
|---|
| 388 |
|
|---|
| 389 | #ifdef GEANT4_QT_DEBUG
|
|---|
| 390 | printf("G4UIQt::SecondaryLoop\n");
|
|---|
| 391 | #endif
|
|---|
| 392 | G4Qt* interactorManager = G4Qt::getInstance (); // TO KEEP ?
|
|---|
| 393 | Prompt(aPrompt); // TO KEEP
|
|---|
| 394 | exitPause = false; // TO KEEP
|
|---|
| 395 | void* event; // TO KEEP
|
|---|
| 396 | while((event = interactorManager->GetEvent())!=NULL) { // TO KEEP
|
|---|
| 397 | interactorManager->DispatchEvent(event); // TO KEEP
|
|---|
| 398 | if(exitPause==true) break; // TO KEEP
|
|---|
| 399 | } // TO KEEP
|
|---|
| 400 | Prompt("session"); // TO KEEP
|
|---|
| 401 | }
|
|---|
| 402 |
|
|---|
| 403 |
|
|---|
| 404 |
|
|---|
| 405 | /**
|
|---|
| 406 | Receive a cout from Geant4. We have to display it in the cout zone
|
|---|
| 407 | @param aString : label to add in the display area
|
|---|
| 408 | @return 0
|
|---|
| 409 | */
|
|---|
| 410 | G4int G4UIQt::ReceiveG4cout (
|
|---|
| 411 | G4String aString
|
|---|
| 412 | )
|
|---|
| 413 | {
|
|---|
| 414 | if (!aString) return 0;
|
|---|
| 415 | G4Qt* interactorManager = G4Qt::getInstance ();
|
|---|
| 416 | if (!interactorManager) return 0;
|
|---|
| 417 |
|
|---|
| 418 | #if QT_VERSION < 0x040000
|
|---|
| 419 | fTextArea->append(QString((char*)aString.data()).simplifyWhiteSpace());
|
|---|
| 420 | fTextArea->verticalScrollBar()->setValue(fTextArea->verticalScrollBar()->maxValue());
|
|---|
| 421 | #else
|
|---|
| 422 | fTextArea->append(QString((char*)aString.data()).trimmed());
|
|---|
| 423 | fTextArea->verticalScrollBar()->setSliderPosition(fTextArea->verticalScrollBar()->maximum());
|
|---|
| 424 | #endif
|
|---|
| 425 | interactorManager->FlushAndWaitExecution();
|
|---|
| 426 | return 0;
|
|---|
| 427 | }
|
|---|
| 428 |
|
|---|
| 429 |
|
|---|
| 430 | /**
|
|---|
| 431 | Receive a cerr from Geant4. We have to display it in the cout zone
|
|---|
| 432 | @param aString : label to add in the display area
|
|---|
| 433 | @return 0
|
|---|
| 434 | */
|
|---|
| 435 | G4int G4UIQt::ReceiveG4cerr (
|
|---|
| 436 | G4String aString
|
|---|
| 437 | )
|
|---|
| 438 | {
|
|---|
| 439 | if (!aString) return 0;
|
|---|
| 440 | G4Qt* interactorManager = G4Qt::getInstance ();
|
|---|
| 441 | if (!interactorManager) return 0;
|
|---|
| 442 |
|
|---|
| 443 | #if QT_VERSION < 0x040000
|
|---|
| 444 | QColor previousColor = fTextArea->color();
|
|---|
| 445 | fTextArea->setColor(Qt::red);
|
|---|
| 446 | fTextArea->append(QString((char*)aString.data()).simplifyWhiteSpace());
|
|---|
| 447 | fTextArea->setColor(previousColor);
|
|---|
| 448 | fTextArea->verticalScrollBar()->setValue(fTextArea->verticalScrollBar()->maxValue());
|
|---|
| 449 | #else
|
|---|
| 450 | QColor previousColor = fTextArea->textColor();
|
|---|
| 451 | fTextArea->setTextColor(Qt::red);
|
|---|
| 452 | fTextArea->append(QString((char*)aString.data()).trimmed());
|
|---|
| 453 | fTextArea->setTextColor(previousColor);
|
|---|
| 454 | fTextArea->verticalScrollBar()->setSliderPosition(fTextArea->verticalScrollBar()->maximum());
|
|---|
| 455 | #endif
|
|---|
| 456 | interactorManager->FlushAndWaitExecution();
|
|---|
| 457 | return 0;
|
|---|
| 458 | }
|
|---|
| 459 |
|
|---|
| 460 |
|
|---|
| 461 |
|
|---|
| 462 | /**
|
|---|
| 463 | Add a new menu to the menu bar
|
|---|
| 464 | @param aName name of menu
|
|---|
| 465 | @param aLabel label to display
|
|---|
| 466 | */
|
|---|
| 467 | void G4UIQt::AddMenu (
|
|---|
| 468 | const char* aName
|
|---|
| 469 | ,const char* aLabel
|
|---|
| 470 | )
|
|---|
| 471 | {
|
|---|
| 472 | if (aName == NULL) return;
|
|---|
| 473 | if (aLabel == NULL) return;
|
|---|
| 474 |
|
|---|
| 475 | #if QT_VERSION < 0x040000
|
|---|
| 476 | QPopupMenu *fileMenu = new QPopupMenu( fMainWindow);
|
|---|
| 477 | fMainWindow->menuBar()->insertItem( aLabel, fileMenu );
|
|---|
| 478 | #else
|
|---|
| 479 | QMenu *fileMenu = new QMenu(aLabel);
|
|---|
| 480 | fMainWindow->menuBar()->insertMenu(fMainWindow->menuBar()->actions().last(),fileMenu);
|
|---|
| 481 | #endif
|
|---|
| 482 |
|
|---|
| 483 | AddInteractor (aName,(G4Interactor)fileMenu);
|
|---|
| 484 | }
|
|---|
| 485 |
|
|---|
| 486 |
|
|---|
| 487 | /**
|
|---|
| 488 | Add a new button to a menu
|
|---|
| 489 | @param aMenu : parent menu
|
|---|
| 490 | @param aLabel : label to display
|
|---|
| 491 | @param aCommand : command to execute as a callback
|
|---|
| 492 | */
|
|---|
| 493 | void G4UIQt::AddButton (
|
|---|
| 494 | const char* aMenu
|
|---|
| 495 | ,const char* aLabel
|
|---|
| 496 | ,const char* aCommand
|
|---|
| 497 | )
|
|---|
| 498 | {
|
|---|
| 499 | if(aMenu==NULL) return; // TO KEEP
|
|---|
| 500 | if(aLabel==NULL) return; // TO KEEP
|
|---|
| 501 | if(aCommand==NULL) return; // TO KEEP
|
|---|
| 502 |
|
|---|
| 503 | #if QT_VERSION < 0x040000
|
|---|
| 504 | QPopupMenu *parent = (QPopupMenu*)GetInteractor(aMenu);
|
|---|
| 505 | #else
|
|---|
| 506 | QMenu *parent = (QMenu*)GetInteractor(aMenu);
|
|---|
| 507 | #endif
|
|---|
| 508 |
|
|---|
| 509 | if(parent==NULL) return;
|
|---|
| 510 |
|
|---|
| 511 | QSignalMapper *signalMapper = new QSignalMapper(this);
|
|---|
| 512 | #if QT_VERSION < 0x030200
|
|---|
| 513 | QAction *action = new QAction(QString(aLabel),QString(aLabel),QKeySequence::QKeySequence (),signalMapper, SLOT(map()));
|
|---|
| 514 | action->addTo(parent);
|
|---|
| 515 | connect(action,SIGNAL(activated()),signalMapper,SLOT(map()));
|
|---|
| 516 |
|
|---|
| 517 | #elif QT_VERSION < 0x040000
|
|---|
| 518 | QAction *action = new QAction(QString(aLabel),QKeySequence::QKeySequence (),signalMapper, SLOT(map()));
|
|---|
| 519 | action->addTo(parent);
|
|---|
| 520 | connect(action,SIGNAL(activated()),signalMapper,SLOT(map()));
|
|---|
| 521 |
|
|---|
| 522 | #else
|
|---|
| 523 | QAction *action = parent->addAction(aLabel, signalMapper, SLOT(map()));
|
|---|
| 524 |
|
|---|
| 525 | #endif
|
|---|
| 526 | connect(signalMapper, SIGNAL(mapped(const QString &)),this, SLOT(ButtonCallback(const QString&)));
|
|---|
| 527 | signalMapper->setMapping(action, QString(aCommand));
|
|---|
| 528 | }
|
|---|
| 529 |
|
|---|
| 530 |
|
|---|
| 531 |
|
|---|
| 532 |
|
|---|
| 533 | /**
|
|---|
| 534 | Open the help dialog in a separate window.<br>
|
|---|
| 535 | This will be display as a tree widget.<br>
|
|---|
| 536 | Implementation of <b>void G4VBasicShell::TerminalHelp(G4String newCommand)</b>
|
|---|
| 537 |
|
|---|
| 538 | @param newCommand : open the tree widget item on this command if is set
|
|---|
| 539 | */
|
|---|
| 540 | void G4UIQt::TerminalHelp(
|
|---|
| 541 | G4String newCommand
|
|---|
| 542 | )
|
|---|
| 543 | {
|
|---|
| 544 | // Create the help dialog
|
|---|
| 545 | if (!fHelpDialog) {
|
|---|
| 546 | #if QT_VERSION < 0x040000
|
|---|
| 547 | fHelpDialog = new QDialog(0,0,FALSE,Qt::WStyle_Title | Qt::WStyle_SysMenu | Qt::WStyle_MinMax );
|
|---|
| 548 | QVBoxLayout *vLayout = new QVBoxLayout(fHelpDialog);
|
|---|
| 549 | QSplitter *splitter = new QSplitter(Qt::Horizontal,fHelpDialog);
|
|---|
| 550 | #else
|
|---|
| 551 | QVBoxLayout *vLayout = new QVBoxLayout();
|
|---|
| 552 | fHelpDialog = new QDialog(0,Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint);
|
|---|
| 553 | QSplitter *splitter = new QSplitter(Qt::Horizontal);
|
|---|
| 554 | #endif
|
|---|
| 555 | QPushButton *exitButton = new QPushButton("Exit",fHelpDialog);
|
|---|
| 556 | connect(exitButton, SIGNAL(clicked()), fHelpDialog,SLOT(close()));
|
|---|
| 557 |
|
|---|
| 558 | // the help tree
|
|---|
| 559 | G4UImanager* UI = G4UImanager::GetUIpointer();
|
|---|
| 560 | if(UI==NULL) return;
|
|---|
| 561 | G4UIcommandTree * treeTop = UI->GetTree();
|
|---|
| 562 |
|
|---|
| 563 | // build widget
|
|---|
| 564 | #if QT_VERSION < 0x040000
|
|---|
| 565 | fHelpTreeWidget = new QListView(splitter);
|
|---|
| 566 | fHelpTreeWidget->setSelectionMode(QListView::Single);
|
|---|
| 567 | fHelpTreeWidget->setRootIsDecorated(true);
|
|---|
| 568 | fHelpTreeWidget->addColumn("Command");
|
|---|
| 569 | fHelpTreeWidget->addColumn("Description",0);
|
|---|
| 570 | // fHelpTreeWidget->setColumnWidth (1,0);
|
|---|
| 571 | fHelpTreeWidget->header()->setResizeEnabled(FALSE,1);
|
|---|
| 572 | // QList<QListViewItem *> items;
|
|---|
| 573 | #else
|
|---|
| 574 | fHelpTreeWidget = new QTreeWidget();
|
|---|
| 575 | fHelpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
|
|---|
| 576 | fHelpTreeWidget->setColumnCount(2);
|
|---|
| 577 | fHelpTreeWidget->setColumnHidden(1,true);
|
|---|
| 578 | QStringList labels;
|
|---|
| 579 | labels << QString("Command") << QString("Description");
|
|---|
| 580 | fHelpTreeWidget->setHeaderLabels(labels);
|
|---|
| 581 | // QList<QTreeWidgetItem *> items;
|
|---|
| 582 | #endif
|
|---|
| 583 |
|
|---|
| 584 | #if QT_VERSION < 0x040000
|
|---|
| 585 | fHelpArea = new QTextEdit(splitter);
|
|---|
| 586 | #else
|
|---|
| 587 | fHelpArea = new QTextEdit();
|
|---|
| 588 | #endif
|
|---|
| 589 | fHelpArea->setReadOnly(true);
|
|---|
| 590 |
|
|---|
| 591 | G4int treeSize = treeTop->GetTreeEntry();
|
|---|
| 592 | #if QT_VERSION < 0x040000
|
|---|
| 593 | QListViewItem * newItem;
|
|---|
| 594 | #else
|
|---|
| 595 | QTreeWidgetItem * newItem;
|
|---|
| 596 | #endif
|
|---|
| 597 | for (int a=0;a<treeSize;a++) {
|
|---|
| 598 | // Creating new item
|
|---|
| 599 |
|
|---|
| 600 | #if QT_VERSION < 0x040000
|
|---|
| 601 | newItem = new QListViewItem(fHelpTreeWidget);
|
|---|
| 602 | newItem->setText(0,QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()).simplifyWhiteSpace());
|
|---|
| 603 | newItem->setText(1,QString((char*)(treeTop->GetTree(a+1)->GetTitle()).data()).simplifyWhiteSpace());
|
|---|
| 604 | #else
|
|---|
| 605 | //FIXME : Qt 4.2
|
|---|
| 606 | // QStringList stringList;
|
|---|
| 607 | // stringList << QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()).trimmed() ;
|
|---|
| 608 | // stringList << QString((char*)(treeTop->GetTree(a+1)->GetTitle()).data()).trimmed() ;
|
|---|
| 609 | // newItem = new QTreeWidgetItem(stringList);
|
|---|
| 610 | // FIXME : Qt 4.0
|
|---|
| 611 | newItem = new QTreeWidgetItem(fHelpTreeWidget);
|
|---|
| 612 | newItem->setText(0,QString((char*)(treeTop->GetTree(a+1)->GetPathName()).data()).trimmed());
|
|---|
| 613 | newItem->setText(1,QString((char*)(treeTop->GetTree(a+1)->GetTitle()).data()).trimmed());
|
|---|
| 614 | #endif
|
|---|
| 615 |
|
|---|
| 616 |
|
|---|
| 617 | // look for childs
|
|---|
| 618 | CreateChildTree(newItem,treeTop->GetTree(a+1));
|
|---|
| 619 | // items.append(newItem);
|
|---|
| 620 | }
|
|---|
| 621 |
|
|---|
| 622 | #if QT_VERSION < 0x040000
|
|---|
| 623 | connect(fHelpTreeWidget, SIGNAL(selectionChanged ()),this, SLOT(HelpTreeClicCallback()));
|
|---|
| 624 | connect(fHelpTreeWidget, SIGNAL(doubleClicked (QListViewItem*)),this, SLOT(HelpTreeDoubleClicCallback(QListViewItem*)));
|
|---|
| 625 | #else
|
|---|
| 626 | connect(fHelpTreeWidget, SIGNAL(itemSelectionChanged ()),this, SLOT(HelpTreeClicCallback()));
|
|---|
| 627 | connect(fHelpTreeWidget, SIGNAL(itemDoubleClicked (QTreeWidgetItem*,int)),this, SLOT(HelpTreeDoubleClicCallback(QTreeWidgetItem*)));
|
|---|
| 628 | #endif
|
|---|
| 629 |
|
|---|
| 630 | // Set layouts
|
|---|
| 631 |
|
|---|
| 632 | #if QT_VERSION >= 0x040000
|
|---|
| 633 | splitter->addWidget(fHelpTreeWidget);
|
|---|
| 634 | splitter->addWidget(fHelpArea);
|
|---|
| 635 | #endif
|
|---|
| 636 |
|
|---|
| 637 |
|
|---|
| 638 | #if QT_VERSION >= 0x040000
|
|---|
| 639 | vLayout->addWidget(splitter);
|
|---|
| 640 | vLayout->addWidget(exitButton);
|
|---|
| 641 | #else
|
|---|
| 642 | vLayout->add(splitter);
|
|---|
| 643 | vLayout->addWidget(exitButton);
|
|---|
| 644 | #endif
|
|---|
| 645 |
|
|---|
| 646 | // set the splitter size
|
|---|
| 647 | #if QT_VERSION >= 0x040000
|
|---|
| 648 | QList<int> list;
|
|---|
| 649 | #else
|
|---|
| 650 | QValueList<int> list;
|
|---|
| 651 | #endif
|
|---|
| 652 | list.append( 400 );
|
|---|
| 653 | list.append( 400 );
|
|---|
| 654 | splitter->setSizes(list);
|
|---|
| 655 |
|
|---|
| 656 | #if QT_VERSION >= 0x040000
|
|---|
| 657 | fHelpDialog->setLayout(vLayout);
|
|---|
| 658 | #endif
|
|---|
| 659 |
|
|---|
| 660 | }
|
|---|
| 661 |
|
|---|
| 662 | // Look for the choosen command "newCommand"
|
|---|
| 663 | size_t i = newCommand.index(" ");
|
|---|
| 664 | G4String targetCom="";
|
|---|
| 665 | if( i != std::string::npos )
|
|---|
| 666 | {
|
|---|
| 667 | G4String newValue = newCommand(i+1,newCommand.length()-(i+1));
|
|---|
| 668 | newValue.strip(G4String::both);
|
|---|
| 669 | targetCom = ModifyToFullPathCommand( newValue );
|
|---|
| 670 | }
|
|---|
| 671 | if (targetCom != "") {
|
|---|
| 672 | #if QT_VERSION < 0x040000
|
|---|
| 673 | QListViewItem* findItem = NULL;
|
|---|
| 674 | QListViewItem* tmpItem = fHelpTreeWidget->firstChild();
|
|---|
| 675 | while (tmpItem != 0) {
|
|---|
| 676 | if (!findItem) {
|
|---|
| 677 | findItem = FindTreeItem(tmpItem,QString((char*)targetCom.data()));
|
|---|
| 678 | }
|
|---|
| 679 | tmpItem = tmpItem->nextSibling();
|
|---|
| 680 | }
|
|---|
| 681 | #else
|
|---|
| 682 | QTreeWidgetItem* findItem = NULL;
|
|---|
| 683 | for (int a=0;a<fHelpTreeWidget->topLevelItemCount();a++) {
|
|---|
| 684 | if (!findItem) {
|
|---|
| 685 | findItem = FindTreeItem(fHelpTreeWidget->topLevelItem(a),QString((char*)targetCom.data()));
|
|---|
| 686 | }
|
|---|
| 687 | }
|
|---|
| 688 | #endif
|
|---|
| 689 |
|
|---|
| 690 | if (findItem) {
|
|---|
| 691 |
|
|---|
| 692 | //collapsed open item
|
|---|
| 693 | #if QT_VERSION < 0x040000
|
|---|
| 694 |
|
|---|
| 695 | // FIXME : Has to be checked
|
|---|
| 696 | QListViewItem* tmpItem = fHelpTreeWidget->firstChild();
|
|---|
| 697 | QList<QListViewItem> openItems;
|
|---|
| 698 | while ((tmpItem != 0) || (!openItems.isEmpty())) {
|
|---|
| 699 | if (tmpItem->isOpen() ) {
|
|---|
| 700 | tmpItem->setOpen(false);
|
|---|
| 701 | openItems.append(tmpItem);
|
|---|
| 702 | tmpItem = tmpItem->firstChild();
|
|---|
| 703 | } else {
|
|---|
| 704 | tmpItem = tmpItem->nextSibling();
|
|---|
| 705 | }
|
|---|
| 706 | if (tmpItem == 0) {
|
|---|
| 707 | tmpItem = openItems.take(openItems.count()-1);
|
|---|
| 708 | }
|
|---|
| 709 | }
|
|---|
| 710 | #else
|
|---|
| 711 | QList<QTreeWidgetItem *> selected;
|
|---|
| 712 |
|
|---|
| 713 | selected = fHelpTreeWidget->selectedItems();
|
|---|
| 714 | if ( selected.count() != 0 ) {
|
|---|
| 715 | QTreeWidgetItem * tmp =selected.at( 0 );
|
|---|
| 716 | while ( tmp) {
|
|---|
| 717 | #if QT_VERSION < 0x040202
|
|---|
| 718 | fHelpTreeWidget->setItemExpanded(tmp,false);
|
|---|
| 719 | #else
|
|---|
| 720 | tmp->setExpanded(false);
|
|---|
| 721 | #endif
|
|---|
| 722 | tmp = tmp->parent();
|
|---|
| 723 | }
|
|---|
| 724 | }
|
|---|
| 725 | #endif
|
|---|
| 726 |
|
|---|
| 727 | // clear old selection
|
|---|
| 728 | fHelpTreeWidget->clearSelection();
|
|---|
| 729 |
|
|---|
| 730 | // set new selection
|
|---|
| 731 | #if QT_VERSION >= 0x040000
|
|---|
| 732 | #if QT_VERSION < 0x040202
|
|---|
| 733 | fHelpTreeWidget->setItemSelected(findItem,true);
|
|---|
| 734 | #else
|
|---|
| 735 | findItem->setSelected(true);
|
|---|
| 736 | #endif
|
|---|
| 737 | #else
|
|---|
| 738 | findItem->setSelected(true);
|
|---|
| 739 | #endif
|
|---|
| 740 |
|
|---|
| 741 | // expand parent item
|
|---|
| 742 | while ( findItem) {
|
|---|
| 743 | #if QT_VERSION < 0x040000
|
|---|
| 744 | findItem->setOpen(true);
|
|---|
| 745 | #else
|
|---|
| 746 | #if QT_VERSION < 0x040202
|
|---|
| 747 | fHelpTreeWidget->setItemExpanded(findItem,true);
|
|---|
| 748 | #else
|
|---|
| 749 | findItem->setExpanded(true);
|
|---|
| 750 | #endif
|
|---|
| 751 | #endif
|
|---|
| 752 | findItem = findItem->parent();
|
|---|
| 753 | }
|
|---|
| 754 |
|
|---|
| 755 | // Call the update of the right textArea
|
|---|
| 756 | HelpTreeClicCallback();
|
|---|
| 757 | }
|
|---|
| 758 | }
|
|---|
| 759 | #if QT_VERSION < 0x040000
|
|---|
| 760 | fHelpDialog->setCaption( tr( "Help on commands" ));
|
|---|
| 761 | #else
|
|---|
| 762 | fHelpDialog->setWindowTitle(tr("Help on commands"));
|
|---|
| 763 | #endif
|
|---|
| 764 | fHelpDialog->resize(800,600);
|
|---|
| 765 | fHelpDialog->move(QPoint(400,150));
|
|---|
| 766 | fHelpDialog->show();
|
|---|
| 767 | fHelpDialog->raise();
|
|---|
| 768 | #if QT_VERSION < 0x040000
|
|---|
| 769 | fHelpDialog->setActiveWindow();
|
|---|
| 770 | #else
|
|---|
| 771 | fHelpDialog->activateWindow();
|
|---|
| 772 | #endif
|
|---|
| 773 | }
|
|---|
| 774 |
|
|---|
| 775 |
|
|---|
| 776 |
|
|---|
| 777 | /** Fill the Help Tree Widget
|
|---|
| 778 | @param aParent : parent item to fill
|
|---|
| 779 | @param aCommandTree : commandTree node associate with this part of the Tree
|
|---|
| 780 | */
|
|---|
| 781 | #if QT_VERSION < 0x040000
|
|---|
| 782 | void G4UIQt::CreateChildTree(
|
|---|
| 783 | QListViewItem *aParent
|
|---|
| 784 | ,G4UIcommandTree *aCommandTree
|
|---|
| 785 | #else
|
|---|
| 786 | void G4UIQt::CreateChildTree(
|
|---|
| 787 | QTreeWidgetItem *aParent
|
|---|
| 788 | ,G4UIcommandTree *aCommandTree
|
|---|
| 789 | #endif
|
|---|
| 790 | )
|
|---|
| 791 | {
|
|---|
| 792 | if (aParent == NULL) return;
|
|---|
| 793 | if (aCommandTree == NULL) return;
|
|---|
| 794 |
|
|---|
| 795 |
|
|---|
| 796 | // Creating new item
|
|---|
| 797 | #if QT_VERSION < 0x040000
|
|---|
| 798 | QListViewItem * newItem;
|
|---|
| 799 | #else
|
|---|
| 800 | QTreeWidgetItem * newItem;
|
|---|
| 801 | #endif
|
|---|
| 802 |
|
|---|
| 803 | // Get the Sub directories
|
|---|
| 804 | for (int a=0;a<aCommandTree->GetTreeEntry();a++) {
|
|---|
| 805 |
|
|---|
| 806 | #if QT_VERSION < 0x040000
|
|---|
| 807 | newItem = new QListViewItem(aParent);
|
|---|
| 808 | newItem->setText(0,QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()).simplifyWhiteSpace());
|
|---|
| 809 | newItem->setText(1,QString((char*)(aCommandTree->GetTree(a+1)->GetTitle()).data()).simplifyWhiteSpace());
|
|---|
| 810 |
|
|---|
| 811 | #else
|
|---|
| 812 | newItem = new QTreeWidgetItem(aParent);
|
|---|
| 813 | newItem->setText(0,QString((char*)(aCommandTree->GetTree(a+1)->GetPathName()).data()).trimmed());
|
|---|
| 814 | newItem->setText(1,QString((char*)(aCommandTree->GetTree(a+1)->GetTitle()).data()).trimmed());
|
|---|
| 815 | #endif
|
|---|
| 816 |
|
|---|
| 817 | CreateChildTree(newItem,aCommandTree->GetTree(a+1));
|
|---|
| 818 | }
|
|---|
| 819 |
|
|---|
| 820 |
|
|---|
| 821 |
|
|---|
| 822 | // Get the Commands
|
|---|
| 823 |
|
|---|
| 824 | for (int a=0;a<aCommandTree->GetCommandEntry();a++) {
|
|---|
| 825 |
|
|---|
| 826 | QStringList stringList;
|
|---|
| 827 | #if QT_VERSION < 0x040000
|
|---|
| 828 | newItem = new QListViewItem(aParent);
|
|---|
| 829 | newItem->setText(0,QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()).simplifyWhiteSpace());
|
|---|
| 830 | newItem->setText(1,QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()).simplifyWhiteSpace());
|
|---|
| 831 | newItem->setOpen(false);
|
|---|
| 832 |
|
|---|
| 833 | #else
|
|---|
| 834 | newItem = new QTreeWidgetItem(aParent);
|
|---|
| 835 | newItem->setText(0,QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()).trimmed());
|
|---|
| 836 | newItem->setText(1,QString((char*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()).trimmed());
|
|---|
| 837 | #if QT_VERSION < 0x040202
|
|---|
| 838 | fHelpTreeWidget->setItemExpanded(newItem,false);
|
|---|
| 839 | #else
|
|---|
| 840 | newItem->setExpanded(false);
|
|---|
| 841 | #endif
|
|---|
| 842 | #endif
|
|---|
| 843 |
|
|---|
| 844 | }
|
|---|
| 845 | }
|
|---|
| 846 |
|
|---|
| 847 |
|
|---|
| 848 | /** Find a treeItemWidget in the help tree
|
|---|
| 849 | @param aCommand item's String to look for
|
|---|
| 850 | @return item if found, NULL if not
|
|---|
| 851 | */
|
|---|
| 852 | #if QT_VERSION < 0x040000
|
|---|
| 853 | QListViewItem* G4UIQt::FindTreeItem(
|
|---|
| 854 | QListViewItem *aParent
|
|---|
| 855 | #else
|
|---|
| 856 | QTreeWidgetItem* G4UIQt::FindTreeItem(
|
|---|
| 857 | QTreeWidgetItem *aParent
|
|---|
| 858 | #endif
|
|---|
| 859 | ,const QString& aCommand
|
|---|
| 860 | )
|
|---|
| 861 | {
|
|---|
| 862 | if (aParent == NULL) return NULL;
|
|---|
| 863 |
|
|---|
| 864 | if (aParent->text(0) == aCommand)
|
|---|
| 865 | return aParent;
|
|---|
| 866 |
|
|---|
| 867 | #if QT_VERSION < 0x040000
|
|---|
| 868 | QListViewItem * tmp = NULL;
|
|---|
| 869 | QListViewItem* tmpItem = aParent->firstChild();
|
|---|
| 870 | while (tmpItem != 0) {
|
|---|
| 871 | if (!tmp)
|
|---|
| 872 | tmp = FindTreeItem(tmpItem,aCommand);
|
|---|
| 873 | tmpItem = tmpItem->nextSibling();
|
|---|
| 874 | }
|
|---|
| 875 |
|
|---|
| 876 | #else
|
|---|
| 877 | QTreeWidgetItem * tmp = NULL;
|
|---|
| 878 | for (int a=0;a<aParent->childCount();a++) {
|
|---|
| 879 | if (!tmp)
|
|---|
| 880 | tmp = FindTreeItem(aParent->child(a),aCommand);
|
|---|
| 881 | }
|
|---|
| 882 | #endif
|
|---|
| 883 | return tmp;
|
|---|
| 884 | }
|
|---|
| 885 |
|
|---|
| 886 |
|
|---|
| 887 | /** Build the command list parameters in a QString<br>
|
|---|
| 888 | Reimplement partialy the G4UIparameter.cc
|
|---|
| 889 | @param aCommand : command to list parameters
|
|---|
| 890 | @see G4UIparameter::List()
|
|---|
| 891 | @see G4UIcommand::List()
|
|---|
| 892 | @return the command list parameters, or "" if nothing
|
|---|
| 893 | */
|
|---|
| 894 | QString G4UIQt::GetCommandList (
|
|---|
| 895 | const G4UIcommand *aCommand
|
|---|
| 896 | )
|
|---|
| 897 | {
|
|---|
| 898 |
|
|---|
| 899 | QString txt ="";
|
|---|
| 900 | if (aCommand == NULL)
|
|---|
| 901 | return txt;
|
|---|
| 902 |
|
|---|
| 903 | G4String commandPath = aCommand->GetCommandPath();
|
|---|
| 904 | G4String rangeString = aCommand->GetRange();
|
|---|
| 905 | G4int n_guidanceEntry = aCommand->GetGuidanceEntries();
|
|---|
| 906 | G4int n_parameterEntry = aCommand->GetParameterEntries();
|
|---|
| 907 |
|
|---|
| 908 | if ((commandPath == "") &&
|
|---|
| 909 | (rangeString == "") &&
|
|---|
| 910 | (n_guidanceEntry == 0) &&
|
|---|
| 911 | (n_parameterEntry == 0)) {
|
|---|
| 912 | return txt;
|
|---|
| 913 | }
|
|---|
| 914 |
|
|---|
| 915 | if((commandPath.length()-1)!='/') {
|
|---|
| 916 | txt += "Command " + QString((char*)(commandPath).data()) + "\n";
|
|---|
| 917 | }
|
|---|
| 918 | txt += "Guidance :\n";
|
|---|
| 919 |
|
|---|
| 920 | for( G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
|
|---|
| 921 | txt += QString((char*)(aCommand->GetGuidanceLine(i_thGuidance)).data()) + "\n";
|
|---|
| 922 | }
|
|---|
| 923 | if( ! rangeString.isNull() ) {
|
|---|
| 924 | txt += " Range of parameters : " + QString((char*)(rangeString).data()) + "\n";
|
|---|
| 925 | }
|
|---|
| 926 | if( n_parameterEntry > 0 ) {
|
|---|
| 927 | G4UIparameter *param;
|
|---|
| 928 |
|
|---|
| 929 | // Re-implementation of G4UIparameter.cc
|
|---|
| 930 |
|
|---|
| 931 | for( G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
|
|---|
| 932 | param = aCommand->GetParameter(i_thParameter);
|
|---|
| 933 | txt += "\nParameter : " + QString((char*)(param->GetParameterName()).data()) + "\n";
|
|---|
| 934 | if( ! param->GetParameterGuidance().isNull() )
|
|---|
| 935 | txt += QString((char*)(param->GetParameterGuidance()).data())+ "\n" ;
|
|---|
| 936 | txt += " Parameter type : " + QString(QChar(param->GetParameterType())) + "\n";
|
|---|
| 937 | if(param->IsOmittable()){
|
|---|
| 938 | txt += " Omittable : True\n";
|
|---|
| 939 | } else {
|
|---|
| 940 | txt += " Omittable : False\n";
|
|---|
| 941 | }
|
|---|
| 942 | if( param->GetCurrentAsDefault() ) {
|
|---|
| 943 | txt += " Default value : taken from the current value\n";
|
|---|
| 944 | } else if( ! param->GetDefaultValue().isNull() ) {
|
|---|
| 945 | txt += " Default value : " + QString((char*)(param->GetDefaultValue()).data())+ "\n";
|
|---|
| 946 | }
|
|---|
| 947 | if( ! param->GetParameterRange().isNull() ) {
|
|---|
| 948 | txt += " Parameter range : " + QString((char*)(param->GetParameterRange()).data())+ "\n";
|
|---|
| 949 | }
|
|---|
| 950 | if( ! param->GetParameterCandidates().isNull() ) {
|
|---|
| 951 | txt += " Candidates : " + QString((char*)(param->GetParameterCandidates()).data())+ "\n";
|
|---|
| 952 | }
|
|---|
| 953 | }
|
|---|
| 954 | }
|
|---|
| 955 | return txt;
|
|---|
| 956 | }
|
|---|
| 957 |
|
|---|
| 958 |
|
|---|
| 959 |
|
|---|
| 960 | /** Implement G4VBasicShell vurtual function
|
|---|
| 961 | */
|
|---|
| 962 | G4bool G4UIQt::GetHelpChoice(
|
|---|
| 963 | G4int& aInt
|
|---|
| 964 | )
|
|---|
| 965 | {
|
|---|
| 966 | #ifdef GEANT4_QT_DEBUG
|
|---|
| 967 | printf("G4UIQt::GetHelpChoice SHOULD NEVER GO HERE");
|
|---|
| 968 | #endif
|
|---|
| 969 | return true;
|
|---|
| 970 | }
|
|---|
| 971 |
|
|---|
| 972 |
|
|---|
| 973 | /** Implement G4VBasicShell vurtual function
|
|---|
| 974 | */
|
|---|
| 975 | void G4UIQt::ExitHelp(
|
|---|
| 976 | )
|
|---|
| 977 | {
|
|---|
| 978 | #ifdef GEANT4_QT_DEBUG
|
|---|
| 979 | printf("G4UIQt::ExitHelp SHOULD NEVER GO HERE");
|
|---|
| 980 | #endif
|
|---|
| 981 | }
|
|---|
| 982 |
|
|---|
| 983 |
|
|---|
| 984 | /** Event filter method. Every event from QtApplication goes here.<br/>
|
|---|
| 985 | We apply a filter only for the Up and Down Arrow press when the QLineEdit<br/>
|
|---|
| 986 | is active. If this filter match, Up arrow we give the previous command<br/>
|
|---|
| 987 | and Down arrow will give the next if exist.<br/>
|
|---|
| 988 | @param obj Emitter of the event
|
|---|
| 989 | @param event Kind of event
|
|---|
| 990 | */
|
|---|
| 991 | bool G4UIQt::eventFilter( // Should stay with a minuscule eventFilter because of Qt
|
|---|
| 992 | QObject *aObj
|
|---|
| 993 | ,QEvent *aEvent
|
|---|
| 994 | )
|
|---|
| 995 | {
|
|---|
| 996 | if (aObj == NULL) return false;
|
|---|
| 997 | if (aEvent == NULL) return false;
|
|---|
| 998 |
|
|---|
| 999 | if (aObj == fCommandHistoryArea) {
|
|---|
| 1000 | if (aEvent->type() == QEvent::KeyPress) {
|
|---|
| 1001 | fCommandArea->setFocus();
|
|---|
| 1002 | }
|
|---|
| 1003 | }
|
|---|
| 1004 | if (aObj == fCommandArea) {
|
|---|
| 1005 | if (aEvent->type() == QEvent::KeyPress) {
|
|---|
| 1006 | QKeyEvent *e = static_cast<QKeyEvent*>(aEvent);
|
|---|
| 1007 | if ((e->key() == (Qt::Key_Down)) ||
|
|---|
| 1008 | (e->key() == (Qt::Key_PageDown)) ||
|
|---|
| 1009 | (e->key() == (Qt::Key_Up)) ||
|
|---|
| 1010 | (e->key() == (Qt::Key_PageUp))) {
|
|---|
| 1011 | #if QT_VERSION < 0x040000
|
|---|
| 1012 | // count rows...
|
|---|
| 1013 | QListViewItem* tmpItem = fCommandHistoryArea->firstChild();
|
|---|
| 1014 | int selection = -1;
|
|---|
| 1015 | int index = 0;
|
|---|
| 1016 | while (tmpItem != 0) {
|
|---|
| 1017 | if (tmpItem == fCommandHistoryArea->selectedItem()) {
|
|---|
| 1018 | selection = index;
|
|---|
| 1019 | }
|
|---|
| 1020 | index ++;
|
|---|
| 1021 | tmpItem = tmpItem->nextSibling();
|
|---|
| 1022 | }
|
|---|
| 1023 | if (fCommandHistoryArea->childCount()) {
|
|---|
| 1024 | if (selection == -1) {
|
|---|
| 1025 | selection = fCommandHistoryArea->childCount()-1;
|
|---|
| 1026 | } else {
|
|---|
| 1027 | if (e->key() == (Qt::Key_Down)) {
|
|---|
| 1028 | if (selection <(fCommandHistoryArea->childCount()-1))
|
|---|
| 1029 | selection++;
|
|---|
| 1030 | } else if (e->key() == (Qt::Key_PageDown)) {
|
|---|
| 1031 | selection = fCommandHistoryArea->childCount()-1;
|
|---|
| 1032 | #else
|
|---|
| 1033 | int selection = fCommandHistoryArea->currentRow();
|
|---|
| 1034 | if (fCommandHistoryArea->count()) {
|
|---|
| 1035 | if (selection == -1) {
|
|---|
| 1036 | selection = fCommandHistoryArea->count()-1;
|
|---|
| 1037 | } else {
|
|---|
| 1038 | if (e->key() == (Qt::Key_Down)) {
|
|---|
| 1039 | if (selection <(fCommandHistoryArea->count()-1))
|
|---|
| 1040 | selection++;
|
|---|
| 1041 | } else if (e->key() == (Qt::Key_PageDown)) {
|
|---|
| 1042 | selection = fCommandHistoryArea->count()-1;
|
|---|
| 1043 | #endif
|
|---|
| 1044 | } else if (e->key() == (Qt::Key_Up)) {
|
|---|
| 1045 | if (selection >0)
|
|---|
| 1046 | selection --;
|
|---|
| 1047 | } else if (e->key() == (Qt::Key_PageUp)) {
|
|---|
| 1048 | selection = 0;
|
|---|
| 1049 | }
|
|---|
| 1050 | }
|
|---|
| 1051 | fCommandHistoryArea->clearSelection();
|
|---|
| 1052 | #if QT_VERSION < 0x040000
|
|---|
| 1053 | QListViewItem* tmpItem = fCommandHistoryArea->firstChild();
|
|---|
| 1054 | int index = 0;
|
|---|
| 1055 | while (tmpItem != 0) {
|
|---|
| 1056 | if (index == selection) {
|
|---|
| 1057 | tmpItem->setSelected(true);
|
|---|
| 1058 | fCommandHistoryArea->setCurrentItem(tmpItem);
|
|---|
| 1059 | }
|
|---|
| 1060 | index ++;
|
|---|
| 1061 | tmpItem = tmpItem->nextSibling();
|
|---|
| 1062 | }
|
|---|
| 1063 | #else
|
|---|
| 1064 | #if QT_VERSION < 0x040202
|
|---|
| 1065 | fCommandHistoryArea->setItemSelected(fCommandHistoryArea->item(selection),true);
|
|---|
| 1066 | #else
|
|---|
| 1067 | fCommandHistoryArea->item(selection)->setSelected(true);
|
|---|
| 1068 | #endif
|
|---|
| 1069 | fCommandHistoryArea->setCurrentItem(fCommandHistoryArea->item(selection));
|
|---|
| 1070 | #endif
|
|---|
| 1071 | }
|
|---|
| 1072 | } else if (e->key() == (Qt::Key_Tab)) {
|
|---|
| 1073 | #if QT_VERSION < 0x040000
|
|---|
| 1074 | G4String ss = Complete(fCommandArea->text().ascii());
|
|---|
| 1075 | #else
|
|---|
| 1076 | G4String ss = Complete(fCommandArea->text().toStdString().c_str());
|
|---|
| 1077 | #endif
|
|---|
| 1078 | fCommandArea->setText((char*)(ss.data()));
|
|---|
| 1079 |
|
|---|
| 1080 | // do not pass by parent, it will disable widget tab focus !
|
|---|
| 1081 | return true;
|
|---|
| 1082 | }
|
|---|
| 1083 | }
|
|---|
| 1084 | }
|
|---|
| 1085 | // pass the event on to the parent class
|
|---|
| 1086 | return QObject::eventFilter(aObj, aEvent);
|
|---|
| 1087 | }
|
|---|
| 1088 |
|
|---|
| 1089 |
|
|---|
| 1090 |
|
|---|
| 1091 |
|
|---|
| 1092 | /***************************************************************************/
|
|---|
| 1093 | //
|
|---|
| 1094 | // SLOTS DEFINITIONS
|
|---|
| 1095 | //
|
|---|
| 1096 | /***************************************************************************/
|
|---|
| 1097 |
|
|---|
| 1098 | /** Called when user give "help" command.
|
|---|
| 1099 | */
|
|---|
| 1100 | void G4UIQt::ShowHelpCallback (
|
|---|
| 1101 | )
|
|---|
| 1102 | {
|
|---|
| 1103 | TerminalHelp("");
|
|---|
| 1104 | }
|
|---|
| 1105 |
|
|---|
| 1106 |
|
|---|
| 1107 | /** Called when user click on clear button. Clear the text Output area
|
|---|
| 1108 | */
|
|---|
| 1109 | void G4UIQt::ClearButtonCallback (
|
|---|
| 1110 | )
|
|---|
| 1111 | {
|
|---|
| 1112 | fTextArea->clear();
|
|---|
| 1113 | }
|
|---|
| 1114 |
|
|---|
| 1115 | /** Called when user exit session
|
|---|
| 1116 | */
|
|---|
| 1117 | void G4UIQt::ExitSession (
|
|---|
| 1118 | )
|
|---|
| 1119 | {
|
|---|
| 1120 | SessionTerminate();
|
|---|
| 1121 | }
|
|---|
| 1122 |
|
|---|
| 1123 |
|
|---|
| 1124 | /** Callback call when "click on a menu entry.<br>
|
|---|
| 1125 | Send the associated command to geant4
|
|---|
| 1126 | */
|
|---|
| 1127 | void G4UIQt::CommandEnteredCallback (
|
|---|
| 1128 | )
|
|---|
| 1129 | {
|
|---|
| 1130 | #if QT_VERSION < 0x040000
|
|---|
| 1131 | G4String command (fCommandArea->text().ascii());
|
|---|
| 1132 | if (fCommandArea->text().simplifyWhiteSpace() != "") {
|
|---|
| 1133 |
|
|---|
| 1134 | QListViewItem *newItem = new QListViewItem(fCommandHistoryArea);
|
|---|
| 1135 | newItem->setText(0,fCommandArea->text());
|
|---|
| 1136 | fCommandHistoryArea->insertItem(newItem);
|
|---|
| 1137 | // now we have to arrange
|
|---|
| 1138 | QListViewItem *temp= fCommandHistoryArea->lastItem();
|
|---|
| 1139 | for (int i=0; i<fCommandHistoryArea->childCount()-1;i++) {
|
|---|
| 1140 | fCommandHistoryArea->takeItem(temp);
|
|---|
| 1141 | fCommandHistoryArea->insertItem(temp);
|
|---|
| 1142 | temp= fCommandHistoryArea->lastItem();
|
|---|
| 1143 | }
|
|---|
| 1144 | #else
|
|---|
| 1145 | G4String command (fCommandArea->text().toStdString().c_str());
|
|---|
| 1146 | if (fCommandArea->text().trimmed() != "") {
|
|---|
| 1147 | fCommandHistoryArea->addItem(fCommandArea->text());
|
|---|
| 1148 | #endif
|
|---|
| 1149 | fCommandHistoryArea->clearSelection();
|
|---|
| 1150 | fCommandHistoryArea->setCurrentItem(NULL);
|
|---|
| 1151 | fCommandArea->setText("");
|
|---|
| 1152 |
|
|---|
| 1153 | G4Qt* interactorManager = G4Qt::getInstance ();
|
|---|
| 1154 | if (interactorManager) {
|
|---|
| 1155 | interactorManager->FlushAndWaitExecution();
|
|---|
| 1156 | }
|
|---|
| 1157 | if (command(0,4) != "help") {
|
|---|
| 1158 | ApplyShellCommand (command,exitSession,exitPause);
|
|---|
| 1159 | } else {
|
|---|
| 1160 | TerminalHelp(command);
|
|---|
| 1161 | }
|
|---|
| 1162 | if(exitSession==true)
|
|---|
| 1163 | SessionTerminate();
|
|---|
| 1164 | }
|
|---|
| 1165 | }
|
|---|
| 1166 |
|
|---|
| 1167 |
|
|---|
| 1168 | /** Callback call when "enter" clicked on the command zone.<br>
|
|---|
| 1169 | Send the command to geant4
|
|---|
| 1170 | @param aCommand
|
|---|
| 1171 | */
|
|---|
| 1172 | void G4UIQt::ButtonCallback (
|
|---|
| 1173 | const QString& aCommand
|
|---|
| 1174 | )
|
|---|
| 1175 | {
|
|---|
| 1176 | #if QT_VERSION < 0x040000
|
|---|
| 1177 | G4String ss = G4String(aCommand.ascii());
|
|---|
| 1178 | #else
|
|---|
| 1179 | G4String ss = G4String(aCommand.toStdString().c_str());
|
|---|
| 1180 | #endif
|
|---|
| 1181 | ApplyShellCommand(ss,exitSession,exitPause);
|
|---|
| 1182 | if(exitSession==true)
|
|---|
| 1183 | SessionTerminate();
|
|---|
| 1184 | }
|
|---|
| 1185 |
|
|---|
| 1186 |
|
|---|
| 1187 |
|
|---|
| 1188 | /** This callback is activated when user selected a item in the help tree
|
|---|
| 1189 | */
|
|---|
| 1190 | void G4UIQt::HelpTreeClicCallback (
|
|---|
| 1191 | )
|
|---|
| 1192 | {
|
|---|
| 1193 | #if QT_VERSION < 0x040000
|
|---|
| 1194 | QListViewItem* item = NULL;
|
|---|
| 1195 | #else
|
|---|
| 1196 | QTreeWidgetItem* item = NULL;
|
|---|
| 1197 | #endif
|
|---|
| 1198 | if (!fHelpTreeWidget)
|
|---|
| 1199 | return ;
|
|---|
| 1200 |
|
|---|
| 1201 | if (!fHelpArea)
|
|---|
| 1202 | return;
|
|---|
| 1203 |
|
|---|
| 1204 | #if QT_VERSION < 0x040000
|
|---|
| 1205 | item =fHelpTreeWidget->selectedItem();
|
|---|
| 1206 | #else
|
|---|
| 1207 | QList<QTreeWidgetItem *> list =fHelpTreeWidget->selectedItems();
|
|---|
| 1208 | if (list.isEmpty())
|
|---|
| 1209 | return;
|
|---|
| 1210 | item = list.first();
|
|---|
| 1211 | #endif
|
|---|
| 1212 | if (!item)
|
|---|
| 1213 | return;
|
|---|
| 1214 |
|
|---|
| 1215 | G4UImanager* UI = G4UImanager::GetUIpointer();
|
|---|
| 1216 | if(UI==NULL) return;
|
|---|
| 1217 | G4UIcommandTree * treeTop = UI->GetTree();
|
|---|
| 1218 | #if QT_VERSION < 0x040000
|
|---|
| 1219 | G4UIcommand* command = treeTop->FindPath(item->text (1).ascii());
|
|---|
| 1220 | #else
|
|---|
| 1221 | G4UIcommand* command = treeTop->FindPath(item->text (1).toStdString().c_str());
|
|---|
| 1222 | #endif
|
|---|
| 1223 | if (command) {
|
|---|
| 1224 | #if QT_VERSION >= 0x040000
|
|---|
| 1225 | #if QT_VERSION < 0x040200
|
|---|
| 1226 | fHelpArea->clear();
|
|---|
| 1227 | fHelpArea->append(GetCommandList(command));
|
|---|
| 1228 | #else
|
|---|
| 1229 | fHelpArea->setText(GetCommandList(command));
|
|---|
| 1230 | #endif
|
|---|
| 1231 | #else
|
|---|
| 1232 | fHelpArea->setText(GetCommandList(command));
|
|---|
| 1233 | #endif
|
|---|
| 1234 | } else {
|
|---|
| 1235 | // this is not a command, this is a sub directory
|
|---|
| 1236 | // We display the Title
|
|---|
| 1237 | #if QT_VERSION >= 0x040000
|
|---|
| 1238 | #if QT_VERSION < 0x040200
|
|---|
| 1239 | fHelpArea->clear();
|
|---|
| 1240 | fHelpArea->append(item->text (1));
|
|---|
| 1241 | #else
|
|---|
| 1242 | fHelpArea->setText(item->text (1));
|
|---|
| 1243 | #endif
|
|---|
| 1244 | #else
|
|---|
| 1245 | fHelpArea->setText(item->text (1));
|
|---|
| 1246 | #endif
|
|---|
| 1247 | }
|
|---|
| 1248 | }
|
|---|
| 1249 |
|
|---|
| 1250 | /** This callback is activated when user double clic on a item in the help tree
|
|---|
| 1251 | */
|
|---|
| 1252 | void G4UIQt::HelpTreeDoubleClicCallback (
|
|---|
| 1253 | #if QT_VERSION < 0x040000
|
|---|
| 1254 | QListViewItem* item
|
|---|
| 1255 | #else
|
|---|
| 1256 | QTreeWidgetItem* item
|
|---|
| 1257 | ,int
|
|---|
| 1258 | #endif
|
|---|
| 1259 | )
|
|---|
| 1260 | {
|
|---|
| 1261 | HelpTreeClicCallback();
|
|---|
| 1262 | fCommandArea->setText(item->text (1));
|
|---|
| 1263 | }
|
|---|
| 1264 |
|
|---|
| 1265 |
|
|---|
| 1266 | /** Callback called when user select an old command in the command history<br>
|
|---|
| 1267 | Give it to the command area.
|
|---|
| 1268 | */
|
|---|
| 1269 | void G4UIQt::CommandHistoryCallback(
|
|---|
| 1270 | )
|
|---|
| 1271 | {
|
|---|
| 1272 | #if QT_VERSION < 0x040000
|
|---|
| 1273 | QListViewItem* item = NULL;
|
|---|
| 1274 | #else
|
|---|
| 1275 | QListWidgetItem* item = NULL;
|
|---|
| 1276 | #endif
|
|---|
| 1277 | if (!fCommandHistoryArea)
|
|---|
| 1278 | return ;
|
|---|
| 1279 |
|
|---|
| 1280 |
|
|---|
| 1281 | #if QT_VERSION < 0x040000
|
|---|
| 1282 | item =fCommandHistoryArea->selectedItem();
|
|---|
| 1283 | #else
|
|---|
| 1284 | QList<QListWidgetItem *> list =fCommandHistoryArea->selectedItems();
|
|---|
| 1285 | if (list.isEmpty())
|
|---|
| 1286 | return;
|
|---|
| 1287 | item = list.first();
|
|---|
| 1288 | #endif
|
|---|
| 1289 | if (!item)
|
|---|
| 1290 | return;
|
|---|
| 1291 | #if QT_VERSION < 0x040000
|
|---|
| 1292 | fCommandArea->setText(item->text(0));
|
|---|
| 1293 | #else
|
|---|
| 1294 | fCommandArea->setText(item->text());
|
|---|
| 1295 | #endif
|
|---|
| 1296 |
|
|---|
| 1297 | }
|
|---|
| 1298 |
|
|---|
| 1299 | #endif
|
|---|