Commit fd915a9e authored by Nicolas Carion's avatar Nicolas Carion
Browse files

linting

parent 009e3078
......@@ -115,8 +115,9 @@ int main(int argc, char **argv)
for (int i = 0; i < args.count(); ++i) {
if (args.at(i).startsWith(QLatin1String("meta.attr"))) {
QString data = args.at(i);
args.replace(i, data.section(QLatin1Char('='), 0, 0) + QStringLiteral("=\"") +
QUrl::fromPercentEncoding(data.section(QLatin1Char('='), 1).toUtf8()) + QLatin1Char('\"'));
args.replace(i,
data.section(QLatin1Char('='), 0, 0) + QStringLiteral("=\"") +
QUrl::fromPercentEncoding(data.section(QLatin1Char('='), 1).toUtf8()) + QLatin1Char('\"'));
}
}
......
......@@ -20,7 +20,9 @@
***************************************************************************/
#include "abstracttreemodel.hpp"
#include "treeitem.hpp"
#include <utility>
int AbstractTreeModel::currentTreeId = 0;
AbstractTreeModel::AbstractTreeModel(QObject *parent)
......@@ -35,15 +37,13 @@ std::shared_ptr<AbstractTreeModel> AbstractTreeModel::construct(QObject *parent)
return self;
}
AbstractTreeModel::~AbstractTreeModel()
{
}
AbstractTreeModel::~AbstractTreeModel() = default;
int AbstractTreeModel::columnCount(const QModelIndex &parent) const
{
if (!parent.isValid()) return rootItem->columnCount();
const int id = (int)parent.internalId();
const auto id = (int)parent.internalId();
auto item = getItemById(id);
return item->columnCount();
}
......@@ -125,7 +125,7 @@ int AbstractTreeModel::rowCount(const QModelIndex &parent) const
return parentItem->childCount();
}
QModelIndex AbstractTreeModel::getIndexFromItem(std::shared_ptr<TreeItem> item) const
QModelIndex AbstractTreeModel::getIndexFromItem(const std::shared_ptr<TreeItem> &item) const
{
if (item == rootItem) {
return QModelIndex();
......@@ -133,7 +133,7 @@ QModelIndex AbstractTreeModel::getIndexFromItem(std::shared_ptr<TreeItem> item)
return index(item->row(), 0, getIndexFromItem(item->parentItem().lock()));
}
void AbstractTreeModel::notifyRowAboutToAppend(std::shared_ptr<TreeItem> item)
void AbstractTreeModel::notifyRowAboutToAppend(const std::shared_ptr<TreeItem> &item)
{
auto index = getIndexFromItem(item);
beginInsertRows(index, item->childCount(), item->childCount());
......@@ -146,7 +146,7 @@ void AbstractTreeModel::notifyRowAppended()
void AbstractTreeModel::notifyRowAboutToDelete(std::shared_ptr<TreeItem> item, int row)
{
auto index = getIndexFromItem(item);
auto index = getIndexFromItem(std::move(item));
beginRemoveRows(index, row, row);
}
......@@ -161,7 +161,7 @@ int AbstractTreeModel::getNextId()
return currentTreeId++;
}
void AbstractTreeModel::registerItem(std::shared_ptr<TreeItem> item)
void AbstractTreeModel::registerItem(const std::shared_ptr<TreeItem> &item)
{
int id = item->getId();
Q_ASSERT(m_allItems.count(id) == 0);
......
......@@ -48,12 +48,12 @@ public:
virtual ~AbstractTreeModel();
/* @brief Given an item from the hierarchy, construct the corresponding ModelIndex */
QModelIndex getIndexFromItem(std::shared_ptr<TreeItem> item) const;
QModelIndex getIndexFromItem(const std::shared_ptr<TreeItem> &item) const;
/* @brief Send the appropriate notification related to a row that we are appending
@param item is the parent item to which row is appended
*/
void notifyRowAboutToAppend(std::shared_ptr<TreeItem> item);
void notifyRowAboutToAppend(const std::shared_ptr<TreeItem> &item);
/* @brief Send the appropriate notification related to a row that we have appended
*/
......@@ -83,15 +83,17 @@ public:
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
friend class TreeItem;
protected:
/* @brief Register a new item. This is a call-back meant to be called from TreeItem */
void registerItem(std::shared_ptr<TreeItem> item);
void registerItem(const std::shared_ptr<TreeItem> &item);
/* @brief Deregister an item. This is a call-back meant to be called from TreeItem */
void deregisterItem(int id);
/* @brief Returns the next valid id to give to a new element */
static int getNextId();
protected:
std::shared_ptr<TreeItem> rootItem;
......
......@@ -22,8 +22,9 @@
#include "treeitem.hpp"
#include "abstracttreemodel.hpp"
#include <QDebug>
#include <utility>
TreeItem::TreeItem(const QList<QVariant> &data, std::shared_ptr<AbstractTreeModel> model, std::shared_ptr<TreeItem> parent, int id)
TreeItem::TreeItem(const QList<QVariant> &data, const std::shared_ptr<AbstractTreeModel> &model, const std::shared_ptr<TreeItem> &parent, int id)
: m_itemData(data)
, m_parentItem(parent)
, m_model(model)
......@@ -34,14 +35,14 @@ TreeItem::TreeItem(const QList<QVariant> &data, std::shared_ptr<AbstractTreeMode
std::shared_ptr<TreeItem> TreeItem::construct(const QList<QVariant> &data, std::shared_ptr<AbstractTreeModel> model, std::shared_ptr<TreeItem> parent, int id)
{
std::shared_ptr<TreeItem> self(new TreeItem(data,model, parent, id));
std::shared_ptr<TreeItem> self(new TreeItem(data, std::move(model), std::move(parent), id));
id = self->m_id;
baseFinishConstruct(self);
return self;
}
// static
void TreeItem::baseFinishConstruct(std::shared_ptr<TreeItem> self)
void TreeItem::baseFinishConstruct(const std::shared_ptr<TreeItem> &self)
{
if (auto ptr = self->m_model.lock()) {
ptr->registerItem(self);
......@@ -94,7 +95,7 @@ void TreeItem::appendChild(std::shared_ptr<TreeItem> child)
}
}
void TreeItem::removeChild(std::shared_ptr<TreeItem> child)
void TreeItem::removeChild(const std::shared_ptr<TreeItem> &child)
{
if (auto ptr = m_model.lock()) {
ptr->notifyRowAboutToDelete(shared_from_this(), child->row());
......@@ -113,7 +114,7 @@ void TreeItem::removeChild(std::shared_ptr<TreeItem> child)
}
}
void TreeItem::changeParent(std::shared_ptr<TreeItem> newParent)
void TreeItem::changeParent(const std::shared_ptr<TreeItem> &newParent)
{
if (auto ptr = m_parentItem.lock()) {
ptr->removeChild(shared_from_this());
......
......@@ -41,12 +41,14 @@ public:
@param id of the newly created item. If left to -1, the id is assigned automatically
@return a ptr to the constructed item
*/
static std::shared_ptr<TreeItem> construct(const QList<QVariant> &data, std::shared_ptr<AbstractTreeModel> model, std::shared_ptr<TreeItem> parent, int id = -1);
static std::shared_ptr<TreeItem> construct(const QList<QVariant> &data, std::shared_ptr<AbstractTreeModel> model, std::shared_ptr<TreeItem> parent,
int id = -1);
friend class AbstractTreeModel;
protected:
// This is protected. Call construct instead
explicit TreeItem(const QList<QVariant> &data, std::shared_ptr<AbstractTreeModel> model, std::shared_ptr<TreeItem> parent, int id = -1);
explicit TreeItem(const QList<QVariant> &data, const std::shared_ptr<AbstractTreeModel> &model, const std::shared_ptr<TreeItem> &parent, int id = -1);
public:
virtual ~TreeItem();
......@@ -64,11 +66,11 @@ public:
/* @brief Remove given child from children list. The parent of the child is updated
accordingly
*/
void removeChild(std::shared_ptr<TreeItem> child);
void removeChild(const std::shared_ptr<TreeItem> &child);
/* @brief Change the parent of the current item. Structures are modified accordingly
*/
void changeParent(std::shared_ptr<TreeItem> newParent);
void changeParent(const std::shared_ptr<TreeItem> &newParent);
/* @brief Retrieves a child of the current item
@param row is the index of the child to retrieve
......@@ -100,16 +102,15 @@ public:
/* @brief Return the id of the current item*/
int getId() const;
protected:
protected:
/* @brief Finish construction of object given its pointer
This is a separated function so that it can be called from derived classes */
static void baseFinishConstruct(std::shared_ptr<TreeItem> self);
static void baseFinishConstruct(const std::shared_ptr<TreeItem> &self);
std::list<std::shared_ptr<TreeItem>> m_childItems;
std::unordered_map<int, std::list<std::shared_ptr<TreeItem>>::iterator>
m_iteratorTable; // this logs the iterator associated which each child id. This allows easy access of a child based on its id.
m_iteratorTable; // this logs the iterator associated which each child id. This allows easy access of a child based on its id.
QList<QVariant> m_itemData;
std::weak_ptr<TreeItem> m_parentItem;
......
......@@ -20,9 +20,11 @@
***************************************************************************/
#include "assetfilter.hpp"
#include "abstractmodel/abstracttreemodel.hpp"
#include "abstractmodel/treeitem.hpp"
#include "assettreemodel.hpp"
#include <utility>
AssetFilter::AssetFilter(QObject *parent)
: QSortFilterProxyModel(parent)
......@@ -38,7 +40,7 @@ void AssetFilter::setFilterName(bool enabled, const QString &pattern)
sort(0);
}
bool AssetFilter::filterName(std::shared_ptr<TreeItem> item) const
bool AssetFilter::filterName(const std::shared_ptr<TreeItem> &item) const
{
if (!m_name_enabled) {
return true;
......@@ -53,7 +55,7 @@ bool AssetFilter::filterName(std::shared_ptr<TreeItem> item) const
bool AssetFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
QModelIndex row = sourceModel()->index(sourceRow, 0, sourceParent);
AbstractTreeModel *model = static_cast<AbstractTreeModel*>(sourceModel());
auto *model = static_cast<AbstractTreeModel *>(sourceModel());
std::shared_ptr<TreeItem> item = model->getItemById((int)row.internalId());
if (item->dataColumn(AssetTreeModel::idCol) == QStringLiteral("root")) {
......@@ -76,7 +78,7 @@ bool AssetFilter::isVisible(const QModelIndex &sourceIndex)
bool AssetFilter::applyAll(std::shared_ptr<TreeItem> item) const
{
return filterName(item);
return filterName(std::move(item));
}
QModelIndex AssetFilter::getNextChild(const QModelIndex &current)
......@@ -92,9 +94,8 @@ QModelIndex AssetFilter::getNextChild(const QModelIndex &current)
}
if (folder.isValid() && rowCount(folder) > 0) {
return index(0, current.column(), folder);
} else {
nextItem = current;
}
nextItem = current;
}
return nextItem;
}
......@@ -112,9 +113,8 @@ QModelIndex AssetFilter::getPreviousChild(const QModelIndex &current)
}
if (folder.isValid() && rowCount(folder) > 0) {
return index(rowCount(folder) - 1, current.column(), folder);
} else {
nextItem = current;
}
nextItem = current;
}
return nextItem;
}
......
......@@ -53,7 +53,7 @@ public:
protected:
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
bool filterName(std::shared_ptr<TreeItem> item) const;
bool filterName(const std::shared_ptr<TreeItem> &item) const;
/* @brief Apply all filter and returns true if the object should be kept after filtering */
virtual bool applyAll(std::shared_ptr<TreeItem> item) const;
......
......@@ -78,5 +78,3 @@ void AssetListWidget::activate(const QModelIndex &ix)
const QString assetId = m_model->data(m_proxyModel->mapToSource(ix), AssetTreeModel::IdRole).toString();
emit activateAsset(getMimeData(assetId));
}
......@@ -116,9 +116,7 @@ void AssetParameterModel::setParameter(const QString &name, const QString &value
}
}
AssetParameterModel::~AssetParameterModel()
{
}
AssetParameterModel::~AssetParameterModel() = default;
QVariant AssetParameterModel::data(const QModelIndex &index, int role) const
{
......@@ -177,7 +175,8 @@ ParamType AssetParameterModel::paramTypeFromStr(const QString &type)
}
if (type == QLatin1String("bool")) {
return ParamType::Bool;
} else if (type == QLatin1String("switch")) {
}
if (type == QLatin1String("switch")) {
return ParamType::Switch;
} else if (type.startsWith(QLatin1String("animated"))) {
return ParamType::Animated;
......
......@@ -38,7 +38,7 @@ AssetParameterView::AssetParameterView(QWidget *parent)
m_lay->setSpacing(2);
}
void AssetParameterView::setModel(std::shared_ptr<AssetParameterModel> model)
void AssetParameterView::setModel(const std::shared_ptr<AssetParameterModel> &model)
{
qDebug() << "set model " << model.get();
unsetModel();
......@@ -82,7 +82,7 @@ void AssetParameterView::refresh(const QModelIndex &topLeft, const QModelIndex &
// We make sure the range is valid
Q_ASSERT(bottomRight.row() < (int)m_widgets.size());
for (size_t i = (size_t)topLeft.row(); i <= (size_t)bottomRight.row(); ++i) {
for (auto i = (size_t)topLeft.row(); i <= (size_t)bottomRight.row(); ++i) {
m_widgets[i]->slotRefresh();
}
}
......@@ -43,7 +43,7 @@ public:
AssetParameterView(QWidget *parent = nullptr);
/** Sets the model to be displayed by current view */
void setModel(std::shared_ptr<AssetParameterModel> model);
void setModel(const std::shared_ptr<AssetParameterModel> &model);
/** Set the widget to display no model (this yield ownership on the smart-ptr)*/
void unsetModel();
......
......@@ -22,21 +22,22 @@
#include "doubleparamwidget.hpp"
#include <QLabel>
#include <QVBoxLayout>
#include <utility>
// temporary place holder for parameters that don't currently have a display class
class Unsupported : public AbstractParamWidget
{
public:
Unsupported(std::shared_ptr<AssetParameterModel> model, QModelIndex index, QWidget *parent)
: AbstractParamWidget(model, index, parent)
: AbstractParamWidget(std::move(model), index, parent)
{
QVBoxLayout *lay = new QVBoxLayout(this);
auto *lay = new QVBoxLayout(this);
lay->setContentsMargins(4, 0, 4, 0);
m_label = new QLabel(this);
lay->addWidget(m_label);
}
void setText(const QString &str) { m_label->setText(str); }
void slotRefresh() {}
void slotRefresh() override {}
protected:
QLabel *m_label;
......@@ -44,15 +45,15 @@ protected:
AbstractParamWidget::AbstractParamWidget(std::shared_ptr<AssetParameterModel> model, QModelIndex index, QWidget *parent)
: QWidget(parent)
, m_model(model)
, m_model(std::move(model))
, m_index(index)
{
}
AbstractParamWidget *AbstractParamWidget::construct(std::shared_ptr<AssetParameterModel> model, QModelIndex index, QWidget *parent)
AbstractParamWidget *AbstractParamWidget::construct(const std::shared_ptr<AssetParameterModel> &model, QModelIndex index, QWidget *parent)
{
// We retrieve the parameter type
ParamType type = model->data(index, AssetParameterModel::TypeRole).value<ParamType>();
auto type = model->data(index, AssetParameterModel::TypeRole).value<ParamType>();
qDebug() << "paramtype " << (int)type;
QString name = model->data(index, AssetParameterModel::NameRole).toString();
......
......@@ -45,7 +45,7 @@ public:
@param index Index of the parameter in the given model
@param parent parent widget
*/
static AbstractParamWidget *construct(std::shared_ptr<AssetParameterModel> model, QModelIndex index, QWidget *parent);
static AbstractParamWidget *construct(const std::shared_ptr<AssetParameterModel> &model, QModelIndex index, QWidget *parent);
signals:
/** @brief Signal sent when the parameters hold by the widgets are modified
......
......@@ -23,9 +23,10 @@
#include "assets/model/assetparametermodel.hpp"
#include "widgets/doublewidget.h"
#include <QVBoxLayout>
#include <utility>
DoubleParamWidget::DoubleParamWidget(std::shared_ptr<AssetParameterModel> model, QModelIndex index, QWidget *parent)
: AbstractParamWidget(model, index, parent)
: AbstractParamWidget(std::move(model), index, parent)
, m_doubleWidget(nullptr)
{
m_lay = new QVBoxLayout(this);
......
......@@ -28,8 +28,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QPainter>
#include <QVariant>
AbstractProjectItem::AbstractProjectItem(PROJECTITEMTYPE type, const QString &id, std::shared_ptr<ProjectItemModel> model,
std::shared_ptr<AbstractProjectItem> parent)
AbstractProjectItem::AbstractProjectItem(PROJECTITEMTYPE type, const QString &id, const std::shared_ptr<ProjectItemModel> &model,
const std::shared_ptr<AbstractProjectItem> &parent)
: TreeItem(QList<QVariant>(), std::static_pointer_cast<AbstractTreeModel>(model), std::static_pointer_cast<TreeItem>(parent))
, m_name()
, m_description()
......@@ -45,8 +45,8 @@ AbstractProjectItem::AbstractProjectItem(PROJECTITEMTYPE type, const QString &id
{
}
AbstractProjectItem::AbstractProjectItem(PROJECTITEMTYPE type, const QDomElement &description, std::shared_ptr<ProjectItemModel> model,
std::shared_ptr<AbstractProjectItem> parent)
AbstractProjectItem::AbstractProjectItem(PROJECTITEMTYPE type, const QDomElement &description, const std::shared_ptr<ProjectItemModel> &model,
const std::shared_ptr<AbstractProjectItem> &parent)
: TreeItem(QList<QVariant>(), std::static_pointer_cast<AbstractTreeModel>(model), std::static_pointer_cast<TreeItem>(parent))
, m_name()
, m_description()
......@@ -62,11 +62,9 @@ AbstractProjectItem::AbstractProjectItem(PROJECTITEMTYPE type, const QDomElement
{
}
AbstractProjectItem::~AbstractProjectItem()
{
}
AbstractProjectItem::~AbstractProjectItem() = default;
bool AbstractProjectItem::operator==(std::shared_ptr<AbstractProjectItem> projectItem) const
bool AbstractProjectItem::operator==(const std::shared_ptr<AbstractProjectItem> &projectItem) const
{
// FIXME: only works for folders
bool equal = this->m_childItems == projectItem->m_childItems;
......
......@@ -54,7 +54,8 @@ public:
* @brief Constructor.
* @param parent parent this item should be added to
*/
AbstractProjectItem(PROJECTITEMTYPE type, const QString &id, std::shared_ptr<ProjectItemModel> model, std::shared_ptr<AbstractProjectItem> parent);
AbstractProjectItem(PROJECTITEMTYPE type, const QString &id, const std::shared_ptr<ProjectItemModel> &model,
const std::shared_ptr<AbstractProjectItem> &parent);
/**
* @brief Creates a project item upon project load.
* @param description element for this item.
......@@ -63,11 +64,11 @@ public:
*
* We try to read the attributes "name" and "description"
*/
AbstractProjectItem(PROJECTITEMTYPE type, const QDomElement &description, std::shared_ptr<ProjectItemModel> model,
std::shared_ptr<AbstractProjectItem> parent);
AbstractProjectItem(PROJECTITEMTYPE type, const QDomElement &description, const std::shared_ptr<ProjectItemModel> &model,
const std::shared_ptr<AbstractProjectItem> &parent);
virtual ~AbstractProjectItem();
bool operator==(std::shared_ptr<AbstractProjectItem> projectItem) const;
bool operator==(const std::shared_ptr<AbstractProjectItem> &projectItem) const;
/** @brief Returns a pointer to the parent item (or NULL). */
std::shared_ptr<AbstractProjectItem> parent() const;
......
......@@ -358,7 +358,7 @@ bool MarkerListModel::importFromJson(const QString &data, bool ignoreConflicts)
QString MarkerListModel::toJson() const
{
QJsonArray list;
for(const auto &marker : m_markerList) {
for (const auto &marker : m_markerList) {
QJsonObject currentMarker;
currentMarker.insert(QLatin1String("pos"), QJsonValue(marker.first.seconds()));
currentMarker.insert(QLatin1String("comment"), QJsonValue(marker.second.first));
......
......@@ -107,7 +107,8 @@ public:
The data should be formated as follows:
[{"pos":0.2, "comment":"marker 1", "type":1}, {...}, ...]
return true on succes and logs undo object
@param ignoreConflicts: if set to false, it aborts if the data contains a marker with same position but different comment and/or type. If set to true, such markers are overridden silently
@param ignoreConflicts: if set to false, it aborts if the data contains a marker with same position but different comment and/or type. If set to true,
such markers are overridden silently
*/
bool importFromJson(const QString &data, bool ignoreConflicts);
......
......@@ -1276,4 +1276,3 @@ void ProjectClip::deregisterTimelineClip(int clipId)
Q_ASSERT(m_registeredClips.count(clipId) > 0);
m_registeredClips.erase(clipId);
}
......@@ -225,7 +225,6 @@ public slots:
* @param statusMessage The job info message */
void setJobStatus(int jobType, int status, int progress = 0, const QString &statusMessage = QString());
private:
bool m_abortAudioThumb;
/** @brief Generate and store file hash if not available. */
......@@ -247,7 +246,6 @@ private:
std::map<int, std::weak_ptr<TimelineModel>> m_registeredClips;
private slots:
void updateFfmpegProgress();
......
Supports Markdown
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