Commit b0f80cb8 authored by Simon Eugster's avatar Simon Eugster

Remove more QLocale usages and validate others

Related: #713
parent 91dafd60
Pipeline #24543 failed with stage
in 3 minutes and 43 seconds
......@@ -33,8 +33,6 @@ AssetCommand::AssetCommand(const std::shared_ptr<AssetParameterModel> &model, co
, m_updateView(false)
, m_stamp(QTime::currentTime())
{
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
m_name = m_model->data(index, AssetParameterModel::NameRole).toString();
const QString id = model->getAssetId();
if (EffectsRepository::get()->exists(id)) {
......@@ -43,26 +41,25 @@ AssetCommand::AssetCommand(const std::shared_ptr<AssetParameterModel> &model, co
setText(i18n("Edit %1", TransitionsRepository::get()->getName(id)));
}
QVariant previousVal = m_model->data(index, AssetParameterModel::ValueRole);
m_oldValue = previousVal.type() == QVariant::Double ? locale.toString(previousVal.toDouble()) : previousVal.toString();
m_oldValue = previousVal.type() == previousVal.toString();
}
void AssetCommand::undo()
{
m_model->setParameter(m_name, m_oldValue, true, m_index);
}
// virtual
void AssetCommand::redo()
{
m_model->setParameter(m_name, m_value, m_updateView, m_index);
m_updateView = true;
}
// virtual
int AssetCommand::id() const
{
return 1;
}
// virtual
bool AssetCommand::mergeWith(const QUndoCommand *other)
{
if (other->id() != id() || static_cast<const AssetCommand *>(other)->m_index != m_index ||
......@@ -82,8 +79,6 @@ AssetMultiCommand::AssetMultiCommand(const std::shared_ptr<AssetParameterModel>
, m_updateView(false)
, m_stamp(QTime::currentTime())
{
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
qDebug()<<"CREATING MULTIPLE COMMAND!!!\nVALUES: "<<m_values;
m_name = m_model->data(indexes.first(), AssetParameterModel::NameRole).toString();
const QString id = model->getAssetId();
......@@ -94,7 +89,7 @@ AssetMultiCommand::AssetMultiCommand(const std::shared_ptr<AssetParameterModel>
}
for (QModelIndex ix : m_indexes) {
QVariant previousVal = m_model->data(ix, AssetParameterModel::ValueRole);
m_oldValues << (previousVal.type() == QVariant::Double ? locale.toString(previousVal.toDouble()) : previousVal.toString());
m_oldValues << previousVal.toString());
}
}
......
......@@ -910,8 +910,6 @@ const QVector<QPair<QString, QVariant>> AssetParameterModel::loadPreset(const QS
void AssetParameterModel::setParameters(const QVector<QPair<QString, QVariant>> &params, bool update)
{
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
ObjectType itemId;
if (!update) {
// Change itemId to NoItem to ensure we don't send any update like refreshProjectItem that would trigger monitor refreshes.
......@@ -919,11 +917,7 @@ void AssetParameterModel::setParameters(const QVector<QPair<QString, QVariant>>
m_ownerId.first = ObjectType::NoItem;
}
for (const auto &param : params) {
if (param.second.type() == QVariant::Double) {
setParameter(param.first, locale.toString(param.second.toDouble()), false);
} else {
setParameter(param.first, param.second.toString(), false);
}
setParameter(param.first, param.second.toString(), false);
}
if (m_keyframes) {
m_keyframes->refresh();
......
......@@ -135,8 +135,6 @@ void AssetParameterView::setModel(const std::shared_ptr<AssetParameterModel> &mo
QVector<QPair<QString, QVariant>> AssetParameterView::getDefaultValues() const
{
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
QVector<QPair<QString, QVariant>> values;
for (int i = 0; i < m_model->rowCount(); ++i) {
QModelIndex index = m_model->index(i, 0);
......@@ -144,7 +142,7 @@ QVector<QPair<QString, QVariant>> AssetParameterView::getDefaultValues() const
auto type = m_model->data(index, AssetParameterModel::TypeRole).value<ParamType>();
QVariant defaultValue = m_model->data(index, AssetParameterModel::DefaultRole);
if (type == ParamType::KeyframeParam || type == ParamType::AnimatedRect) {
QString val = type == ParamType::KeyframeParam ? locale.toString(defaultValue.toDouble()) : defaultValue.toString();
QString val = defaultValue.toString();
if (!val.contains(QLatin1Char('='))) {
val.prepend(QStringLiteral("%1=").arg(m_model->data(index, AssetParameterModel::ParentInRole).toInt()));
defaultValue = QVariant(val);
......
......@@ -17,9 +17,6 @@
***************************************************************************/
#include "cubicbezierspline.h"
#include <QLocale>
#include <QStringList>
#include <QVector>
#include <cmath>
/** @brief For sorting a Bezier spline. Whether a is before b. */
......@@ -66,8 +63,6 @@ void CubicBezierSpline::fromString(const QString &spline)
QString CubicBezierSpline::toString() const
{
QStringList spline;
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
for (const BPoint &p : m_points) {
spline << QStringLiteral("%1;%2#%3;%4#%5;%6")
.arg(QString::number(p.h1.x(), 'f'), QString::number(p.h1.y(), 'f'), QString::number(p.p.x(), 'f'),
......
......@@ -407,7 +407,6 @@ template <typename CurveWidget_t> void CurveParamWidget<CurveWidget_t>::slotRefr
{
if (m_model->data(m_index, AssetParameterModel::TypeRole).template value<ParamType>() == ParamType::Curve) {
QList<QPointF> points;
QLocale locale;
// Rounding gives really weird results. (int) (10 * 0.3) gives 2! So for now, add 0.5 to get correct result
int number = m_model->data(m_index, AssetParameterModel::Enum3Role).toDouble() * 10 + 0.5;
int start = m_model->data(m_index, AssetParameterModel::MinRole).toInt();
......
......@@ -441,7 +441,7 @@ void KeyframeEdit::slotAdjustKeyframeInfo(bool seek)
m_position->setRange(min, max, true);
m_position->setPosition(getPos(item->row()));
m_position->blockSignals(false);
QLocale locale;
QLocale locale; // Used to convert user input → OK
for (int col = 0; col < keyframe_list->columnCount(); ++col) {
DoubleWidget *doubleparam = static_cast<DoubleWidget *>(m_slidersLayout->itemAtPosition(col, 0)->widget());
......
......@@ -646,7 +646,7 @@ void KeyframeImport::importSelectedData()
Fun redo = []() { return true; };
// Geometry target
int finalAlign = m_alignCombo->currentIndex();
QLocale locale;
QLocale locale; // Import from clipboard – OK to use locale here?
locale.setNumberOptions(QLocale::OmitGroupSeparator);
for (const auto &ix : m_indexes) {
// update keyframes in other indexes
......
......@@ -128,16 +128,8 @@ void ListParamWidget::slotRefresh()
if (names.count() != values.count()) {
names = values;
}
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
for (int i = 0; i < names.count(); i++) {
QString val = values.at(i);
bool ok;
double num = val.toDouble(&ok);
if (ok) {
val = locale.toString(num);
}
m_list->addItem(names.at(i), val);
m_list->addItem(names.at(i), values.at(i));
}
if (!value.isEmpty()) {
int ix = m_list->findData(value);
......
......@@ -29,7 +29,7 @@ ProjectSortProxyModel::ProjectSortProxyModel(QObject *parent)
, m_searchType(0)
, m_searchRating(0)
{
m_collator.setLocale(QLocale());
m_collator.setLocale(QLocale()); // Locale used for sorting → OK
m_collator.setCaseSensitivity(Qt::CaseInsensitive);
m_collator.setNumericMode(true);
m_selection = new QItemSelectionModel(this);
......
......@@ -331,7 +331,7 @@ void ProfilesDialog::slotUpdateDisplay(QString currentProfilePath)
m_view.profiles_list->blockSignals(false);
return;
}
QLocale locale;
QLocale locale; // Used for UI output → OK
locale.setNumberOptions(QLocale::OmitGroupSeparator);
m_selectedProfileIndex = m_view.profiles_list->currentIndex();
if (currentProfilePath.isEmpty()) {
......
......@@ -1740,7 +1740,12 @@ auto DocumentValidator::upgradeTo100(const QLocale &documentLocale) -> QString {
// List of properties which always need to be fixed
// Example: <property name="aspect_ratio">1,00247</property>
QList<QString> generalPropertiesToFix = {"warp_speed", "length", "aspect_ratio"};
QList<QString> generalPropertiesToFix = {
"warp_speed",
"length",
"aspect_ratio",
"kdenlive:clipanalysis.motion_vector_list",
};
// Fix properties just by name, anywhere in the file
auto props = m_doc.elementsByTagName(QStringLiteral("property"));
......
......@@ -155,7 +155,7 @@ bool ProxyJob::startJob()
mltParameters.append(QStringLiteral("terminate_on_pause=1"));
// TODO: currently, when rendering an xml file through melt, the display ration is lost, so we enforce it manually
mltParameters << QStringLiteral("aspect=") + QLocale().toString(display_ratio);
mltParameters << QStringLiteral("aspect=") + QString::number(display_ratio, 'f');
// Ask for progress reporting
mltParameters << QStringLiteral("progress=1");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment