edbee - Qt Editor Library
textchange.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <QString>
9 
11 
12 namespace edbee {
13 
19 {
20 public:
21  TextChange(int offset, int length, const QString& text );
22  virtual ~TextChange();
23 
24  virtual void execute(TextDocument* document);
25  virtual void revert(TextDocument* document);
26 
27 protected:
28  virtual void mergeStoredData( AbstractRangedChange* change );
29 
30 public:
31  virtual bool giveAndMerge(TextDocument *document, Change* textChange );
32 
33  virtual QString toString();
34 
35  int offset() const;
36  void setOffset( int offset );
37  virtual int docLength() const;
38  virtual int storedLength() const;
39 
40  void setDocLength( int len );
41 
42  QString storedText() const;
43  void setStoredText( const QString& text );
44  void appendStoredText( const QString& text );
45  const QString docText( TextDocument* doc ) const;
46 
47  QString testString();
48 
49 protected:
50  void replaceText( TextDocument* document );
51 
52 private:
53  int offset_;
54  int length_;
55  QString text_;
56 };
57 
58 } // edbee
void replaceText(TextDocument *document)
replaces the text and stores the &#39;old&#39; content
Definition: textchange.cpp:184
This is the base and abstract class of a text document A TextDocument is the model part of the editor...
Definition: textdocument.h:40
virtual int docLength() const
This is the length in the document.
Definition: textchange.cpp:126
TextChange(int offset, int length, const QString &text)
Constructs a single textchange.
Definition: textchange.cpp:21
void setStoredText(const QString &text)
Sets the text of this change.
Definition: textchange.cpp:155
This is the basic text change that&#39;s the base of the textchanges.
Definition: textchange.h:18
void setDocLength(int len)
Set the length of the change.
Definition: textchange.cpp:141
const QString docText(TextDocument *doc) const
This method returns the text currently in the document.
Definition: textchange.cpp:169
void appendStoredText(const QString &text)
Appends the text to this change.
Definition: textchange.cpp:162
virtual ~TextChange()
undo&#39;s a single textchange
Definition: textchange.cpp:30
Copyright 2011-2013 - Reliable Bits Software by Blommers IT.
Definition: commentcommand.cpp:22
QString storedText() const
The text currently stored in this textchange.
Definition: textchange.cpp:147
virtual void execute(TextDocument *document)
executes the given textchange
Definition: textchange.cpp:37
int offset() const
Return the offset.
Definition: textchange.cpp:111
A basic change.
Definition: change.h:18
virtual bool giveAndMerge(TextDocument *document, Change *textChange)
This method gives the given change to this textchange. The changes will be merged if possible...
Definition: textchange.cpp:90
virtual QString toString()
converts the change to a string
Definition: textchange.cpp:102
virtual int storedLength() const
The content length is the length that&#39;s currently stored in memory.
Definition: textchange.cpp:133
virtual void revert(TextDocument *document)
Reverts the single textchange.
Definition: textchange.cpp:45
void setOffset(int offset)
set the new offset
Definition: textchange.cpp:119
This is an abstract class for ranged changes This are changes (text changes and line changes) that sp...
Definition: abstractrangedchange.h:15
QString testString()
This method returns a string used for testing.
Definition: textchange.cpp:176
virtual void mergeStoredData(AbstractRangedChange *change)
This method merges the old data with the new data change the data to merge with. ...
Definition: textchange.cpp:53