Commit 749d5e59 authored by Vincent Pinon's avatar Vincent Pinon
Browse files

fix bunch of cast warnings (manual)

parent 71ef7b64
......@@ -51,7 +51,7 @@ int AbstractTreeModel::columnCount(const QModelIndex &parent) const
{
if (!parent.isValid()) return rootItem->columnCount();
const auto id = (int)parent.internalId();
const auto id = int(parent.internalId());
auto item = getItemById(id);
return item->columnCount();
}
......@@ -65,7 +65,7 @@ QVariant AbstractTreeModel::data(const QModelIndex &index, int role) const
if (role != Qt::DisplayRole) {
return QVariant();
}
auto item = getItemById((int)index.internalId());
auto item = getItemById(int(index.internalId()));
return item->dataColumn(index.column());
}
......@@ -74,7 +74,7 @@ Qt::ItemFlags AbstractTreeModel::flags(const QModelIndex &index) const
const auto flags = QAbstractItemModel::flags(index);
if (index.isValid()) {
auto item = getItemById((int)index.internalId());
auto item = getItemById(int(index.internalId()));
if (item->depth() == 1) {
return flags & ~Qt::ItemIsSelectable;
}
......@@ -96,7 +96,7 @@ QModelIndex AbstractTreeModel::index(int row, int column, const QModelIndex &par
if (!parent.isValid())
parentItem = rootItem;
else
parentItem = getItemById((int)parent.internalId());
parentItem = getItemById(int(parent.internalId()));
if (row >= parentItem->childCount()) return QModelIndex();
......@@ -110,7 +110,7 @@ QModelIndex AbstractTreeModel::parent(const QModelIndex &index) const
{
if (!index.isValid()) return {};
std::shared_ptr<TreeItem> childItem = getItemById((int)index.internalId());
std::shared_ptr<TreeItem> childItem = getItemById(int(index.internalId()));
std::shared_ptr<TreeItem> parentItem = childItem->parentItem().lock();
Q_ASSERT(parentItem);
......@@ -128,7 +128,7 @@ int AbstractTreeModel::rowCount(const QModelIndex &parent) const
if (!parent.isValid())
parentItem = rootItem;
else
parentItem = getItemById((int)parent.internalId());
parentItem = getItemById(int(parent.internalId()));
return parentItem->childCount();
}
......
......@@ -169,7 +169,7 @@ bool TreeItem::changeParent(std::shared_ptr<TreeItem> newParent)
std::shared_ptr<TreeItem> TreeItem::child(int row) const
{
Q_ASSERT(row >= 0 && row < (int)m_childItems.size());
Q_ASSERT(row >= 0 && row < int(m_childItems.size()));
auto it = m_childItems.cbegin();
std::advance(it, row);
return (*it);
......@@ -177,7 +177,7 @@ std::shared_ptr<TreeItem> TreeItem::child(int row) const
int TreeItem::childCount() const
{
return (int)m_childItems.size();
return int(m_childItems.size());
}
int TreeItem::columnCount() const
......@@ -205,7 +205,7 @@ int TreeItem::row() const
if (auto ptr = m_parentItem.lock()) {
// we compute the distance in the parent's children list
auto it = ptr->m_childItems.begin();
return (int)std::distance(it, (decltype(it))ptr->m_iteratorTable.at(m_id));
return int(std::distance(it, static_cast<decltype(it)>(ptr->m_iteratorTable.at(m_id))));
}
return -1;
}
......
......@@ -132,11 +132,11 @@ template <typename AssetType> bool AbstractAssetsRepository<AssetType>::parseInf
eff.setAttribute(QStringLiteral("tag"), id);
eff.setAttribute(QStringLiteral("id"), id);
Mlt::Properties param_props((mlt_properties)metadata->get_data("parameters"));
Mlt::Properties param_props(mlt_properties(metadata->get_data("parameters")));
for (int j = 0; param_props.is_valid() && j < param_props.count(); ++j) {
QDomElement params = doc.createElement(QStringLiteral("parameter"));
Mlt::Properties paramdesc((mlt_properties)param_props.get_data(param_props.get_name(j)));
Mlt::Properties paramdesc(mlt_properties(param_props.get_data(param_props.get_name(j))));
params.setAttribute(QStringLiteral("name"), paramdesc.get("identifier"));
if (params.attribute(QStringLiteral("name")) == QLatin1String("argument")) {
// This parameter has to be given as attribute when using command line, do not show it in Kdenlive
......@@ -256,9 +256,9 @@ template <typename AssetType> bool AbstractAssetsRepository<AssetType>::exists(c
template <typename AssetType> QVector<QPair<QString, QString>> AbstractAssetsRepository<AssetType>::getNames() const
{
QVector<QPair<QString, QString>> res;
res.reserve((int)m_assets.size());
res.reserve(int(m_assets.size()));
for (const auto &asset : m_assets) {
if (((int) (asset.second.type) == -1) || (!KdenliveSettings::gpu_accel() && asset.first.contains(QLatin1String("movit.")))) {
if ((int(asset.second.type) == -1) || (!KdenliveSettings::gpu_accel() && asset.first.contains(QLatin1String("movit.")))) {
// Hide GPU effects/compositions when movit disabled
continue;
}
......@@ -310,7 +310,7 @@ template <typename AssetType> bool AbstractAssetsRepository<AssetType>::parseInf
// Check if there is a maximal version set
if (currentAsset.hasAttribute(QStringLiteral("version"))) {
// a specific version of the filter is required
if (m_assets.at(tag).version < (int)(100 * currentAsset.attribute(QStringLiteral("version")).toDouble())) {
if (m_assets.at(tag).version < int(100 * currentAsset.attribute(QStringLiteral("version")).toDouble())) {
return false;
}
}
......
......@@ -72,7 +72,7 @@ bool AssetFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParen
{
QModelIndex row = sourceModel()->index(sourceRow, 0, sourceParent);
auto *model = static_cast<AbstractTreeModel *>(sourceModel());
std::shared_ptr<TreeItem> item = model->getItemById((int)row.internalId());
std::shared_ptr<TreeItem> item = model->getItemById(int(row.internalId()));
if (item->dataColumn(AssetTreeModel::idCol) == QStringLiteral("root")) {
// In that case, we have a category. We hide it if it does not have children.
......
......@@ -50,7 +50,7 @@ QString AssetTreeModel::getName(const QModelIndex &index) const
if (!index.isValid()) {
return QString();
}
std::shared_ptr<TreeItem> item = getItemById((int)index.internalId());
std::shared_ptr<TreeItem> item = getItemById(int(index.internalId()));
if (item->depth() == 1) {
return item->dataColumn(0).toString();
}
......@@ -62,7 +62,7 @@ bool AssetTreeModel::isFavorite(const QModelIndex &index) const
if (!index.isValid()) {
return false;
}
std::shared_ptr<TreeItem> item = getItemById((int)index.internalId());
std::shared_ptr<TreeItem> item = getItemById(int(index.internalId()));
if (item->depth() == 1) {
return false;
}
......@@ -74,7 +74,7 @@ QString AssetTreeModel::getDescription(bool isEffect, const QModelIndex &index)
if (!index.isValid()) {
return QString();
}
std::shared_ptr<TreeItem> item = getItemById((int)index.internalId());
std::shared_ptr<TreeItem> item = getItemById(int(index.internalId()));
if (isEffect && item->depth() == 1) {
return QString();
}
......@@ -95,7 +95,7 @@ QVariant AssetTreeModel::data(const QModelIndex &index, int role) const
return QVariant();
}
std::shared_ptr<TreeItem> item = getItemById((int)index.internalId());
std::shared_ptr<TreeItem> item = getItemById(int(index.internalId()));
switch (role) {
case IdRole:
return item->dataColumn(AssetTreeModel::idCol);
......
......@@ -65,7 +65,7 @@ QImage AssetIconProvider::makeIcon(const QString &effectName, const QSize &size)
bool isAudio = false;
bool isCustom = false;
bool isGroup = false;
AssetListType::AssetType type = (AssetListType::AssetType)effectName.section(QLatin1Char('/'), -1).toInt();
AssetListType::AssetType type = AssetListType::AssetType(effectName.section(QLatin1Char('/'), -1).toInt());
if (m_effect) {
isAudio = type == AssetListType::AssetType::Audio || type == AssetListType::AssetType::CustomAudio;
isCustom = type == AssetListType::AssetType::CustomAudio || type == AssetListType::AssetType::Custom;
......
......@@ -370,7 +370,7 @@ bool KeyframeModel::updateKeyframeType(GenTime pos, int type, Fun &undo, Fun &re
QWriteLocker locker(&m_lock);
Q_ASSERT(m_keyframeList.count(pos) > 0);
KeyframeType oldType = m_keyframeList[pos].first;
KeyframeType newType = convertFromMltType((mlt_keyframe_type)type);
KeyframeType newType = convertFromMltType(mlt_keyframe_type(type));
QVariant value = m_keyframeList[pos].second;
// Check if keyframe is different
if (m_paramType == ParamType::KeyframeParam) {
......@@ -601,7 +601,7 @@ bool KeyframeModel::removeAllKeyframes(Fun &undo, Fun &redo)
std::vector<GenTime> all_pos;
Fun local_undo = []() { return true; };
Fun local_redo = []() { return true; };
int kfrCount = (int)m_keyframeList.size() - 1;
int kfrCount = int(m_keyframeList.size()) - 1;
if (kfrCount <= 0) {
// Nothing to do
UPDATE_UNDO_REDO(local_redo, local_undo, undo, redo);
......@@ -732,7 +732,7 @@ QString KeyframeModel::getRotoProperty() const
int out = in + ptr->data(m_index, AssetParameterModel::ParentDurationRole).toInt();
QVariantMap map;
for (const auto &keyframe : m_keyframeList) {
map.insert(QString::number(keyframe.first.frames(pCore->getCurrentFps())).rightJustified(log10((double)out) + 1, '0'), keyframe.second.second);
map.insert(QString::number(keyframe.first.frames(pCore->getCurrentFps())).rightJustified(int(log10(double(out + 1))), '0'), keyframe.second.second);
}
doc = QJsonDocument::fromVariant(map);
}
......@@ -867,7 +867,7 @@ void KeyframeModel::resetAnimProperty(const QString &prop)
effectName = i18n("effect");
}
Fun update_local = [this]() {
emit dataChanged(index(0), index((int)m_keyframeList.size()), {});
emit dataChanged(index(0), index(int(m_keyframeList.size())), {});
return true;
};
update_local();
......@@ -971,7 +971,7 @@ QVariant KeyframeModel::getInterpolatedValue(const GenTime &pos) const
// This is a fake query to force the animation to be parsed
(void)mlt_prop.anim_get_double("key", 0, out);
mlt_rect rect = mlt_prop.anim_get_rect("key", pos.frames(pCore->getCurrentFps()));
QString res = QStringLiteral("%1 %2 %3 %4").arg((int)rect.x).arg((int)rect.y).arg((int)rect.w).arg((int)rect.h);
QString res = QStringLiteral("%1 %2 %3 %4").arg(int(rect.x)).arg(int(rect.y)).arg(int(rect.w)).arg(int(rect.h));
if (useOpacity) {
res.append(QStringLiteral(" %1").arg(QString::number(rect.o, 'f')));
}
......@@ -999,7 +999,8 @@ QVariant KeyframeModel::getInterpolatedValue(const GenTime &pos) const
// - equal to 1 on next keyframe
qreal relPos = 0;
if (next->first != prev->first) {
relPos = (pos.frames(pCore->getCurrentFps()) - prev->first.frames(pCore->getCurrentFps())) / (qreal)(((next->first - prev->first).frames(pCore->getCurrentFps())));
relPos = (pos.frames(pCore->getCurrentFps()) - prev->first.frames(pCore->getCurrentFps())) / qreal
(((next->first - prev->first).frames(pCore->getCurrentFps())));
}
int count = qMin(p1.count(), p2.count());
QList<QVariant> vlist;
......@@ -1119,11 +1120,11 @@ QList<QPoint> KeyframeModel::getRanges(const QString &animData, const std::share
mlt_keyframe_type type;
anim.key_get(0, frame, type);
mlt_rect rect = mlt_prop.anim_get_rect("key", frame);
QPoint pX(rect.x, rect.x);
QPoint pY(rect.y, rect.y);
QPoint pW(rect.w, rect.w);
QPoint pH(rect.h, rect.h);
QPoint pO(rect.o, rect.o);
QPoint pX(int(rect.x), int(rect.x));
QPoint pY(int(rect.y), int(rect.y));
QPoint pW(int(rect.w), int(rect.w));
QPoint pH(int(rect.h), int(rect.h));
QPoint pO(int(rect.o), int(rect.o));
for (int i = 1; i < anim.key_count(); ++i) {
anim.key_get(i, frame, type);
if (!animData.contains(QLatin1Char('='))) {
......@@ -1131,16 +1132,16 @@ QList<QPoint> KeyframeModel::getRanges(const QString &animData, const std::share
type = mlt_keyframe_linear;
}
rect = mlt_prop.anim_get_rect("key", frame);
pX.setX(qMin((int)rect.x, pX.x()));
pX.setY(qMax((int)rect.x, pX.y()));
pY.setX(qMin((int)rect.y, pY.x()));
pY.setY(qMax((int)rect.y, pY.y()));
pW.setX(qMin((int)rect.w, pW.x()));
pW.setY(qMax((int)rect.w, pW.y()));
pH.setX(qMin((int)rect.h, pH.x()));
pH.setY(qMax((int)rect.h, pH.y()));
pO.setX(qMin((int)rect.o, pO.x()));
pO.setY(qMax((int)rect.o, pO.y()));
pX.setX(qMin(int(rect.x), pX.x()));
pX.setY(qMax(int(rect.x), pX.y()));
pY.setX(qMin(int(rect.y), pY.x()));
pY.setY(qMax(int(rect.y), pY.y()));
pW.setX(qMin(int(rect.w), pW.x()));
pW.setY(qMax(int(rect.w), pW.y()));
pH.setX(qMin(int(rect.h), pH.x()));
pH.setY(qMax(int(rect.h), pH.y()));
pO.setX(qMin(int(rect.o), pO.x()));
pO.setY(qMax(int(rect.o), pO.y()));
// value = QVariant(QStringLiteral("%1 %2 %3 %4 %5").arg(rect.x).arg(rect.y).arg(rect.w).arg(rect.h).arg(locale.toString(rect.o)));
}
QList<QPoint> result{pX, pY, pW, pH, pO};
......@@ -1204,7 +1205,7 @@ bool KeyframeModel::removeNextKeyframes(GenTime pos, Fun &undo, Fun &redo)
}
all_pos.push_back(m.first);
}
int kfrCount = (int)all_pos.size();
int kfrCount = int(all_pos.size());
// we trigger only one global remove/insertrow event
Fun update_redo_start = [this, firstPos, kfrCount]() {
beginRemoveRows(QModelIndex(), firstPos, kfrCount);
......
......@@ -138,7 +138,7 @@ bool KeyframeModelList::addKeyframe(int frame, double val)
} else {
value = param->getInterpolatedValue(pos);
}
return param->addKeyframe(pos, (KeyframeType)KdenliveSettings::defaultkeyframeinterp(), value, true, undo, redo);
return param->addKeyframe(pos, KeyframeType(KdenliveSettings::defaultkeyframeinterp()), value, true, undo, redo);
};
return applyOperation(op, update ? i18n("Change keyframe type") : i18n("Add keyframe"));
}
......@@ -524,7 +524,7 @@ void KeyframeModelList::checkConsistency()
}
}
Fun local_update = []() { return true; };
auto type = (KeyframeType)KdenliveSettings::defaultkeyframeinterp();
auto type = KeyframeType(KdenliveSettings::defaultkeyframeinterp());
for (const auto &param : m_parameters) {
QList<GenTime> list = param.second->getKeyframePos();
for (auto &time : fullList) {
......
......@@ -117,7 +117,7 @@ void KeyframeMonitorHelper::slotUpdateFromMonitorData(const QVariantList &center
// Center rect to new pos
QPointF offset = expected - pt;
r.translate(offset);
QString res = QString("%1 %2 %3 %4").arg((int)r.x()).arg((int)r.y()).arg((int)r.width()).arg((int)r.height());
QString res = QString("%1 %2 %3 %4").arg(int(r.x())).arg(int(r.y())).arg(int(r.width())).arg(int(r.height()));
if (data.size() > 4) {
res.append(QString(" %1").arg(data.at(4)));
}
......
......@@ -86,7 +86,7 @@ void KeyframeView::slotSetPosition(int pos, bool isInRange)
m_position = pos;
int offset = pCore->getItemIn(m_model->getOwnerId());
emit atKeyframe(m_model->hasKeyframe(pos + offset), m_model->singleKeyframe());
double zoomPos = (double) m_position / m_duration;
double zoomPos = double(m_position) / m_duration;
if (zoomPos < m_zoomHandle.x()) {
double interval = m_zoomHandle.y() - m_zoomHandle.x();
zoomPos = qBound(0.0, zoomPos - interval / 5, 1.0);
......@@ -127,7 +127,7 @@ void KeyframeView::slotAddKeyframe(int pos)
pos = m_position;
}
int offset = pCore->getItemIn(m_model->getOwnerId());
m_model->addKeyframe(GenTime(pos + offset, pCore->getCurrentFps()), (KeyframeType)KdenliveSettings::defaultkeyframeinterp());
m_model->addKeyframe(GenTime(pos + offset, pCore->getCurrentFps()), KeyframeType(KdenliveSettings::defaultkeyframeinterp()));
}
const QString KeyframeView::getAssetId()
......@@ -202,7 +202,7 @@ void KeyframeView::slotGoToNext()
auto next = m_model->getNextKeyframe(GenTime(m_position + offset, pCore->getCurrentFps()), &ok);
if (ok) {
emit seekToPos(qMin((int)next.first.frames(pCore->getCurrentFps()) - offset, m_duration - 1));
emit seekToPos(qMin(int(next.first.frames(pCore->getCurrentFps())) - offset, m_duration - 1));
} else {
// no keyframe after current position
emit seekToPos(m_duration - 1);
......@@ -221,7 +221,7 @@ void KeyframeView::slotGoToPrev()
auto prev = m_model->getPrevKeyframe(GenTime(m_position + offset, pCore->getCurrentFps()), &ok);
if (ok) {
emit seekToPos(qMax(0, (int)prev.first.frames(pCore->getCurrentFps()) - offset));
emit seekToPos(qMax(0, int(prev.first.frames(pCore->getCurrentFps())) - offset));
} else {
// no keyframe after current position
emit seekToPos(m_duration - 1);
......@@ -323,7 +323,7 @@ void KeyframeView::mousePressEvent(QMouseEvent *event)
} else if (event->y() > m_zoomHeight + 2) {
// click on zoom area
if (m_hoverZoom) {
m_clickOffset = ((double) event->x() - m_offset) / (width() - 2 * m_offset);
m_clickOffset = (double(event->x()) - m_offset) / (width() - 2 * m_offset);
}
return;
}
......@@ -352,25 +352,25 @@ void KeyframeView::mouseMoveEvent(QMouseEvent *event)
double zoomStart = m_zoomHandle.x() * (width() - 2 * m_offset);
double zoomEnd = m_zoomHandle.y() * (width() - 2 * m_offset);
double zoomFactor = (width() - 2 * m_offset) / (zoomEnd - zoomStart);
int pos = ((event->x() - m_offset) / zoomFactor + zoomStart ) / m_scale;
int pos = int(((double(event->x()) - m_offset) / zoomFactor + zoomStart ) / m_scale);
pos = qBound(0, pos, m_duration - 1);
GenTime position(pos + offset, pCore->getCurrentFps());
if ((event->buttons() & Qt::LeftButton) != 0u) {
if (m_hoverZoomIn || m_hoverZoomOut || m_hoverZoom) {
// Moving zoom handles
if (m_hoverZoomIn) {
m_zoomHandle.setX(qMin(qMax(0., (double)(event->x() - m_offset) / (width() - 2 * m_offset)), m_zoomHandle.y() - 0.015));
m_zoomHandle.setX(qMin(qMax(0., double(event->x() - m_offset) / (width() - 2 * m_offset)), m_zoomHandle.y() - 0.015));
update();
return;
}
if (m_hoverZoomOut) {
m_zoomHandle.setY(qMax(qMin(1., (double)(event->x() - m_offset) / (width() - 2 * m_offset)), m_zoomHandle.x() + 0.015));
m_zoomHandle.setY(qMax(qMin(1., double(event->x() - m_offset) / (width() - 2 * m_offset)), m_zoomHandle.x() + 0.015));
update();
return;
}
// moving zoom zone
if (m_hoverZoom) {
double clickOffset = ((double)event->x() - m_offset) / (width() - 2 * m_offset) - m_clickOffset;
double clickOffset = (double(event->x()) - m_offset) / (width() - 2 * m_offset) - m_clickOffset;
double newX = m_zoomHandle.x() + clickOffset;
if (newX < 0) {
clickOffset = - m_zoomHandle.x();
......@@ -382,7 +382,7 @@ void KeyframeView::mouseMoveEvent(QMouseEvent *event)
newY = 1;
newX = m_zoomHandle.x() + clickOffset;
}
m_clickOffset = ((double)event->x() - m_offset) / (width() - 2 * m_offset);
m_clickOffset = (double(event->x()) - m_offset) / (width() - 2 * m_offset);
m_zoomHandle = QPointF(newX, newY);
update();
}
......@@ -583,7 +583,7 @@ void KeyframeView::mouseDoubleClickEvent(QMouseEvent *event)
}
// add new keyframe
m_model->addKeyframe(position, (KeyframeType)KdenliveSettings::defaultkeyframeinterp());
m_model->addKeyframe(position, KeyframeType(KdenliveSettings::defaultkeyframeinterp()));
} else {
QWidget::mouseDoubleClickEvent(event);
}
......@@ -636,7 +636,7 @@ void KeyframeView::paintEvent(QPaintEvent *event)
QStylePainter p(this);
int maxWidth = width() - 2 * m_offset;
m_scale = maxWidth / (double)(m_duration - 1);
m_scale = maxWidth / double(m_duration - 1);
int headOffset = m_lineHeight / 2;
int offset = pCore->getItemIn(m_model->getOwnerId());
m_zoomStart = m_zoomHandle.x() * maxWidth;
......@@ -644,7 +644,7 @@ void KeyframeView::paintEvent(QPaintEvent *event)
int zoomEnd = qCeil(m_zoomHandle.y() * maxWidth);
/* ticks */
double fps = pCore->getCurrentFps();
int displayedLength = m_duration / m_zoomFactor / fps;
int displayedLength = int(m_duration / m_zoomFactor / fps);
double factor = 1;
if (displayedLength < 2) {
// 1 frame tick
......
......@@ -165,6 +165,7 @@ AssetParameterModel::AssetParameterModel(std::unique_ptr<Mlt::Properties> asset,
case ParamType::Animated: // Fine because unsupported
case ParamType::Addedgeometry: // Fine because unsupported
case ParamType::Url:
case ParamType::UrlList:
// All fine
converted = false;
break;
......
......@@ -246,10 +246,10 @@ void AssetParameterView::refresh(const QModelIndex &topLeft, const QModelIndex &
}
size_t max = m_widgets.size() - 1;
if (bottomRight.isValid()) {
max = qMin(max, (size_t)bottomRight.row());
max = qMin(max, size_t(bottomRight.row()));
}
Q_ASSERT(max < m_widgets.size());
for (auto i = (size_t)topLeft.row(); i <= max; ++i) {
for (auto i = size_t(topLeft.row()); i <= max; ++i) {
m_widgets[i]->slotRefresh();
}
}
......
......@@ -36,7 +36,7 @@ static QColor stringToColor(QString strColor)
if (strColor.length() == 10) {
// 0xRRGGBBAA
intval = strColor.toUInt(&ok, 16);
color.setRgb((int)((intval >> 24) & 0xff), // r
color.setRgb(int((intval >> 24) & 0xff), // r
(intval >> 16) & 0xff, // g
(intval >> 8) & 0xff, // b
intval & 0xff); // a
......@@ -52,7 +52,7 @@ static QColor stringToColor(QString strColor)
color.setRgb((intval >> 16) & 0xff, // r
(intval >> 8) & 0xff, // g
intval & 0xff, // b
(int)((intval >> 24) & 0xff)); // a
int((intval >> 24) & 0xff)); // a
} else if (strColor.length() == 8) {
// 0xRRGGBB
strColor = strColor.replace('#', QLatin1String("0x"));
......
......@@ -88,8 +88,8 @@ template <typename Curve_t> void AbstractCurveWidget<Curve_t>::paintBackground(Q
* Grid
*/
if (m_gridLines != 0) {
double stepH = m_wWidth / (double)(m_gridLines + 1);
double stepV = m_wHeight / (double)(m_gridLines + 1);
double stepH = m_wWidth / double(m_gridLines + 1);
double stepV = m_wHeight / double(m_gridLines + 1);
for (int i = 1; i <= m_gridLines; ++i) {
p->drawLine(QLineF(i * stepH, 0, i * stepH, m_wHeight));
p->drawLine(QLineF(0, i * stepV, m_wWidth, i * stepV));
......
......@@ -106,13 +106,13 @@ void BezierSplineEditor::mousePressEvent(QMouseEvent *event)
{
int wWidth = width() - 1;
int wHeight = height() - 1;
int offsetX = 1 / 8. * m_zoomLevel * wWidth;
int offsetY = 1 / 8. * m_zoomLevel * wHeight;
int offsetX = int(1 / 8. * m_zoomLevel * wWidth);
int offsetY = int(1 / 8. * m_zoomLevel * wHeight);
wWidth -= 2 * offsetX;
wHeight -= 2 * offsetY;
double x = (event->pos().x() - offsetX) / (double)(wWidth);
double y = 1.0 - (event->pos().y() - offsetY) / (double)(wHeight);
double x = (event->pos().x() - offsetX) / double(wWidth);
double y = 1.0 - (event->pos().y() - offsetY) / double(wHeight);
BPoint::PointType selectedPoint;
int closestPointIndex = nearestPointInRange(QPointF(x, y), wWidth, wHeight, &selectedPoint);
......@@ -145,10 +145,10 @@ void BezierSplineEditor::mousePressEvent(QMouseEvent *event)
if (m_currentPointIndex < m_curve.count() - 1) {
m_grabPNext = m_curve.getPoint(m_currentPointIndex + 1);
}
m_grabOffsetX = point[(int)m_currentPointType].x() - x;
m_grabOffsetY = point[(int)m_currentPointType].y() - y;
m_grabOffsetX = point[int(m_currentPointType)].x() - x;
m_grabOffsetY = point[int(m_currentPointType)].y() - y;
point[(int)m_currentPointType] = QPointF(x + m_grabOffsetX, y + m_grabOffsetY);
point[int(m_currentPointType)] = QPointF(x + m_grabOffsetX, y + m_grabOffsetY);
m_curve.setPoint(m_currentPointIndex, point);
......@@ -163,13 +163,13 @@ void BezierSplineEditor::mouseMoveEvent(QMouseEvent *event)
{
int wWidth = width() - 1;
int wHeight = height() - 1;
int offsetX = 1 / 8. * m_zoomLevel * wWidth;
int offsetY = 1 / 8. * m_zoomLevel * wHeight;
int offsetX = int(1 / 8. * m_zoomLevel * wWidth);
int offsetY = int(1 / 8. * m_zoomLevel * wHeight);
wWidth -= 2 * offsetX;
wHeight -= 2 * offsetY;
double x = (event->pos().x() - offsetX) / (double)(wWidth);
double y = 1.0 - (event->pos().y() - offsetY) / (double)(wHeight);
double x = (event->pos().x() - offsetX) / double(wWidth);
double y = 1.0 - (event->pos().y() - offsetY) / double(wHeight);
if (m_state == State_t::NORMAL) {
// If no point is selected set the cursor shape if on top
......@@ -296,8 +296,8 @@ int BezierSplineEditor::nearestPointInRange(const QPointF &p, int wWidth, int wH
if (nearestIndex >= 0 && (nearestIndex == m_currentPointIndex || pointType == BPoint::PointType::P || m_showAllHandles)) {
// a point was found and it is not a hidden handle
BPoint point = m_curve.getPoint(nearestIndex);
double dx = (p.x() - point[(int)pointType].x()) * wWidth;
double dy = (p.y() - point[(int)pointType].y()) * wHeight;
double dx = (p.x() - point[int(pointType)].x()) * wWidth;
double dy = (p.y() - point[int(pointType)].y()) * wHeight;
if (dx * dx + dy * dy <= m_grabRadius * m_grabRadius) {
*sel = pointType;
return nearestIndex;
......
......@@ -196,7 +196,7 @@ std::pair<int, BPoint::PointType> CubicBezierSpline::closestPoint(const QPointF
if (distanceSquared < nearestDistanceSquared) {
nearestIndex = i;
nearestDistanceSquared = distanceSquared;
selectedPoint = (BPoint::PointType)j;
selectedPoint = BPoint::PointType(j);
}
}
++i;
......
......@@ -288,7 +288,7 @@ qreal KisCubicCurve::Data::value(qreal x)
*/
x = qBound(spline.begin(), x, spline.end());
qreal y = spline.getValue(x);
return qBound((qreal)0.0, y, (qreal)1.0);
return qBound(qreal(0.0), y, qreal(1.0));
}
template <typename _T_, typename _T2_> void KisCubicCurve::Data::updateTransfer(QVector<_T_> *transfer, bool &valid, _T2_ min, _T2_ max, int size)
......