Changeset 99607 in vbox
- Timestamp:
- May 4, 2023 2:18:46 PM (17 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/snapshots
- Files:
-
- 2 edited
-
UISnapshotPane.cpp (modified) (7 diffs)
-
UISnapshotPane.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/snapshots/UISnapshotPane.cpp
r99602 r99607 178 178 179 179 180 /** QScrollBar subclass for snapshots widget. */ 181 class UISnapshotScrollBar : public QScrollBar 182 { 183 Q_OBJECT; 184 185 signals: 186 187 /** Notify listeners about our visibility changed. */ 188 void sigNotifyAboutVisibilityChange(); 189 190 public: 191 192 /** Constructs scroll-bar passing @a enmOrientation and @a pParent to the base-class. */ 193 UISnapshotScrollBar(Qt::Orientation enmOrientation, QWidget *pParent = 0); 194 195 protected: 196 197 /** Handles show @a pEvent. */ 198 virtual void showEvent(QShowEvent *pEvent) RT_OVERRIDE; 199 }; 200 201 180 202 /** QITreeWidget subclass for snapshots items. */ 181 203 class UISnapshotTree : public QITreeWidget 182 204 { 183 205 Q_OBJECT; 206 207 signals: 208 209 /** Notify listeners about one of scroll-bars visibility changed. */ 210 void sigNotifyAboutScrollBarVisibilityChange(); 184 211 185 212 public: … … 505 532 506 533 /********************************************************************************************************************************* 534 * Class UISnapshotScrollBar implementation. * 535 *********************************************************************************************************************************/ 536 UISnapshotScrollBar::UISnapshotScrollBar(Qt::Orientation enmOrientation, QWidget *pParent /* = 0 */) 537 : QScrollBar(enmOrientation, pParent) 538 { 539 } 540 541 void UISnapshotScrollBar::showEvent(QShowEvent *pEvent) 542 { 543 QScrollBar::showEvent(pEvent); 544 emit sigNotifyAboutVisibilityChange(); 545 } 546 547 548 /********************************************************************************************************************************* 507 549 * Class UISnapshotTree implementation. * 508 550 *********************************************************************************************************************************/ … … 520 562 setEditTriggers( QAbstractItemView::SelectedClicked 521 563 | QAbstractItemView::EditKeyPressed); 564 565 /* Replace scroll-bars: */ 566 UISnapshotScrollBar *pScrollBarH = new UISnapshotScrollBar(Qt::Horizontal, this); 567 if (pScrollBarH) 568 { 569 connect(pScrollBarH, &UISnapshotScrollBar::sigNotifyAboutVisibilityChange, 570 this, &UISnapshotTree::sigNotifyAboutScrollBarVisibilityChange); 571 setHorizontalScrollBar(pScrollBarH); 572 } 573 UISnapshotScrollBar *pScrollBarV = new UISnapshotScrollBar(Qt::Vertical, this); 574 if (pScrollBarV) 575 { 576 connect(pScrollBarV, &UISnapshotScrollBar::sigNotifyAboutVisibilityChange, 577 this, &UISnapshotTree::sigNotifyAboutScrollBarVisibilityChange); 578 setVerticalScrollBar(pScrollBarV); 579 } 522 580 } 523 581 … … 1098 1156 1099 1157 /* Make the current item visible: */ 1100 if (pSnapshotItem) 1101 { 1102 m_pSnapshotTree->horizontalScrollBar()->setValue(0); 1103 m_pSnapshotTree->scrollToItem(pSnapshotItem); 1104 m_pSnapshotTree->horizontalScrollBar()->setValue(m_pSnapshotTree->indentation() * pSnapshotItem->level()); 1105 } 1158 sltHandleScrollBarVisibilityChange(); 1106 1159 1107 1160 /* Update action states: */ … … 1240 1293 } 1241 1294 1295 void UISnapshotPane::sltHandleScrollBarVisibilityChange() 1296 { 1297 /* Acquire "current snapshot" item: */ 1298 const UISnapshotItem *pSnapshotItem = UISnapshotItem::toSnapshotItem(m_pSnapshotTree->currentItem()); 1299 1300 /* Make the current item visible: */ 1301 if (pSnapshotItem) 1302 { 1303 m_pSnapshotTree->horizontalScrollBar()->setValue(0); 1304 m_pSnapshotTree->scrollToItem(pSnapshotItem); 1305 m_pSnapshotTree->horizontalScrollBar()->setValue(m_pSnapshotTree->indentation() * pSnapshotItem->level()); 1306 } 1307 } 1308 1242 1309 void UISnapshotPane::prepare() 1243 1310 { … … 1378 1445 connect(m_pSnapshotTree, &UISnapshotTree::itemDoubleClicked, 1379 1446 this, &UISnapshotPane::sltHandleItemDoubleClick); 1447 connect(m_pSnapshotTree, &UISnapshotTree::sigNotifyAboutScrollBarVisibilityChange, 1448 this, &UISnapshotPane::sltHandleScrollBarVisibilityChange, Qt::QueuedConnection); 1380 1449 1381 1450 /* Add into layout: */ … … 1461 1530 1462 1531 /* Choose current item: */ 1463 m_pSnapshotTree->scrollToItem(pCurrentItem);1464 1532 m_pSnapshotTree->setCurrentItem(pCurrentItem); 1465 1533 sltHandleCurrentItemChange(); -
trunk/src/VBox/Frontends/VirtualBox/src/snapshots/UISnapshotPane.h
r99218 r99607 165 165 /** Handles tree-widget @a pItem double-click. */ 166 166 void sltHandleItemDoubleClick(QTreeWidgetItem *pItem); 167 /** Handles tree-widget's scroll-bar visibility change. */ 168 void sltHandleScrollBarVisibilityChange(); 167 169 /** @} */ 168 170
Note:
See TracChangeset
for help on using the changeset viewer.

