From b91cfae3080bb8aea883cda782250c0c723a9d32 Mon Sep 17 00:00:00 2001 From: Vlad Zagorodniy Date: Sun, 3 Feb 2019 22:04:09 +0200 Subject: [PATCH] [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 --- kcmkwin/common/CMakeLists.txt | 2 +- .../{effectmodel.cpp => effectsmodel.cpp} | 44 +++++++++---------- .../common/{effectmodel.h => effectsmodel.h} | 6 +-- kcmkwin/kwindesktop/animationsmodel.cpp | 14 +++--- kcmkwin/kwindesktop/animationsmodel.h | 4 +- .../kwineffects/effectsfilterproxymodel.cpp | 12 ++--- kcmkwin/kwineffects/kcm.cpp | 8 ++-- kcmkwin/kwineffects/kcm.h | 4 +- 8 files changed, 47 insertions(+), 47 deletions(-) rename kcmkwin/common/{effectmodel.cpp => effectsmodel.cpp} (94%) rename kcmkwin/common/{effectmodel.h => effectsmodel.h} (97%) diff --git a/kcmkwin/common/CMakeLists.txt b/kcmkwin/common/CMakeLists.txt index c9eaf7107f..f6e211a543 100644 --- a/kcmkwin/common/CMakeLists.txt +++ b/kcmkwin/common/CMakeLists.txt @@ -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 diff --git a/kcmkwin/common/effectmodel.cpp b/kcmkwin/common/effectsmodel.cpp similarity index 94% rename from kcmkwin/common/effectmodel.cpp rename to kcmkwin/common/effectsmodel.cpp index 9725c8b56a..7998c4477f 100644 --- a/kcmkwin/common/effectmodel.cpp +++ b/kcmkwin/common/effectsmodel.cpp @@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ -#include "effectmodel.h" +#include "effectsmodel.h" #include #include @@ -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 EffectModel::roleNames() const +QHash EffectsModel::roleNames() const { QHash roleNames; roleNames[NameRole] = "NameRole"; @@ -113,7 +113,7 @@ QHash 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(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(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; diff --git a/kcmkwin/common/effectmodel.h b/kcmkwin/common/effectsmodel.h similarity index 97% rename from kcmkwin/common/effectmodel.h rename to kcmkwin/common/effectsmodel.h index ea81466d07..68b9981ab9 100644 --- a/kcmkwin/common/effectmodel.h +++ b/kcmkwin/common/effectsmodel.h @@ -34,7 +34,7 @@ along with this program. If not, see . 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 roleNames() const override; @@ -254,7 +254,7 @@ private: QVector m_effectsList; - Q_DISABLE_COPY(EffectModel) + Q_DISABLE_COPY(EffectsModel) }; } diff --git a/kcmkwin/kwindesktop/animationsmodel.cpp b/kcmkwin/kwindesktop/animationsmodel.cpp index ccab2809b2..17e31dfdfd 100644 --- a/kcmkwin/kwindesktop/animationsmodel.cpp +++ b/kcmkwin/kwindesktop/animationsmodel.cpp @@ -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(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()); } diff --git a/kcmkwin/kwindesktop/animationsmodel.h b/kcmkwin/kwindesktop/animationsmodel.h index 36b579eddd..10d4acc3e5 100644 --- a/kcmkwin/kwindesktop/animationsmodel.h +++ b/kcmkwin/kwindesktop/animationsmodel.h @@ -20,12 +20,12 @@ along with this program. If not, see . #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) diff --git a/kcmkwin/kwineffects/effectsfilterproxymodel.cpp b/kcmkwin/kwineffects/effectsfilterproxymodel.cpp index dfa7b98a1d..6edc647b45 100644 --- a/kcmkwin/kwineffects/effectsfilterproxymodel.cpp +++ b/kcmkwin/kwineffects/effectsfilterproxymodel.cpp @@ -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; } } diff --git a/kcmkwin/kwineffects/kcm.cpp b/kcmkwin/kwineffects/kcm.cpp index 1bac16512b..64df43640a 100644 --- a/kcmkwin/kwineffects/kcm.cpp +++ b/kcmkwin/kwineffects/kcm.cpp @@ -16,8 +16,8 @@ */ #include "kcm.h" -#include "effectmodel.h" #include "effectsfilterproxymodel.h" +#include "effectsmodel.h" #include #include @@ -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("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); } } diff --git a/kcmkwin/kwineffects/kcm.h b/kcmkwin/kwineffects/kcm.h index c8d8239d39..788ba3c3c3 100644 --- a/kcmkwin/kwineffects/kcm.h +++ b/kcmkwin/kwineffects/kcm.h @@ -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) };