Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 30bbf15f authored by Nicolas Carion's avatar Nicolas Carion

linting

parent b09c59a8
......@@ -25,8 +25,8 @@
#include <QDebug>
#include <utility>
#include <unordered_set>
#include <queue>
#include <unordered_set>
int AbstractTreeModel::currentTreeId = 0;
AbstractTreeModel::AbstractTreeModel(QObject *parent)
......@@ -41,7 +41,8 @@ std::shared_ptr<AbstractTreeModel> AbstractTreeModel::construct(QObject *parent)
return self;
}
AbstractTreeModel::~AbstractTreeModel(){
AbstractTreeModel::~AbstractTreeModel()
{
m_allItems.clear();
rootItem.reset();
}
......@@ -201,16 +202,14 @@ std::shared_ptr<TreeItem> AbstractTreeModel::getRoot() const
bool AbstractTreeModel::checkConsistency()
{
// first check that the root is all good
if (!rootItem || !rootItem->m_isRoot || !rootItem->isInModel()
|| m_allItems.count(rootItem->getId()) == 0){
qDebug() << !rootItem->m_isRoot << !rootItem->isInModel()
<< (m_allItems.count(rootItem->getId()) == 0);
if (!rootItem || !rootItem->m_isRoot || !rootItem->isInModel() || m_allItems.count(rootItem->getId()) == 0) {
qDebug() << !rootItem->m_isRoot << !rootItem->isInModel() << (m_allItems.count(rootItem->getId()) == 0);
qDebug() << "ERROR: Model is not valid because root is not properly constructed";
return false;
}
// Then we traverse the tree from the root, checking the infos on the way
std::unordered_set<int> seenIDs;
std::queue<std::pair<int, std::pair<int, int>> > queue; // store (id, (depth, parentId))
std::queue<std::pair<int, std::pair<int, int>>> queue; // store (id, (depth, parentId))
queue.push({rootItem->getId(), {0, rootItem->getId()}});
while (!queue.empty()) {
auto current = queue.front();
......@@ -236,17 +235,16 @@ bool AbstractTreeModel::checkConsistency()
return false;
}
if (currentId != rootItem->getId()) {
if((currentDepth == 0 || currentItem->m_isRoot)) {
if ((currentDepth == 0 || currentItem->m_isRoot)) {
qDebug() << "ERROR: Invalid tree: duplicate root";
return false;
}
if (auto ptr = currentItem->parentItem().lock()) {
if (ptr->getId() != parentId ||
ptr->child(currentItem->row())->getId() != currentItem->getId()) {
if (ptr->getId() != parentId || ptr->child(currentItem->row())->getId() != currentItem->getId()) {
qDebug() << "ERROR: Invalid tree: invalid parent link";
return false;
}
} else {
} else {
qDebug() << "ERROR: Invalid tree: invalid parent";
return false;
}
......
......@@ -50,7 +50,6 @@ public:
/* @brief Given an item from the hierarchy, construct the corresponding ModelIndex */
QModelIndex getIndexFromItem(const std::shared_ptr<TreeItem> &item) const;
/* @brief Return a ptr to an item given its id */
std::shared_ptr<TreeItem> getItemById(int id) const;
......
......@@ -160,7 +160,7 @@ bool TreeItem::changeParent(std::shared_ptr<TreeItem> newParent)
res = newParent->appendChild(shared_from_this());
if (res) {
m_parentItem = newParent;
} else if (oldParent){
} else if (oldParent) {
// something went wrong, we have to reset the parent.
bool reverse = oldParent->appendChild(shared_from_this());
Q_ASSERT(reverse);
......@@ -249,7 +249,8 @@ void TreeItem::deregisterSelf()
}
}
bool TreeItem::hasAncestor(int id) {
bool TreeItem::hasAncestor(int id)
{
if (m_id == id) {
return true;
}
......
......@@ -20,8 +20,8 @@
***************************************************************************/
#include "assetpanel.hpp"
#include "effects/effectstack/model/effectstackmodel.hpp"
#include "effects/effectstack/model/effectitemmodel.hpp"
#include "effects/effectstack/model/effectstackmodel.hpp"
#include "effects/effectstack/view/effectstackview.hpp"
#include "kdenlivesettings.h"
#include "model/assetparametermodel.hpp"
......@@ -62,7 +62,7 @@ void AssetPanel::showTransition(int tid, std::shared_ptr<AssetParameterModel> tr
m_transitionWidget->setModel(transitionModel, QPair<int, int>(-1, -1), true);
}
void AssetPanel::showEffectStack(const QString &clipName, std::shared_ptr<EffectStackModel> effectsModel, QPair <int, int>range)
void AssetPanel::showEffectStack(const QString &clipName, std::shared_ptr<EffectStackModel> effectsModel, QPair<int, int> range)
{
clear();
m_assetTitle->setText(i18n("%1 effects", clipName));
......@@ -125,8 +125,7 @@ const QString AssetPanel::getStyleSheet()
QStringLiteral("QFrame#decoframesub {border-top:1px solid palette(light);} QFrame#decoframesub[active=\"true\"] {background: %1;}").arg(hgh.name()));
// group background
stylesheet.append(QStringLiteral(
"QFrame#decoframegroup {border:2px solid palette(dark);margin:0px;margin-top:2px;} "));
stylesheet.append(QStringLiteral("QFrame#decoframegroup {border:2px solid palette(dark);margin:0px;margin-top:2px;} "));
// effect title bar
stylesheet.append(QStringLiteral("QFrame#frame {margin-bottom:2px;} QFrame#frame[target=\"true\"] "
......
......@@ -47,7 +47,7 @@ public:
void showTransition(int tid, std::shared_ptr<AssetParameterModel> transition_model);
/* @brief Shows the parameters of the given effect stack model */
void showEffectStack(const QString &clipName, std::shared_ptr<EffectStackModel> effectsModel, QPair <int, int>range);
void showEffectStack(const QString &clipName, std::shared_ptr<EffectStackModel> effectsModel, QPair<int, int> range);
/* @brief Clear the panel so that it doesn't display anything */
void clear();
......
......@@ -19,13 +19,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#include "assetcommand.hpp"
#include "transitions/transitionsrepository.hpp"
#include "effects/effectsrepository.hpp"
#include "transitions/transitionsrepository.hpp"
#include <memory>
AssetCommand::AssetCommand(std::shared_ptr<AssetParameterModel> model, const QModelIndex &index, const QString &value, QUndoCommand *parent)
: QUndoCommand(parent)
, m_model(model)
......@@ -67,11 +65,11 @@ int AssetCommand::id() const
// virtual
bool AssetCommand::mergeWith(const QUndoCommand *other)
{
if (other->id() != id() || static_cast<const AssetCommand *>(other)->m_index != m_index || m_stamp.msecsTo(static_cast<const AssetCommand *>(other)->m_stamp) > 3000) {
if (other->id() != id() || static_cast<const AssetCommand *>(other)->m_index != m_index ||
m_stamp.msecsTo(static_cast<const AssetCommand *>(other)->m_stamp) > 3000) {
return false;
}
m_value = static_cast<const AssetCommand *>(other)->m_value;
m_stamp = static_cast<const AssetCommand *>(other)->m_stamp;
return true;
}
......@@ -23,8 +23,8 @@
#define ASSETCOMMAND_H
#include "assetparametermodel.hpp"
#include <QUndoCommand>
#include <QTime>
#include <QUndoCommand>
class AssetCommand : public QUndoCommand
{
......
......@@ -21,8 +21,8 @@
#include "assetparametermodel.hpp"
#include "core.h"
#include "klocalizedstring.h"
#include "kdenlivesettings.h"
#include "klocalizedstring.h"
#include "profiles/profilemodel.hpp"
#include <QDebug>
#include <QLocale>
......@@ -173,7 +173,9 @@ QVariant AssetParameterModel::data(const QModelIndex &index, int role) const
return element.attribute(QStringLiteral("opacity")) != QLatin1String("false");
case ValueRole: {
QString value = m_asset->get(paramName.toUtf8().constData());
return value.isEmpty() ? (element.attribute(QStringLiteral("value")).isNull() ? parseAttribute(QStringLiteral("default"), element) : element.attribute(QStringLiteral("value"))) : value;
return value.isEmpty() ? (element.attribute(QStringLiteral("value")).isNull() ? parseAttribute(QStringLiteral("default"), element)
: element.attribute(QStringLiteral("value")))
: value;
}
case ListValuesRole:
return element.attribute(QStringLiteral("paramlist")).split(QLatin1Char(';'));
......@@ -195,7 +197,7 @@ int AssetParameterModel::rowCount(const QModelIndex &parent) const
// static
ParamType AssetParameterModel::paramTypeFromStr(const QString &type)
{
if (type == QLatin1String("double") || type == QLatin1String("float") ||type == QLatin1String("constant")) {
if (type == QLatin1String("double") || type == QLatin1String("float") || type == QLatin1String("constant")) {
return ParamType::Double;
}
if (type == QLatin1String("list")) {
......@@ -341,4 +343,3 @@ int AssetParameterModel::getParentId() const
{
return m_parentId;
}
......@@ -39,7 +39,6 @@
*/
enum class ParamType {
Double,
List,
......
......@@ -21,11 +21,11 @@
#include "assetparameterview.hpp"
#include "assets/model/assetparametermodel.hpp"
#include "assets/model/assetcommand.hpp"
#include "assets/model/assetparametermodel.hpp"
#include "assets/view/widgets/abstractparamwidget.hpp"
#include "effectstack/widgets/animationwidget.h"
#include "core.h"
#include "effectstack/widgets/animationwidget.h"
#include <QDebug>
#include <QFontDatabase>
......@@ -42,7 +42,7 @@ AssetParameterView::AssetParameterView(QWidget *parent)
setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
}
void AssetParameterView::setModel(const std::shared_ptr<AssetParameterModel> &model, QPair <int, int>range, bool addSpacer)
void AssetParameterView::setModel(const std::shared_ptr<AssetParameterModel> &model, QPair<int, int> range, bool addSpacer)
{
qDebug() << "set model " << model.get();
unsetModel();
......@@ -59,7 +59,7 @@ void AssetParameterView::setModel(const std::shared_ptr<AssetParameterModel> &mo
} else {
auto w = AbstractParamWidget::construct(model, index, range, this);
if (type == ParamType::Geometry || type == ParamType::Animated || type == ParamType::RestrictedAnim || type == ParamType::AnimatedRect) {
animWidget = static_cast<AnimationWidget*>(w);
animWidget = static_cast<AnimationWidget *>(w);
}
connect(w, &AbstractParamWidget::valueChanged, this, &AssetParameterView::commitChanges);
m_lay->addWidget(w);
......@@ -83,7 +83,7 @@ void AssetParameterView::resetValues()
}
}
void AssetParameterView::setRange(QPair <int, int> range)
void AssetParameterView::setRange(QPair<int, int> range)
{
QMutexLocker lock(&m_lock);
for (int i = 0; i < m_widgets.size(); ++i) {
......@@ -140,4 +140,3 @@ int AssetParameterView::contentHeight() const
{
return m_lay->sizeHint().height();
}
......@@ -23,9 +23,9 @@
#define ASSETPARAMETERVIEW_H
#include <QModelIndex>
#include <QMutex>
#include <QVector>
#include <QWidget>
#include <QMutex>
#include <memory>
/* @brief This class is the view for a list of parameters.
......@@ -44,7 +44,7 @@ public:
AssetParameterView(QWidget *parent = nullptr);
/** Sets the model to be displayed by current view */
void setModel(const std::shared_ptr<AssetParameterModel> &model, QPair <int, int>range, bool addSpacer = false);
void setModel(const std::shared_ptr<AssetParameterModel> &model, QPair<int, int> range, bool addSpacer = false);
/** Set the widget to display no model (this yield ownership on the smart-ptr)*/
void unsetModel();
......@@ -56,7 +56,7 @@ public:
void resetValues();
/** The parent clip in/out points changed, update effects */
void setRange(QPair <int, int> range);
void setRange(QPair<int, int> range);
protected:
/** @brief This is a handler for the dataChanged slot of the model.
......
......@@ -22,8 +22,8 @@
#include "boolparamwidget.hpp"
#include "doubleparamwidget.hpp"
#include "effectstack/widgets/animationwidget.h"
#include "effectstack/widgets/listparamwidget.h"
#include "effectstack/widgets/keyframeedit.h"
#include "effectstack/widgets/listparamwidget.h"
#include <QLabel>
#include <QVBoxLayout>
......@@ -56,7 +56,8 @@ AbstractParamWidget::AbstractParamWidget(std::shared_ptr<AssetParameterModel> mo
{
}
AbstractParamWidget *AbstractParamWidget::construct(const std::shared_ptr<AssetParameterModel> &model, QModelIndex index, QPair<int, int> range, QWidget *parent)
AbstractParamWidget *AbstractParamWidget::construct(const std::shared_ptr<AssetParameterModel> &model, QModelIndex index, QPair<int, int> range,
QWidget *parent)
{
// We retrieve the parameter type
auto type = model->data(index, AssetParameterModel::TypeRole).value<ParamType>();
......
......@@ -68,7 +68,7 @@ public slots:
/** @brief update the clip's in/out point
*/
virtual void slotSetRange(QPair<int, int>range) = 0;
virtual void slotSetRange(QPair<int, int> range) = 0;
protected:
std::shared_ptr<AssetParameterModel> m_model;
......
......@@ -64,7 +64,8 @@ void DoubleParamWidget::slotRefresh()
m_lay->addWidget(m_doubleWidget);
// Connect signal
connect(m_doubleWidget, &DoubleWidget::valueChanged, [this, locale](double value) { emit valueChanged(m_index, locale.toString(value / m_doubleWidget->factor)); });
connect(m_doubleWidget, &DoubleWidget::valueChanged,
[this, locale](double value) { emit valueChanged(m_index, locale.toString(value / m_doubleWidget->factor)); });
}
void DoubleParamWidget::slotShowComment(bool show)
......@@ -75,4 +76,3 @@ void DoubleParamWidget::slotShowComment(bool show)
void DoubleParamWidget::slotSetRange(QPair<int, int>)
{
}
......@@ -1386,7 +1386,7 @@ QString Bin::slotAddFolder(const QString &folderName)
std::shared_ptr<AbstractProjectItem> currentItem = m_itemModel->getBinItemByIndex(m_proxyModel->mapToSource(ix));
parentFolder = std::static_pointer_cast<ProjectFolder>(currentItem->getEnclosingFolder());
}
qDebug() << "pranteforder id"<<parentFolder->clipId();
qDebug() << "pranteforder id" << parentFolder->clipId();
QString newId;
Fun undo = []() { return true; };
Fun redo = []() { return true; };
......@@ -1400,7 +1400,7 @@ QString Bin::slotAddFolder(const QString &folderName)
}
auto folder = m_itemModel->getFolderByBinId(newId);
ix = m_itemModel->getIndexFromItem(folder);
qDebug() << "selecting"<<ix;
qDebug() << "selecting" << ix;
if (ix.isValid()) {
qDebug() << "ix valid";
m_proxyModel->selectionModel()->clearSelection();
......@@ -2844,7 +2844,6 @@ void Bin::slotItemEdited(const QModelIndex &ix, const QModelIndex &, const QVect
}
}
void Bin::renameSubClipCommand(const QString &id, const QString &newName, const QString &oldName, int in, int out)
{
auto *command = new RenameBinSubClipCommand(this, id, newName, oldName, in, out);
......
......@@ -96,7 +96,6 @@ void MoveBinFolderCommand::redo()
m_bin->doMoveFolder(m_clipId, m_newParentId);
}
RenameBinSubClipCommand::RenameBinSubClipCommand(Bin *bin, const QString &clipId, const QString &newName, const QString &oldName, int in, int out,
QUndoCommand *parent)
: QUndoCommand(parent)
......
......@@ -22,8 +22,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "projectfolder.h"
#include "bin.h"
#include "projectclip.h"
#include "core.h"
#include "projectclip.h"
#include "projectitemmodel.h"
#include "utils/KoIconUtils.h"
......
......@@ -26,16 +26,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "doc/kdenlivedoc.h"
#include "kdenlivesettings.h"
#include "macros.hpp"
#include "profiles/profilemodel.hpp"
#include "projectclip.h"
#include "projectfolder.h"
#include "projectsubclip.h"
#include "profiles/profilemodel.hpp"
#include <KLocalizedString>
#include <QIcon>
#include <QMimeData>
#include <qvarlengtharray.h>
#include <mlt++/Mlt.h>
#include <qvarlengtharray.h>
ProjectItemModel::ProjectItemModel(Bin *bin, QObject *parent)
: AbstractTreeModel(parent)
......@@ -326,11 +326,11 @@ QStringList ProjectItemModel::getEnclosingFolderInfo(const QModelIndex &index) c
void ProjectItemModel::clean()
{
std::vector<std::shared_ptr<TreeItem> > toDelete;
std::vector<std::shared_ptr<TreeItem>> toDelete;
for (int i = 0; i < rootItem->childCount(); ++i) {
toDelete.push_back(rootItem->child(i));
}
for (const auto& child : toDelete) {
for (const auto &child : toDelete) {
rootItem->removeChild(child);
}
Q_ASSERT(rootItem->childCount() == 0);
......@@ -410,16 +410,16 @@ void ProjectItemModel::registerItem(const std::shared_ptr<TreeItem> &item)
}
void ProjectItemModel::deregisterItem(int id, TreeItem *item)
{
auto clip = static_cast<AbstractProjectItem*>(item);
auto clip = static_cast<AbstractProjectItem *>(item);
manageBinClipDeletion(clip);
AbstractTreeModel::deregisterItem(id, item);
}
void ProjectItemModel::manageBinClipInsertion(const std::shared_ptr<AbstractProjectItem> &binElem)
{
switch(binElem->itemType()) {
switch (binElem->itemType()) {
case AbstractProjectItem::FolderItem: {
//When a folder is inserted, we have to store its path into the properties
// When a folder is inserted, we have to store its path into the properties
if (binElem->parent()) {
QString propertyName = "kdenlive:folder." + binElem->parent()->clipId() + QLatin1Char('.') + binElem->clipId();
m_binPlaylist->set(propertyName.toUtf8().constData(), binElem->name().toUtf8().constData());
......@@ -433,9 +433,9 @@ void ProjectItemModel::manageBinClipInsertion(const std::shared_ptr<AbstractProj
void ProjectItemModel::manageBinClipDeletion(AbstractProjectItem *binElem)
{
switch(binElem->itemType()) {
switch (binElem->itemType()) {
case AbstractProjectItem::FolderItem: {
//When a folder is removed, we clear the path info
// When a folder is removed, we clear the path info
if (!binElem->lastParentId().isEmpty()) {
QString propertyName = "kdenlive:folder." + binElem->lastParentId() + QLatin1Char('.') + binElem->clipId();
m_binPlaylist->set(propertyName.toUtf8().constData(), (char *)nullptr);
......@@ -483,7 +483,7 @@ bool ProjectItemModel::requestAddFolder(QString &id, const QString &name, const
Fun ProjectItemModel::requestRenameFolder_lambda(std::shared_ptr<AbstractProjectItem> folder, const QString &newName)
{
int id = folder->getId();
return [this, id, newName](){
return [this, id, newName]() {
auto currentFolder = std::static_pointer_cast<AbstractProjectItem>(m_allItems[id].lock());
if (!currentFolder) {
return false;
......
......@@ -131,7 +131,6 @@ public:
void registerItem(const std::shared_ptr<TreeItem> &item) override;
void deregisterItem(int id, TreeItem *item) override;
protected:
/* @brief This function updates the underlying binPlaylist object to reflect deletion of a bin item
@param binElem is the bin item deleted. Note that exceptionnally, this function takes a raw pointer instead of a smart one.
......
......@@ -51,7 +51,7 @@ MltDeviceCapture::MltDeviceCapture(QString profile, /*VideoSurface *surface, */
{
analyseAudio = KdenliveSettings::monitor_audio();
if (profile.isEmpty()) {
//profile = KdenliveSettings::current_profile();
// profile = KdenliveSettings::current_profile();
}
buildConsumer(profile);
connect(this, &MltDeviceCapture::unblockPreview, this, &MltDeviceCapture::slotPreparePreview);
......
......@@ -356,8 +356,7 @@ void Core::clearAssetPanel(int itemId)
m_mainWindow->clearAssetPanel(itemId);
}
void Core::adjustAssetRange(int itemId, int in , int out)
void Core::adjustAssetRange(int itemId, int in, int out)
{
m_mainWindow->adjustAssetPanelRange(itemId, in, out);
}
......@@ -11,9 +11,9 @@ the Free Software Foundation, either version 3 of the License, or
#ifndef CORE_H
#define CORE_H
#include "definitions.h"
#include "kdenlivecore_export.h"
#include "undohelper.hpp"
#include "definitions.h"
#include <QObject>
#include <QTabWidget>
#include <QUrl>
......@@ -99,7 +99,7 @@ public:
/** @brief Returns a pointer to the current profile */
std::unique_ptr<ProfileModel> &getCurrentProfile() const;
/** @brief Define the active profile
/** @brief Define the active profile
* @returns true if profile exists, false if not found
*/
bool setCurrentProfile(const QString &profilePath);
......@@ -135,7 +135,7 @@ public:
void displayMessage(const QString &message, MessageType type, int timeout);
/** @brief Clear asset view if itemId is displayed. */
void clearAssetPanel(int itemId);
void adjustAssetRange(int itemId, int in , int out);
void adjustAssetRange(int itemId, int in, int out);
private:
explicit Core();
......
......@@ -19,14 +19,14 @@
#include "kdenlivesettingsdialog.h"
#include "clipcreationdialog.h"
#include "core.h"
#include "dialogs/profilesdialog.h"
#include "encodingprofilesdialog.h"
#include "kdenlivesettings.h"
#include "profiles/profilemodel.hpp"
#include "profilesdialog.h"
#include "project/dialogs/profilewidget.h"
#include "renderer.h"
#include "core.h"
#include "profiles/profilemodel.hpp"
#include "utils/KoIconUtils.h"
#ifdef USE_V4L
......@@ -1467,4 +1467,3 @@ void KdenliveSettingsDialog::slotReloadShuttleDevices()
QTimer::singleShot(200, this, SLOT(slotUpdateShuttleDevice()));
#endif // USE_JOGSHUTTLE
}
......@@ -18,12 +18,12 @@
***************************************************************************/
#include "renderwidget.h"
#include "core.h"
#include "dialogs/profilesdialog.h"
#include "kdenlivesettings.h"
#include "profiles/profilemodel.hpp"
#include "profiles/profilerepository.hpp"
#include "timecode.h"
#include "core.h"
#include "ui_saveprofile_ui.h"
#include "utils/KoIconUtils.h"
......
......@@ -21,7 +21,6 @@
#include "bin/bin.h"
#include "bin/bincommands.h"
#include "bin/model/markerlistmodel.hpp"
#include "profiles/profilerepository.hpp"
#include "bin/projectclip.h"
#include "core.h"
#include "dialogs/profilesdialog.h"
......@@ -36,6 +35,7 @@
#include "mltcontroller/effectscontroller.h"
#include "mltcontroller/producerqueue.h"
#include "profiles/profilemodel.hpp"
#include "profiles/profilerepository.hpp"
#include "project/clipmanager.h"
#include "project/projectcommands.h"
#include "renderer.h"
......@@ -1331,7 +1331,7 @@ void KdenliveDoc::loadDocumentProperties()
}
}
if (!profileFound) {
qDebug()<<"ERROR, no matching profile found";
qDebug() << "ERROR, no matching profile found";
}
updateProjectProfile(false);
}
......@@ -1470,9 +1470,9 @@ void KdenliveDoc::switchProfile(MltVideoProfile profile, const QString &id, cons
profile.height, QString::number((double)profile.frame_rate_num / profile.frame_rate_den, 'f', 2),
adjustMessage)) == KMessageBox::Continue) {
profile.description = QStringLiteral("%1x%2 %3fps")
.arg(profile.width)
.arg(profile.height)
.arg(QString::number((double)profile.frame_rate_num / profile.frame_rate_den, 'f', 2));
.arg(profile.width)
.arg(profile.height)
.arg(QString::number((double)profile.frame_rate_num / profile.frame_rate_den, 'f', 2));
ProfilesDialog::saveProfile(profile);
// reload profiles from disk
ProfileRepository::get()->refresh();
......
......@@ -21,9 +21,9 @@
#include "abstracteffectitem.hpp"
#include "core.h"
#include "effects/effectsrepository.hpp"
#include "effectstackmodel.hpp"
#include "core.h"
#include <utility>
AbstractEffectItem::AbstractEffectItem(const QList<QVariant> &data, const std::shared_ptr<AbstractTreeModel> &stack)
......@@ -35,8 +35,14 @@ AbstractEffectItem::AbstractEffectItem(const QList<QVariant> &data, const std::s
void AbstractEffectItem::markEnabled(const QString &name, bool enabled)
{
Fun undo = [this, enabled]() { setEnabled(!enabled);return true; };
Fun redo = [this, enabled]() { setEnabled(enabled);return true; };
Fun undo = [this, enabled]() {
setEnabled(!enabled);
return true;
};
Fun redo = [this, enabled]() {
setEnabled(enabled);
return true;
};
redo();
pCore->pushUndo(undo, redo, enabled ? i18n("Enable %1", name) : i18n("Disable %1", name));
}
......@@ -71,4 +77,3 @@ bool AbstractEffectItem::isEnabled() const
}
return m_enabled && m_effectStackEnabled && parentEnabled;
}
......@@ -46,9 +46,9 @@ public:
/* @brief Returns whether the effect is enabled */
bool isEnabled() const;
friend class EffectGroupModel;
protected:
friend class EffectGroupModel;
protected:
/* @brief Toogles the mlt effect according to the current activation state*/
virtual void updateEnable() = 0;
......
......@@ -24,8 +24,7 @@
#include "effectstackmodel.hpp"
#include <utility>
EffectGroupModel::EffectGroupModel(const QList<QVariant> &data, const QString &name,
const std::shared_ptr<AbstractTreeModel> &stack)
EffectGroupModel::EffectGroupModel(const QList<QVariant> &data, const QString &name, const std::shared_ptr<AbstractTreeModel> &stack)
: AbstractEffectItem(data, stack)
, m_name(name)
{
......@@ -44,7 +43,6 @@ std::shared_ptr<EffectGroupModel> EffectGroupModel::construct(const QString &nam
return self;
}
void EffectGroupModel::updateEnable()
{
for (int i = 0; i < childCount(); ++i) {
......
......@@ -22,8 +22,8 @@
#ifndef EFFECTGROUPMODEL_H
#define EFFECTGROUPMODEL_H
#include "abstractmodel/treeitem.hpp"
#include "abstracteffectitem.hpp"
#include "abstractmodel/treeitem.hpp"
class EffectStackModel;
/* @brief This represents a group of effects of the effectstack
......@@ -37,15 +37,12 @@ public:
*/
static std::shared_ptr<EffectGroupModel> construct(const QString &name, std::shared_ptr<AbstractTreeModel> stack);