Commit 262e6181 authored by Nicolas Carion's avatar Nicolas Carion
Browse files

Linting + cleaning

parent 30b6f281
......@@ -22,8 +22,8 @@
#include "abstracttreemodel.hpp"
#include "treeitem.hpp"
#include <utility>
#include <QDebug>
#include <utility>
int AbstractTreeModel::currentTreeId = 0;
AbstractTreeModel::AbstractTreeModel(QObject *parent)
......@@ -165,37 +165,13 @@ int AbstractTreeModel::getNextId()
void AbstractTreeModel::registerItem(const std::shared_ptr<TreeItem> &item)
{
int id = item->getId();
qDebug() << "bottom registering "<<item->getId();
Q_ASSERT(m_allItems.count(id) == 0);
m_allItems[id] = item;
/*if (!m_allItems[id]->isInModel()) {
qDebug() << "inserting in model"<<id;
m_allItems[id]->setIsInModel(true);
if (auto ptr = m_allItems[id]->parentItem().lock()) {
notifyRowAboutToAppend(ptr);
notifyRowAppended();
qDebug() << "notifying"<<id;
} else {
qDebug() << "no parent"<<id;
}
} else {
qDebug() << "already in model"<<id;
}*/
}
void AbstractTreeModel::deregisterItem(int id)
{
qDebug() << "bottom deregistering "<<id;
Q_ASSERT(m_allItems.count(id) > 0);
// if item is in model, we must send signal that it is deleted
/* if (m_allItems[id]->isInModel()) {
m_allItems[id]->setIsInModel(false);
if (auto ptr = m_allItems[id]->parentItem().lock()) {
notifyRowAboutToDelete(ptr, m_allItems[id]->row());
notifyRowDeleted();
}
} */
m_allItems.erase(id);
}
......
......@@ -22,8 +22,8 @@
#include "treeitem.hpp"
#include "abstracttreemodel.hpp"
#include <QDebug>
#include <utility>
#include <numeric>
#include <utility>
TreeItem::TreeItem(const QList<QVariant> &data, const std::shared_ptr<AbstractTreeModel> &model, const std::shared_ptr<TreeItem> &parent, int id)
: m_itemData(data)
......@@ -46,7 +46,7 @@ std::shared_ptr<TreeItem> TreeItem::construct(const QList<QVariant> &data, std::
// static
void TreeItem::baseFinishConstruct(const std::shared_ptr<TreeItem> &self)
{
qDebug() << "FINISHED constructing "<<self->getId();
qDebug() << "FINISHED constructing " << self->getId();
if (auto ptr = self->m_model.lock()) {
ptr->registerItem(self);
} else {
......@@ -69,7 +69,7 @@ std::shared_ptr<TreeItem> TreeItem::appendChild(const QList<QVariant> &data)
if (auto ptr = m_model.lock()) {
ptr->notifyRowAboutToAppend(shared_from_this());
auto child = construct(data, ptr, shared_from_this());
qDebug() << "appending child"<<child->getId() <<"to "<<m_id;
qDebug() << "appending child" << child->getId() << "to " << m_id;
child->m_depth = m_depth + 1;
int id = child->getId();
m_childItems.push_back(child);
......@@ -90,7 +90,7 @@ void TreeItem::appendChild(std::shared_ptr<TreeItem> child)
ptr->notifyRowAboutToAppend(shared_from_this());
child->m_depth = m_depth + 1;
child->m_parentItem = shared_from_this();
qDebug() << "appending child2"<<child->getId() <<"to "<<m_id;
qDebug() << "appending child2" << child->getId() << "to " << m_id;
int id = child->getId();
auto it = m_childItems.insert(m_childItems.end(), std::move(child));
m_iteratorTable[id] = it;
......@@ -105,7 +105,7 @@ void TreeItem::appendChild(std::shared_ptr<TreeItem> child)
void TreeItem::removeChild(const std::shared_ptr<TreeItem> &child)
{
if (auto ptr = m_model.lock()) {
qDebug() << "removing child"<<child->getId() <<"from "<<m_id;
qDebug() << "removing child" << child->getId() << "from " << m_id;
ptr->notifyRowAboutToDelete(shared_from_this(), child->row());
// get iterator corresponding to child
auto it = m_iteratorTable[child->getId()];
......@@ -125,7 +125,7 @@ void TreeItem::removeChild(const std::shared_ptr<TreeItem> &child)
void TreeItem::changeParent(std::shared_ptr<TreeItem> newParent)
{
qDebug() << "changing parent of "<<m_id;
qDebug() << "changing parent of " << m_id;
if (auto ptr = m_parentItem.lock()) {
ptr->removeChild(shared_from_this());
}
......
......@@ -108,13 +108,13 @@ public:
@param init is the initial value of the operation
@param is the binary op to apply (signature should be (T, shared_ptr<TreeItem>)->T)
*/
template<class T, class BinaryOperation>
T accumulate(T init, BinaryOperation op);
template <class T, class BinaryOperation> T accumulate(T init, BinaryOperation op);
/* @brief Returns true if the model has been notified about the existence of this object
*/
bool isInModel() const;
void setIsInModel(bool isInModel);
protected:
/* @brief Finish construction of object given its pointer
This is a separated function so that it can be called from derived classes */
......@@ -134,8 +134,7 @@ protected:
bool m_isInModel;
};
template<class T, class BinaryOperation>
T TreeItem::accumulate(T init, BinaryOperation op)
template <class T, class BinaryOperation> T TreeItem::accumulate(T init, BinaryOperation op)
{
T res = op(init, shared_from_this());
return std::accumulate(m_childItems.begin(), m_childItems.end(), res, op);
......
......@@ -21,13 +21,14 @@
#include "assetparametermodel.hpp"
#include "core.h"
#include "klocalizedstring.h"
#include "profiles/profilemodel.hpp"
#include <QDebug>
#include <QLocale>
#include <QString>
#include "klocalizedstring.h"
AssetParameterModel::AssetParameterModel(Mlt::Properties *asset, const QDomElement &assetXml, const QString &assetId, Kdenlive::MonitorId monitor, QObject *parent)
AssetParameterModel::AssetParameterModel(Mlt::Properties *asset, const QDomElement &assetXml, const QString &assetId, Kdenlive::MonitorId monitor,
QObject *parent)
: QAbstractListModel(parent)
, m_xml(assetXml)
, m_assetId(assetId)
......@@ -116,7 +117,7 @@ void AssetParameterModel::setParameter(const QString &name, const QString &value
m_fixedParams[name] = value;
}
}
//refresh monitor after asset change
// refresh monitor after asset change
QSize range(m_asset->get_int("in"), m_asset->get_int("out"));
pCore->refreshProjectRange(range);
}
......
......@@ -66,9 +66,26 @@ class AssetParameterModel : public QAbstractListModel
Q_OBJECT
public:
explicit AssetParameterModel(Mlt::Properties *asset, const QDomElement &assetXml, const QString &assetId, Kdenlive::MonitorId monitor = Kdenlive::ProjectMonitor, QObject *parent = nullptr);
explicit AssetParameterModel(Mlt::Properties *asset, const QDomElement &assetXml, const QString &assetId,
Kdenlive::MonitorId monitor = Kdenlive::ProjectMonitor, QObject *parent = nullptr);
virtual ~AssetParameterModel();
enum { NameRole = Qt::UserRole + 1, TypeRole, CommentRole, MinRole, MaxRole, DefaultRole, SuffixRole, DecimalsRole, ValueRole, ListValuesRole, ListNamesRole, FactorRole, OpacityRole, InRole, OutRole };
enum {
NameRole = Qt::UserRole + 1,
TypeRole,
CommentRole,
MinRole,
MaxRole,
DefaultRole,
SuffixRole,
DecimalsRole,
ValueRole,
ListValuesRole,
ListNamesRole,
FactorRole,
OpacityRole,
InRole,
OutRole
};
/* @brief Returns the id of the asset represented by this object */
QString getAssetId() const;
......
......@@ -25,9 +25,9 @@
#include "assets/view/widgets/abstractparamwidget.hpp"
#include <QDebug>
#include <QFontDatabase>
#include <QLabel>
#include <QVBoxLayout>
#include <QFontDatabase>
#include <utility>
AssetParameterView::AssetParameterView(QWidget *parent)
......
......@@ -19,10 +19,10 @@
#include "abstractparamwidget.hpp"
#include "assets/model/assetparametermodel.hpp"
#include "doubleparamwidget.hpp"
#include "boolparamwidget.hpp"
#include "effectstack/widgets/listparamwidget.h"
#include "doubleparamwidget.hpp"
#include "effectstack/widgets/animationwidget.h"
#include "effectstack/widgets/listparamwidget.h"
#include <QLabel>
#include <QVBoxLayout>
......
......@@ -62,7 +62,6 @@ AbstractProjectItem::AbstractProjectItem(PROJECTITEMTYPE type, const QDomElement
{
}
bool AbstractProjectItem::operator==(const std::shared_ptr<AbstractProjectItem> &projectItem) const
{
// FIXME: only works for folders
......@@ -233,7 +232,7 @@ std::shared_ptr<AbstractProjectItem> AbstractProjectItem::getEnclosingFolder(boo
bool AbstractProjectItem::selfSoftDelete(Fun &undo, Fun &redo)
{
for(const auto& child : m_childItems) {
for (const auto &child : m_childItems) {
std::static_pointer_cast<AbstractProjectItem>(child)->selfSoftDelete(undo, redo);
}
Fun operation = [this]() {
......@@ -245,9 +244,9 @@ bool AbstractProjectItem::selfSoftDelete(Fun &undo, Fun &redo)
}
return true;
};
std::shared_ptr<TreeItem> self = shared_from_this();
std::shared_ptr<TreeItem> self = shared_from_this();
Fun reverse = [this, self]() {
//self is capture explicitly to prevent deletion of the object
// self is capture explicitly to prevent deletion of the object
if (auto ptr = m_model.lock()) {
ptr->registerItem(self);
} else {
......@@ -256,7 +255,7 @@ bool AbstractProjectItem::selfSoftDelete(Fun &undo, Fun &redo)
}
return true;
};
if(operation()) {
if (operation()) {
UPDATE_UNDO_REDO(operation, reverse, undo, redo);
return true;
}
......
......@@ -181,7 +181,7 @@ public:
/** @brief Returns true if a clip corresponding to this bin is inserted in a timeline.
Note that this function does not account for children, use TreeItem::accumulate if you want to get that information as well.
*/
virtual bool isIncludedInTimeline(){ return false; }
virtual bool isIncludedInTimeline() { return false; }
signals:
void childAdded(AbstractProjectItem *child);
......
......@@ -1019,7 +1019,7 @@ void Bin::slotDeleteClip()
}
std::shared_ptr<AbstractProjectItem> item = m_itemModel->getBinItemByIndex(m_proxyModel->mapToSource(ix));
if (!item) {
qDebug()<<"Suspicious: item not found when trying to delete";
qDebug() << "Suspicious: item not found when trying to delete";
continue;
}
auto checkInclusion = [](bool included, std::shared_ptr<TreeItem> item) {
......@@ -1038,7 +1038,7 @@ void Bin::slotDeleteClip()
}
Fun undo = []() { return true; };
Fun redo = []() { return true; };
for (const auto& item : items) {
for (const auto &item : items) {
m_itemModel->requestBinClipDeletion(item->clipId(), undo, redo);
}
pCore->pushUndo(undo, redo, i18n("Delete bin Clips"));
......
......@@ -285,10 +285,10 @@ CommentedTime MarkerListModel::getMarker(const GenTime &pos, bool *ok) const
return t;
}
QList <CommentedTime> MarkerListModel::getAllMarkers() const
QList<CommentedTime> MarkerListModel::getAllMarkers() const
{
READ_LOCK();
QList <CommentedTime> markers;
QList<CommentedTime> markers;
for (const auto &marker : m_markerList) {
CommentedTime t(marker.first, marker.second.first, marker.second.second);
markers << t;
......
......@@ -91,7 +91,7 @@ public:
CommentedTime getMarker(const GenTime &pos, bool *ok) const;
/* @brief Returns all markers in model */
QList <CommentedTime> getAllMarkers() const;
QList<CommentedTime> getAllMarkers() const;
/* @brief Returns true if a marker exists at given pos
Notice that add/remove queries are done in real time (gentime), but this request is made in frame
......
......@@ -678,7 +678,7 @@ bool ProjectClip::deleteClipMarkers(QUndoCommand *command)
for (auto &marker : markers) {
marker.setMarkerType(-1);
}
//TODO: group all markers in one undo/redo operation
// TODO: group all markers in one undo/redo operation
addMarkers(markers);
return true;
}
......@@ -1278,7 +1278,7 @@ void ProjectClip::deregisterTimelineClip(int clipId)
bool ProjectClip::selfSoftDelete(Fun &undo, Fun &redo)
{
for(const auto& clip : m_registeredClips) {
for (const auto &clip : m_registeredClips) {
if (auto timeline = clip.second.lock()) {
timeline->requestClipDeletion(clip.first, undo, redo);
} else {
......
......@@ -274,7 +274,7 @@ std::shared_ptr<ProjectClip> ProjectItemModel::getClipByBinID(const QString &bin
if (binId.contains(QLatin1Char('_'))) {
return getClipByBinID(binId.section(QLatin1Char('_'), 0, 0));
}
for (const auto &clip: m_allItems) {
for (const auto &clip : m_allItems) {
auto c = std::static_pointer_cast<AbstractProjectItem>(clip.second);
if (c->itemType() == AbstractProjectItem::ClipItem && c->clipId() == binId) {
return std::static_pointer_cast<ProjectClip>(c);
......@@ -285,7 +285,7 @@ std::shared_ptr<ProjectClip> ProjectItemModel::getClipByBinID(const QString &bin
std::shared_ptr<ProjectFolder> ProjectItemModel::getFolderByBinId(const QString &binId)
{
for (const auto &clip: m_allItems) {
for (const auto &clip : m_allItems) {
auto c = std::static_pointer_cast<AbstractProjectItem>(clip.second);
if (c->itemType() == AbstractProjectItem::FolderItem && c->clipId() == binId) {
return std::static_pointer_cast<ProjectFolder>(c);
......@@ -381,8 +381,7 @@ bool ProjectItemModel::requestBinClipDeletion(const QString &binId, Fun &undo, F
Q_ASSERT(clip);
if (!clip) return false;
int parentId = -1;
if (auto ptr = clip->parent())
parentId = ptr->getId();
if (auto ptr = clip->parent()) parentId = ptr->getId();
Fun operation = [this, binId]() {
/* Deletion simply deregister clip and remove it from parent.
The actual object is not actually deleted, because a shared_pointer to it
......@@ -402,16 +401,16 @@ bool ProjectItemModel::requestBinClipDeletion(const QString &binId, Fun &undo, F
Fun reverse = [this, clip, parentId]() {
/* To undo deletion, we reregister the clip */
std::shared_ptr<TreeItem> parent;
qDebug() << "reversing deletion. Parentid ="<<parentId;
qDebug() << "reversing deletion. Parentid =" << parentId;
if (parentId != -1) {
qDebug()<<"parent found";
qDebug() << "parent found";
parent = getItemById(parentId);
}
clip->changeParent(parent);
return true;
};
bool res = operation();
qDebug() << "operation succes"<<res;
qDebug() << "operation succes" << res;
if (res) {
LOCK_IN_LAMBDA(operation);
LOCK_IN_LAMBDA(reverse);
......@@ -419,23 +418,23 @@ bool ProjectItemModel::requestBinClipDeletion(const QString &binId, Fun &undo, F
res = clip->selfSoftDelete(undo, redo);
// PUSH_LAMBDA(operation, redo);
// PUSH_LAMBDA(reverse, undo);
qDebug() << "soltDelete succes"<<res;
qDebug() << "soltDelete succes" << res;
}
if (res) {
}
qDebug() << "Deletion success"<<res;
qDebug() << "Deletion success" << res;
return res;
}
void ProjectItemModel::registerItem(const std::shared_ptr<TreeItem> &item)
{
// TODO refac : here should go the logic of adding the clip into the bin playlist
qDebug() << "Top registering "<<item->getId();
qDebug() << "Top registering " << item->getId();
AbstractTreeModel::registerItem(item);
}
void ProjectItemModel::deregisterItem(int id)
{
// TODO refac : here should go the logic of adding the clip into the bin playlist
qDebug() << "Top deregistering "<<id;
qDebug() << "Top deregistering " << id;
AbstractTreeModel::deregisterItem(id);
}
......@@ -25,9 +25,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "abstractmodel/abstracttreemodel.hpp"
#include "mltcontroller/bincontroller.h"
#include <QSize>
#include <QReadWriteLock>
#include "undohelper.hpp"
#include <QReadWriteLock>
#include <QSize>
class AbstractProjectItem;
class ProjectClip;
......
......@@ -121,7 +121,6 @@ public:
/** @brief This function must be called whenever the profile used changes */
void profileChanged();
/** @brief Create and push and undo object based on the corresponding functions
Note that if you class permits and requires it, you should use the macro PUSH_UNDO instead*/
void pushUndo(const Fun &undo, const Fun &redo, const QString &text);
......
......@@ -569,8 +569,8 @@ void KdenliveSettingsDialog::initDevices()
void KdenliveSettingsDialog::slotReadAudioDevices()
{
QString result = QString(m_readProcess.readAllStandardOutput());
//qCDebug(KDENLIVE_LOG) << "// / / / / / READING APLAY: ";
//qCDebug(KDENLIVE_LOG) << result;
// qCDebug(KDENLIVE_LOG) << "// / / / / / READING APLAY: ";
// qCDebug(KDENLIVE_LOG) << result;
const QStringList lines = result.split(QLatin1Char('\n'));
for (const QString &data : lines) {
////qCDebug(KDENLIVE_LOG) << "// READING LINE: " << data;
......
......@@ -108,7 +108,7 @@ bool DocumentValidator::validate(const double currentVersion)
#elif defined(Q_OS_WIN)
std::locale::global(std::locale(requestedLocale.toUtf8().constData()));
#else
setlocale(LC_NUMERIC, requestedLocale.toUtf8().constData());
setlocale(LC_NUMERIC, requestedLocale.toUtf8().constData());
#endif
if (numericalSeparator != documentLocale.decimalPoint()) {
// Parse installed locales to find one matching
......
......@@ -386,9 +386,9 @@ QDomDocument KdenliveDoc::createEmptyDocument(const QList<TrackInfo> &tracks)
Mlt::Playlist playlist2(docProfile);
track.insert_track(playlist1, 0);
track.insert_track(playlist2, 1);
tractor.insert_track(track, i+1);
tractor.insert_track(track, i + 1);
}
QScopedPointer <Mlt::Field> field(tractor.field());
QScopedPointer<Mlt::Field> field(tractor.field());
QString compositeService = TransitionHandler::compositeTransition();
for (int i = 0; i <= tracks.count(); i++) {
if (i > 0) {
......@@ -1296,8 +1296,7 @@ QMap<QString, QString> KdenliveDoc::documentProperties()
m_projectFolder + QLatin1Char('/') + m_documentProperties.value(QStringLiteral("documentid")));
}
m_documentProperties.insert(QStringLiteral("profile"), profilePath());
m_documentProperties.insert(QStringLiteral("position"),
QString::number(pCore->monitorManager()->projectMonitor()->position()));
m_documentProperties.insert(QStringLiteral("position"), QString::number(pCore->monitorManager()->projectMonitor()->position()));
if (!m_documentProperties.contains(QStringLiteral("decimalPoint"))) {
m_documentProperties.insert(QStringLiteral("decimalPoint"), QLocale().decimalPoint());
}
......@@ -1732,4 +1731,3 @@ CommentedTime KdenliveDoc::getGuide(const GenTime &pos, bool *ok) const
{
return m_guideModel->getMarker(pos, ok);
}
......@@ -409,8 +409,7 @@ void EffectStackView2::setupListView()
// show monitor scene if necessary
m_effectMetaInfo.monitor->slotShowEffectScene(m_monitorSceneWanted);
}
int position =
(m_effectMetaInfo.monitor->position() - (m_status == TIMELINE_CLIP ? m_clipref->startPos().frames(KdenliveSettings::project_fps()) : 0));
int position = (m_effectMetaInfo.monitor->position() - (m_status == TIMELINE_CLIP ? m_clipref->startPos().frames(KdenliveSettings::project_fps()) : 0));
currentEffect->slotSyncEffectsPos(position);
currentEffect->setActive(isSelected);
m_effects.append(currentEffect);
......@@ -615,7 +614,8 @@ void EffectStackView2::slotUpdateEffectState(bool disable, int index, MonitorSce
if (m_monitorSceneWanted != MonitorSceneDefault) {
CollapsibleEffect *activeEffect = getEffectByIndex(index);
if (activeEffect) {
int position = (m_effectMetaInfo.monitor->position() - (m_status == TIMELINE_CLIP ? m_clipref->startPos().frames(KdenliveSettings::project_fps()) : 0));
int position =
(m_effectMetaInfo.monitor->position() - (m_status == TIMELINE_CLIP ? m_clipref->startPos().frames(KdenliveSettings::project_fps()) : 0));
activeEffect->slotSyncEffectsPos(position);
}
}
......@@ -810,7 +810,8 @@ void EffectStackView2::slotSetCurrentEffect(int ix)
effect->setActive(true);
m_monitorSceneWanted = effect->needsMonitorEffectScene();
m_effectMetaInfo.monitor->slotShowEffectScene(m_monitorSceneWanted);
int position = (m_effectMetaInfo.monitor->position() - (m_status == TIMELINE_CLIP ? m_clipref->startPos().frames(KdenliveSettings::project_fps()) : 0));
int position = (m_effectMetaInfo.monitor->position() -
(m_status == TIMELINE_CLIP ? m_clipref->startPos().frames(KdenliveSettings::project_fps()) : 0));
effect->slotSyncEffectsPos(position);
} else {
effect->setActive(false);
......
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