Commit 2f3fbdbe authored by Nicolas Carion's avatar Nicolas Carion
Browse files

clang-tidy modernize

parent 8d03962a
......@@ -303,27 +303,27 @@ void fuzz(const std::string &input)
int compoId = get_compo(tim);
valid = valid && (compoId >= 0);
// std::cout << "got compo" << compoId << std::endl;
arguments.push_back(compoId);
arguments.emplace_back(compoId);
} else if (arg_name == "clipId") {
std::shared_ptr<TimelineModel> tim =
(ptr.can_convert<std::shared_ptr<TimelineModel>>() ? ptr.convert<std::shared_ptr<TimelineModel>>() : nullptr);
int clipId = get_clip(tim);
valid = valid && (clipId >= 0);
arguments.push_back(clipId);
arguments.emplace_back(clipId);
// std::cout << "got clipId" << clipId << std::endl;
} else if (arg_name == "trackId") {
std::shared_ptr<TimelineModel> tim =
(ptr.can_convert<std::shared_ptr<TimelineModel>>() ? ptr.convert<std::shared_ptr<TimelineModel>>() : nullptr);
int trackId = get_track(tim);
valid = valid && (trackId >= 0);
arguments.push_back(rttr::variant(trackId));
arguments.emplace_back(trackId);
// std::cout << "got trackId" << trackId << std::endl;
} else if (arg_name == "itemId") {
std::shared_ptr<TimelineModel> tim =
(ptr.can_convert<std::shared_ptr<TimelineModel>>() ? ptr.convert<std::shared_ptr<TimelineModel>>() : nullptr);
int itemId = get_item(tim);
valid = valid && (itemId >= 0);
arguments.push_back(itemId);
arguments.emplace_back(itemId);
// std::cout << "got itemId" << itemId << std::endl;
} else if (arg_name == "ids") {
int count = 0;
......@@ -339,7 +339,7 @@ void fuzz(const std::string &input)
valid = valid && (itemId >= 0);
ids.insert(itemId);
}
arguments.push_back(ids);
arguments.emplace_back(ids);
} else {
valid = false;
}
......@@ -349,12 +349,12 @@ void fuzz(const std::string &input)
int a = 0;
ss >> a;
// std::cout << "read int " << a << std::endl;
arguments.push_back(a);
arguments.emplace_back(a);
} else if (arg_type == rttr::type::get<bool>()) {
bool a = false;
ss >> a;
// std::cout << "read bool " << a << std::endl;
arguments.push_back(a);
arguments.emplace_back(a);
} else if (arg_type == rttr::type::get<QString>()) {
std::string str = "";
ss >> str;
......@@ -362,7 +362,7 @@ void fuzz(const std::string &input)
if (str == "$$") {
str = "";
}
arguments.push_back(QString::fromStdString(str));
arguments.emplace_back(QString::fromStdString(str));
} else if (arg_type.is_enumeration()) {
int a = 0;
ss >> a;
......@@ -375,7 +375,7 @@ void fuzz(const std::string &input)
}
} else {
if (p.get_type() == rttr::type::get<int>()) {
arguments.push_back(-1);
arguments.emplace_back(-1);
} else {
assert(false);
}
......@@ -410,8 +410,8 @@ void fuzz(const std::string &input)
all_clips.clear();
all_tracks.clear();
all_compositions.clear();
for (size_t i = 0; i < all_timelines.size(); ++i) {
all_timelines[i].reset();
for (auto &all_timeline : all_timelines) {
all_timeline.reset();
}
pCore->m_projectManager = nullptr;
......
......@@ -28,7 +28,7 @@
#include <QString>
#include <QStringList>
#include <QUrl>
#include <stdio.h>
#include <cstdio>
int main(int argc, char **argv)
{
......@@ -118,7 +118,7 @@ int main(int argc, char **argv)
out = consumer.attribute("out").toInt();
}
}
RenderJob *rJob = new RenderJob(render, playlist, target, pid, in, out);
auto *rJob = new RenderJob(render, playlist, target, pid, in, out);
rJob->start();
return app.exec();
} else {
......
......@@ -23,7 +23,7 @@
#include <QStringList>
#include <QThread>
#include <QtDBus>
#include <utility>
// Can't believe I need to do this to sleep.
class SleepThread : QThread
{
......@@ -35,9 +35,9 @@ public:
RenderJob::RenderJob(const QString &render, const QString &scenelist, const QString &target, int pid, int in, int out)
: QObject()
, m_scenelist(scenelist)
, m_dest(target)
, m_dest(std::move(target))
, m_progress(0)
, m_prog(render)
, m_prog(std::move(render))
, m_player()
, m_jobUiserver(nullptr)
, m_kdenliveinterface(nullptr)
......
......@@ -103,12 +103,12 @@ QModelIndex AbstractTreeModel::index(int row, int column, const QModelIndex &par
std::shared_ptr<TreeItem> childItem = parentItem->child(row);
if (childItem) return createIndex(row, column, quintptr(childItem->getId()));
return QModelIndex();
return {};
}
QModelIndex AbstractTreeModel::parent(const QModelIndex &index) const
{
if (!index.isValid()) return QModelIndex();
if (!index.isValid()) return {};
std::shared_ptr<TreeItem> childItem = getItemById((int)index.internalId());
std::shared_ptr<TreeItem> parentItem = childItem->parentItem().lock();
......@@ -136,7 +136,7 @@ int AbstractTreeModel::rowCount(const QModelIndex &parent) const
QModelIndex AbstractTreeModel::getIndexFromItem(const std::shared_ptr<TreeItem> &item) const
{
if (item == rootItem) {
return QModelIndex();
return {};
}
auto parentIndex = getIndexFromItem(item->parentItem().lock());
return index(item->row(), 0, parentIndex);
......@@ -151,7 +151,7 @@ QModelIndex AbstractTreeModel::getIndexFromId(int id) const
if (auto ptr = m_allItems.at(id).lock()) return getIndexFromItem(ptr);
Q_ASSERT(false);
return QModelIndex();
return {};
}
void AbstractTreeModel::notifyRowAboutToAppend(const std::shared_ptr<TreeItem> &item)
......
......@@ -46,7 +46,7 @@ protected:
explicit AbstractTreeModel(QObject *parent = nullptr);
public:
virtual ~AbstractTreeModel();
~AbstractTreeModel() override;
/* @brief Given an item from the hierarchy, construct the corresponding ModelIndex */
QModelIndex getIndexFromItem(const std::shared_ptr<TreeItem> &item) const;
......
......@@ -25,8 +25,8 @@
#include <numeric>
#include <utility>
TreeItem::TreeItem(const QList<QVariant> &data, const std::shared_ptr<AbstractTreeModel> &model, bool isRoot, int id)
: m_itemData(data)
TreeItem::TreeItem(QList<QVariant> data, const std::shared_ptr<AbstractTreeModel> &model, bool isRoot, int id)
: m_itemData(std::move(data))
, m_model(model)
, m_depth(0)
, m_id(id == -1 ? AbstractTreeModel::getNextId() : id)
......
......@@ -60,7 +60,7 @@ public:
protected:
// This is protected. Call construct instead
explicit TreeItem(const QList<QVariant> &data, const std::shared_ptr<AbstractTreeModel> &model, bool isRoot, int id = -1);
explicit TreeItem(QList<QVariant> data, const std::shared_ptr<AbstractTreeModel> &model, bool isRoot, int id = -1);
public:
virtual ~TreeItem();
......
......@@ -38,7 +38,8 @@ template <typename AssetType> class AbstractAssetsRepository
public:
AbstractAssetsRepository();
virtual ~AbstractAssetsRepository(){};
virtual ~AbstractAssetsRepository() = default;
;
/* @brief Returns true if a given asset exists
*/
......
......@@ -31,7 +31,7 @@
#include <xlocale.h>
#endif
template <typename AssetType> AbstractAssetsRepository<AssetType>::AbstractAssetsRepository() {}
template <typename AssetType> AbstractAssetsRepository<AssetType>::AbstractAssetsRepository() = default;
template <typename AssetType> void AbstractAssetsRepository<AssetType>::init()
{
......
......@@ -28,7 +28,7 @@
AssetFilter::AssetFilter(QObject *parent)
: QSortFilterProxyModel(parent)
, m_name_enabled(false)
{
setFilterRole(Qt::DisplayRole);
setSortRole(Qt::DisplayRole);
......
......@@ -64,7 +64,7 @@ protected:
/* @brief Apply all filter and returns true if the object should be kept after filtering */
virtual bool applyAll(std::shared_ptr<TreeItem> item) const;
bool m_name_enabled;
bool m_name_enabled{false};
QString m_name_value;
};
#endif
......@@ -34,7 +34,7 @@ class AssetTreeModel : public AbstractTreeModel
{
public:
explicit AssetTreeModel(QObject *parent = 0);
explicit AssetTreeModel(QObject *parent = nullptr);
enum { IdRole = Qt::UserRole + 1, NameRole, FavoriteRole };
......
......@@ -32,7 +32,7 @@
AssetListWidget::AssetListWidget(QWidget *parent)
: QQuickWidget(parent)
, m_assetIconProvider(nullptr)
{
KDeclarative::KDeclarative kdeclarative;
kdeclarative.setDeclarativeEngine(engine());
......
......@@ -41,7 +41,7 @@ class AssetListWidget : public QQuickWidget
public:
AssetListWidget(QWidget *parent = Q_NULLPTR);
virtual ~AssetListWidget();
~AssetListWidget() override;
/* @brief Returns the name of the asset given its model index */
QString getName(const QModelIndex &index) const;
......@@ -74,7 +74,7 @@ protected:
std::shared_ptr<AssetTreeModel> m_model;
std::unique_ptr<AssetFilter> m_proxyModel;
// the QmlEngine takes ownership of the image provider
AssetIconProvider *m_assetIconProvider;
AssetIconProvider *m_assetIconProvider{nullptr};
signals:
void activateAsset(const QVariantMap data);
......
......@@ -53,7 +53,7 @@ AssetPanel::AssetPanel(QWidget *parent)
, m_transitionWidget(new TransitionStackView(this))
, m_effectStackWidget(new EffectStackView(this))
{
QToolBar *buttonToolbar = new QToolBar(this);
auto *buttonToolbar = new QToolBar(this);
buttonToolbar->addWidget(m_assetTitle);
int size = style()->pixelMetric(QStyle::PM_SmallIconSize);
QSize iconSize(size, size);
......@@ -99,11 +99,11 @@ AssetPanel::AssetPanel(QWidget *parent)
m_lay->addWidget(buttonToolbar);
m_lay->setContentsMargins(0, 0, 0, 0);
m_lay->setSpacing(0);
QVBoxLayout *lay = new QVBoxLayout(m_container);
auto *lay = new QVBoxLayout(m_container);
lay->setContentsMargins(0, 0, 0, 0);
lay->addWidget(m_transitionWidget);
lay->addWidget(m_effectStackWidget);
QScrollArea *sc = new QScrollArea;
auto *sc = new QScrollArea;
sc->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
sc->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
sc->setFrameStyle(QFrame::NoFrame);
......
......@@ -38,8 +38,8 @@ void CornersHelper::slotUpdateFromMonitorData(const QVariantList &v)
const QVariantList points = QVariant(v).toList();
QSize frameSize = pCore->getCurrentFrameSize();
int ix = 0;
for (int i = 0; i < points.size(); i++) {
QPointF pt = points.at(i).toPointF();
for (const auto &point : points) {
QPointF pt = point.toPointF();
double x = (pt.x() / frameSize.width() + 1) / 3;
double y = (pt.y() / frameSize.height() + 1) / 3;
emit updateKeyframeData(m_indexes.at(ix), x);
......@@ -54,7 +54,7 @@ void CornersHelper::refreshParams(int pos)
QList<double> coords;
QSize frameSize = pCore->getCurrentFrameSize();
for (const auto &ix : m_indexes) {
ParamType type = m_model->data(ix, AssetParameterModel::TypeRole).value<ParamType>();
auto type = m_model->data(ix, AssetParameterModel::TypeRole).value<ParamType>();
if (type != ParamType::KeyframeParam) {
continue;
}
......
......@@ -46,7 +46,7 @@ ObjectId KeyframeModelList::getOwnerId() const
if (auto ptr = m_model.lock()) {
return ptr->getOwnerId();
}
return ObjectId();
return {};
}
void KeyframeModelList::addParameter(const QModelIndex &index)
......@@ -98,7 +98,7 @@ bool KeyframeModelList::addKeyframe(int frame, double val)
bool isRectParam = false;
if (m_inTimelineIndex.isValid()) {
if (auto ptr = m_model.lock()) {
ParamType tp = ptr->data(m_inTimelineIndex, AssetParameterModel::TypeRole).value<ParamType>();
auto tp = ptr->data(m_inTimelineIndex, AssetParameterModel::TypeRole).value<ParamType>();
if (tp == ParamType::AnimatedRect) {
isRectParam = true;
}
......@@ -166,7 +166,7 @@ bool KeyframeModelList::updateKeyframe(GenTime oldPos, GenTime pos, const QVaria
bool isRectParam = false;
if (m_inTimelineIndex.isValid()) {
if (auto ptr = m_model.lock()) {
ParamType tp = ptr->data(m_inTimelineIndex, AssetParameterModel::TypeRole).value<ParamType>();
auto tp = ptr->data(m_inTimelineIndex, AssetParameterModel::TypeRole).value<ParamType>();
if (tp == ParamType::AnimatedRect) {
isRectParam = true;
}
......@@ -201,7 +201,7 @@ bool KeyframeModelList::updateKeyframe(GenTime pos, const QVariant &value, const
pos = kf.first;
}
if (auto ptr = m_model.lock()) {
AssetKeyframeCommand *command = new AssetKeyframeCommand(ptr, index, value, pos);
auto *command = new AssetKeyframeCommand(ptr, index, value, pos);
pCore->pushUndo(command);
}
return true;
......
......@@ -24,7 +24,7 @@ BPoint::BPoint()
: h1(-1, -1)
, p(-1, -1)
, h2(-1, -1)
, handlesLinked(true)
{
}
......
......@@ -66,7 +66,7 @@ public:
/** handle 2 */
QPointF h2;
/** handles are linked to achieve a natural locking spline => PH1 = -r*PH2 ; a line can be drawn through h1, p, h2 */
bool handlesLinked;
bool handlesLinked{true};
};
#endif
......@@ -65,10 +65,10 @@ void RotoHelper::refreshParams(int pos)
if (!keyframes->isEmpty()) {
QVariant splineData = keyframes->getInterpolatedValue(pos, m_indexes.first());
QList<BPoint> p = getPoints(splineData, pCore->getCurrentFrameSize());
for (int i = 0; i < p.size(); i++) {
centerPoints << QVariant(p.at(i).p);
controlPoints << QVariant(p.at(i).h1);
controlPoints << QVariant(p.at(i).h2);
for (const auto &i : p) {
centerPoints << QVariant(i.p);
controlPoints << QVariant(i.h1);
controlPoints << QVariant(i.h2);
}
if (m_monitor) {
m_monitor->setUpEffectGeometry(QRect(), centerPoints, controlPoints);
......
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