Commit b91cfae3 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii

[kcmkwin] Rename EffectModel to EffectsModel

Summary: Model names have plural form.

Test Plan: Compiles.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18712
parent dc3bc5f7
......@@ -4,7 +4,7 @@ add_definitions(-DTRANSLATION_DOMAIN=\"kcmkwincommon\")
include_directories(${KWIN_SOURCE_DIR}/effects)
set(kcmkwincommon_SRC
effectmodel.cpp
effectsmodel.cpp
)
qt5_add_dbus_interface(kcmkwincommon_SRC
......
......@@ -19,7 +19,7 @@ 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 "effectmodel.h"
#include "effectsmodel.h"
#include <config-kwin.h>
#include <effect_builtins.h>
......@@ -80,17 +80,17 @@ static QString translatedCategory(const QString &category)
return translatedCategories[index];
}
static EffectModel::Status effectStatus(bool enabled)
static EffectsModel::Status effectStatus(bool enabled)
{
return enabled ? EffectModel::Status::Enabled : EffectModel::Status::Disabled;
return enabled ? EffectsModel::Status::Enabled : EffectsModel::Status::Disabled;
}
EffectModel::EffectModel(QObject *parent)
EffectsModel::EffectsModel(QObject *parent)
: QAbstractItemModel(parent)
{
}
QHash<int, QByteArray> EffectModel::roleNames() const
QHash<int, QByteArray> EffectsModel::roleNames() const
{
QHash<int, QByteArray> roleNames;
roleNames[NameRole] = "NameRole";
......@@ -113,7 +113,7 @@ QHash<int, QByteArray> EffectModel::roleNames() const
return roleNames;
}
QModelIndex EffectModel::index(int row, int column, const QModelIndex &parent) const
QModelIndex EffectsModel::index(int row, int column, const QModelIndex &parent) const
{
if (parent.isValid() || column > 0 || column < 0 || row < 0 || row >= m_effectsList.count()) {
return {};
......@@ -122,19 +122,19 @@ QModelIndex EffectModel::index(int row, int column, const QModelIndex &parent) c
return createIndex(row, column);
}
QModelIndex EffectModel::parent(const QModelIndex &child) const
QModelIndex EffectsModel::parent(const QModelIndex &child) const
{
Q_UNUSED(child)
return {};
}
int EffectModel::columnCount(const QModelIndex &parent) const
int EffectsModel::columnCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)
return 1;
}
int EffectModel::rowCount(const QModelIndex &parent) const
int EffectsModel::rowCount(const QModelIndex &parent) const
{
if (parent.isValid()) {
return 0;
......@@ -142,7 +142,7 @@ int EffectModel::rowCount(const QModelIndex &parent) const
return m_effectsList.count();
}
QVariant EffectModel::data(const QModelIndex &index, int role) const
QVariant EffectsModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid()) {
return {};
......@@ -192,7 +192,7 @@ QVariant EffectModel::data(const QModelIndex &index, int role) const
}
}
bool EffectModel::setData(const QModelIndex &index, const QVariant &value, int role)
bool EffectsModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
if (!index.isValid()) {
return QAbstractItemModel::setData(index, value, role);
......@@ -228,7 +228,7 @@ bool EffectModel::setData(const QModelIndex &index, const QVariant &value, int r
return QAbstractItemModel::setData(index, value, role);
}
void EffectModel::loadBuiltInEffects(const KConfigGroup &kwinConfig, const KPluginInfo::List &configs)
void EffectsModel::loadBuiltInEffects(const KConfigGroup &kwinConfig, const KPluginInfo::List &configs)
{
const auto builtins = BuiltInEffects::availableEffects();
for (auto builtin : builtins) {
......@@ -274,7 +274,7 @@ void EffectModel::loadBuiltInEffects(const KConfigGroup &kwinConfig, const KPlug
}
}
void EffectModel::loadJavascriptEffects(const KConfigGroup &kwinConfig)
void EffectsModel::loadJavascriptEffects(const KConfigGroup &kwinConfig)
{
const auto plugins = KPackage::PackageLoader::self()->listPackages(
QStringLiteral("KWin/Effect"),
......@@ -319,7 +319,7 @@ void EffectModel::loadJavascriptEffects(const KConfigGroup &kwinConfig)
}
}
void EffectModel::loadPluginEffects(const KConfigGroup &kwinConfig, const KPluginInfo::List &configs)
void EffectsModel::loadPluginEffects(const KConfigGroup &kwinConfig, const KPluginInfo::List &configs)
{
const auto pluginEffects = KPluginLoader::findPlugins(
QStringLiteral("kwin/effects/plugins/"),
......@@ -387,7 +387,7 @@ void EffectModel::loadPluginEffects(const KConfigGroup &kwinConfig, const KPlugi
}
}
void EffectModel::load(LoadOptions options)
void EffectsModel::load(LoadOptions options)
{
KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Plugins");
......@@ -473,12 +473,12 @@ void EffectModel::load(LoadOptions options)
endResetModel();
}
void EffectModel::updateEffectStatus(const QModelIndex &rowIndex, Status effectState)
void EffectsModel::updateEffectStatus(const QModelIndex &rowIndex, Status effectState)
{
setData(rowIndex, static_cast<int>(effectState), StatusRole);
}
void EffectModel::save()
void EffectsModel::save()
{
KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Plugins");
......@@ -529,7 +529,7 @@ void EffectModel::save()
}
}
void EffectModel::defaults()
void EffectsModel::defaults()
{
for (int i = 0; i < m_effectsList.count(); ++i) {
const auto &effect = m_effectsList.at(i);
......@@ -541,7 +541,7 @@ void EffectModel::defaults()
}
}
bool EffectModel::needsSave() const
bool EffectsModel::needsSave() const
{
return std::any_of(m_effectsList.constBegin(), m_effectsList.constEnd(),
[](const EffectData &data) {
......@@ -550,7 +550,7 @@ bool EffectModel::needsSave() const
);
}
QModelIndex EffectModel::findByPluginId(const QString &pluginId) const
QModelIndex EffectsModel::findByPluginId(const QString &pluginId) const
{
auto it = std::find_if(m_effectsList.constBegin(), m_effectsList.constEnd(),
[pluginId](const EffectData &data) {
......@@ -595,7 +595,7 @@ static KCModule *findScriptedConfig(const QString &pluginId, QObject *parent)
return factory->create<KCModule>(pluginId, parent);
}
void EffectModel::requestConfigure(const QModelIndex &index, QWindow *transientParent)
void EffectsModel::requestConfigure(const QModelIndex &index, QWindow *transientParent)
{
if (!index.isValid()) {
return;
......@@ -635,7 +635,7 @@ void EffectModel::requestConfigure(const QModelIndex &index, QWindow *transientP
delete dialog;
}
bool EffectModel::shouldStore(const EffectData &data) const
bool EffectsModel::shouldStore(const EffectData &data) const
{
Q_UNUSED(data)
return true;
......
......@@ -34,7 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin
{
class KWIN_EXPORT EffectModel : public QAbstractItemModel
class KWIN_EXPORT EffectsModel : public QAbstractItemModel
{
Q_OBJECT
......@@ -139,7 +139,7 @@ public:
Enabled = Qt::Checked
};
explicit EffectModel(QObject *parent = nullptr);
explicit EffectsModel(QObject *parent = nullptr);
// Reimplemented from QAbstractItemModel.
QHash<int, QByteArray> roleNames() const override;
......@@ -254,7 +254,7 @@ private:
QVector<EffectData> m_effectsList;
Q_DISABLE_COPY(EffectModel)
Q_DISABLE_COPY(EffectsModel)
};
}
......@@ -24,7 +24,7 @@ namespace KWin
{
AnimationsModel::AnimationsModel(QObject *parent)
: EffectModel(parent)
: EffectsModel(parent)
{
connect(this, &AnimationsModel::currentIndexChanged, this,
[this] {
......@@ -78,7 +78,7 @@ bool AnimationsModel::shouldStore(const EffectData &data) const
QStringLiteral("Virtual Desktop Switching Animation"), Qt::CaseInsensitive);
}
EffectModel::Status AnimationsModel::status(int row) const
EffectsModel::Status AnimationsModel::status(int row) const
{
return Status(data(index(row, 0), static_cast<int>(StatusRole)).toInt());
}
......@@ -107,7 +107,7 @@ int AnimationsModel::modelCurrentIndex() const
void AnimationsModel::load()
{
EffectModel::load();
EffectsModel::load();
setEnabled(modelCurrentEnabled());
setCurrentIndex(modelCurrentIndex());
}
......@@ -116,17 +116,17 @@ void AnimationsModel::save()
{
for (int i = 0; i < rowCount(); ++i) {
const auto status = (m_enabled && i == m_currentIndex)
? EffectModel::Status::Enabled
: EffectModel::Status::Disabled;
? EffectsModel::Status::Enabled
: EffectsModel::Status::Disabled;
updateEffectStatus(index(i, 0), status);
}
EffectModel::save();
EffectsModel::save();
}
void AnimationsModel::defaults()
{
EffectModel::defaults();
EffectsModel::defaults();
setEnabled(modelCurrentEnabled());
setCurrentIndex(modelCurrentIndex());
}
......
......@@ -20,12 +20,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
#include "effectmodel.h"
#include "effectsmodel.h"
namespace KWin
{
class AnimationsModel : public EffectModel
class AnimationsModel : public EffectsModel
{
Q_OBJECT
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
......
......@@ -17,7 +17,7 @@
#include "effectsfilterproxymodel.h"
#include "effectmodel.h"
#include "effectsmodel.h"
namespace KWin
{
......@@ -78,22 +78,22 @@ bool EffectsFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex
const QModelIndex idx = sourceModel()->index(sourceRow, 0, sourceParent);
if (!m_query.isEmpty()) {
const bool matches = idx.data(EffectModel::NameRole).toString().contains(m_query, Qt::CaseInsensitive) ||
idx.data(EffectModel::DescriptionRole).toString().contains(m_query, Qt::CaseInsensitive) ||
idx.data(EffectModel::CategoryRole).toString().contains(m_query, Qt::CaseInsensitive);
const bool matches = idx.data(EffectsModel::NameRole).toString().contains(m_query, Qt::CaseInsensitive) ||
idx.data(EffectsModel::DescriptionRole).toString().contains(m_query, Qt::CaseInsensitive) ||
idx.data(EffectsModel::CategoryRole).toString().contains(m_query, Qt::CaseInsensitive);
if (!matches) {
return false;
}
}
if (m_excludeInternal) {
if (idx.data(EffectModel::InternalRole).toBool()) {
if (idx.data(EffectsModel::InternalRole).toBool()) {
return false;
}
}
if (m_excludeUnsupported) {
if (!idx.data(EffectModel::SupportedRole).toBool()) {
if (!idx.data(EffectsModel::SupportedRole).toBool()) {
return false;
}
}
......
......@@ -16,8 +16,8 @@
*/
#include "kcm.h"
#include "effectmodel.h"
#include "effectsfilterproxymodel.h"
#include "effectsmodel.h"
#include <KAboutData>
#include <KLocalizedString>
......@@ -35,7 +35,7 @@ namespace KWin
DesktopEffectsKCM::DesktopEffectsKCM(QObject *parent, const QVariantList &args)
: KQuickAddons::ConfigModule(parent, args)
, m_model(new EffectModel(this))
, m_model(new EffectsModel(this))
{
qmlRegisterType<EffectsFilterProxyModel>("org.kde.private.kcms.kwin.effects", 1, 0, "EffectsFilterProxyModel");
......@@ -51,7 +51,7 @@ DesktopEffectsKCM::DesktopEffectsKCM(QObject *parent, const QVariantList &args)
setButtons(Apply | Default);
connect(m_model, &EffectModel::dataChanged, this, &DesktopEffectsKCM::updateNeedsSave);
connect(m_model, &EffectsModel::dataChanged, this, &DesktopEffectsKCM::updateNeedsSave);
}
DesktopEffectsKCM::~DesktopEffectsKCM()
......@@ -93,7 +93,7 @@ void DesktopEffectsKCM::openGHNS(QQuickItem *context)
if (dialog->exec() == QDialog::Accepted) {
if (!dialog->changedEntries().isEmpty()) {
m_model->load(EffectModel::LoadOptions::KeepDirty);
m_model->load(EffectsModel::LoadOptions::KeepDirty);
}
}
......
......@@ -25,7 +25,7 @@
namespace KWin
{
class EffectModel;
class EffectsModel;
class DesktopEffectsKCM : public KQuickAddons::ConfigModule
{
......@@ -50,7 +50,7 @@ private Q_SLOTS:
void updateNeedsSave();
private:
EffectModel *m_model;
EffectsModel *m_model;
Q_DISABLE_COPY(DesktopEffectsKCM)
};
......
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