From 8dd159d21f0c89ac2a828814284967fc631ab571 Mon Sep 17 00:00:00 2001 From: mental Date: Mon, 6 Mar 2006 05:08:31 +0000 Subject: [PATCH] add DocumentSubset::_clear --- ChangeLog | 5 +++++ src/document-subset.cpp | 15 +++++++++++++++ src/document-subset.h | 1 + 3 files changed, 21 insertions(+) diff --git a/ChangeLog b/ChangeLog index 492c77a14..15e64ddf1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-03-06 MenTaLguY + + * src/document-subset.h, src/document-subset.cpp: + add DocumentSubset::_clear + 2006-03-05 MenTaLguY * src/document-subset.h, src/document-subset.cpp: diff --git a/src/document-subset.cpp b/src/document-subset.cpp index f6b32c0f4..ba6e416cd 100644 --- a/src/document-subset.cpp +++ b/src/document-subset.cpp @@ -142,6 +142,7 @@ struct DocumentSubset::Relations : public GC::Managed, void addOne(SPObject *obj); void remove(SPObject *obj, bool subtree); void reorder(SPObject *obj); + void clear(); private: Record &_doAdd(SPObject *obj) { @@ -277,6 +278,16 @@ void DocumentSubset::Relations::remove(SPObject *obj, bool subtree) { changed_signal.emit(); } +void DocumentSubset::Relations::clear() { + Record &root=records[NULL]; + + while (!root.children.empty()) { + _doRemoveSubtree(root.children.front()); + } + + changed_signal.emit(); +} + void DocumentSubset::Relations::reorder(SPObject *obj) { SPObject::ParentIterator parent=obj; @@ -316,6 +327,10 @@ void DocumentSubset::_remove(SPObject *obj, bool subtree) { _relations->remove(obj, subtree); } +void DocumentSubset::_clear() { + _relations->clear(); +} + bool DocumentSubset::includes(SPObject *obj) const { return _relations->get(obj); } diff --git a/src/document-subset.h b/src/document-subset.h index 269b4c59b..e424a289c 100644 --- a/src/document-subset.h +++ b/src/document-subset.h @@ -42,6 +42,7 @@ protected: void _addOne(SPObject *obj); void _removeOne(SPObject *obj) { _remove(obj, false); } void _removeSubtree(SPObject *obj) { _remove(obj, true); } + void _clear(); private: DocumentSubset(DocumentSubset const &); // no copy -- 2.30.2