From f69c0d399c57d25cda78177a197a0b71d1dc5118 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Fri, 10 Jul 2009 04:24:46 +0000 Subject: Duplicate works on discontiguous selections by duplicating each selection. UndoGroup class simplifies grouping actions together in the undo history. --- src/Document.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/Document.h') diff --git a/src/Document.h b/src/Document.h index 4751cd2c8..240d59e39 100644 --- a/src/Document.h +++ b/src/Document.h @@ -320,6 +320,27 @@ private: void NotifyModified(DocModification mh); }; +class UndoGroup { + Document *pdoc; + bool groupNeeded; +public: + UndoGroup(Document *pdoc_, bool groupNeeded_=true) : + pdoc(pdoc_), groupNeeded(groupNeeded_) { + if (groupNeeded) { + pdoc->BeginUndoAction(); + } + } + ~UndoGroup() { + if (groupNeeded) { + pdoc->EndUndoAction(); + } + } + bool Needed() const { + return groupNeeded; + } +}; + + /** * To optimise processing of document modifications by DocWatchers, a hint is passed indicating the * scope of the change. -- cgit v1.2.3