diff options
author | Caroline Chao <caroline.chao@digia.com> | 2014-09-16 10:10:11 +0200 |
---|---|---|
committer | Caroline Chao <caroline.chao@digia.com> | 2014-09-16 14:51:27 +0200 |
commit | 6003d1144070eedca43b14103446736e3e889b53 (patch) | |
tree | 40a7d5c08a011634113d18caf02d1b2b96386772 | |
parent | eec99c10abf982363caa46243f16ab83d75b65bb (diff) |
Fix Favorites not being updated properly
Change-Id: Ibab9d90051ed774b7388036c9498b434ba6f852e
Reviewed-by: Niels Weber <niels.weber@digia.com>
-rw-r--r-- | src/model.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/model.cpp b/src/model.cpp index abe138e..2ff33c9 100644 --- a/src/model.cpp +++ b/src/model.cpp @@ -83,14 +83,15 @@ void Model::addFavorite( const QString &data) QMap<QString, QVariant> temp; for (int i = 0; i < m_data.count(); i++) { temp = m_data.at(i); - QString key = temp.key(data); - if (key == "id") { - if (!temp["favorite"].toBool()) { - temp["favorite"] = true; - m_data.replace(i, temp); - Q_EMIT dataChanged(this->index(i), this->index(i)); + if (temp.keys().contains("id")) { + if (data == temp["id"]) { + if (!temp["favorite"].toBool()) { + temp["favorite"] = true; + m_data.replace(i, temp); + Q_EMIT dataChanged(this->index(i), this->index(i)); + } + break; } - break; } } } |