Changeset 100330 in vbox
- Timestamp:
- Jun 29, 2023 11:15:59 AM (17 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/medium/viso
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoContentBrowser.cpp
r100329 r100330 401 401 if (!pClickedItem) 402 402 return; 403 if (!pClickedItem->isDirectory()) 404 return; 403 405 QString strISOPath = pClickedItem->data(UICustomFileSystemModelData_ISOFilePath).toString(); 404 406 if (pClickedItem->isUpDirectory()) 405 { 406 QModelIndex currentRoot = m_pTableProxyModel->mapToSource(m_pTableView->rootIndex()); 407 /* Go up if we are not already in root: */ 408 if (currentRoot != m_pModel->rootIndex()) 409 { 410 setTableRootIndex(currentRoot.parent()); 411 } 412 } 407 goUp(); 413 408 else if (!strISOPath.isEmpty()) 414 409 { … … 561 556 m_pRenameAction = m_pActionPool->action(UIActionIndex_M_VISOCreator_Rename); 562 557 m_pResetAction = m_pActionPool->action(UIActionIndex_M_VISOCreator_Reset); 563 m_pGoHome = m_pActionPool->action(UIActionIndex_M_VISOCreator_VisoContent_GoHome);564 558 m_pGoUp = m_pActionPool->action(UIActionIndex_M_VISOCreator_VisoContent_GoUp); 565 559 m_pGoForward = m_pActionPool->action(UIActionIndex_M_VISOCreator_VisoContent_GoForward); … … 571 565 AssertReturnVoid(m_pResetAction); 572 566 AssertReturnVoid(m_pToolBar); 573 AssertReturnVoid(m_pGoHome);574 567 AssertReturnVoid(m_pGoUp); 575 568 AssertReturnVoid(m_pGoForward); … … 582 575 m_pToolBar->addAction(m_pGoForward); 583 576 m_pToolBar->addAction(m_pGoUp); 584 m_pToolBar->addAction(m_pGoHome);585 577 m_pToolBar->addSeparator(); 586 578 m_pToolBar->addAction(m_pRemoveAction); … … 636 628 connect(m_pRenameAction, &QAction::triggered, 637 629 this,&UIVisoContentBrowser::sltItemRenameAction); 630 631 if (m_pGoUp) 632 connect(m_pGoUp, &QAction::triggered, this, &UIVisoContentBrowser::sltGoUp); 633 if (m_pGoForward) 634 connect(m_pGoForward, &QAction::triggered, this, &UIVisoContentBrowser::sltGoForward); 635 if (m_pGoBackward) 636 connect(m_pGoBackward, &QAction::triggered, this, &UIVisoContentBrowser::sltGoBackward); 638 637 } 639 638 … … 643 642 return 0; 644 643 return m_pModel->rootItem(); 644 } 645 646 UICustomFileSystemItem* UIVisoContentBrowser::startItem() 647 { 648 UICustomFileSystemItem* pRoot = rootItem(); 649 650 if (!pRoot || pRoot->childCount() <= 0) 651 return 0; 652 return pRoot->child(0); 645 653 } 646 654 … … 669 677 m_pTableView->setRootIndex(tableIndex); 670 678 updateNavigationWidgetPath(currentPath()); 679 if (m_pGoUp) 680 m_pGoUp->setEnabled(!onStartItem()); 671 681 } 672 682 … … 844 854 if (m_pTableProxyModel) 845 855 m_pTableProxyModel->invalidate(); 846 847 848 856 } 849 857 … … 885 893 menu.addAction(m_pResetAction); 886 894 menu.exec(pSender->mapToGlobal(point)); 895 } 896 897 void UIVisoContentBrowser::sltGoUp() 898 { 899 goUp(); 887 900 } 888 901 … … 922 935 } 923 936 937 bool UIVisoContentBrowser::onStartItem() 938 { 939 if (!m_pTableView || !m_pModel) 940 return false; 941 QModelIndex index = m_pTableProxyModel->mapToSource(m_pTableView->rootIndex()); 942 UICustomFileSystemItem *pItem = static_cast<UICustomFileSystemItem*>((index).internalPointer()); 943 if (!index.isValid() || !pItem) 944 return false; 945 if (pItem != startItem()) 946 return false; 947 return true; 948 } 949 950 void UIVisoContentBrowser::goUp() 951 { 952 AssertReturnVoid(m_pTableProxyModel); 953 AssertReturnVoid(m_pTableView); 954 QModelIndex currentRoot = m_pTableProxyModel->mapToSource(m_pTableView->rootIndex()); 955 if (!currentRoot.isValid()) 956 return; 957 /* Go up if we are not already in root: */ 958 if (!onStartItem()) 959 { 960 setTableRootIndex(currentRoot.parent()); 961 } 962 } 924 963 #include "UIVisoContentBrowser.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoContentBrowser.h
r100329 r100330 85 85 void sltResetAction(); 86 86 void sltItemRenameAction(); 87 void sltGoUp(); 87 88 88 89 protected: … … 107 108 void initializeModel(); 108 109 UICustomFileSystemItem *rootItem(); 110 /* Child of root. */ 111 UICustomFileSystemItem *startItem(); 109 112 110 113 /** @name Index conversion functions. These are half-smart and tries to determine the source model before conversion. … … 128 131 * in the table view. */ 129 132 QList<UICustomFileSystemItem*> tableSelectedItems(); 133 bool onStartItem(); 134 void goUp(); 130 135 UIVisoContentTableView *m_pTableView; 131 136 UICustomFileSystemModel *m_pModel;
Note:
See TracChangeset
for help on using the changeset viewer.