[109172] users/mojca/ports/science/geant4/files/patch-upstream-qt.496.diff

mojca at macports.org mojca at macports.org
Fri Aug 9 05:23:58 PDT 2013


Revision: 109172
          https://trac.macports.org/changeset/109172
Author:   mojca at macports.org
Date:     2013-08-09 05:23:58 -0700 (Fri, 09 Aug 2013)
Log Message:
-----------
mojca/geant4: add the forgotten patch

Added Paths:
-----------
    users/mojca/ports/science/geant4/files/patch-upstream-qt.496.diff

Added: users/mojca/ports/science/geant4/files/patch-upstream-qt.496.diff
===================================================================
--- users/mojca/ports/science/geant4/files/patch-upstream-qt.496.diff	                        (rev 0)
+++ users/mojca/ports/science/geant4/files/patch-upstream-qt.496.diff	2013-08-09 12:23:58 UTC (rev 109172)
@@ -0,0 +1,162 @@
+--- source/interfaces/basic/include/G4UIQt.hh.orig
++++ source/interfaces/basic/include/G4UIQt.hh
+@@ -215,6 +215,7 @@ private:
+ 
+   QToolBar *fToolbarApp;
+   QToolBar *fToolbarUser;
++  G4String fLastErrMessage;
+ 
+   bool fMoveSelected;
+   bool fRotateSelected;
+@@ -226,6 +227,7 @@ private Q_SLOTS :
+   void ExitSession();
+   void ClearButtonCallback();
+   void CommandEnteredCallback();
++  void CommandEditedCallback(const QString &);
+   void ButtonCallback(const QString&);
+   void HelpTreeClicCallback();
+   void HelpTreeDoubleClicCallback();
+--- source/interfaces/basic/src/G4UIQt.cc.orig
++++ source/interfaces/basic/src/G4UIQt.cc
+@@ -270,6 +270,7 @@ G4UIQt::G4UIQt (
+ 
+   // Connect signal
+   connect(fCommandArea, SIGNAL(returnPressed()), SLOT(CommandEnteredCallback()));
++  connect(fCommandArea, SIGNAL(textEdited(const QString &)), SLOT(CommandEditedCallback(const QString &)));
+   connect(fUITabWidget, SIGNAL(currentChanged(int)), SLOT(ToolBoxActivated(int)));
+ 
+   if(UI!=NULL) UI->SetCoutDestination(this);  // TO KEEP
+@@ -720,10 +721,10 @@ G4int G4UIQt::ReceiveG4cout (
+  
+   QStringList result = newStr.filter(fCoutFilter->text());
+ 
+-  if (result.join("\n").isEmpty()) {
++  if (result.join("").isEmpty()) {
+     return 0;
+   }
+-  fCoutTBTextArea->append(result.join("\n"));
++  fCoutTBTextArea->append(result.join(""));
+   fCoutTBTextArea->repaint();
+ 
+   fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
+@@ -753,7 +754,11 @@ G4int G4UIQt::ReceiveG4cerr (
+ 
+   // Suppress space, \n,\t,\r...
+   if (QString(aString.data()).trimmed() != "") {
+-    QMessageBox::critical(fMainWindow, "Error",aString.data());
++    if ((G4StateManager::GetStateManager()->GetCurrentState() == G4State_Abort) ||
++        (G4StateManager::GetStateManager()->GetCurrentState() == G4State_Quit )) {
++      // In case of Abort or Quit, the useful error message should be in the last error message !
++      QMessageBox::critical(fMainWindow, "Error",QString(fLastErrMessage.data())+"\n"+aString.data());
++    }
+   }
+   QColor previousColor = fCoutTBTextArea->textColor();
+   fCoutTBTextArea->setTextColor(Qt::red);
+@@ -761,6 +766,10 @@ G4int G4UIQt::ReceiveG4cerr (
+   fCoutTBTextArea->setTextColor(previousColor);
+   fCoutTBTextArea->verticalScrollBar()->setSliderPosition(fCoutTBTextArea->verticalScrollBar()->maximum());
+   fCoutTBTextArea->repaint();
++
++  if (QString(aString.data()).trimmed() != "") {
++    fLastErrMessage = aString;
++  }
+   return 0;
+ }
+ 
+@@ -1585,17 +1594,18 @@ void G4UIQt::AddIcon(const char* aLabel, const char* aIconFile, const char* aCom
+   QToolBar *currentToolbar = NULL;
+   if (userToolBar) {
+     if (fToolbarUser == NULL) {
+-      fToolbarUser = new QToolBar(fMainWindow);
++      fToolbarUser = new QToolBar();
+       fToolbarUser->setIconSize (QSize(20,20));
+       fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarUser);
+     }
+     currentToolbar = fToolbarUser;
+   } else {
+     if (fToolbarApp == NULL) {
+-      fToolbarApp = new QToolBar(fMainWindow);
++      fToolbarApp = new QToolBar();
+       fToolbarApp->setIconSize (QSize(20,20));
+       fMainWindow->addToolBar(Qt::TopToolBarArea, fToolbarApp);
+     }
++    fMainWindow->show();
+     currentToolbar = fToolbarApp;
+   }
+ 
+@@ -2558,27 +2568,56 @@ void G4UIQt::ExitHelp(
+ void G4UIQt::CommandEnteredCallback (
+ )
+ {
+-  G4String command (fCommandArea->text().toStdString().c_str());
+-  if (fCommandArea->text().trimmed() != "") {
+-    fHistoryTBTableList->addItem(fCommandArea->text());
+-    fHistoryTBTableList->clearSelection();
+-    fHistoryTBTableList->setCurrentItem(NULL);
+-    fCommandArea->setText("");
+-
+-    G4Qt* interactorManager = G4Qt::getInstance ();
+-    if (interactorManager) { 
+-      interactorManager->FlushAndWaitExecution();
+-    }
+-    if (command(0,4) != "help") {
+-      ApplyShellCommand (command,exitSession,exitPause);
+-    } else {
+-      ActivateCommand(command);
++  // split by any new line character
++  QStringList list = fCommandArea->text().split(QRegExp("[\r\n]"),QString::SkipEmptyParts);
++
++  // Apply for all commands
++  for (unsigned int a=0; a< list.size(); a++) {
++    QString txt (list[a].trimmed());
++    if (txt != "") {
++      fHistoryTBTableList->addItem(txt);
++      fHistoryTBTableList->clearSelection();
++      fHistoryTBTableList->setCurrentItem(NULL);
++      fCommandArea->setText("");
++      G4Qt* interactorManager = G4Qt::getInstance ();
++      if (interactorManager) {
++        interactorManager->FlushAndWaitExecution();
++      }
++
++      G4String command = txt.toStdString().c_str();
++      if (command(0,4) != "help") {
++        ApplyShellCommand (command,exitSession,exitPause);
++      } else {
++        ActivateCommand(command);
++      }
+     }
+-    // Rebuild help tree
+-    FillHelpTree();
++  }
++
++  // Rebuild help tree
++  FillHelpTree();
+ 
+-    if(exitSession==true) 
+-      SessionTerminate();
++  if(exitSession==true)
++    SessionTerminate();
++}
++
++
++/** Callback when the text in the line edit is changed.
++ When a newline is inserted, trigger the Activate Command
++ on this text end set unchanged the end of the line after the newline.
++ */
++void G4UIQt::CommandEditedCallback(const QString & )
++{
++  QStringList list = fCommandArea->text().split(QRegExp("[\r\n]"),QString::SkipEmptyParts);
++
++  if (list.size() > 1) { // trigger ActivateCommand
++    for (int a=0; a<list.size()-1; a++) {
++      // set only the first part
++      fCommandArea->setText(list[a]);
++      // trigger callback
++      CommandEnteredCallback();
++    }
++    // reset unfinished command
++    fCommandArea->setText(list[list.size()-1]);
+   }
+ }
+ 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20130809/f8a009d2/attachment.html>


More information about the macports-changes mailing list