┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2012-05-14 17:41:18 +0200
committerPeter Penz <[email protected]>2012-05-14 17:42:10 +0200
commitf74c72b9652ea4613156cc58b681c9244395cf72 (patch)
tree7207a8b38dc9141e0ea5cd1375fbb2b42a7d8a3f /src/kitemviews
parentc10affe267ed32a2df61e357b33fdb90911b045d (diff)
Fix several bookmark synchronization issues
Diffstat (limited to 'src/kitemviews')
-rw-r--r--src/kitemviews/kstandarditem.cpp9
-rw-r--r--src/kitemviews/kstandarditemmodel.cpp9
-rw-r--r--src/kitemviews/kstandarditemmodel.h6
3 files changed, 19 insertions, 5 deletions
diff --git a/src/kitemviews/kstandarditem.cpp b/src/kitemviews/kstandarditem.cpp
index dc03a0d25..6cb5b049b 100644
--- a/src/kitemviews/kstandarditem.cpp
+++ b/src/kitemviews/kstandarditem.cpp
@@ -103,7 +103,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 +138,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
diff --git a/src/kitemviews/kstandarditemmodel.cpp b/src/kitemviews/kstandarditemmodel.cpp
index fbcda8370..e3d40038d 100644
--- a/src/kitemviews/kstandarditemmodel.cpp
+++ b/src/kitemviews/kstandarditemmodel.cpp
@@ -93,11 +93,13 @@ void KStandardItemModel::removeItem(int index)
KStandardItem* item = m_items[index];
m_indexesForItems.remove(item);
m_items.removeAt(index);
+
+ onItemRemoved(index, item);
+ emit itemsRemoved(KItemRangeList() << KItemRange(index, 1));
+
delete item;
item = 0;
- onItemRemoved(index);
- emit itemsRemoved(KItemRangeList() << KItemRange(index, 1));
// TODO: no hierarchical items are handled yet
}
}
@@ -202,9 +204,10 @@ void KStandardItemModel::onItemChanged(int index, const QSet<QByteArray>& change
Q_UNUSED(changedRoles);
}
-void KStandardItemModel::onItemRemoved(int index)
+void KStandardItemModel::onItemRemoved(int index, KStandardItem* removedItem)
{
Q_UNUSED(index);
+ Q_UNUSED(removedItem);
}
diff --git a/src/kitemviews/kstandarditemmodel.h b/src/kitemviews/kstandarditemmodel.h
index be5b7c438..047c1e9b6 100644
--- a/src/kitemviews/kstandarditemmodel.h
+++ b/src/kitemviews/kstandarditemmodel.h
@@ -91,9 +91,11 @@ protected:
/**
* Is invoked after an item has been removed and before the signal
- * itemsRemoved() gets emitted.
+ * itemsRemoved() gets emitted. The item \a removedItem has already
+ * been removed from the model and will get deleted after the
+ * execution of onItemRemoved().
*/
- virtual void onItemRemoved(int index);
+ virtual void onItemRemoved(int index, KStandardItem* removedItem);
private:
QList<KStandardItem*> m_items;