Example #1
0
/*!
    \property QProgressBar::text
    \brief the descriptive text shown with the progress bar

    The text returned is the same as the text displayed in the center
    (or in some styles, to the left) of the progress bar.

    The progress shown in the text may be smaller than the minimum value,
    indicating that the progress bar is in the "reset" state before any
    progress is set.

    In the default implementation, the text either contains a percentage
    value that indicates the progress so far, or it is blank because the
    progress bar is in the reset state.
*/
QString QProgressBar::text() const
{
    Q_D(const QProgressBar);
    if ((d->maximum == 0 && d->minimum == 0) || d->value < d->minimum
            || (d->value == INT_MIN && d->minimum == INT_MIN))
        return QString();

    qint64 totalSteps = qint64(d->maximum) - d->minimum;

    QString result = d->format;
    QLocale locale = d->locale; // Omit group separators for compatibility with previous versions that were non-localized.
    locale.setNumberOptions(locale.numberOptions() | QLocale::OmitGroupSeparator);
    result.replace(QLatin1String("%m"), locale.toString(totalSteps));
    result.replace(QLatin1String("%v"), locale.toString(d->value));

    // If max and min are equal and we get this far, it means that the
    // progress bar has one step and that we are on that step. Return
    // 100% here in order to avoid division by zero further down.
    if (totalSteps == 0) {
        result.replace(QLatin1String("%p"), locale.toString(int(100)));
        return result;
    }

    int progress = (qreal(d->value) - d->minimum) * 100.0 / totalSteps;
    result.replace(QLatin1String("%p"), locale.toString(progress));
    return result;
}
void testGetNumeric(QInputDialog *dialog, SpinBoxType * = 0, ValueType * = 0)
{
    SpinBoxType *sbox = qFindChild<SpinBoxType *>(dialog);
    QVERIFY(sbox != 0);

    QLineEdit *ledit = qFindChild<QLineEdit *>(static_cast<QObject *>(sbox));
    QVERIFY(ledit != 0);

    QDialogButtonBox *bbox = qFindChild<QDialogButtonBox *>(dialog);
    QVERIFY(bbox != 0);
    QPushButton *okButton = bbox->button(QDialogButtonBox::Ok);
    QVERIFY(okButton != 0);

    QVERIFY(sbox->value() >= sbox->minimum());
    QVERIFY(sbox->value() <= sbox->maximum());
    QVERIFY(sbox->hasAcceptableInput());
    QLocale loc;
    QCOMPARE(
        normalizeNumericString(ledit->selectedText()),
        normalizeNumericString(loc.toString(sbox->value())));
    QVERIFY(okButton->isEnabled());

    const ValueType origValue = sbox->value();

    testInvalidateAndRestore<SpinBoxType, ValueType>(sbox, okButton, ledit);
    testTypingValue<SpinBoxType>(sbox, okButton, QString("%1").arg(sbox->minimum()));
    testTypingValue<SpinBoxType>(sbox, okButton, QString("%1").arg(sbox->maximum()));
    testTypingValue<SpinBoxType>(sbox, okButton, QString("%1").arg(sbox->minimum() - 1));
    testTypingValue<SpinBoxType>(sbox, okButton, QString("%1").arg(sbox->maximum() + 1));
    testTypingValue<SpinBoxType>(sbox, okButton, "0");
    testTypingValue<SpinBoxType>(sbox, okButton, "0.0");
    testTypingValue<SpinBoxType>(sbox, okButton, "foobar");

    testTypingValue<SpinBoxType>(sbox, okButton, loc.toString(origValue));
}
// -------------------------------------------------------------------------------------------------
void ParameterBox::updateValues() throw ()
{
    QLocale loc;
    
    // update the left value
    if (m_leftValue < 0.0)
    {
        m_leftMarker->setText(tr("(no marker)"));
    }
    else
    {
        m_leftMarker->setText(loc.toString(m_leftValue, 'f', 4) + " ms");
    }
    
    
    // update the right value
    if (m_rightValue < 0.0)
    {
        m_rightMarker->setText(tr("(no marker)"));
    }
    else
    {
        m_rightMarker->setText(loc.toString(m_rightValue, 'f', 4) + " ms");
    }
    
    // update the diff display
    if (m_leftValue < 0.0 || m_rightValue < 0.0)
    {
        m_diff->setText(tr("(no difference)"));
    }
    else
    {
        m_diff->setText(loc.toString(m_rightValue - m_leftValue, 'f', 4) + " ms");
    }
}
Example #4
0
// Returns the size in human readable format
QString MainWindow::readableSize( qint64 size ) const
{
    static const QString sizeStrs[] = {
        tr("B"), tr("KiB"), tr("MiB"), tr("GiB"), tr("TiB") };

    QLocale defaultLocale;
    unsigned int i;
    double humanSize = size;

    for ( i=0; i+1 < (sizeof(sizeStrs)/sizeof(QString)) && (humanSize/1024.0) >= 1024.0; i++ )
        humanSize /= 1024.0;

    if ( humanSize >= 1024.0 ) {
        humanSize /= 1024.0;
        i++;
    }

    QString output;
    if ( i == 0 )
        // No decimal part if we display straight bytes.
        output = defaultLocale.toString( (int) humanSize );
    else
        output = defaultLocale.toString( humanSize, 'f', 1 );

    output += QString(" ") + sizeStrs[i];

    return output;
}
Example #5
0
QString MultiPeakFit::logFitInfo(int iterations, int status)
{
	QString info = Fit::logFitInfo(iterations, status);
	if (d_peaks == 1)
		return info;

    ApplicationWindow *app = (ApplicationWindow *)parent();
    QLocale locale = app->locale();

	info += tr("Peak") + "\t" + tr("Area") + "\t";
	info += tr("Center") + "\t" + tr("Width") + "\t" + tr("Height") + "\n";
	info += "---------------------------------------------------------------------------------------\n";
	for (int j=0; j<d_peaks; j++){
		info += QString::number(j+1) + "\t";
		info += locale.toString(d_results[3*j], 'e', d_prec) + "\t";
		info += locale.toString(d_results[3*j+1], 'e', d_prec) + "\t";
		info += locale.toString(d_results[3*j+2], 'e', d_prec) + "\t";

		if (d_profile == Lorentz)
			info += locale.toString(M_2_PI*d_results[3*j]/d_results[3*j+2], 'e', d_prec) + "\n";
		else
			info += locale.toString(sqrt(M_2_PI)*d_results[3*j]/d_results[3*j+2], 'e', d_prec) + "\n";
	}
	info += "---------------------------------------------------------------------------------------\n";
	return info;
}
void SupportedProtocolsDialog::updateStatistics()
{
    QLocale locale = QLocale::system();
    QString hint = tr("%1 protocols, %2 fields.")
            .arg(locale.toString(ui->protoTreeWidget->topLevelItemCount()))
            .arg(locale.toString(field_count_));
    ui->hintLabel->setText(hint);
}
void SupportedProtocolsDialog::updateStatistics()
{
    QLocale locale = QLocale::system();
    QString hint = tr("%1 protocols, %2 fields.")
                   .arg(locale.toString(ui->protoTreeWidget->topLevelItemCount()))
                   .arg(locale.toString(field_count_));
    ui->hintLabel->setText(hint);
    wsApp->processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers, 1);
}
Example #8
0
void Differentiation::output()
{
    double *result = new double[d_n - 1];
	for (int i = 1; i < d_n - 1; i++){
		double xl = d_x[i - 1];
		double xc = d_x[i];
		double xr = d_x[i + 1];

		if (xr != xc && xl != xc)
			result[i] = 0.5*((d_y[i + 1] - d_y[i])/(xr - xc) + (d_y[i] - d_y[i - 1])/(xc - xl));
		else if (xr != xc)
			result[i] = (d_y[i + 1] - d_y[i])/(xr - xc);
		else if (xl != xc)
			result[i] = (d_y[i] - d_y[i - 1])/(xc - xl);
		else
			result[i] = result[i - 1];
	}

    ApplicationWindow *app = (ApplicationWindow *)parent();
    QLocale locale = app->locale();
    QString tableName = app->generateUniqueName(QString(objectName()));
    QString dataSet;
	if (d_curve)
		dataSet = d_curve->title().text();
	else
		dataSet = d_y_col_name;

    int prec = app->d_decimal_digits;
	int rows = d_n - 2;
	int col = 1;
	if (!d_result_table || d_result_table->numRows() < rows){
		d_result_table = app->newHiddenTable(tableName, tr("Derivative") + " " + tr("of", "Derivative of")  + " " + dataSet, rows, 2);
		for (int i = 1; i < d_n-1; i++) {
			int aux = i - 1;
			d_result_table->setText(aux, 0, locale.toString(d_x[i], 'g', prec));
			d_result_table->setText(aux, 1, locale.toString(result[i], 'g', prec));
		}
	} else {
		col = d_result_table->numCols();
		d_result_table->addCol();
		for (int i = 1; i < d_n-1; i++)
			d_result_table->setText(i - 1, col, locale.toString(result[i], 'g', prec));
	}

    delete[] result;

	if (d_graphics_display){
		if (!d_output_graph){
			createOutputGraph();
			d_output_graph->removeLegend();
		}

		d_output_graph->insertCurve(d_result_table, d_result_table->colLabel(col), 0);
		if (d_update_output_graph)
			d_output_graph->updatePlot();
	}
}
Example #9
0
void NumberFormatsWidget::localeChanged(QLocale locale)
{
    number1->setText(locale.toString(-123456));
    number2->setText(locale.toString(1234.56, 'f', 2));
    number3->setText(locale.toString(1234.56, 'e', 4));

    measurementSystem->setText(
                locale.measurementSystem() == QLocale::ImperialSystem ? "US" : "Metric");
}
Example #10
0
QString CallgrindHelper::toPercent(float costs, const QLocale &locale)
{
    if (costs > 99.9f)
        return locale.toString(100) + locale.percent();
    if (costs > 9.99f)
        return locale.toString(costs, 'f', 1) + locale.percent();
    if (costs > 0.009f)
        return locale.toString(costs, 'f', 2) + locale.percent();
    return QString("<") + locale.toString(0.01f) + locale.percent();
}
Example #11
0
QStringList PluginGauss::toCSV(const QJsonObject& data, const QLocale& csvLocale)
{
    QStringList list;
    list << csvLocale.toString(data[DATE_GAUSS_AGE_STR].toDouble());
    list << csvLocale.toString(data[DATE_GAUSS_ERROR_STR].toDouble());
    list << csvLocale.toString(data[DATE_GAUSS_A_STR].toDouble());
    list << csvLocale.toString(data[DATE_GAUSS_B_STR].toDouble());
    list << csvLocale.toString(data[DATE_GAUSS_C_STR].toDouble());
    return list;
}
Example #12
0
QString datetimeToString(QDateTime datetime)
{
    QLocale locale;

    // return time for today or date for older
    if (datetime.date() == QDate::currentDate())
        return locale.toString(datetime.time(), QLocale::NarrowFormat);

    return locale.toString(datetime.date(), QLocale::NarrowFormat);
}
Example #13
0
 QStringList LightInSurfacePosition::info() const
{
	QLocale locale; 
	auto position4 = m_transformation * make_float4(initialPosition, 1.0f);
	auto position = optix::make_float3(position4 / position4.w);
	auto x = locale.toString(position.x, 'f', 2);
	auto y = locale.toString(position.y, 'f', 2);
	auto z = locale.toString(position.z, 'f', 2);
	return QStringList() << x << y << z;
}
Example #14
0
QStringList Plugin14C::toCSV(const QJsonObject& data, const QLocale& csvLocale)
{
    QStringList list;
    list << csvLocale.toString(data[DATE_14C_AGE_STR].toDouble());
    list << csvLocale.toString(data[DATE_14C_ERROR_STR].toDouble());
    list << data[DATE_14C_REF_CURVE_STR].toString();
    list << csvLocale.toString(data[DATE_14C_DELTA_R_STR].toDouble());
    list << csvLocale.toString(data[DATE_14C_DELTA_R_ERROR_STR].toDouble());
    return list;
}
Example #15
0
void MyCalendar::updateDate()
{
    QDateTime dateTmp;
    int currentDay;
    QLocale local = QLocale::English;
    if (local.toString(date, "ddd") == "Sun")
        currentDay = 0;
    else if (local.toString(date, "ddd") == "Mon")
        currentDay = 1;
    else if (local.toString(date, "ddd") == "Tue")
        currentDay = 2;
    else if (local.toString(date, "ddd") == "Wed")
        currentDay = 3;
    else if (local.toString(date, "ddd") == "Thu")
        currentDay = 4;
    else if (local.toString(date, "ddd") == "Fri")
        currentDay = 5;
    else if (local.toString(date, "ddd") == "Sat")
        currentDay = 6;

    for(int i = 0; i < 7; i++)
    {
        dateTmp = date.addDays(-currentDay + i);
        ui->scheduleTable->setItem(0, i + 1, new QTableWidgetItem(local.toString(dateTmp,"yy/MM/dd ddd.")));
    }
}
Example #16
0
QMap<QString, QString> TransitionHandler::getTransitionParamsFromXml(const QDomElement &xml)
{
    QDomNodeList attribs = xml.elementsByTagName(QStringLiteral("parameter"));
    QMap<QString, QString> map;
    QLocale locale;
    for (int i = 0; i < attribs.count(); ++i) {
        QDomElement e = attribs.item(i).toElement();
        QString name = e.attribute(QStringLiteral("name"));
        map[name] = e.attribute(QStringLiteral("default"));
        if (e.hasAttribute(QStringLiteral("value"))) {
            map[name] = e.attribute(QStringLiteral("value"));
        }
        double factor = e.attribute(QStringLiteral("factor"), QStringLiteral("1")).toDouble();
        double offset = e.attribute(QStringLiteral("offset"), QStringLiteral("0")).toDouble();
        if (factor!= 1 || offset != 0) {
            if (e.attribute(QStringLiteral("type")) == QLatin1String("simplekeyframe")) {
                QStringList values = e.attribute(QStringLiteral("value")).split(';', QString::SkipEmptyParts);
                for (int j = 0; j < values.count(); ++j) {
                    QString pos = values.at(j).section(QLatin1Char('='), 0, 0);
                    double val = (values.at(j).section(QLatin1Char('='), 1, 1).toDouble() - offset) / factor;
                    values[j] = pos + '=' + locale.toString(val);
                }
                map[name] = values.join(QLatin1Char(';'));
            } else if (e.attribute(QStringLiteral("type")) != QLatin1String("addedgeometry")) {
                map[name] = locale.toString((locale.toDouble(map.value(name)) - offset) / factor);
                //map[name]=map[name].replace(".",","); //FIXME how to solve locale conversion of . ,
            }
        }
        if (e.attribute(QStringLiteral("namedesc")).contains(';')) {
            //TODO: Deprecated, does not seem used anywhere...
            QString format = e.attribute(QStringLiteral("format"));
            QStringList separators = format.split(QStringLiteral("%d"), QString::SkipEmptyParts);
            QStringList values = e.attribute(QStringLiteral("value")).split(QRegExp("[,:;x]"));
            QString neu;
            QTextStream txtNeu(&neu);
            if (values.size() > 0)
                txtNeu << (int)values[0].toDouble();
            int i = 0;
            for (i = 0; i < separators.size() && i + 1 < values.size(); ++i) {
                txtNeu << separators[i];
                txtNeu << (int)(values[i+1].toDouble());
            }
            if (i < separators.size())
                txtNeu << separators[i];
            map[e.attribute(QStringLiteral("name"))] = neu;
        }

    }
    return map;
}
Example #17
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void FloatVec3Widget::setupGui()
{
  // Catch when the filter is about to execute the preflight
  connect(getFilter(), SIGNAL(preflightAboutToExecute()),
          this, SLOT(beforePreflight()));

  // Catch when the filter is finished running the preflight
  connect(getFilter(), SIGNAL(preflightExecuted()),
          this, SLOT(afterPreflight()));

  // Catch when the filter wants its values updated
  connect(getFilter(), SIGNAL(updateFilterParameters(AbstractFilter*)),
          this, SLOT(filterNeedsInputParameters(AbstractFilter*)));


  connect(xData, SIGNAL(textChanged(const QString&)),
          this, SLOT(widgetChanged(const QString&) ) );
  connect(yData, SIGNAL(textChanged(const QString&)),
          this, SLOT(widgetChanged(const QString&) ) );
  connect(zData, SIGNAL(textChanged(const QString&)),
          this, SLOT(widgetChanged(const QString&) ) );

  QLocale loc = QLocale::system();

  QDoubleValidator* xVal = new QDoubleValidator(xData);
  xData->setValidator(xVal);
  xVal->setLocale(loc);

  QDoubleValidator* yVal = new QDoubleValidator(yData);
  yData->setValidator(yVal);
  yVal->setLocale(loc);

  QDoubleValidator* zVal = new QDoubleValidator(zData);
  zData->setValidator(zVal);
  zVal->setLocale(loc);
  if (getFilterParameter() != NULL)
  {
    label->setText(getFilterParameter()->getHumanLabel() );

    FloatVec3_t data = getFilter()->property(PROPERTY_NAME_AS_CHAR).value<FloatVec3_t>();

    xData->setText(loc.toString(data.x));
    yData->setText(loc.toString(data.y));
    zData->setText(loc.toString(data.z));
  }

  errorLabel->hide();

}
Example #18
0
QwtPlotCurve* Filter::addResultCurve(double *x, double *y)
{
    ApplicationWindow *app = (ApplicationWindow *)parent();
    QLocale locale = app->locale();
    const QString tableName = app->generateUniqueName(QString(objectName()));
	QString dataSet;
	if (d_curve)
		dataSet = d_curve->title().text();
	else
		dataSet = d_y_col_name;

    d_result_table = app->newHiddenTable(tableName, d_explanation + " " + tr("of") + " " + dataSet, d_points, 2);
	for (int i=0; i<d_points; i++){
		d_result_table->setText(i, 0, locale.toString(x[i], 'e', app->d_decimal_digits));
		d_result_table->setText(i, 1, locale.toString(y[i], 'e', app->d_decimal_digits));
	}

	DataCurve *c = 0;
	if (d_graphics_display){
		c = new DataCurve(d_result_table, tableName + "_1", tableName + "_2");
		c->setData(x, y, d_points);
    	c->setPen(QPen(ColorBox::color(d_curveColorIndex), 1));

		if (!d_output_graph)
			d_output_graph = createOutputGraph()->activeGraph();

		d_output_graph->insertPlotItem(c, Graph::Line);
    	d_output_graph->updatePlot();
	}
	return (QwtPlotCurve*)c;
}
Example #19
0
QString BitcoinUnits::format(int unit, qint64 n, bool fPlus)
{
    // Note: not using straight sprintf here because we do NOT want
    // localized number formatting.
    if(!valid(unit))
        return QString(); // Refuse to format invalid unit
    qint64 coin = factor(unit);
    int num_decimals = decimals(unit);
    qint64 n_abs = (n > 0 ? n : -n);
    qint64 quotient = n_abs / coin;
    qint64 remainder = n_abs % coin;
    QString remainder_str = QString::number(remainder).rightJustified(num_decimals, '0');

    // Right-trim excess zeros after the decimal point
    int nTrim = 0;
    for (int i = remainder_str.size()-1; i>=2 && (remainder_str.at(i) == '0'); --i)
        ++nTrim;
    remainder_str.chop(nTrim);

    QString quotientString;

    if (n < 0) {
        quotient = -quotient;
    }
    else if ( n > 0 && fPlus ) {
        quotientString += "+";
    }

    QLocale local;
    return quotientString + local.toString(quotient) + local.decimalPoint() + remainder_str;
}
Example #20
0
QString KPropertySizeFDelegate::valueToString(const QVariant& value, const QLocale &locale) const
{
    const QSizeF s(value.toSizeF());
    if (s.isNull()) {
        if (locale.language() == QLocale::C) {
            return QString();
        }
        return QObject::tr("None", "Null value");
    }
    if (locale.language() == QLocale::C) {
        return QString::fromLatin1("%1x%2").arg(s.width()).arg(s.height());
    }
    return QObject::tr("%1x%2", "Size")
        .arg(locale.toString(s.width()))
        .arg(locale.toString(s.height()));
}
Example #21
0
/*!
 * \brief GUI::ChangeDeleteUserDialog::slotUpdateUserData
 * Setzt die Benutzerdaten des aktuell selektierten mSelectedEmail in den dazugehörigen Gui Elementen.
 */
