VirtualBox

Changeset 76909 in vbox


Ignore:
Timestamp:
Jan 21, 2019 8:51:44 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
128278
Message:

FE/Qt: bugref:9183. adding a context menu to tree widget

Location:
trunk/src/VBox/Frontends/VirtualBox/src/medium
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.cpp

    r76907 r76909  
    369369        connect(m_pTreeWidget, &QITreeWidget::itemSelectionChanged, this, &UIMediumSelector::sltHandleItemSelectionChanged);
    370370        connect(m_pTreeWidget, &QITreeWidget::itemDoubleClicked, this, &UIMediumSelector::sltHandleTreeWidgetDoubleClick);
     371        connect(m_pTreeWidget, &QITreeWidget::customContextMenuRequested, this, &UIMediumSelector::sltHandleTreeContextMenuRequest);
    371372    }
    372373
     
    384385                this, &UIMediumSelector::sltHandleShowNextMatchingItem);
    385386        connect(m_pSearchWidget, &UIMediumSearchWidget::sigShowPreviousMatchingItem,
    386                 this, &UIMediumSelector::sltHandlehowPreviousMatchingItem);
     387                this, &UIMediumSelector::sltHandleShowPreviousMatchingItem);
    387388    }
    388389}
     
    513514        m_pTreeWidget->setSortingEnabled(true);
    514515        m_pTreeWidget->sortItems(0, Qt::AscendingOrder);
     516        m_pTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
    515517    }
    516518
     
    611613}
    612614
    613 void UIMediumSelector::sltHandlehowPreviousMatchingItem()
     615void UIMediumSelector::sltHandleShowPreviousMatchingItem()
    614616{
    615617    if (m_mathingItemList.isEmpty())
     
    618620        m_iCurrentShownIndex = m_mathingItemList.size() -1;
    619621    scrollToItem(m_mathingItemList[m_iCurrentShownIndex]);
     622}
     623
     624void UIMediumSelector::sltHandleTreeContextMenuRequest(const QPoint &point)
     625{
     626    QWidget *pSender = qobject_cast<QWidget*>(sender());
     627    if (!pSender)
     628        return;
     629
     630    QMenu menu;
     631    QAction *pExpandAll = menu.addAction(tr("Expand All"));
     632    QAction *pCollapseAll = menu.addAction(tr("Collapse All"));
     633
     634    connect(pExpandAll, &QAction::triggered, this, &UIMediumSelector::sltHandleTreeExpandAllSignal);
     635    connect(pCollapseAll, &QAction::triggered, this, &UIMediumSelector::sltHandleTreeCollapseAllSignal);
     636
     637    menu.exec(pSender->mapToGlobal(point));
     638}
     639
     640void UIMediumSelector::sltHandleTreeExpandAllSignal()
     641{
     642    if (m_pTreeWidget)
     643        m_pTreeWidget->expandAll();
     644}
     645
     646void UIMediumSelector::sltHandleTreeCollapseAllSignal()
     647{
     648    if (m_pTreeWidget)
     649        m_pTreeWidget->collapseAll();
     650
     651    if (m_pAttachedSubTreeRoot)
     652        m_pTreeWidget->setExpanded(m_pTreeWidget->itemIndex(m_pAttachedSubTreeRoot), true);
     653    if (m_pNotAttachedSubTreeRoot)
     654        m_pTreeWidget->setExpanded(m_pTreeWidget->itemIndex(m_pNotAttachedSubTreeRoot), true);
    620655}
    621656
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.h

    r76907 r76909  
    7171    void sltHandlePerformSearch();
    7272    void sltHandleShowNextMatchingItem();
    73     void sltHandlehowPreviousMatchingItem();
     73    void sltHandleShowPreviousMatchingItem();
     74    void sltHandleTreeContextMenuRequest(const QPoint &point);
     75    void sltHandleTreeExpandAllSignal();
     76    void sltHandleTreeCollapseAllSignal();
    7477
    7578 private:
Note: See TracChangeset for help on using the changeset viewer.

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