From 68a2ef914305fac139eaf3bdb8264a3927d75e45 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Fri, 17 Jul 2009 19:37:47 +0000 Subject: [PATCH] remove revision-information entries when items got deleted in the model svn path=/trunk/KDE/kdebase/apps/; revision=998498 --- src/dolphinmodel.cpp | 17 ++++++++++++++++- src/dolphinmodel.h | 3 +++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/dolphinmodel.cpp b/src/dolphinmodel.cpp index f399c3304..c5ea06a36 100644 --- a/src/dolphinmodel.cpp +++ b/src/dolphinmodel.cpp @@ -70,7 +70,12 @@ bool DolphinModel::setData(const QModelIndex& index, const QVariant& value, int const QPersistentModelIndex key = index; const RevisionState state = static_cast(value.toInt()); if (m_revisionHash.value(key, LocalRevision) != state) { - m_hasRevisionData = true; + if (!m_hasRevisionData) { + connect(this, SIGNAL(rowsRemoved (const QModelIndex&, int, int)), + this, SLOT(slotRowsRemoved(const QModelIndex&, int, int))); + m_hasRevisionData = true; + } + m_revisionHash.insert(key, state); emit dataChanged(index, index); return true; @@ -138,6 +143,16 @@ bool DolphinModel::hasRevisionData() const return m_hasRevisionData; } +void DolphinModel::slotRowsRemoved(const QModelIndex& parent, int start, int end) +{ + Q_ASSERT(hasRevisionData()); + + const int column = parent.column(); + for (int row = start; row <= end; ++row) { + m_revisionHash.remove(parent.child(row, column)); + } +} + QVariant DolphinModel::displayRoleData(const QModelIndex& index) const { QString retString; diff --git a/src/dolphinmodel.h b/src/dolphinmodel.h index 717f21d4e..45fd1efa2 100644 --- a/src/dolphinmodel.h +++ b/src/dolphinmodel.h @@ -54,6 +54,9 @@ public: bool hasRevisionData() const; +private slots: + void slotRowsRemoved(const QModelIndex& parent, int start, int end); + private: QVariant displayRoleData(const QModelIndex& index) const; QVariant sortRoleData(const QModelIndex& index) const; -- 2.47.3