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