Editor: Fix block for offset calculation

Take block bounding rects into account, when calculating the row count
or the center visible line.

Change-Id: If933828867df25920eeb56359e9a42a8b95d9c6d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2017-11-23 14:17:48 +01:00
parent c67902ec4e
commit 464a9ad9ab
3 changed files with 50 additions and 19 deletions

View File

@@ -453,14 +453,14 @@ public:
*
* Any invalid row will return -1 as line number.
*/
int lineForVisibleRow(int row) const;
int blockNumberForVisibleRow(int row) const;
/*! Returns the first visible line of the document. */
int firstVisibleLine() const;
int firstVisibleBlockNumber() const;
/*! Returns the last visible line of the document. */
int lastVisibleLine() const;
int lastVisibleBlockNumber() const;
/*! Returns the line visible closest to the vertical center of the editor. */
int centerVisibleLine() const;
int centerVisibleBlockNumber() const;
Core::HighlightScrollBarController *highlightScrollBarController() const;
@@ -472,6 +472,7 @@ signals:
protected:
QTextBlock blockForVisibleRow(int row) const;
QTextBlock blockForVerticalOffset(int offset) const;
bool event(QEvent *e) override;
void inputMethodEvent(QInputMethodEvent *e) override;
void keyPressEvent(QKeyEvent *e) override;