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

Add proper transitionfilter to display selcted transitions only

parent 4fa39c87
......@@ -3,6 +3,7 @@ set(kdenlive_SRCS
transitions/transitionsrepository.cpp
transitions/transitionlist/view/transitionlistwidget.cpp
transitions/transitionlist/model/transitiontreemodel.cpp
transitions/transitionlist/model/transitionfilter.cpp
transitions/view/transitionparameterview.cpp
transitions/view/transitionstackview.cpp
PARENT_SCOPE)
......
/***************************************************************************
* Copyright (C) 2017 by Nicolas Carion *
* This file is part of Kdenlive. See www.kdenlive.org. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) version 3 or any later version accepted by the *
* membership of KDE e.V. (or its successor approved by the membership *
* of KDE e.V.), which shall act as a proxy defined in Section 14 of *
* version 3 of the license. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#include "transitionfilter.hpp"
#include "abstractmodel/treeitem.hpp"
#include "assets/assetlist/model/assettreemodel.hpp"
TransitionFilter::TransitionFilter(QObject *parent)
: AssetFilter(parent)
{
m_type_enabled = false;
}
void TransitionFilter::setFilterType(bool enabled, TransitionType type)
{
m_type_enabled = enabled;
m_type_value = type;
invalidateFilter();
}
bool TransitionFilter::filterType(const std::shared_ptr<TreeItem> &item) const
{
if (!m_type_enabled) {
return true;
}
if (m_type_value == TransitionType::Favorites) {
return item->dataColumn(AssetTreeModel::favCol).toBool();
}
auto itemType = item->dataColumn(AssetTreeModel::typeCol).value<TransitionType>();
return itemType == m_type_value;
}
bool TransitionFilter::applyAll(std::shared_ptr<TreeItem> item) const
{
return filterName(item) && filterType(item);
}
/***************************************************************************
* Copyright (C) 2017 by Nicolas Carion *
* This file is part of Kdenlive. See www.kdenlive.org. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) version 3 or any later version accepted by the *
* membership of KDE e.V. (or its successor approved by the membership *
* of KDE e.V.), which shall act as a proxy defined in Section 14 of *
* version 3 of the license. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#ifndef TRANSITIONFILTER_H
#define TRANSITIONFILTER_H
#include "assets/assetlist/model/assetfilter.hpp"
#include "transitions/transitionsrepository.hpp"
#include <QSortFilterProxyModel>
#include <memory>
/* @brief This class is used as a proxy model to filter the effect tree based on given criterion (name, type).
It simply adds a filter of type
*/
class TransitionFilter : public AssetFilter
{
Q_OBJECT
public:
TransitionFilter(QObject *parent = nullptr);
/* @brief Manage the type filter
@param enabled whether to enable this filter
@param type Effect type to display
*/
void setFilterType(bool enabled, TransitionType type);
protected:
bool filterType(const std::shared_ptr<TreeItem> &item) const;
bool applyAll(std::shared_ptr<TreeItem> item) const override;
bool m_type_enabled;
TransitionType m_type_value;
};
#endif
......@@ -20,9 +20,8 @@
***************************************************************************/
#include "transitionlistwidget.hpp"
#include "effects/effectlist/model/effectfilter.hpp"
#include "transitions/transitionlist/model/transitionfilter.hpp"
#include "../model/transitiontreemodel.hpp"
#include "assets/assetlist/model/assetfilter.hpp"
#include "transitions/transitionsrepository.hpp"
#include <QQmlContext>
......@@ -33,7 +32,7 @@ TransitionListWidget::TransitionListWidget(QWidget *parent)
m_model = TransitionTreeModel::construct(false, this);
m_proxyModel.reset(new EffectFilter(this));
m_proxyModel.reset(new TransitionFilter(this));
m_proxyModel->setSourceModel(m_model.get());
m_proxyModel->setSortRole(AssetTreeModel::NameRole);
m_proxyModel->sort(0, Qt::AscendingOrder);
......@@ -69,8 +68,8 @@ void TransitionListWidget::updateFavorite(const QModelIndex &index)
void TransitionListWidget::setFilterType(const QString &type)
{
if (type == "favorites") {
static_cast<EffectFilter *>(m_proxyModel.get())->setFilterType(true, EffectType::Favorites);
static_cast<TransitionFilter *>(m_proxyModel.get())->setFilterType(true, TransitionType::Favorites);
} else {
static_cast<EffectFilter *>(m_proxyModel.get())->setFilterType(false, EffectType::Video);
static_cast<TransitionFilter *>(m_proxyModel.get())->setFilterType(false, TransitionType::Favorites);
}
}
......@@ -33,7 +33,7 @@
* Note that this class is a Singleton
*/
enum class TransitionType { AudioComposition, VideoComposition, AudioTransition, VideoTransition };
enum class TransitionType { AudioComposition, VideoComposition, AudioTransition, VideoTransition, Favorites };
Q_DECLARE_METATYPE(TransitionType)
class TransitionsRepository : public AbstractAssetsRepository<TransitionType>
......
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