void GUI::ChangeDeleteUserDialog::slotUpdateUserData()
{
    mHousehold->retrieveUserList(mUserList);
    if(!mUserList.isEmpty())
    {
        for(int i = 0; i < mUserList.size(); i++)
        {
			if(mUserList.at(i).getEmail() == mSelectedEmail)
            {
				ui->forenameLineEdit->setText(mUserList.at(i).getFirstName());
				ui->familyNameLineEdit->setText(mUserList.at(i).getLastName());
                ui->birthDayDateEdit->setDate(mUserList.at(i).getBirthDate());
                if(mUserList.at(i).getLocked() == true)
                {
                    ui->lockedCheckBox->setChecked(true);
                }
                QLocale locale = QLocale(QLocale::English, QLocale::UnitedStates);


                ui->balanceLineEdit->setText(locale.toString(mUserList.at(i).getBalance(),'f',2).remove(","));
				ui->emailLineEdit->setText(mUserList.at(i).getEmail());
                mSelectedUserId = mUserList.at(i).getUserId();
            }
        }
    }
}
Example #22
0
QString DSliderSpinBox::valueString() const
{
    const Q_D(DSliderSpinBox);

    QLocale locale;
    return locale.toString((double)d->value, 'f', d->validator->decimals());
}
Example #23
0
void TimelineVis::processVis()
{
    proc_to_order = QMap<int, int>();
    order_to_proc = QMap<int, int>();
    for (int i = 0; i < trace->num_tasks; i++) {
        proc_to_order[i] = i;
        order_to_proc[i] = i;
    }

    // Determine needs for task labels
    int max_task = pow(10,ceil(log10(trace->num_tasks)) + 1) - 1;
    QPainter * painter = new QPainter();
    painter->begin(this);
    painter->setPen(Qt::black);
    painter->setFont(QFont("Helvetica", 10));
    QLocale systemlocale = QLocale::system();
    QFontMetrics font_metrics = painter->fontMetrics();
    QString testString = systemlocale.toString(max_task);
    labelWidth = font_metrics.width(testString);
    labelHeight = font_metrics.height();
    labelDescent = font_metrics.descent();
    painter->end();
    delete painter;

    visProcessed = true;
}
Example #24
0
QWidget *
ChannelMapDelegate::createEditor(QWidget *parent,
                                 const QStyleOptionViewItem &/*option*/,
                                 const QModelIndex &index) const
{
    assert(index.isValid());
    int channelCount;
    QString name;
    switch (index.column()) {
    case CHANNELMAPTABLECOLUMN_INPUT_CHANNEL:
        channelCount = inputChannelCount;
        name = inputName;
        break;
    case CHANNELMAPTABLECOLUMN_OUTPUT_CHANNEL:
        channelCount = outputChannelCount;
        name = outputName;
        break;
    default:
        assert(false);
    }
    QComboBox *comboBox = new QComboBox(parent);
    QLocale locale = QLocale::system();
    for (int i = 1; i <= channelCount; i++) {
        comboBox->addItem(tr("%1 - Channel %2").arg(name, locale.toString(i)));
    }
    return comboBox;
}
Example #25
0
QV4::ReturnedValue QQmlNumberExtension::method_toLocaleCurrencyString(QV4::CallContext *ctx)
{
    if (ctx->argc() > 2)
        V4THROW_ERROR("Locale: Number.toLocaleCurrencyString(): Invalid arguments");

    double number = ctx->thisObject().toNumber();

    if (ctx->argc() == 0) {
        // Use QLocale for standard toLocaleString() function
        QLocale locale;
        return ctx->d()->engine->newString(locale.toString(number))->asReturnedValue();
    }

    if (!isLocaleObject(ctx->args()[0]))
        V4THROW_ERROR("Locale: Number.toLocaleCurrencyString(): Invalid arguments");

    QV4::Scope scope(ctx);

    GET_LOCALE_DATA_RESOURCE(ctx->args()[0]);

    QString symbol;
    if (ctx->argc() > 1) {
        if (!ctx->args()[1].isString())
            V4THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments");
        symbol = ctx->args()[1].toQStringNoThrow();
    }

    return ctx->d()->engine->newString(r->d()->locale.toCurrencyString(number, symbol))->asReturnedValue();
}
Example #26
0
QString DDoubleSliderSpinBox::valueString() const
{
    const Q_D(DAbstractSliderSpinBox);

    QLocale locale;
    return locale.toString((double)d->value / d->factor, 'f', d->validator->decimals());
}
Example #27
0
QString filesizeToString(qint64 filesize)
{
    // convert to kB, MB, GB: use 1000 instead of 1024 as divisor because it seems to be
    // the usual way to display file size (like on Ubuntu)
    QLocale locale;
    if (filesize < 1000LL)
        return locale.toString(filesize)+" bytes";

    if (filesize < 1000000LL)
        return locale.toString((double)filesize/1000.0, 'f', 2)+" kB";

    if (filesize < 1000000000LL)
        return locale.toString((double)filesize/1000000.0, 'f', 2)+" MB";

    return locale.toString((double)filesize/1000000000.0, 'f', 2)+" GB";
}
Example #28
0
void BinController::saveDocumentProperties(const QMap <QString, QString> props, const QMap <double, QString> guidesData)
{
    // Clear previous properites
    Mlt::Properties playlistProps(m_binPlaylist->get_properties());
    Mlt::Properties docProperties;
    docProperties.pass_values(playlistProps, "kdenlive:docproperties.");
    for (int i = 0; i < docProperties.count(); i++) {
        QString propName = QStringLiteral("kdenlive:docproperties.") + docProperties.get_name(i);
        playlistProps.set(propName.toUtf8().constData(), (char *)NULL);
    }
    // Clear previous guides
    Mlt::Properties guideProperties;
    guideProperties.pass_values(playlistProps, "kdenlive:guide.");
    for (int i = 0; i < guideProperties.count(); i++) {
        QString propName = QStringLiteral("kdenlive:guide.") + guideProperties.get_name(i);
        playlistProps.set(propName.toUtf8().constData(), (char *)NULL);
    }

    QMapIterator<QString, QString> i(props);
    while (i.hasNext()) {
        i.next();
        playlistProps.set(("kdenlive:docproperties." + i.key()).toUtf8().constData(), i.value().toUtf8().constData());
    }

    // Append guides
    QMapIterator<double, QString> g(guidesData);
    QLocale locale;
    while (g.hasNext()) {
        g.next();
        QString propertyName = "kdenlive:guide." + locale.toString(g.key());
        playlistProps.set(propertyName.toUtf8().constData(), g.value().toUtf8().constData());
    }
}
Example #29
0
void ThreadRunnerDlgImpl::onUpdateTimer()
{
    QString s;
    if (m_bShowCounter)
    {
        static QLocale loc ("C");
        s = loc.toString(m_nCounter) + ". ";
    }

    int n ((int)m_vStepInfo.size());
    if (n >= 1)
    {
        s = truncateLarge(s + m_vStepInfo[0], s.size());

        for (int i = 1; i < n; ++i)
        {
            s += "\n" + truncateLarge(m_vStepInfo[i]);
        }
    }

    time_t t (time(0));
    if (m_bShowPauseAbort)
    {
        s += tr("\n\nTotal time: %1" // ttt1 show Total time only if different from Running time
            "\nRunning time: %2").arg(getTimeFmt(t - m_tRealBegin)).arg(getTimeFmt((m_pThread->m_bPaused ? m_tPauseBegin : t) - m_tRunningBegin));
    }
    else
    {
        s += "\n\n" + tr("Time: %1").arg(getTimeFmt(t - m_tRealBegin));
    }

    m_pCurrentL->setText(s);
}
Example #30
0
void PartDetailsDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
    QLabel * label = dynamic_cast<QLabel*>(editor);
    if(label && index.isValid()){
        int column = index.column();
        QString text;
        if(column==PartsSqlTableModel::ColumnCreateDate){
            QDateTime date = index.data(Qt::EditRole).toDateTime();
            QLocale locale;
            text = locale.toString(date, QLocale::ShortFormat);
        }
        else if(column==PartsSqlTableModel::ColumnActualStock || column==PartsSqlTableModel::ColumnMinStock){
            QVariant stockVar = index.data(Qt::EditRole);
            if(stockVar.isValid()){
                QVariant partUnitVar = index.model()->index(index.row(), PartsSqlTableModel::ColumnPartUnit).data();
                QString posfix = partUnitVar.isValid() ? partUnitVar.toString() : QString();
                text = QString("%1 %2").arg(stockVar.toInt()).arg(posfix);
            }            
        }
        else{
            text = index.data(Qt::DisplayRole).toString();
        }
        label->setText(text);
    }
    else {
        setEditorData(editor, index);
    }
}