diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | e9ae80694875f869892f13f4fcaf1170a00dea41 (patch) | |
tree | aa2f8d8a217e2d376224c8d46b7397b68d35de2d /quanta/parts/kafka/cursors.h | |
download | tdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.tar.gz tdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.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/kdewebdev@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'quanta/parts/kafka/cursors.h')
-rw-r--r-- | quanta/parts/kafka/cursors.h | 150 |
1 files changed, 150 insertions, 0 deletions
diff --git a/quanta/parts/kafka/cursors.h b/quanta/parts/kafka/cursors.h new file mode 100644 index 00000000..22eea7b1 --- /dev/null +++ b/quanta/parts/kafka/cursors.h @@ -0,0 +1,150 @@ +/*************************************************************************** + cursor.h + ------------------- + + copyright : (C) 2004 - Nicolas Deschildre + email : ndeschildre@kdewebdev.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 CURSORS_H + #define CURSORS_H + + /** + * This represents a Node selection : StartNode and StartOffset, endNode and endOffset. + * IT can also only hold the cursor. If so, cursorNodeEndSel() will be empty. + * TODO: selection support + */ + class NodeSelection + { + public: + NodeSelection(Node* node = 0L, int offset = 0){m_cursorNode = node; m_cursorOffset = offset;} + ~NodeSelection(){} + + /** + * @return Return the Node when the selection start (and where the cursor is if + * m_cursorAtSelectionStart). + */ + Node* cursorNode(){return m_cursorNode;} + void setCursorNode(Node* node){m_cursorNode = node;} + + /** + * @return Returns the offset of the cursor where the selection begin (and where the cursor is if + * m_cursorAtSelectionStart) + */ + int cursorOffset(){return m_cursorOffset;} + void setCursorOffset(int offset){m_cursorOffset = offset;} + + private: + Node* m_cursorNode, *m_cursorNodeEndSel; + int m_cursorOffset, m_cursorOffsetEndSel; + bool m_cursorAtSelectionStart; + }; + + /** + * This represents a Node selection : startNode and startOffset, endNode and endOffset. + * The difference with NodeSelection is that it don't store the Node address of startNode + * and endNode, but it store the Node position of the Node tree e.g. it is the first child + * of the second child of the rootNode... + * It can also only hold the cursor. If so, cursorNodeEndSel() will be empty. + */ +class NodeSelectionInd +{ +public: + NodeSelectionInd(); + NodeSelectionInd(Node* cursor_node, int cursor_offset); + NodeSelectionInd(Node* start_node, int start_offset, Node* end_node, int end_offset); + ~NodeSelectionInd(); + + /** + * Compare nodeselection to the current instance. + */ + bool operator==(const NodeSelectionInd & nodeSelection); + + void operator=(const NodeSelectionInd & nodeSelection); + + /** + * Take the current VPL cursor selection coordinates, if not speficied otherwise, translate + * them into Node cursor coordinates and store them. + */ + void fillWithVPLCursorSelection(); + + bool hasSelection() const; + + /**---------------------------------- GET/SET --------------------------------------------*/ + + /** + * @return Returns the location of the Node where the selection begin (and where the cursor is if + * m_cursorAtSelectionStart). + */ + QValueList<int>& cursorNode() {return m_cursorNode;} + + /** + * @param cursorNode Set the location of the Node where the selection begin (and where the cursor is if + * m_cursorAtSelectionStart) + */ + void setCursorNode(QValueList<int> cursorNode) {m_cursorNode = cursorNode;} + + /** + * @return Returns the offset of the cursor where the selection begin (and where the cursor is if + * m_cursorAtSelectionStart) + */ + int cursorOffset() {return m_cursorOffset;} + + /** + * @param cursorOffset Set the offset of the cursor where the selection begin (and where the cursor is if + * m_cursorAtSelectionStart) + */ + void setCursorOffset(int cursorOffset) {m_cursorOffset = cursorOffset;} + + /** + * @return Returns true if the cursor is at the beginning of the selection. Otherwise, it is + * at the end of the selection. + */ + bool cursorAtSelectionStart() {return m_cursorAtSelectionStart;} + + /** + * @param cursorAtSelectionStart Set if the cursor is at the beginning of the selection. + */ + void setCursorAtSelectionStart(bool cursorAtSelectionStart) {m_cursorAtSelectionStart = cursorAtSelectionStart;} + + /** + * @return Returns the location of the end selection Node where the + * selection ends. + * Empty if this instance only carry the cursor coordinates. + */ + QValueList<int>& cursorNodeEndSel() {return m_cursorNodeEndSel;} + + /** + * @param cursorNodeEndSel Set the location of the end selection Node where the + * selection ends. + */ + void setCursorNodeEndSel(QValueList<int> cursorNodeEndSel) + {m_cursorNodeEndSel = cursorNodeEndSel;} + + /** + * @return Returns the offset of the cursor in the Node of the end of the selection. + */ + int cursorOffsetEndSel() {return m_cursorOffsetEndSel;} + + /** + * @param cursorOffsetEndSel Set the offset of the cursor in the Node of the end of the selection + */ + void setCursorOffsetEndSel(int cursorOffsetEndSel) + {m_cursorOffsetEndSel = cursorOffsetEndSel;} + +private: + QValueList<int> m_cursorNode, m_cursorNodeEndSel; + int m_cursorOffset, m_cursorOffsetEndSel; + bool m_cursorAtSelectionStart; +}; + +#endif |