コード例 #1
0
bool Double2StringFilter::load(XmlStreamReader* reader) {
  QXmlStreamAttributes attribs = reader->attributes();
  QString format_str =
      attribs.value(reader->namespaceUri().toString(), "format").toString();
  QString digits_str =
      attribs.value(reader->namespaceUri().toString(), "digits").toString();

  if (AbstractSimpleFilter::load(reader)) {
    bool ok;
    int digits = digits_str.toInt(&ok);
    if ((format_str.size() != 1) || !ok)
      reader->raiseError(tr("missing or invalid format attribute(s)"));
    else {
      setNumericFormat(format_str.at(0).toAscii());
      setNumDigits(digits);
    }
  } else
    return false;

  return !reader->hasError();
}
コード例 #2
0
void TableDialog::updatePrecision(int prec)
{
    setNumericFormat(formatBox->currentIndex(), prec, applyToRightCols->isChecked());
}
コード例 #3
0
void TableDialog::apply()
{
    if (colName->text().contains("_")){
        QMessageBox::warning(this, tr("MantidPlot - Warning"),
        tr("For internal consistency reasons the underscore character is replaced with a minus sign."));}

    QString name=colName->text().replace("-", "_");
    if (name.contains(QRegExp("\\W"))){
        QMessageBox::warning(this,tr("MantidPlot - Error"), tr("The column names must only contain letters and digits!"));
        name.remove(QRegExp("\\W"));
	}

    int sc = d_table->selectedColumn();
    d_table->setColumnWidth(colWidth->value(), applyToAllBox->isChecked());
    d_table->setColComment(sc, comments->text().replace("\n", " ").replace("\t", " "));
    d_table->setColName(sc, name.replace("_", "-"), enumerateAllBox->isChecked());

    bool rightColumns = applyToRightCols->isChecked();
    if (rightColumns){
        bool readOnly = boxReadOnly->isChecked();
		for (int i = sc; i<d_table->numCols(); i++){
            d_table->setReadOnlyColumn(i, readOnly);
			d_table->hideColumn(i, boxHideColumn->isChecked());
		}
    } else {
        d_table->setReadOnlyColumn(sc, boxReadOnly->isChecked());
		d_table->hideColumn(sc, boxHideColumn->isChecked());
	}

    int format = formatBox->currentIndex();
    int colType = displayBox->currentIndex();
    switch(colType)
	{
	case 0:
		setNumericFormat(formatBox->currentIndex(), precisionBox->value(), rightColumns);
	break;

	case 1:
		setTextFormat(rightColumns);
	break;

	case 2:
		 setDateTimeFormat(colType, formatBox->currentText(), rightColumns);
	break;

	case 3:
		setDateTimeFormat(colType, formatBox->currentText(), rightColumns);
	break;

	case 4:
        if(format == 0)
            setMonthFormat("MMM", rightColumns);
        else if(format == 1)
            setMonthFormat("MMMM", rightColumns);
        else if(format == 2)
            setMonthFormat("M", rightColumns);
	break;

	case 5:
        if(format == 0)
            setDayFormat("ddd", rightColumns);
        else if(format == 1)
            setDayFormat("dddd", rightColumns);
        else if(format == 2)
            setDayFormat("d", rightColumns);
	break;
	}
}