Exemplo n.º 1
0
KJavaProcess::KJavaProcess( QObject* parent )
	: KProcess( parent ),
	d(new KJavaProcessPrivate)

{
    connect( this, SIGNAL( readyReadStandardOutput() ),
             this, SLOT( slotReceivedData() ) );
    connect( this, SIGNAL( finished( int, QProcess::ExitStatus ) ),
             this, SLOT( slotExited() ) );
    connect( this, SIGNAL( error(  QProcess::ProcessError ) ),
             this, SLOT( slotExited() ) );

    d->jvmPath = "java";
    d->mainClass = "-help";
}
Exemplo n.º 2
0
// -------------------------------------------------------------------------
bool SpiceFile::recreateSubNetlist(QString *SpiceFile, QString *FileName)
{
  // initialize collectors
  ErrText = "";
  NetText = "";
  SimText = "";
  NetLine = "";

  // evaluate properties
  if(Props.at(1)->Value != "")
    makeSubcircuit = true;
  else
    makeSubcircuit = false;
  if(Props.at(2)->Value == "yes")
    insertSim = true;
  else
    insertSim = false;

  // preprocessor run if necessary
  QString preprocessor = Props.at(3)->Value;
  if (preprocessor != "none") {
    bool piping = true;
    QString script;
#ifdef __MINGW32__
    QString interpreter = "tinyperl.exe";
#else
    QString interpreter = "perl";
#endif
    if (preprocessor == "ps2sp") {
      script = "ps2sp";
    } else if (preprocessor == "spicepp") {
      script = "spicepp.pl";
    } else if (preprocessor == "spiceprm") {
      script = "spiceprm";
      piping = false;
    }
    script = QucsSettings.BinDir + script;
    SpicePrep = new Q3Process(this);
    SpicePrep->addArgument(interpreter);
    SpicePrep->addArgument(script);
    SpicePrep->addArgument(*SpiceFile);

    QFile PrepFile;
    QString PrepName = *SpiceFile + ".pre";

    if (!piping) {
      SpicePrep->addArgument(PrepName);
      connect(SpicePrep, SIGNAL(readyReadStdout()), SLOT(slotSkipOut()));
      connect(SpicePrep, SIGNAL(readyReadStderr()), SLOT(slotGetPrepErr()));
    } else {
      connect(SpicePrep, SIGNAL(readyReadStdout()), SLOT(slotGetPrepOut()));
      connect(SpicePrep, SIGNAL(readyReadStderr()), SLOT(slotGetPrepErr()));
    }

    QMessageBox *MBox = new QMessageBox(QObject::tr("Info"),
	       QObject::tr("Preprocessing SPICE file \"%1\".").arg(*SpiceFile),
               QMessageBox::NoIcon, QMessageBox::Abort,
               QMessageBox::NoButton, QMessageBox::NoButton, 0, 0, true,
	       Qt::WStyle_DialogBorder |  Qt::WDestructiveClose);
    connect(SpicePrep, SIGNAL(processExited()), MBox, SLOT(close()));

    if (piping) {
      PrepFile.setName(PrepName);
      if(!PrepFile.open(QIODevice::WriteOnly)) {
	ErrText +=
	  QObject::tr("ERROR: Cannot save preprocessed SPICE file \"%1\".").
	  arg(PrepName);
	return false;
      }
      prestream = new QTextStream(&PrepFile);
    }

    if(!SpicePrep->start()) {
      ErrText += QObject::tr("ERROR: Cannot execute \"%1\".").
	arg(interpreter + " " + script + "\".");
      if (piping) {
	PrepFile.close();
	delete prestream;
      }
      return false;
    }
    SpicePrep->closeStdin();

    MBox->exec();
    delete SpicePrep;
    if (piping) {
      PrepFile.close();
      delete prestream;
    }
    *SpiceFile = PrepName;
  }

  // begin command line construction
  QStringList com;
  com << (QucsSettings.BinDir + "qucsconv");
  if(makeSubcircuit) com << "-g" << "_ref";
  com << "-if" << "spice" << "-of" << "qucs";
  com << "-i" << *SpiceFile;

  // begin netlist text creation
  if(makeSubcircuit) {
    QString f = properFileName(*FileName);
    NetText += "\n.Def:" + properName(f) + " ";
    QString PortNames = Props.at(1)->Value;
    PortNames.replace(',', ' ');
    NetText += PortNames;
    if(makeSubcircuit) NetText += " _ref";
  }
  NetText += "\n";

  // startup SPICE conversion process
  QucsConv = new Q3Process(this);
  QucsConv->setArguments(com);
  connect(QucsConv, SIGNAL(readyReadStdout()), SLOT(slotGetNetlist()));
  connect(QucsConv, SIGNAL(readyReadStderr()), SLOT(slotGetError()));
  connect(QucsConv, SIGNAL(processExited()), SLOT(slotExited()));
  if(!QucsConv->start()) {
    ErrText += QObject::tr("ERROR: Cannot start QucsConv!");
    return false;
  }
  (*outstream) << NetText;
  (*filstream) << NetText;
  QucsConv->closeStdin();

  // waiting info dialog box
  QMessageBox *MBox = new QMessageBox(QObject::tr("Info"),
	       QObject::tr("Converting SPICE file \"%1\".").arg(*SpiceFile),
               QMessageBox::NoIcon, QMessageBox::Abort,
               QMessageBox::NoButton, QMessageBox::NoButton, 0, 0, true,
	       Qt::WStyle_DialogBorder | Qt::WDestructiveClose);
  connect(QucsConv, SIGNAL(processExited()), MBox, SLOT(close()));
  MBox->exec();

  // finish
  delete QucsConv;
  lastLoaded = QDateTime::currentDateTime();
  return true;
}