Merge remote-tracking branch 'upstream/master' into omega-hotfix

This commit is contained in:
Quentin Guidée
2020-02-20 23:41:50 +01:00
18 changed files with 92 additions and 40 deletions

View File

@@ -32,10 +32,9 @@ public:
bool selectCellAtLocation(int i, int j, bool setFirstResponder = true, bool withinTemporarySelection = false);
HighlightCell * selectedCell();
protected:
void unhighlightSelectedCell();
SelectableTableViewDataSource * m_selectionDataSource;
SelectableTableViewDelegate * m_delegate;
private:
void unhighlightSelectedCell();
};
#endif

View File

@@ -81,8 +81,33 @@ void ScrollView::scrollToContentPoint(KDPoint p, bool allowOverscroll) {
}
void ScrollView::scrollToContentRect(KDRect rect, bool allowOverscroll) {
scrollToContentPoint(rect.topLeft(), allowOverscroll);
scrollToContentPoint(rect.bottomRight(), allowOverscroll);
KDPoint tl = rect.topLeft();
KDPoint br = rect.bottomRight();
KDRect visibleRect = visibleContentRect();
/* We first check that we can display the whole rect. If we can't, we focus
* the croll to the closest part of the rect. */
if (visibleRect.height() < rect.height()) {
// The visible rect is too small to display 'rect'
if (rect.top() >= visibleRect.top()) {
// We scroll to display the top part of rect
br = KDPoint(br.x(), rect.top() + visibleRect.height());
} else {
// We scroll to display the bottom part of rect
tl = KDPoint(tl.x(), rect.bottom() - visibleRect.height());
}
}
if (visibleRect.width() < rect.width()) {
// The visible rect is too small to display 'rect'
if (rect.left() >= visibleRect.left()) {
// We scroll to display the left part of rect
br = KDPoint(rect.left() + visibleRect.width(), br.y());
} else {
// We scroll to display the right part of rect
tl = KDPoint(rect.right() - visibleRect.width(), tl.y());
}
}
scrollToContentPoint(tl, allowOverscroll);
scrollToContentPoint(br, allowOverscroll);
}
KDRect ScrollView::visibleContentRect() {