language/editor
KDevelop::DocumentRangeObject Class Reference
Base class for any object which has an associated range of text. More...
#include <documentrangeobject.h>
Inherits KTextEditor::SmartRangeWatcher.
Public Types | |
| enum | RangeOwning { Own, DontOwn } |
Public Member Functions | |
| DocumentRangeObject (const SimpleRange &range) | |
| virtual | ~DocumentRangeObject () |
| void | clearSmartRange () |
| bool | contains (const SimpleCursor &cursor) const |
| RangeOwning | ownsRange () const |
| SimpleRange | range () const |
| virtual void | setData (DocumentRangeObjectData *, bool constructorCalled=true) |
| void | setRange (const SimpleRange &range) |
| void | setRangeOwning (RangeOwning ownsRange) |
| void | setSmartRange (KTextEditor::SmartRange *range, RangeOwning ownsRange=Own) |
| KTextEditor::SmartRange * | smartRange () const |
| KTextEditor::SmartRange * | takeRange () |
Protected Member Functions | |
| DocumentRangeObject (DocumentRangeObjectData &dd, const SimpleRange &range=SimpleRange::invalid()) | |
| DocumentRangeObject (DocumentRangeObject &useDataFrom) | |
| virtual void | aboutToWriteData () |
| virtual bool | canWriteData () const |
| virtual void | rangeDeleted (KTextEditor::SmartRange *range) |
Static Protected Member Functions | |
| static QMutex * | mutex () |
Protected Attributes | |
| DocumentRangeObjectData * | d_ptr |
Detailed Description
Base class for any object which has an associated range of text.
This allows text without a currently loaded text editor to be represented.
- Todo:
- Silently synchronising from smart ranges to return the range is not a good idea, because as soon as the user receives the range, it may be out of date already. Better to force them to understand that the smart mutex must be locked and thus retrieve a useful range to start with.
Definition at line 77 of file documentrangeobject.h.
Member Enumeration Documentation
An enumeration of ownership for the smart range.
Definition at line 91 of file documentrangeobject.h.
Constructor & Destructor Documentation
| KDevelop::DocumentRangeObject::DocumentRangeObject | ( | const SimpleRange & | range | ) |
Constructor.
- Parameters:
-
document The document which this object is located in. May be empty, then it will not be changed (can come from a copy constructor) range The range which this object occupies. May be invalid, then it is not changed (So it can come from a copy constructor)
Definition at line 96 of file documentrangeobject.cpp.
| KDevelop::DocumentRangeObject::~DocumentRangeObject | ( | ) | [virtual] |
Destructor.
Definition at line 125 of file documentrangeobject.cpp.
| KDevelop::DocumentRangeObject::DocumentRangeObject | ( | DocumentRangeObject & | useDataFrom | ) | [protected] |
Constructor for copy constructors in subclasses.
This constructor should be used when sharing the data from another object without owning it. This object will use that data, but will not destroy it on destruction. This object must be destroyed before the object given through
- Parameters:
-
useDataFrom is destroyed! dd data to copy. ownsData set to true if this object owns the private data including the smart range and should delete it when this object is deleted, otherwise set to false (the default)
Definition at line 111 of file documentrangeobject.cpp.
| KDevelop::DocumentRangeObject::DocumentRangeObject | ( | DocumentRangeObjectData & | dd, | |
| const SimpleRange & | range = SimpleRange::invalid() | |||
| ) | [protected] |
Constructor for copy constructors in subclasses.
- Parameters:
-
dd data to copy. document document in which this object is located. range text range which this object covers.
Definition at line 103 of file documentrangeobject.cpp.
Member Function Documentation
| void KDevelop::DocumentRangeObject::clearSmartRange | ( | ) |
Clear the smart range from this object.
Definition at line 193 of file documentrangeobject.cpp.
| bool KDevelop::DocumentRangeObject::contains | ( | const SimpleCursor & | cursor | ) | const |
Determine if this range contains the given cursor.
- Parameters:
-
cursor cursor to check if it is contained by this range.
- Returns:
- true if the cursor is contained by this range, otherwise false.
Definition at line 218 of file documentrangeobject.cpp.
| QMutex * KDevelop::DocumentRangeObject::mutex | ( | ) | [static, protected] |
Static shared mutex protecting internal data. May be used to protect private data in subclasses.
- Returns:
- the internal mutex
Definition at line 255 of file documentrangeobject.cpp.
| RangeOwning KDevelop::DocumentRangeObject::ownsRange | ( | ) | const |
Determine whether this object owns its smart range.
- Returns:
- true if the object owns its smart range, otherwise false.
| SimpleRange KDevelop::DocumentRangeObject::range | ( | ) | const |
Returns the text range of this object.
Definition at line 198 of file documentrangeobject.cpp.
| void KDevelop::DocumentRangeObject::rangeDeleted | ( | KTextEditor::SmartRange * | range | ) | [protected, virtual] |
Reimplementation of KTextEditor::SmartWatcher::rangeDeleted(), to clean up the smart range when it is deleted (for example, on file close).
- Todo:
- this sux
Definition at line 223 of file documentrangeobject.cpp.
| void KDevelop::DocumentRangeObject::setData | ( | DocumentRangeObjectData * | data, | |
| bool | constructorCalled = true | |||
| ) | [virtual] |
Sets a new data pointer.
The data will be owned by this object if it is dynamic. The old data is deleted if it was dynamic.
- Parameters:
-
constructorCalled Whether the constructor of the data object was called while its creation. If not, it means that the data is only moved into another place
Definition at line 117 of file documentrangeobject.cpp.
| void KDevelop::DocumentRangeObject::setRange | ( | const SimpleRange & | range | ) |
Set the text range (non-smart range) for this object.
- Parameters:
-
range new text range
Definition at line 203 of file documentrangeobject.cpp.
| void KDevelop::DocumentRangeObject::setRangeOwning | ( | RangeOwning | ownsRange | ) |
Sets whether this object owns its smart range, and should delete it when it is deleted.
- Parameters:
-
ownsRange whether this object owns its smart range.
| void KDevelop::DocumentRangeObject::setSmartRange | ( | KTextEditor::SmartRange * | range, | |
| RangeOwning | ownsRange = Own | |||
| ) |
Sets the text range to this object.
If ownsRange is false, the range won't be deleted when the object is deleted. Does not change the url associated to this object, because that cannot be retrieved from the smart-range in a thread-safe way.
- Warning:
- you need to hold the smart mutex in order to call this function from anywhere but a copy constructor.
Definition at line 148 of file documentrangeobject.cpp.
| SmartRange * KDevelop::DocumentRangeObject::smartRange | ( | ) | const |
Access the smart range of this object.
- Returns:
- the SmartRange if the object has one, otherwise returns null
Definition at line 210 of file documentrangeobject.cpp.
| KTextEditor::SmartRange * KDevelop::DocumentRangeObject::takeRange | ( | ) |
Take the range from this object, and set its smart range to null.
- Warning:
- USE WITH CARE!! You must be willing to immediately delete this range object if you take its range.
- Returns:
- this object's smart range
Definition at line 234 of file documentrangeobject.cpp.
Member Data Documentation
Data pointer shared across the inheritance hierarchy.
Definition at line 191 of file documentrangeobject.h.
The documentation for this class was generated from the following files:
KDE 4.4 API Reference