| 43 | } |
| 44 | |
| 45 | QString DocumentContextReader::getLineText(int lineNumber, int cursorPosition) const |
| 46 | { |
| 47 | if (!m_document || lineNumber < 0) |
| 48 | return QString(); |
| 49 | |
| 50 | QTextBlock block = m_document->begin(); |
| 51 | int currentLine = 0; |
| 52 | |
| 53 | while (block.isValid()) { |
| 54 | if (currentLine == lineNumber) { |
| 55 | QString text = block.text(); |
| 56 | if (cursorPosition >= 0 && cursorPosition <= text.length()) { |
| 57 | text = text.left(cursorPosition); |
| 58 | } |
| 59 | return text; |
| 60 | } |
| 61 | |
| 62 | block = block.next(); |
| 63 | currentLine++; |
| 64 | } |
| 65 | |
| 66 | return QString(); |
| 67 | } |
| 68 | |
| 69 | QString DocumentContextReader::getContextBefore( |
| 70 | int lineNumber, int cursorPosition, int linesCount) const |