Ejemplo n.º 1
0
void AntProjectPart::optionsAccepted()
{
  if (!m_antOptionsWidget || !m_classPathWidget)
    return;

  m_antOptions.m_buildXML = m_antOptionsWidget->BuildXML->url();

  switch (m_antOptionsWidget->Verbosity->currentItem())
  {
  case 1:
    m_antOptions.m_verbosity = AntOptions::Verbose;
    break;
  case 2:
    m_antOptions.m_verbosity = AntOptions::Debug;
    break;
  default:
    m_antOptions.m_verbosity = AntOptions::Quiet;
    break;
  }

  for (int i=0; i<m_antOptionsWidget->Properties->numRows(); ++i)
  {
    QString key = m_antOptionsWidget->Properties->text(i,0);
    m_antOptions.m_properties.replace(key, m_antOptionsWidget->Properties->text(i,1));
    kdDebug() << "PROP: " << key << "  = " << m_antOptionsWidget->Properties->text(i,1);

    QCheckTableItem *item =(QCheckTableItem*) m_antOptionsWidget->Properties->item(i,0);
    m_antOptions.m_defineProperties.replace(key, item->isChecked());
  }

  m_classPath = m_classPathWidget->ClassPath->items();

  m_antOptionsWidget = 0;
  m_classPathWidget = 0;
}
Ejemplo n.º 2
0
bool WatchersDialog::parseWatchers(CvsService_stub* cvsService, 
                                   const QStringList& files)
{
    setCaption(i18n("CVS Watchers"));

    DCOPRef job = cvsService->watchers(files);
    if( !cvsService->ok() )
        return false;

    ProgressDialog dlg(this, "Watchers", job, "watchers", i18n("CVS Watchers"));
    if( !dlg.execute() )
        return false;

    QString line;
    int numRows = 0;
    while( dlg.getLine(line) )
    {
        // parse the output line        
        QStringList list = splitLine(line);

        // ignore empty lines and unknown files
        if( list.isEmpty() || list[0] == "?" )
            continue;

        // add a new row to the table
        table->setNumRows(numRows + 1);

        table->setText(numRows, 0, list[0]);
        table->setText(numRows, 1, list[1]);

        QCheckTableItem* item = new QCheckTableItem(table, "");
        item->setChecked(list.contains("edit"));
        table->setItem(numRows, 2, item);

        item = new QCheckTableItem(table, "");
        item->setChecked(list.contains("unedit"));
        table->setItem(numRows, 3, item);

        item = new QCheckTableItem(table, "");
        item->setChecked(list.contains("commit"));
        table->setItem(numRows, 4, item);

        ++numRows;
    }

    return true;
}
Ejemplo n.º 3
0
void AntProjectPart::projectConfigWidget(KDialogBase *dlg)
{
  QVBox *vbox = dlg->addVBoxPage(i18n("Ant Options"));
  m_antOptionsWidget = new AntOptionsWidget(vbox);

  m_antOptionsWidget->BuildXML->setURL(m_antOptions.m_buildXML);

  switch (m_antOptions.m_verbosity)
  {
  case AntOptions::Quiet:
    m_antOptionsWidget->Verbosity->setCurrentItem(0);
    break;
  case AntOptions::Verbose:
    m_antOptionsWidget->Verbosity->setCurrentItem(1);
    break;
  default:
    m_antOptionsWidget->Verbosity->setCurrentItem(2);
    break;
  }

  m_antOptionsWidget->Properties->setNumRows(m_antOptions.m_properties.count());
  m_antOptionsWidget->Properties->setNumCols(2);

  QMap<QString,QString>::Iterator it;
  int i=0;
  for (it = m_antOptions.m_properties.begin(); it != m_antOptions.m_properties.end(); ++it)
  {
    QCheckTableItem *citem = new QCheckTableItem(m_antOptionsWidget->Properties, it.key());
    citem->setChecked(m_antOptions.m_defineProperties[it.key()]);
    m_antOptionsWidget->Properties->setItem(i,0, citem);
    QTableItem *item = new QTableItem(m_antOptionsWidget->Properties, QTableItem::WhenCurrent, it.data());
    m_antOptionsWidget->Properties->setItem(i,1, item);
    ++i;
  }

  connect(dlg, SIGNAL(okClicked()), this, SLOT(optionsAccepted()));

  vbox = dlg->addVBoxPage(i18n("Classpath"));
  m_classPathWidget = new ClassPathWidget(vbox);

  m_classPathWidget->ClassPath->insertStringList(m_classPath);
}
Ejemplo n.º 4
0
void fitDialog::accept()
{
    QString curve = boxCurve->currentText();
    QStringList curvesList = graph->curvesList();
    if (curvesList.contains(curve) <= 0)
    {
        QMessageBox::critical(this,tr("QtiPlot - Warning"),
                              tr("The curve <b> %1 </b> doesn't exist anymore! Operation aborted!").arg(curve));
        boxCurve->clear();
        boxCurve->insertStringList(curvesList);
        return;
    }

    if (!validInitialValues())
        return;

    QString from=boxFrom->text().lower();
    QString to=boxTo->text().lower();
    QString tolerance=boxTolerance->text().lower();
    double start,end,eps;
    try
    {
        myParser parser;
        parser.SetExpr(from.ascii());
        start=parser.Eval();
    }
    catch(mu::ParserError &e)
    {
        QMessageBox::critical(0, tr("QtiPlot - Start limit error"),e.GetMsg());
        boxFrom->setFocus();
        return;
    }

    try
    {
        myParser parser;
        parser.SetExpr(to.ascii());
        end=parser.Eval();
    }
    catch(mu::ParserError &e)
    {
        QMessageBox::critical(0, tr("QtiPlot - End limit error"),e.GetMsg());
        boxTo->setFocus();
        return;
    }

    if (start>=end)
    {
        QMessageBox::critical(0, tr("QtiPlot - Input error"),
                              tr("Please enter x limits that satisfy: from < end!"));
        boxTo->setFocus();
        return;
    }

    try
    {
        myParser parser;
        parser.SetExpr(tolerance.ascii());
        eps=parser.Eval();
    }
    catch(mu::ParserError &e)
    {
        QMessageBox::critical(0, tr("QtiPlot - Tolerance input error"),e.GetMsg());
        boxTolerance->setFocus();
        return;
    }

    if (eps<0 || eps>=1)
    {
        QMessageBox::critical(0, tr("QtiPlot - Tolerance input error"),
                              tr("The tolerance value must be positive and less than 1!"));
        boxTolerance->setFocus();
        return;
    }

    int i, n=0, rows=boxParams->numRows();
    if (boxParams->numCols() == 3)
    {
        for (i=0; i<rows; i++)
        {   //count the non-constant parameters
            QCheckTableItem *it = (QCheckTableItem *)boxParams->item (i, 2);
            if (!it->isChecked())
                n++;
        }
    }
    else
        n=rows;

    QStringList parameters, initialValues;
    myParser parser;
    bool error=FALSE;
    QString formula = boxFunction->text();
    try
    {
        bool withNames = containsUserFunctionName(formula);
        while(withNames)
        {
            for (i=0; i<(int)userFunctionNames.count(); i++)
            {
                if (formula.contains(userFunctionNames[i]))
                {
                    QStringList l = QStringList::split("=", userFunctions[i], true);
                    formula.replace(userFunctionNames[i], "(" + l[1] + ")");
                }
            }
            withNames = containsUserFunctionName(formula);
        }

        for (i=0; i<(int)builtInFunctionNames.count(); i++)
        {
            if (formula.contains(builtInFunctionNames[i]))
                formula.replace(builtInFunctionNames[i], "(" + builtInFunctions[i] + ")");
        }

        double *paramsInit = new double[n];
        if (boxParams->numCols() == 3)
        {
            for (i=0; i<rows; i++)
            {
                QCheckTableItem *it = (QCheckTableItem *)boxParams->item (i, 2);
                int j = 0;
                if (!it->isChecked())
                {
                    paramsInit[j]=boxParams->text(i,1).toDouble();
                    parser.DefineVar(boxParams->text(i,0).ascii(), &paramsInit[j]);
                    parameters<<boxParams->text(i,0);
                    initialValues<<boxParams->text(i,1);
                    j++;
                }
                else
                    formula.replace(boxParams->text(i,0), boxParams->text(i,1));
            }
        }
        else
        {
            for (i=0; i<n; i++)
            {
                paramsInit[i]=boxParams->text(i,1).toDouble();
                parser.DefineVar(boxParams->text(i,0).ascii(), &paramsInit[i]);
                parameters<<boxParams->text(i,0);
                initialValues<<boxParams->text(i,1);
            }
        }

        parser.SetExpr(formula.ascii());
        double x=start;
        parser.DefineVar("x", &x);
        parser.Eval();
        delete[] paramsInit;
    }
    catch(mu::ParserError &e)
    {
        QString errorMsg = boxFunction->text() + " = " + formula + "\n" + e.GetMsg() + "\n" +
                           tr("Please verify that you have initialized all the parameters!");

        QMessageBox::critical(0, tr("QtiPlot - Input function error"), errorMsg);
        boxFunction->setFocus();
        error = true;
    }

    if (!error)
    {
        ApplicationWindow *app = (ApplicationWindow *)this->parent();
        graph->setFitID(++app->fitNumber);
        QString result;
        if (boxUseBuiltIn->isChecked() && categoryBox->currentItem() == 1)
            result = fitBuiltInFunction(curve,funcBox->currentText(),initialValues, start,end,
                                        boxPoints->value(),boxSolver->currentItem(),eps, boxColor->currentItem());
        else if (boxUseBuiltIn->isChecked() && categoryBox->currentItem() == 3)
        {
            result = graph->fitPluginFunction(curve, pluginFilesList[funcBox->currentItem()],
                                              initialValues, start, end, boxPoints->value(),
                                              boxSolver->currentItem(), eps, boxColor->currentItem());
        }
        else
            result = graph->fitNonlinearCurve(curve, lblFunction->text()+"="+formula, parameters, initialValues,
                                              start, end, boxPoints->value(), boxSolver->currentItem(), eps, boxColor->currentItem());

        QStringList res = graph->fitResults();
        if (boxParams->numCols() == 3)
        {
            int j = 0;
            for (i=0; i<rows; i++)
            {
                QCheckTableItem *it = (QCheckTableItem *)boxParams->item (i, 2);
                if (!it->isChecked())
                    boxParams->setText(i, 1, res[j++]);
            }
        }
        else
        {
            for (i=0; i<rows; i++)
                boxParams->setText(i, 1, res[i]);
        }

        app->updateLog(result);
    }
}