From 4534cd03b9369423d997504c1c7aca2974d4bc91 Mon Sep 17 00:00:00 2001 From: Antonis Tsiapaliokas Date: Wed, 28 Aug 2013 10:31:57 +0300 Subject: [PATCH] EffectFilterModel::findImage should always return a QString Also translate the rowIndex from the EffectFilterModel to the EffectModel --- kcmkwin/kwincompositing/model.cpp | 14 +++++++------- kcmkwin/kwincompositing/model.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/kcmkwin/kwincompositing/model.cpp b/kcmkwin/kwincompositing/model.cpp index 1133e34421..8a0775261f 100644 --- a/kcmkwin/kwincompositing/model.cpp +++ b/kcmkwin/kwincompositing/model.cpp @@ -238,9 +238,8 @@ void EffectModel::reload() { loadEffects(); } -void EffectModel::effectStatus(int rowIndex, bool effectState) { - QModelIndex currentIndex = createIndex(rowIndex, 0); - setData(currentIndex, effectState, EffectModel::EffectStatusRole); +void EffectModel::effectStatus(const QModelIndex &rowIndex, bool effectState) { + setData(rowIndex, effectState, EffectModel::EffectStatusRole); } void EffectModel::syncConfig() { @@ -276,9 +275,8 @@ void EffectModel::enableWidnowManagement(bool enabled) { EffectFilterModel::EffectFilterModel(QObject *parent) :QSortFilterProxyModel(parent), - m_effectModel(0) + m_effectModel( new EffectModel(this)) { - m_effectModel = new EffectModel(this); setSourceModel(m_effectModel); } @@ -338,11 +336,13 @@ bool EffectFilterModel::filterAcceptsRow(int source_row, const QModelIndex &sour } void EffectFilterModel::effectStatus(int rowIndex, bool effectState) { - m_effectModel->effectStatus(rowIndex, effectState); + const QModelIndex sourceIndex = mapToSource(index(rowIndex, 0)); + + m_effectModel->effectStatus(sourceIndex, effectState); } QString EffectFilterModel::findImage(const QString &imagePath, int size) { - m_effectModel->findImage(imagePath, size); + return m_effectModel->findImage(imagePath, size); } void EffectFilterModel::reload() { diff --git a/kcmkwin/kwincompositing/model.h b/kcmkwin/kwincompositing/model.h index efdfb592d0..ec158fa15e 100644 --- a/kcmkwin/kwincompositing/model.h +++ b/kcmkwin/kwincompositing/model.h @@ -74,7 +74,7 @@ public: virtual QHash< int, QByteArray > roleNames() const override; - void effectStatus(int rowIndex, bool effectState); + void effectStatus(const QModelIndex &rowIndex, bool effectState); QString findImage(const QString &imagePath, int size = 128); void reload(); void syncConfig();