]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kstandarditem.cpp
Merge branch 'Applications/18.04'
[dolphin.git] / src / kitemviews / kstandarditem.cpp
index dc03a0d251f888c7b59cae396c77b33e7fa8ebac..4fb3f8f9834143e61fdf4806199a5f8f11e24b93 100644 (file)
  ***************************************************************************/
 
 #include "kstandarditem.h"
-
-#include <KDebug>
 #include "kstandarditemmodel.h"
 
 KStandardItem::KStandardItem(KStandardItem* parent) :
     m_parent(parent),
     m_children(),
-    m_model(0),
+    m_model(nullptr),
     m_data()
 {
 }
@@ -33,7 +31,7 @@ KStandardItem::KStandardItem(KStandardItem* parent) :
 KStandardItem::KStandardItem(const QString& text, KStandardItem* parent) :
     m_parent(parent),
     m_children(),
-    m_model(0),
+    m_model(nullptr),
     m_data()
 {
     setText(text);
@@ -42,7 +40,7 @@ KStandardItem::KStandardItem(const QString& text, KStandardItem* parent) :
 KStandardItem::KStandardItem(const QString& icon, const QString& text, KStandardItem* parent) :
     m_parent(parent),
     m_children(),
-    m_model(0),
+    m_model(nullptr),
     m_data()
 {
     setIcon(icon);
@@ -103,7 +101,14 @@ QString KStandardItem::group() const
 
 void KStandardItem::setDataValue(const QByteArray& role, const QVariant& value)
 {
+    const QVariant previous = m_data.value(role);
+    if (previous == value) {
+        return;
+    }
+
     m_data.insert(role, value);
+    onDataValueChanged(role, value, previous);
+
     if (m_model) {
         const int index = m_model->index(this);
         QSet<QByteArray> changedRoles;
@@ -131,7 +136,9 @@ KStandardItem* KStandardItem::parent() const
 
 void KStandardItem::setData(const QHash<QByteArray, QVariant>& values)
 {
+    const QHash<QByteArray, QVariant> previous = m_data;
     m_data = values;
+    onDataChanged(values, previous);
 }
 
 QHash<QByteArray, QVariant> KStandardItem::data() const