- Timestamp:
- Mar 27, 2019 2:43:18 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.cpp
r77922 r77923 140 140 } 141 141 142 void UIChooserItemGroup::scrollBy(int iDelta) 143 { 144 m_pScrollArea->scrollBy(iDelta); 145 } 146 142 147 void UIChooserItemGroup::makeSureItemIsVisible(UIChooserItem *pItem) 143 148 { -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.h
r77922 r77923 90 90 /** @name Navigation stuff. 91 91 * @{ */ 92 /** Performs scrolling by @a iDelta pixels. */ 93 void scrollBy(int iDelta); 94 92 95 /** Makes sure passed @a pItem is visible within the current root item. 93 96 * @note Please keep in mind that any group item can be a root, but there -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp
r77922 r77923 1087 1087 void UIChooserModel::sltStartScrolling() 1088 1088 { 1089 /* Make sure view exists: */ 1090 AssertPtrReturnVoid(view()); 1091 1089 1092 /* Should we scroll? */ 1090 1093 if (!m_fIsScrollingInProgress) … … 1094 1097 m_fIsScrollingInProgress = false; 1095 1098 1096 /* Get view/scrollbar: */1097 QGraphicsView *pView = view();1098 QScrollBar *pVerticalScrollBar = pView->verticalScrollBar();1099 1100 1099 /* Convert mouse position to view co-ordinates: */ 1101 const QPoint mousePos = pView->mapFromGlobal(QCursor::pos());1100 const QPoint mousePos = view()->mapFromGlobal(QCursor::pos()); 1102 1101 /* Mouse position is at the top of view? */ 1103 1102 if (mousePos.y() < m_iScrollingTokenSize && mousePos.y() > 0) 1104 1103 { 1105 1104 int iValue = mousePos.y(); 1106 if (!iValue) iValue = 1; 1107 int iDelta = m_iScrollingTokenSize / iValue; 1108 if (pVerticalScrollBar->value() > pVerticalScrollBar->minimum()) 1109 { 1110 /* Backward scrolling: */ 1111 pVerticalScrollBar->setValue(pVerticalScrollBar->value() - 2 * iDelta); 1112 m_fIsScrollingInProgress = true; 1113 QTimer::singleShot(10, this, SLOT(sltStartScrolling())); 1114 } 1105 if (!iValue) 1106 iValue = 1; 1107 const int iDelta = m_iScrollingTokenSize / iValue; 1108 /* Backward scrolling: */ 1109 root()->toGroupItem()->scrollBy(- 2 * iDelta); 1110 m_fIsScrollingInProgress = true; 1111 QTimer::singleShot(10, this, SLOT(sltStartScrolling())); 1115 1112 } 1116 1113 /* Mouse position is at the bottom of view? */ 1117 else if (mousePos.y() > pView->height() - m_iScrollingTokenSize && mousePos.y() < pView->height()) 1118 { 1119 int iValue = pView->height() - mousePos.y(); 1120 if (!iValue) iValue = 1; 1121 int iDelta = m_iScrollingTokenSize / iValue; 1122 if (pVerticalScrollBar->value() < pVerticalScrollBar->maximum()) 1123 { 1124 /* Forward scrolling: */ 1125 pVerticalScrollBar->setValue(pVerticalScrollBar->value() + 2 * iDelta); 1126 m_fIsScrollingInProgress = true; 1127 QTimer::singleShot(10, this, SLOT(sltStartScrolling())); 1128 } 1114 else if (mousePos.y() > view()->height() - m_iScrollingTokenSize && mousePos.y() < view()->height()) 1115 { 1116 int iValue = view()->height() - mousePos.y(); 1117 if (!iValue) 1118 iValue = 1; 1119 const int iDelta = m_iScrollingTokenSize / iValue; 1120 /* Forward scrolling: */ 1121 root()->toGroupItem()->scrollBy(2 * iDelta); 1122 m_fIsScrollingInProgress = true; 1123 QTimer::singleShot(10, this, SLOT(sltStartScrolling())); 1129 1124 } 1130 1125 } … … 1600 1595 bool UIChooserModel::processDragMoveEvent(QGraphicsSceneDragDropEvent *pEvent) 1601 1596 { 1597 /* Make sure view exists: */ 1598 AssertPtrReturn(view(), false); 1599 1602 1600 /* Do we scrolling already? */ 1603 1601 if (m_fIsScrollingInProgress) 1604 1602 return false; 1605 1603 1606 /* Get view: */1607 QGraphicsView *pView = view();1608 1609 1604 /* Check scroll-area: */ 1610 const QPoint eventPoint = pView->mapFromGlobal(pEvent->screenPos());1611 if ( (eventPoint.y() < m_iScrollingTokenSize) ||1612 (eventPoint.y() > pView->height() - m_iScrollingTokenSize))1605 const QPoint eventPoint = view()->mapFromGlobal(pEvent->screenPos()); 1606 if ( (eventPoint.y() < m_iScrollingTokenSize) 1607 || (eventPoint.y() > view()->height() - m_iScrollingTokenSize)) 1613 1608 { 1614 1609 /* Set scrolling in progress: */ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsScrollArea.cpp
r77310 r77923 96 96 { 97 97 return m_pViewport; 98 } 99 100 void UIGraphicsScrollArea::scrollBy(int iDelta) 101 { 102 m_pScrollBar->setValue(m_pScrollBar->value() + iDelta); 98 103 } 99 104 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsScrollArea.h
r77228 r77923 50 50 QIGraphicsWidget *viewport() const; 51 51 52 /** Performs scrolling by @a iDelta pixels. */ 53 void scrollBy(int iDelta); 54 52 55 /** Makes sure passed @a rect is visible. */ 53 56 void makeSureRectIsVisible(const QRectF &rect);
Note:
See TracChangeset
for help on using the changeset viewer.