VirtualBox

Changeset 100330 in vbox


Ignore:
Timestamp:
Jun 29, 2023 11:15:59 AM (17 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9080. Implementing slots for content browser's navigation actions.

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  
    401401    if (!pClickedItem)
    402402        return;
     403    if (!pClickedItem->isDirectory())
     404        return;
    403405    QString strISOPath = pClickedItem->data(UICustomFileSystemModelData_ISOFilePath).toString();
    404406    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();
    413408    else if (!strISOPath.isEmpty())
    414409    {
     
    561556    m_pRenameAction = m_pActionPool->action(UIActionIndex_M_VISOCreator_Rename);
    562557    m_pResetAction = m_pActionPool->action(UIActionIndex_M_VISOCreator_Reset);
    563     m_pGoHome = m_pActionPool->action(UIActionIndex_M_VISOCreator_VisoContent_GoHome);
    564558    m_pGoUp = m_pActionPool->action(UIActionIndex_M_VISOCreator_VisoContent_GoUp);
    565559    m_pGoForward = m_pActionPool->action(UIActionIndex_M_VISOCreator_VisoContent_GoForward);
     
    571565    AssertReturnVoid(m_pResetAction);
    572566    AssertReturnVoid(m_pToolBar);
    573     AssertReturnVoid(m_pGoHome);
    574567    AssertReturnVoid(m_pGoUp);
    575568    AssertReturnVoid(m_pGoForward);
     
    582575    m_pToolBar->addAction(m_pGoForward);
    583576    m_pToolBar->addAction(m_pGoUp);
    584     m_pToolBar->addAction(m_pGoHome);
    585577    m_pToolBar->addSeparator();
    586578    m_pToolBar->addAction(m_pRemoveAction);
     
    636628        connect(m_pRenameAction, &QAction::triggered,
    637629                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);
    638637}
    639638
     
    643642        return 0;
    644643    return m_pModel->rootItem();
     644}
     645
     646UICustomFileSystemItem* UIVisoContentBrowser::startItem()
     647{
     648    UICustomFileSystemItem* pRoot = rootItem();
     649
     650    if (!pRoot || pRoot->childCount() <= 0)
     651        return 0;
     652    return pRoot->child(0);
    645653}
    646654
     
    669677        m_pTableView->setRootIndex(tableIndex);
    670678    updateNavigationWidgetPath(currentPath());
     679    if (m_pGoUp)
     680        m_pGoUp->setEnabled(!onStartItem());
    671681}
    672682
     
    844854    if (m_pTableProxyModel)
    845855        m_pTableProxyModel->invalidate();
    846 
    847 
    848856}
    849857
     
    885893    menu.addAction(m_pResetAction);
    886894    menu.exec(pSender->mapToGlobal(point));
     895}
     896
     897void UIVisoContentBrowser::sltGoUp()
     898{
     899    goUp();
    887900}
    888901
     
    922935}
    923936
     937bool 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
     950void 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}
    924963#include "UIVisoContentBrowser.moc"
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoContentBrowser.h

    r100329 r100330  
    8585    void sltResetAction();
    8686    void sltItemRenameAction();
     87    void sltGoUp();
    8788
    8889protected:
     
    107108    void                    initializeModel();
    108109    UICustomFileSystemItem *rootItem();
     110    /* Child of root. */
     111    UICustomFileSystemItem *startItem();
    109112
    110113    /** @name Index conversion functions. These are half-smart and tries to determine the source model before conversion.
     
    128131     *  in the table view. */
    129132    QList<UICustomFileSystemItem*> tableSelectedItems();
     133    bool                           onStartItem();
     134    void                           goUp();
    130135    UIVisoContentTableView       *m_pTableView;
    131136    UICustomFileSystemModel      *m_pModel;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette