summaryrefslogtreecommitdiffstats
path: root/kcoloredit/editablestreamhistory.h
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit47d455dd55be855e4cc691c32f687f723d9247ee (patch)
tree52e236aaa2576bdb3840ebede26619692fed6d7d /kcoloredit/editablestreamhistory.h
downloadtdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.tar.gz
tdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegraphics@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kcoloredit/editablestreamhistory.h')
-rw-r--r--kcoloredit/editablestreamhistory.h107
1 files changed, 107 insertions, 0 deletions
diff --git a/kcoloredit/editablestreamhistory.h b/kcoloredit/editablestreamhistory.h
new file mode 100644
index 00000000..9fe59d99
--- /dev/null
+++ b/kcoloredit/editablestreamhistory.h
@@ -0,0 +1,107 @@
+/***************************************************************************
+ editablestreamhistory.h - description
+ -------------------
+ begin : Sun Jul 9 2000
+ copyright : (C) 2000 by Artur Rataj
+ email : art@zeus.polsl.gliwice.pl
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef EDITABLESTREAMHISTORY_H
+#define EDITABLESTREAMHISTORY_H
+
+/** A template class adding undo/redo history for EDITABLE_STREAM paste and cut
+ * methods
+ * @author Artur Rataj
+ */
+template <class EDITABLE_STREAM> class EditableStreamHistory {
+public:
+ /** Constructs the class with stream as an EDITABLE_STREAM and
+ * a given number of undo levels
+ */
+ EditableStreamHistory(EDITABLE_STREAM* stream, const int undoLevels);
+ ~EditableStreamHistory();
+ /** Cuts a stream at index, of length length.
+ * Uses undo/redo history.
+ * @return A stream that has been cut out
+ */
+ EDITABLE_STREAM cut(const int index, const int length);
+ /** Pastes a stream at index. Uses undo/redo history */
+ void paste(const int index, EDITABLE_STREAM& pasteStream);
+ /** Replaces a stream at index. Uses undo/redo history */
+ void replace(const int index, EDITABLE_STREAM& replaceStream);
+ /** @return Whether undo possible */
+ bool undoPossible();
+ /** @return Whether redo possible */
+ bool redoPossible();
+ /** Undoes if possible */
+ void undo();
+ /** Redoes if possible */
+ void redo();
+ /** @return A pointer to editableStream */
+ EDITABLE_STREAM* editableStream();
+
+protected:
+ /** An editable stream */
+ EDITABLE_STREAM* m_editableStream;
+ /** A number of undo levels */
+ int m_undoLevels;
+};
+
+template <class EDITABLE_STREAM> EditableStreamHistory<EDITABLE_STREAM>::
+ EditableStreamHistory(EDITABLE_STREAM* stream, const int undoLevels) {
+ m_editableStream = stream;
+ m_undoLevels = undoLevels;
+}
+template <class EDITABLE_STREAM> EditableStreamHistory<EDITABLE_STREAM>::~EditableStreamHistory() {
+}
+
+template <class EDITABLE_STREAM> EDITABLE_STREAM
+ EditableStreamHistory<EDITABLE_STREAM>::cut(const int index, const int length) {
+ EDITABLE_STREAM cut_stream = m_editableStream->cut(index, length);
+ return cut_stream;
+}
+
+template <class EDITABLE_STREAM> void
+ EditableStreamHistory<EDITABLE_STREAM>::paste(const int index, EDITABLE_STREAM& pasteStream) {
+ m_editableStream->paste(index, pasteStream);
+}
+
+template <class EDITABLE_STREAM> void
+ EditableStreamHistory<EDITABLE_STREAM>::replace(const int index, EDITABLE_STREAM& replaceStream) {
+ m_editableStream->cut(index, replaceStream.length());
+ m_editableStream->paste(index, replaceStream);
+}
+
+template <class EDITABLE_STREAM> bool
+ EditableStreamHistory<EDITABLE_STREAM>::undoPossible() {
+ return false;
+}
+
+template <class EDITABLE_STREAM> bool
+ EditableStreamHistory<EDITABLE_STREAM>::redoPossible() {
+ return false;
+}
+
+template <class EDITABLE_STREAM> void
+ EditableStreamHistory<EDITABLE_STREAM>::undo() {
+}
+
+template <class EDITABLE_STREAM> void
+ EditableStreamHistory<EDITABLE_STREAM>::redo() {
+}
+
+template <class EDITABLE_STREAM> EDITABLE_STREAM*
+ EditableStreamHistory<EDITABLE_STREAM>::editableStream() {
+ return m_editableStream;
+}
+
+#endif